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 --- .../test/lib/Elastica/Test/Query/RangeTest.php | 79 ++++++++++++++++++++++ 1 file changed, 79 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..108ef0c9 --- /dev/null +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RangeTest.php @@ -0,0 +1,79 @@ +_getClient(); + $index = $client->getIndex('test'); + $index->create(array(), true); + $type = $index->getType('test'); + + $type->addDocuments(array( + new Document(1, array('age' => 16, 'height' => 140)), + new Document(2, array('age' => 21, 'height' => 155)), + new Document(3, array('age' => 33, 'height' => 160)), + new Document(4, array('age' => 68, 'height' => 160)), + )); + + $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); + } + + /** + * @group unit + */ + 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()); + } + + /** + * @group unit + */ + 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