Esempio n. 1
0
 /**
  * Tests searching
  *
  * @param IndexGenerator $generator Index generator
  *
  * @return void
  * @dataProvider provideTestSearch
  */
 public function testSearch(IndexGenerator $generator)
 {
     $index = $generator->getIndex();
     foreach ($generator->getKeys() as $key) {
         $result = $index->search($key);
         $this->assertNotNull($result, "key: {$key}, max: {$generator->getMaximum()}," . " step: {$generator->getStepSize()}" . " length: {$generator->getIndexLength()}");
         $expected = preg_quote($generator->generateData($key));
         $this->assertRegExp("/{$expected}/", $result->getData());
     }
 }
Esempio n. 2
0
 /**
  * Tests that every key of the index will be found
  * 
  * @param IndexGenerator $generator 
  * @dataProvider provideLargerTestCases
  */
 public function testFindAllKeys(IndexGenerator $generator)
 {
     $expectedKeys = $generator->getKeys();
     foreach ($generator->getIndex() as $result) {
         $this->assertEquals(array_shift($expectedKeys), $result->getKey());
     }
     $this->assertEmpty($expectedKeys);
 }