/**
  * @return string
  */
 public function generateData($key)
 {
     $padding = str_repeat(" ", $this->indexFieldOffset);
     $indexKey = str_pad($key, $this->getIndexFieldLength());
     $data = parent::generateData($key);
     return $padding . $indexKey . $data;
 }
Beispiel #2
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());
     }
 }