Yioop_V9.5_Source_Code_Documentation

IndexManagerTest extends UnitTest
in package

Used to run unit tests for the IndexManager class. IndexManager acts a a resource manager for the open indexes used to process a query.

Table of Contents

case_name  = "TestCase"
The suffix that all TestCase methods need to have to be called by run()
NEW_BUNDLE  = "IndexData200000000"
Name of the included version3 Index bundle to test
OLD_BUNDLE  = "IndexData1421025145"
Name of the included pre version3 Index bundle to test
TEST_DIR  = __DIR__ . '/test_files/index_manager_test'
Prefix of folders for index manager test
$current_method  : string
Contains the value of the next test case to be run can be used by setUp
$index_archive  : object
Holds current instance of IndexDocumentBundle
$test_case_results  : array<string|int, mixed>
Used to store the results for each test sub case
$test_objects  : array<string|int, mixed>
Used to hold objects to be used in tests
__construct()  : mixed
Constructor should be overridden to do any set up that occurs before and test cases
assertEqual()  : mixed
Checks that $x and $y are the same, the result of the test is added to $this->test_case_results
assertFalse()  : mixed
Checks that $x can coerced to false, the result of the test is added to $this->test_case_results
assertNotEqual()  : mixed
Checks that $x and $y are not the same, the result of the test is added to $this->test_case_results
assertTrue()  : mixed
Checks that $x can coerced to true, the result of the test is added to $this->test_case_results
getIndexTestCase()  : mixed
Test case if IndexManager can determine the type and version of an index to be able to return an instantiated version fo that index.
getVersionTestCase()  : mixed
Test case used to test whether or not the index manager can determine the version of a Yioop index.
getWordInfoTestCase()  : mixed
Tests if IndexManager can return the dictionary information about a word stored in an index it manages.
run()  : array<string|int, mixed>
Execute each of the test cases of this unit test and return the results
setUp()  : mixed
Before each test sets up a test directory with an old and new bundle in it
tearDown()  : mixed
Used after each test to delete the test directory
docidFromInt()  : string
Computes a 24 byte docId by padding an int to the left with 0's
docidFromIntKeys()  : string
docids are typically made from three 8byte strings. This function takes three ints and left pads each with '0' (\x30) and concatenates then to make a 24 byte docid. As docids use their 8 byte to say whether the id is for a document (replace with 'd') or a link (replace with 'l') this function uses the value of the $is_doc flag to determine which value overwrite the 8th byte with.

Constants

case_name

The suffix that all TestCase methods need to have to be called by run()

public mixed case_name = "TestCase"

NEW_BUNDLE

Name of the included version3 Index bundle to test

public mixed NEW_BUNDLE = "IndexData200000000"

OLD_BUNDLE

Name of the included pre version3 Index bundle to test

public mixed OLD_BUNDLE = "IndexData1421025145"

TEST_DIR

Prefix of folders for index manager test

public mixed TEST_DIR = __DIR__ . '/test_files/index_manager_test'

Properties

$current_method

Contains the value of the next test case to be run can be used by setUp

public string $current_method

$index_archive

Holds current instance of IndexDocumentBundle

public object $index_archive

$test_case_results

Used to store the results for each test sub case

public array<string|int, mixed> $test_case_results

$test_objects

Used to hold objects to be used in tests

public array<string|int, mixed> $test_objects

Methods

__construct()

Constructor should be overridden to do any set up that occurs before and test cases

public __construct() : mixed
Return values
mixed

assertEqual()

Checks that $x and $y are the same, the result of the test is added to $this->test_case_results

public assertEqual(mixed $x, mixed $y[, string $description = "" ]) : mixed
Parameters
$x : mixed

a first item to compare

$y : mixed

a second item to compare

$description : string = ""

information about this test subcase

Return values
mixed

assertFalse()

Checks that $x can coerced to false, the result of the test is added to $this->test_case_results

public assertFalse(mixed $x[, string $description = "" ]) : mixed
Parameters
$x : mixed

item to check

$description : string = ""

information about this test subcase

Return values
mixed

assertNotEqual()

Checks that $x and $y are not the same, the result of the test is added to $this->test_case_results

public assertNotEqual(mixed $x, mixed $y[, string $description = "" ]) : mixed
Parameters
$x : mixed

a first item to compare

$y : mixed

a second item to compare

$description : string = ""

information about this test subcase

Return values
mixed

assertTrue()

Checks that $x can coerced to true, the result of the test is added to $this->test_case_results

public assertTrue(mixed $x[, string $description = "" ]) : mixed
Parameters
$x : mixed

item to check

$description : string = ""

information about this test subcase

Return values
mixed

getIndexTestCase()

Test case if IndexManager can determine the type and version of an index to be able to return an instantiated version fo that index.

public getIndexTestCase() : mixed
Return values
mixed

getVersionTestCase()

Test case used to test whether or not the index manager can determine the version of a Yioop index.

public getVersionTestCase() : mixed
Return values
mixed

getWordInfoTestCase()

Tests if IndexManager can return the dictionary information about a word stored in an index it manages.

public getWordInfoTestCase() : mixed
Return values
mixed

run()

Execute each of the test cases of this unit test and return the results

public run([string $method = null ]) : array<string|int, mixed>
Parameters
$method : string = null

if not null then the method to run, else run all methods

Return values
array<string|int, mixed>

test case results

setUp()

Before each test sets up a test directory with an old and new bundle in it

public setUp() : mixed
Return values
mixed

tearDown()

Used after each test to delete the test directory

public tearDown() : mixed
Return values
mixed

docidFromInt()

Computes a 24 byte docId by padding an int to the left with 0's

protected docidFromInt(int $i) : string
Parameters
$i : int

integer to make docId from

Return values
string

docid made by padding

docidFromIntKeys()

docids are typically made from three 8byte strings. This function takes three ints and left pads each with '0' (\x30) and concatenates then to make a 24 byte docid. As docids use their 8 byte to say whether the id is for a document (replace with 'd') or a link (replace with 'l') this function uses the value of the $is_doc flag to determine which value overwrite the 8th byte with.

protected docidFromIntKeys(int $i_hash_url, int $j_hash_page, int $k_hash_host[, bool $is_doc = true ]) : string
Parameters
$i_hash_url : int

an int for first 8 bytes (in non-artificial docids would be for the crawlHash of url document from)

$j_hash_page : int

an int for first 8 bytes (in non-artificial docids would be for the crawlHash of document)

$k_hash_host : int

an int for first 8 bytes (in non-artificial docids would be for the crawlHash of hostname of site document from)

$is_doc : bool = true

whether the hash is for a document or a link

Return values
string

24 byte docid.


        

Search results