From a1789ddde42033f1b05cc4929491214ee6e79383 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 17 Dec 2015 09:15:42 +0100 Subject: Update to MediaWiki 1.26.0 --- .../elastica/test/lib/Elastica/Test/ScrollTest.php | 105 +++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 vendor/ruflin/elastica/test/lib/Elastica/Test/ScrollTest.php (limited to 'vendor/ruflin/elastica/test/lib/Elastica/Test/ScrollTest.php') diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ScrollTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ScrollTest.php new file mode 100644 index 00000000..df5b0317 --- /dev/null +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ScrollTest.php @@ -0,0 +1,105 @@ +_prepareSearch()); + $count = 1; + + /** @var ResultSet $resultSet */ + foreach ($scroll as $scrollId => $resultSet) { + $this->assertNotEmpty($scrollId); + + $results = $resultSet->getResults(); + switch (true) { + case $count === 1: + // hits: 1 - 5 + $this->assertEquals(5, $resultSet->count()); + $this->assertEquals('1', $results[0]->getId()); + $this->assertEquals('5', $results[4]->getId()); + break; + case $count === 2: + // hits: 6 - 10 + $this->assertEquals(5, $resultSet->count()); + $this->assertEquals('6', $results[0]->getId()); + $this->assertEquals('10', $results[4]->getId()); + break; + case $count === 3: + // hit: 11 + $this->assertEquals(1, $resultSet->count()); + $this->assertEquals('11', $results[0]->getId()); + break; + case $count === 4: + $this->assertEquals(0, $resultSet->count()); + break; + default: + $this->fail('too many iterations'); + } + + $count++; + } + } + + /** + * Scroll must not overwrite options. + * + * @group functional + */ + public function testSearchRevert() + { + $search = $this->_prepareSearch(); + + $search->setOption(Search::OPTION_SCROLL, 'must'); + $search->setOption(Search::OPTION_SCROLL_ID, 'not'); + $search->setOption(Search::OPTION_SEARCH_TYPE, 'change'); + $old = $search->getOptions(); + + $scroll = new Scroll($search); + + $scroll->rewind(); + $this->assertEquals($old, $search->getOptions()); + + $scroll->next(); + $this->assertEquals($old, $search->getOptions()); + } + + /** + * index: 11 docs + * query size: 5. + * + * @return Search + */ + private function _prepareSearch() + { + $index = $this->_createIndex(); + $index->refresh(); + + $docs = array(); + for ($x = 1; $x <= 11; $x++) { + $docs[] = new Document($x, array('id' => $x, 'key' => 'value')); + } + + $type = $index->getType('scrollTest'); + $type->addDocuments($docs); + $index->refresh(); + + $search = new Search($this->_getClient()); + $search->addIndex($index)->addType($type); + $search->getQuery()->setSize(5); + + return $search; + } +} -- cgit v1.2.3-54-g00ecf