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/Query/RangeTest.php | 73 ++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RangeTest.php (limited to 'vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RangeTest.php') diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RangeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RangeTest.php new file mode 100644 index 00000000..4cd75bc8 --- /dev/null +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RangeTest.php @@ -0,0 +1,73 @@ +_getClient(); + $index = $client->getIndex('test'); + $index->create(array(), true); + $type = $index->getType('test'); + + $doc = new Document(1, array('age' => 16, 'height' => 140)); + $type->addDocument($doc); + $doc = new Document(2, array('age' => 21, 'height' => 155)); + $type->addDocument($doc); + $doc = new Document(3, array('age' => 33, 'height' => 160)); + $type->addDocument($doc); + $doc = new Document(4, array('age' => 68, 'height' => 160)); + $type->addDocument($doc); + + $index->optimize(); + $index->refresh(); + + $query = new Range('age', array('from' => 10, 'to' => 20)); + $result = $type->search($query)->count(); + $this->assertEquals(1, $result); + + $query = new Range(); + $query->addField('height', array('gte' => 160)); + + $result = $type->search($query)->count(); + $this->assertEquals(2, $result); + } + + public function testToArray() + { + $range = new Range(); + + $field = array('from' => 20, 'to' => 40); + $range->addField('age', $field); + + $expectedArray = array( + 'range' => array( + 'age' => $field, + ) + ); + + $this->assertEquals($expectedArray, $range->toArray()); + } + + public function testConstruct() + { + $ranges = array('from' => 20, 'to' => 40); + $range = new Range( + 'age', + $ranges + ); + + $expectedArray = array( + 'range' => array( + 'age' => $ranges, + ) + ); + + $this->assertEquals($expectedArray, $range->toArray()); + } +} -- cgit v1.2.3-54-g00ecf