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 --- .../lib/Elastica/Test/Facet/StatisticalTest.php | 82 ++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/StatisticalTest.php (limited to 'vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/StatisticalTest.php') diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/StatisticalTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/StatisticalTest.php new file mode 100644 index 00000000..dc374289 --- /dev/null +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/StatisticalTest.php @@ -0,0 +1,82 @@ +_getClient(); + $index = $client->getIndex('test'); + $index->create(array(), true); + $type = $index->getType('helloworld'); + + $doc = new Document(1, array('price' => 10)); + $type->addDocument($doc); + $doc = new Document(2, array('price' => 35)); + $type->addDocument($doc); + $doc = new Document(2, array('price' => 45)); + $type->addDocument($doc); + + $facet = new Statistical('stats'); + $facet->setField('price'); + + $query = new Query(); + $query->addFacet($facet); + $query->setQuery(new MatchAll()); + + $index->refresh(); + + $response = $type->search($query); + $facets = $response->getFacets(); + + $this->assertEquals(55, $facets['stats']['total']); + $this->assertEquals(10, $facets['stats']['min']); + $this->assertEquals(45, $facets['stats']['max']); + } + + /** + * @group functional + */ + public function testStatisticalWithSetFields() + { + $client = $this->_getClient(); + $index = $client->getIndex('test'); + $index->create(array(), true); + $type = $index->getType('helloworld'); + + $doc = new Document(1, array('price' => 10, 'price2' => 20)); + $type->addDocument($doc); + $doc = new Document(2, array('price' => 35, 'price2' => 70)); + $type->addDocument($doc); + $doc = new Document(2, array('price' => 45, 'price2' => 90)); + $type->addDocument($doc); + + $facet = new Statistical('stats'); + $facet->setFields(array('price', 'price2')); + + $query = new Query(); + $query->addFacet($facet); + $query->setQuery(new MatchAll()); + + $index->refresh(); + + $response = $type->search($query); + $facets = $response->getFacets(); + + $this->assertEquals(165, $facets['stats']['total']); + $this->assertEquals(10, $facets['stats']['min']); + $this->assertEquals(90, $facets['stats']['max']); + } +} -- cgit v1.2.2