WordIteratorTest
extends UnitTest
in package
Tests the functionality of the WordIterator class used to iterate over documents in an IndexDocumentBundle containing a term.
Table of Contents
- case_name = "TestCase"
- The suffix that all TestCase methods need to have to be called by run()
- TEST_BUNDLE = "IndexData200000000"
- Name of IndexDocumentBundle used to store test documents
- TEST_DIR = __DIR__ . '/test_files/word_iterator_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
- IndexDocumentBundle used to store test documents
- $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
- findTermTestCase() : mixed
- Sets of a IndexDocumentBundle storing 10 documents. The word 'be' appears in every document and the words or1, or2, ..., or10 each appear in 1 document. The test then checks the number of documents returns by the WordIterator's currentDocsWithWord method to see if this is the case.
- run() : array<string|int, mixed>
- Execute each of the test cases of this unit test and return the results
- setUp() : mixed
- Sets up test dir for document bunble then instantiates IndexDocumentBundle
- tearDown() : mixed
- Deletes test directory and test document bundle
- docidFromIntKeys() : string
- Auxiliary method used to create a document id for a test document
Constants
case_name
The suffix that all TestCase methods need to have to be called by run()
public
mixed
case_name
= "TestCase"
TEST_BUNDLE
Name of IndexDocumentBundle used to store test documents
public
mixed
TEST_BUNDLE
= "IndexData200000000"
TEST_DIR
Prefix of folders for index manager test
public
mixed
TEST_DIR
= __DIR__ . '/test_files/word_iterator_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
IndexDocumentBundle used to store test documents
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 —findTermTestCase()
Sets of a IndexDocumentBundle storing 10 documents. The word 'be' appears in every document and the words or1, or2, ..., or10 each appear in 1 document. The test then checks the number of documents returns by the WordIterator's currentDocsWithWord method to see if this is the case.
public
findTermTestCase() : 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()
Sets up test dir for document bunble then instantiates IndexDocumentBundle
public
setUp() : mixed
Return values
mixed —tearDown()
Deletes test directory and test document bundle
public
tearDown() : mixed
Return values
mixed —docidFromIntKeys()
Auxiliary method used to create a document id for a test document
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 integer that is supposed to be used to correspond to the hash of a url component of a doc_id
- $j_hash_page : int
-
an integer that is supposed to be used to correspond to the hash of a web page component of a doc_id
- $k_hash_host : int
-
an integer that is supposed to be used to correspond to the hash of a url's host component of a doc_id
- $is_doc : bool = true
-
whether to make a doc_id for a link to doc item or for a document
Return values
string —doc_id to associate with that integer