From 15e69f7b20b6596b9148030acce5b59993b95a45 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 18 Dec 2015 06:00:00 +0100 Subject: Update to MediaWiki 1.25.4 --- .../test/lib/Elastica/Test/ResultSetTest.php | 93 ++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 vendor/ruflin/elastica/test/lib/Elastica/Test/ResultSetTest.php (limited to 'vendor/ruflin/elastica/test/lib/Elastica/Test/ResultSetTest.php') diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ResultSetTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ResultSetTest.php new file mode 100644 index 00000000..2a62111d --- /dev/null +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ResultSetTest.php @@ -0,0 +1,93 @@ +_createIndex(); + $type = $index->getType('test'); + + $doc = new Document(1, array('name' => 'elastica search')); + $type->addDocument($doc); + $doc = new Document(2, array('name' => 'elastica library')); + $type->addDocument($doc); + $doc = new Document(3, array('name' => 'elastica test')); + $type->addDocument($doc); + $index->refresh(); + + $resultSet = $type->search('elastica search'); + + $this->assertInstanceOf('Elastica\ResultSet', $resultSet); + $this->assertEquals(3, $resultSet->getTotalHits()); + $this->assertGreaterThan(0, $resultSet->getMaxScore()); + $this->assertInternalType('array', $resultSet->getResults()); + $this->assertEquals(3, count($resultSet)); + } + + public function testArrayAccess() + { + $index = $this->_createIndex(); + $type = $index->getType('test'); + + $doc = new Document(1, array('name' => 'elastica search')); + $type->addDocument($doc); + $doc = new Document(2, array('name' => 'elastica library')); + $type->addDocument($doc); + $doc = new Document(3, array('name' => 'elastica test')); + $type->addDocument($doc); + $index->refresh(); + + $resultSet = $type->search('elastica search'); + + $this->assertInstanceOf('Elastica\ResultSet', $resultSet); + $this->assertInstanceOf('Elastica\Result', $resultSet[0]); + $this->assertInstanceOf('Elastica\Result', $resultSet[1]); + $this->assertInstanceOf('Elastica\Result', $resultSet[2]); + + $this->assertFalse(isset($resultSet[3])); + } + + /** + * @expectedException \Elastica\Exception\InvalidException + */ + public function testInvalidOffsetCreation() + { + $index = $this->_createIndex(); + $type = $index->getType('test'); + + $doc = new Document(1, array('name' => 'elastica search')); + $type->addDocument($doc); + $index->refresh(); + + $resultSet = $type->search('elastica search'); + + $result = new Result(array('_id' => 'fakeresult')); + $resultSet[1] = $result; + } + + /** + * @expectedException \Elastica\Exception\InvalidException + */ + public function testInvalidOffsetGet() + { + $index = $this->_createIndex(); + $type = $index->getType('test'); + + $doc = new Document(1, array('name' => 'elastica search')); + $type->addDocument($doc); + $index->refresh(); + + $resultSet = $type->search('elastica search'); + + return $resultSet[3]; + } +} -- cgit v1.2.3-54-g00ecf