public function provideTestComplexity() { $cases = array(); $generator = new FixedSizeIndexGenerator(); $generator->setIndexLength(10000); $cases[] = array($generator); return $cases; }
/** * Tests finding all keys with different index configurations * * @dataProvider provideTestIndexConfiguration */ public function testIndexConfiguration($offset, $indexFieldLength, $length) { $generator = new FixedSizeIndexGenerator(); $generator->setIndexFieldOffset($offset); $generator->setIndexFieldLength($indexFieldLength); $generator->setIndexLength($length); $index = $generator->getIndex(); for ($key = 0; $key < $length; $key++) { $result = $index->search($key); $this->assertNotNull($result, "key: {$key}"); $this->assertRegExp('/data_' . $key . '_.*\\$/s', $result->getData(), "key: {$key}"); } }
/** * Test cases for testFailSearch() * * @return void */ public function provideTestFailSearch() { $cases = array(); // different sizes $lengths = array(0, 1, 10, IndexGenerator::getBlockSize() - 1, IndexGenerator::getBlockSize(), IndexGenerator::getBlockSize() + 1, IndexGenerator::getBlockSize() * 4); foreach ($lengths as $length) { // Fail searching for MIN(index) - 1 $generator = new FixedSizeIndexGenerator(); $generator->setIndexLength($length); $generator->getIndex(); $cases[] = array($generator->getIndex(), $generator->getMinimum() - 1); // Fail searching for MAX(index) + 1 $generator = new FixedSizeIndexGenerator(); $generator->setIndexLength($length); $generator->getIndex(); $cases[] = array($generator->getIndex(), $generator->getMaximum() + 1); // Fail searching for any missing key inside the index range $generator = new FixedSizeIndexGenerator(); $generator->setIndexLength($length); $generator->setStepSize(2); $generator->getIndex(); $cases[] = array($generator->getIndex(), $generator->getMaximum() / 2 + 0.1); } return $cases; }
/** * Test cases for testAllValidRanges() */ public function provideTestAllValidRanges() { $cases = array(); $generator = new FixedSizeIndexGenerator(); $generator->setIndexLength(0); $cases[] = array($generator); $generator = new FixedSizeIndexGenerator(); $generator->setIndexLength(1); $cases[] = array($generator); $generator = new FixedSizeIndexGenerator(); $generator->setIndexLength(10); $cases[] = array($generator); $generator = new FixedSizeIndexGenerator(); $generator->setIndexLength(100); $cases[] = array($generator); $generator = new FixedSizeIndexGenerator(); $generator->setIndexLength(200); $cases[] = array($generator); return $cases; }
/** * Provides test cases above 1000 * * @return array */ public function provideLargerTestCases() { $cases = $this->provideTestCases(); // 1000 entries $generator = new FixedSizeIndexGenerator(); $generator->setIndexLength(1000); $cases[] = array($generator); // 10000 entries $generator = new FixedSizeIndexGenerator(); $generator->setIndexLength(10000); $cases[] = array($generator); return $cases; }