diff options
Diffstat (limited to 'vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation')
22 files changed, 0 insertions, 1068 deletions
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/AvgTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/AvgTest.php deleted file mode 100644 index 5c6fe13d..00000000 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/AvgTest.php +++ /dev/null @@ -1,38 +0,0 @@ -<?php - -namespace Elastica\Test\Aggregation; - - -use Elastica\Aggregation\Avg; -use Elastica\Document; -use Elastica\Index; -use Elastica\Query; - -class AvgTest extends BaseAggregationTest -{ - protected function setUp() - { - parent::setUp(); - $this->_index = $this->_createIndex('avg'); - $docs = array( - new Document('1', array('price' => 5)), - new Document('2', array('price' => 8)), - new Document('3', array('price' => 1)), - new Document('4', array('price' => 3)), - ); - $this->_index->getType('test')->addDocuments($docs); - $this->_index->refresh(); - } - - public function testAvgAggregation() - { - $agg = new Avg("avg"); - $agg->setField('price'); - - $query = new Query(); - $query->addAggregation($agg); - $results = $this->_index->search($query)->getAggregations(); - $this->assertEquals((5 + 8 + 1 + 3) / 4.0, $results['avg']['value']); - } -} -
\ No newline at end of file diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/BaseAggregationTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/BaseAggregationTest.php deleted file mode 100644 index 5569ca78..00000000 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/BaseAggregationTest.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php - -namespace Elastica\Test\Aggregation; - - -use Elastica\Index; -use Elastica\Test\Base; - -abstract class BaseAggregationTest extends Base -{ - /** - * @var Index - */ - protected $_index; - - protected function tearDown() - { - parent::tearDown(); - if ($this->_index instanceof Index) { - $this->_index->delete(); - } - } - - protected function _createIndex($name = 'test', $delete = true, $shards = 1) - { - return parent::_createIndex('test_aggregation_' . $name, $delete, $shards); - } -}
\ No newline at end of file diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/CardinalityTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/CardinalityTest.php deleted file mode 100644 index d2f4d2be..00000000 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/CardinalityTest.php +++ /dev/null @@ -1,38 +0,0 @@ -<?php - -namespace Elastica\Test\Aggregation; - - -use Elastica\Aggregation\Cardinality; -use Elastica\Document; -use Elastica\Query; - -class CardinalityTest extends BaseAggregationTest -{ - protected function setUp() - { - parent::setUp(); - $this->_index = $this->_createIndex("cardinality"); - $docs = array( - new Document("1", array("color" => "blue")), - new Document("2", array("color" => "blue")), - new Document("3", array("color" => "red")), - new Document("4", array("color" => "green")), - ); - $this->_index->getType("test")->addDocuments($docs); - $this->_index->refresh(); - } - - public function testCardinalityAggregation() - { - $agg = new Cardinality("cardinality"); - $agg->setField("color"); - - $query = new Query(); - $query->addAggregation($agg); - $results = $this->_index->search($query)->getAggregation("cardinality"); - - $this->assertEquals(3, $results['value']); - } -} - diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/DateHistogramTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/DateHistogramTest.php deleted file mode 100644 index d5bd878c..00000000 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/DateHistogramTest.php +++ /dev/null @@ -1,43 +0,0 @@ -<?php - -namespace Elastica\Test\Aggregation; - - -use Elastica\Aggregation\DateHistogram; -use Elastica\Document; -use Elastica\Query; -use Elastica\Type\Mapping; - -class DateHistogramTest extends BaseAggregationTest -{ - protected function setUp() - { - parent::setUp(); - $this->_index = $this->_createIndex("date_histogram"); - $mapping = new Mapping(); - $mapping->setProperties(array( - "created" => array("type" => "date") - )); - $type = $this->_index->getType("test"); - $type->setMapping($mapping); - $docs = array( - new Document("1", array("created" => 1390962135000)), - new Document("2", array("created" => 1390965735000)), - new Document("3", array("created" => 1390954935000)), - ); - $type->addDocuments($docs); - $this->_index->refresh(); - } - - public function testDateHistogramAggregation() - { - $agg = new DateHistogram("hist", "created", "1h"); - - $query = new Query(); - $query->addAggregation($agg); - $results = $this->_index->search($query)->getAggregation("hist"); - - $this->assertEquals(3, sizeof($results['buckets'])); - } -} -
\ No newline at end of file diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/DateRangeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/DateRangeTest.php deleted file mode 100644 index 781f2112..00000000 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/DateRangeTest.php +++ /dev/null @@ -1,51 +0,0 @@ -<?php - -namespace Elastica\Test\Aggregation; - - -use Elastica\Aggregation\DateRange; -use Elastica\Document; -use Elastica\Query; -use Elastica\Type\Mapping; - -class DateRangeTest extends BaseAggregationTest -{ - protected function setUp() - { - parent::setUp(); - $this->_index = $this->_createIndex("date_range"); - $mapping = new Mapping(); - $mapping->setProperties(array( - "created" => array("type" => "date") - )); - $type = $this->_index->getType("test"); - $type->setMapping($mapping); - $docs = array( - new Document("1", array("created" => 1390962135000)), - new Document("2", array("created" => 1390965735000)), - new Document("3", array("created" => 1390954935000)), - ); - $type->addDocuments($docs); - $this->_index->refresh(); - } - - public function testDateRangeAggregation() - { - $agg = new DateRange("date"); - $agg->setField("created"); - $agg->addRange(1390958535000)->addRange(null, 1390958535000); - - $query = new Query(); - $query->addAggregation($agg); - $results = $this->_index->search($query)->getAggregation("date"); - - foreach ($results['buckets'] as $bucket) { - if (array_key_exists('to', $bucket)) { - $this->assertEquals(1, $bucket['doc_count']); - } else if (array_key_exists('from', $bucket)) { - $this->assertEquals(2, $bucket['doc_count']); - } - } - } -} -
\ No newline at end of file diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ExtendedStatsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ExtendedStatsTest.php deleted file mode 100644 index e125c9c9..00000000 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ExtendedStatsTest.php +++ /dev/null @@ -1,43 +0,0 @@ -<?php - -namespace Elastica\Test\Aggregation; - - -use Elastica\Aggregation\ExtendedStats; -use Elastica\Document; -use Elastica\Query; - -class ExtendedStatsTest extends BaseAggregationTest -{ - protected function setUp() - { - parent::setUp(); - $this->_index = $this->_createIndex("extended_stats"); - $docs = array( - new Document("1", array("price" => 5)), - new Document("2", array("price" => 8)), - new Document("3", array("price" => 1)), - new Document("4", array("price" => 3)), - ); - $this->_index->getType("test")->addDocuments($docs); - $this->_index->refresh(); - } - - public function testExtendedStatsAggregation() - { - $agg = new ExtendedStats("stats"); - $agg->setField("price"); - - $query = new Query(); - $query->addAggregation($agg); - $results = $this->_index->search($query)->getAggregation("stats"); - - $this->assertEquals(4, $results['count']); - $this->assertEquals(1, $results['min']); - $this->assertEquals(8, $results['max']); - $this->assertEquals((5 + 8 + 1 + 3) / 4.0, $results['avg']); - $this->assertEquals((5 + 8 + 1 + 3), $results['sum']); - $this->assertTrue(array_key_exists('sum_of_squares', $results)); - } -} -
\ No newline at end of file diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/FilterTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/FilterTest.php deleted file mode 100644 index dd4d4c2d..00000000 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/FilterTest.php +++ /dev/null @@ -1,78 +0,0 @@ -<?php - -namespace Elastica\Test\Aggregation; - - -use Elastica\Aggregation\Avg; -use Elastica\Aggregation\Filter; -use Elastica\Document; -use Elastica\Filter\Range; -use Elastica\Filter\Term; -use Elastica\Query; - -class FilterTest extends BaseAggregationTest -{ - protected function setUp() - { - parent::setUp(); - $this->_index = $this->_createIndex("filter"); - $docs = array( - new Document("1", array("price" => 5, "color" => "blue")), - new Document("2", array("price" => 8, "color" => "blue")), - new Document("3", array("price" => 1, "color" => "red")), - new Document("4", array("price" => 3, "color" => "green")), - ); - $this->_index->getType("test")->addDocuments($docs); - $this->_index->refresh(); - } - - public function testToArray() - { - $expected = array( - "filter" => array("range" => array("stock" => array("gt" => 0))), - "aggs" => array( - "avg_price" => array("avg" => array("field" => "price")) - ) - ); - - $agg = new Filter("in_stock_products"); - $agg->setFilter(new Range("stock", array("gt" => 0))); - $avg = new Avg("avg_price"); - $avg->setField("price"); - $agg->addAggregation($avg); - - $this->assertEquals($expected, $agg->toArray()); - } - - public function testFilterAggregation() - { - $agg = new Filter("filter"); - $agg->setFilter(new Term(array("color" => "blue"))); - $avg = new Avg("price"); - $avg->setField("price"); - $agg->addAggregation($avg); - - $query = new Query(); - $query->addAggregation($agg); - - $results = $this->_index->search($query)->getAggregation("filter"); - $results = $results['price']['value']; - - $this->assertEquals((5 + 8) / 2.0, $results); - } - - public function testFilterNoSubAggregation() - { - $agg = new Avg("price"); - $agg->setField("price"); - - $query = new Query(); - $query->addAggregation($agg); - - $results = $this->_index->search($query)->getAggregation("price"); - $results = $results['value']; - - $this->assertEquals((5 + 8 + 1 + 3) / 4.0, $results); - } -} -
\ No newline at end of file diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GeoDistanceTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GeoDistanceTest.php deleted file mode 100644 index 7fd677b1..00000000 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GeoDistanceTest.php +++ /dev/null @@ -1,45 +0,0 @@ -<?php - -namespace Elastica\Test\Aggregation; - - -use Elastica\Aggregation\GeoDistance; -use Elastica\Document; -use Elastica\Query; -use Elastica\Type\Mapping; - -class GeoDistanceTest extends BaseAggregationTest -{ - protected function setUp() - { - parent::setUp(); - $this->_index = $this->_createIndex("geo_distance"); - $mapping = new Mapping(); - $mapping->setProperties(array( - "location" => array("type" => "geo_point") - )); - $type = $this->_index->getType("test"); - $type->setMapping($mapping); - $docs = array( - new Document("1", array("location" => array("lat" => 32.849437, "lon" => -117.271732))), - new Document("2", array("location" => array("lat" => 32.798320, "lon" => -117.246648))), - new Document("3", array("location" => array("lat" => 37.782439, "lon" => -122.392560))), - ); - $type->addDocuments($docs); - $this->_index->refresh(); - } - - public function testGeoDistanceAggregation() - { - $agg = new GeoDistance("geo", "location", array("lat" => 32.804654, "lon" => -117.242594)); - $agg->addRange(null, 100); - $agg->setUnit("mi"); - - $query = new Query(); - $query->addAggregation($agg); - $results = $this->_index->search($query)->getAggregation("geo"); - - $this->assertEquals(2, $results['buckets'][0]['doc_count']); - } -} -
\ No newline at end of file diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GeohashGridTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GeohashGridTest.php deleted file mode 100644 index 38a047f7..00000000 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GeohashGridTest.php +++ /dev/null @@ -1,45 +0,0 @@ -<?php - -namespace Elastica\Test\Aggregation; - - -use Elastica\Aggregation\GeohashGrid; -use Elastica\Document; -use Elastica\Query; -use Elastica\Type\Mapping; - -class GeohashGridTest extends BaseAggregationTest -{ - protected function setUp() - { - parent::setUp(); - $this->_index = $this->_createIndex("geohash_grid"); - $mapping = new Mapping(); - $mapping->setProperties(array( - "location" => array("type" => "geo_point") - )); - $type = $this->_index->getType("test"); - $type->setMapping($mapping); - $docs = array( - new Document("1", array("location" => array("lat" => 32.849437, "lon" => -117.271732))), - new Document("2", array("location" => array("lat" => 32.798320, "lon" => -117.246648))), - new Document("3", array("location" => array("lat" => 37.782439, "lon" => -122.392560))), - ); - $type->addDocuments($docs); - $this->_index->refresh(); - } - - public function testGeohashGridAggregation() - { - $agg = new GeohashGrid("hash", "location"); - $agg->setPrecision(3); - - $query = new Query(); - $query->addAggregation($agg); - $results = $this->_index->search($query)->getAggregation("hash"); - - $this->assertEquals(2, $results['buckets'][0]['doc_count']); - $this->assertEquals(1, $results['buckets'][1]['doc_count']); - } -} -
\ No newline at end of file diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GlobalAggregationTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GlobalAggregationTest.php deleted file mode 100644 index 80366f50..00000000 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GlobalAggregationTest.php +++ /dev/null @@ -1,27 +0,0 @@ -<?php - -namespace Elastica\Test\Aggregation; - - -use Elastica\Aggregation\Avg; -use Elastica\Aggregation\GlobalAggregation; - -class GlobalAggregationTest extends BaseAggregationTest -{ - public function testToArray() - { - $expected = array( - "global" => new \stdClass(), - "aggs" => array( - "avg_price" => array("avg" => array("field" => "price")) - ) - ); - - $agg = new GlobalAggregation("all_products"); - $avg = new Avg("avg_price"); - $avg->setField("price"); - $agg->addAggregation($avg); - $this->assertEquals($expected, $agg->toArray()); - } -} -
\ No newline at end of file diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/HistogramTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/HistogramTest.php deleted file mode 100644 index 35032f43..00000000 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/HistogramTest.php +++ /dev/null @@ -1,45 +0,0 @@ -<?php - -namespace Elastica\Test\Aggregation; - - -use Elastica\Document; -use Elastica\Aggregation\Histogram; -use Elastica\Query; - -class HistogramTest extends BaseAggregationTest -{ - protected function setUp() - { - parent::setUp(); - $this->_index = $this->_createIndex("histogram"); - $docs = array( - new Document("1", array("price" => 5, "color" => "blue")), - new Document("2", array("price" => 8, "color" => "blue")), - new Document("3", array("price" => 1, "color" => "red")), - new Document("4", array("price" => 30, "color" => "green")), - new Document("5", array("price" => 40, "color" => "red")), - new Document("6", array("price" => 35, "color" => "green")), - new Document("7", array("price" => 42, "color" => "red")), - new Document("8", array("price" => 41, "color" => "blue")), - ); - $this->_index->getType("test")->addDocuments($docs); - $this->_index->refresh(); - } - - public function testHistogramAggregation() - { - $agg = new Histogram("hist", "price", 10); - $agg->setMinimumDocumentCount(0); // should return empty buckets - - $query = new Query(); - $query->addAggregation($agg); - $results = $this->_index->search($query)->getAggregation("hist"); - - $buckets = $results['buckets']; - $this->assertEquals(5, sizeof($buckets)); - $this->assertEquals(30, $buckets[3]['key']); - $this->assertEquals(2, $buckets[3]['doc_count']); - } -} -
\ No newline at end of file diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/IpRangeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/IpRangeTest.php deleted file mode 100644 index fce6f857..00000000 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/IpRangeTest.php +++ /dev/null @@ -1,56 +0,0 @@ -<?php - -namespace Elastica\Test\Aggregation; - - -use Elastica\Aggregation\IpRange; -use Elastica\Document; -use Elastica\Query; -use Elastica\Type\Mapping; - -class IpRangeTest extends BaseAggregationTest -{ - protected function setUp() - { - parent::setUp(); - $this->_index = $this->_createIndex("ip_range"); - $mapping = new Mapping(); - $mapping->setProperties(array( - "address" => array("type" => "ip") - )); - $type = $this->_index->getType("test"); - $type->setMapping($mapping); - $docs = array( - new Document("1", array("address" => "192.168.1.100")), - new Document("2", array("address" => "192.168.1.150")), - new Document("3", array("address" => "192.168.1.200")), - ); - $type->addDocuments($docs); - $this->_index->refresh(); - } - - public function testIpRangeAggregation() - { - $agg = new IpRange("ip", "address"); - $agg->addRange("192.168.1.101"); - $agg->addRange(null, "192.168.1.200"); - - $cidrRange = "192.168.1.0/24"; - $agg->addMaskRange($cidrRange); - - $query = new Query(); - $query->addAggregation($agg); - $results = $this->_index->search($query)->getAggregation("ip"); - - foreach ($results['buckets'] as $bucket) { - if (array_key_exists('key', $bucket) && $bucket['key'] == $cidrRange) { - // the CIDR mask - $this->assertEquals(3, $bucket['doc_count']); - } else { - // the normal ip ranges - $this->assertEquals(2, $bucket['doc_count']); - } - } - } -} -
\ No newline at end of file diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MaxTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MaxTest.php deleted file mode 100644 index 0f5475b3..00000000 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MaxTest.php +++ /dev/null @@ -1,72 +0,0 @@ -<?php - -namespace Elastica\Test\Aggregation; - - -use Elastica\Aggregation\Max; -use Elastica\Document; -use Elastica\Query; -use Elastica\Script; - -class MaxTest extends BaseAggregationTest -{ - protected function setUp() - { - parent::setUp(); - $this->_index = $this->_createIndex('max'); - $docs = array( - new Document('1', array('price' => 5)), - new Document('2', array('price' => 8)), - new Document('3', array('price' => 1)), - new Document('4', array('price' => 3)), - ); - $this->_index->getType('test')->addDocuments($docs); - $this->_index->refresh(); - } - - public function testToArray() - { - $expected = array( - "max" => array( - "field" => "price", - "script" => "_value * conversion_rate", - "params" => array( - "conversion_rate" => 1.2 - ) - ), - "aggs" => array( - "subagg" => array("max" => array("field" => "foo")) - ) - ); - - $agg = new Max("min_price_in_euros"); - $agg->setField("price"); - $agg->setScript(new Script("_value * conversion_rate", array('conversion_rate' => 1.2))); - $max = new Max("subagg"); - $max->setField("foo"); - $agg->addAggregation($max); - - $this->assertEquals($expected, $agg->toArray()); - } - - public function testMaxAggregation() - { - $agg = new Max("min_price"); - $agg->setField("price"); - - $query = new Query(); - $query->addAggregation($agg); - $results = $this->_index->search($query)->getAggregation("min_price"); - - $this->assertEquals(8, $results['value']); - - // test using a script - $agg->setScript(new Script("_value * conversion_rate", array("conversion_rate" => 1.2))); - $query = new Query(); - $query->addAggregation($agg); - $results = $this->_index->search($query)->getAggregation("min_price"); - - $this->assertEquals(8 * 1.2, $results['value']); - } -} -
\ No newline at end of file diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MinTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MinTest.php deleted file mode 100644 index 44b52fb4..00000000 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MinTest.php +++ /dev/null @@ -1,38 +0,0 @@ -<?php - -namespace Elastica\Test\Aggregation; - - -use Elastica\Aggregation\Min; -use Elastica\Document; -use Elastica\Query; - -class MinTest extends BaseAggregationTest -{ - protected function setUp() - { - parent::setUp(); - $this->_index = $this->_createIndex('min'); - $docs = array( - new Document('1', array('price' => 5)), - new Document('2', array('price' => 8)), - new Document('3', array('price' => 1)), - new Document('4', array('price' => 3)), - ); - $this->_index->getType('test')->addDocuments($docs); - $this->_index->refresh(); - } - - public function testMinAggregation() - { - $agg = new Min("min_price"); - $agg->setField("price"); - - $query = new Query(); - $query->addAggregation($agg); - $results = $this->_index->search($query)->getAggregation("min_price"); - - $this->assertEquals(1, $results['value']); - } -} -
\ No newline at end of file diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MissingTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MissingTest.php deleted file mode 100644 index 2a852ed0..00000000 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MissingTest.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php - -namespace Elastica\Test\Aggregation; - - -use Elastica\Aggregation\Missing; -use Elastica\Document; -use Elastica\Query; - -class MissingTest extends BaseAggregationTest -{ - protected function setUp() - { - parent::setUp(); - $this->_index = $this->_createIndex('missing'); - $docs = array( - new Document('1', array('price' => 5, "color" => "blue")), - new Document('2', array('price' => 8, "color" => "blue")), - new Document('3', array('price' => 1)), - new Document('4', array('price' => 3, "color" => "green")), - ); - $this->_index->getType('test')->addDocuments($docs); - $this->_index->refresh(); - } - - public function testMissingAggregation() - { - $agg = new Missing("missing", "color"); - - $query = new Query(); - $query->addAggregation($agg); - $results = $this->_index->search($query)->getAggregation("missing"); - - $this->assertEquals(1, $results['doc_count']); - } -} -
\ No newline at end of file diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/NestedTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/NestedTest.php deleted file mode 100644 index ed6de99e..00000000 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/NestedTest.php +++ /dev/null @@ -1,62 +0,0 @@ -<?php - -namespace Elastica\Test\Aggregation; - - -use Elastica\Aggregation\Min; -use Elastica\Aggregation\Nested; -use Elastica\Document; -use Elastica\Query; -use Elastica\Type\Mapping; - -class NestedTest extends BaseAggregationTest -{ - protected function setUp() - { - parent::setUp(); - $this->_index = $this->_createIndex("nested"); - $mapping = new Mapping(); - $mapping->setProperties(array( - "resellers" => array( - "type" => "nested", - "properties" => array( - "name" => array("type" => "string"), - "price" => array("type" => "double") - ) - ) - )); - $type = $this->_index->getType("test"); - $type->setMapping($mapping); - $docs = array( - new Document("1", array( - "resellers" => array( - "name" => "spacely sprockets", - "price" => 5.55 - ) - )), - new Document("1", array( - "resellers" => array( - "name" => "cogswell cogs", - "price" => 4.98 - ) - )) - ); - $type->addDocuments($docs); - $this->_index->refresh(); - } - - public function testNestedAggregation() - { - $agg = new Nested("resellers", "resellers"); - $min = new Min("min_price"); - $min->setField("price"); - $agg->addAggregation($min); - - $query = new Query(); - $query->addAggregation($agg); - $results = $this->_index->search($query)->getAggregation("resellers"); - - $this->assertEquals(4.98, $results['min_price']['value']); - } -} -
\ No newline at end of file diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/RangeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/RangeTest.php deleted file mode 100644 index fb5ca2fe..00000000 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/RangeTest.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php - -namespace Elastica\Test\Aggregation; - - -use Elastica\Aggregation\Range; -use Elastica\Document; -use Elastica\Query; - -class RangeTest extends BaseAggregationTest -{ - protected function setUp() - { - parent::setUp(); - $this->_index = $this->_createIndex('range'); - $docs = array( - new Document('1', array('price' => 5)), - new Document('2', array('price' => 8)), - new Document('3', array('price' => 1)), - new Document('4', array('price' => 3)), - new Document('5', array('price' => 1.5)), - new Document('6', array('price' => 2)), - ); - $this->_index->getType('test')->addDocuments($docs); - $this->_index->refresh(); - } - - public function testRangeAggregation() - { - $agg = new Range("range"); - $agg->setField("price"); - $agg->addRange(1.5, 5); - - $query = new Query(); - $query->addAggregation($agg); - $results = $this->_index->search($query)->getAggregation("range"); - - $this->assertEquals(2, $results['buckets'][0]['doc_count']); - } -} -
\ No newline at end of file diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ReverseNestedTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ReverseNestedTest.php deleted file mode 100644 index 215dac63..00000000 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ReverseNestedTest.php +++ /dev/null @@ -1,124 +0,0 @@ -<?php - -namespace Elastica\Test\Aggregation; - -use Elastica\Aggregation\Terms; -use Elastica\Aggregation\Nested; -use Elastica\Aggregation\ReverseNested; -use Elastica\Document; -use Elastica\Query; -use Elastica\Type\Mapping; - -class ReverseNestedTest extends BaseAggregationTest -{ - protected function setUp() - { - parent::setUp(); - $this->_index = $this->_createIndex("nested"); - $mapping = new Mapping(); - $mapping->setProperties(array( - "comments" => array( - "type" => "nested", - "properties" => array( - "name" => array("type" => "string"), - "body" => array("type" => "string") - ) - ) - )); - $type = $this->_index->getType("test"); - $type->setMapping($mapping); - $docs = array( - new Document("1", array( - "comments" => array( - array( - "name" => "bob", - "body" => "this is bobs comment", - ), - array( - "name" => "john", - "body" => "this is johns comment", - ), - ), - "tags" => array("foo", "bar"), - )), - new Document("2", array( - "comments" => array( - array( - "name" => "bob", - "body" => "this is another comment from bob", - ), - array( - "name" => "susan", - "body" => "this is susans comment", - ), - ), - "tags" => array("foo", "baz"), - )) - ); - $type->addDocuments($docs); - $this->_index->refresh(); - } - - public function testPathNotSetIfNull() - { - $agg = new ReverseNested('nested'); - $this->assertFalse($agg->hasParam('path')); - } - - public function testPathSetIfNotNull() - { - $agg = new ReverseNested('nested', 'some_field'); - $this->assertEquals('some_field', $agg->getParam('path')); - } - - public function testReverseNestedAggregation() - { - $agg = new Nested("comments", "comments"); - $names = new Terms("name"); - $names->setField("comments.name"); - - $tags = new Terms("tags"); - $tags->setField("tags"); - - $reverseNested = new ReverseNested("main"); - $reverseNested->addAggregation($tags); - - $names->addAggregation($reverseNested); - - $agg->addAggregation($names); - - $query = new Query(); - $query->addAggregation($agg); - $results = $this->_index->search($query)->getAggregation("comments"); - - $this->assertArrayHasKey('name', $results); - $nameResults = $results['name']; - - $this->assertCount(3, $nameResults['buckets']); - - // bob - $this->assertEquals('bob', $nameResults['buckets'][0]['key']); - $tags = array( - array('key' => 'foo', 'doc_count' => 2), - array('key' => 'bar', 'doc_count' => 1), - array('key' => 'baz', 'doc_count' => 1), - ); - $this->assertEquals($tags, $nameResults['buckets'][0]['main']['tags']['buckets']); - - // john - $this->assertEquals('john', $nameResults['buckets'][1]['key']); - $tags = array( - array('key' => 'bar', 'doc_count' => 1), - array('key' => 'foo', 'doc_count' => 1), - ); - $this->assertEquals($tags, $nameResults['buckets'][1]['main']['tags']['buckets']); - - // susan - $this->assertEquals('susan', $nameResults['buckets'][2]['key']); - $tags = array( - array('key' => 'baz', 'doc_count' => 1), - array('key' => 'foo', 'doc_count' => 1), - ); - $this->assertEquals($tags, $nameResults['buckets'][2]['main']['tags']['buckets']); - } -} diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/StatsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/StatsTest.php deleted file mode 100644 index 2d315abf..00000000 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/StatsTest.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php - -namespace Elastica\Test\Aggregation; - - -use Elastica\Aggregation\Stats; -use Elastica\Document; -use Elastica\Query; - -class StatsTest extends BaseAggregationTest -{ - protected function setUp() - { - parent::setUp(); - $this->_index = $this->_createIndex('stats'); - $docs = array( - new Document('1', array('price' => 5)), - new Document('2', array('price' => 8)), - new Document('3', array('price' => 1)), - new Document('4', array('price' => 3)), - ); - $this->_index->getType('test')->addDocuments($docs); - $this->_index->refresh(); - } - - public function testStatsAggregation() - { - $agg = new Stats("stats"); - $agg->setField("price"); - - $query = new Query(); - $query->addAggregation($agg); - $results = $this->_index->search($query)->getAggregation("stats"); - - $this->assertEquals(4, $results['count']); - $this->assertEquals(1, $results['min']); - $this->assertEquals(8, $results['max']); - $this->assertEquals((5 + 8 + 1 + 3) / 4.0, $results['avg']); - $this->assertEquals((5 + 8 + 1 + 3), $results['sum']); - } -} -
\ No newline at end of file diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/SumTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/SumTest.php deleted file mode 100644 index 3b3c56a2..00000000 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/SumTest.php +++ /dev/null @@ -1,38 +0,0 @@ -<?php - -namespace Elastica\Test\Aggregation; - - -use Elastica\Aggregation\Sum; -use Elastica\Document; -use Elastica\Query; - -class SumTest extends BaseAggregationTest -{ - protected function setUp() - { - parent::setUp(); - $this->_index = $this->_createIndex('sum'); - $docs = array( - new Document('1', array('price' => 5)), - new Document('2', array('price' => 8)), - new Document('3', array('price' => 1)), - new Document('4', array('price' => 3)), - ); - $this->_index->getType('test')->addDocuments($docs); - $this->_index->refresh(); - } - - public function testSumAggregation() - { - $agg = new Sum("sum"); - $agg->setField("price"); - - $query = new Query(); - $query->addAggregation($agg); - $results = $this->_index->search($query)->getAggregation("sum"); - - $this->assertEquals(5 + 8 + 1 + 3, $results['value']); - } -} -
\ No newline at end of file diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/TermsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/TermsTest.php deleted file mode 100644 index d9f37a20..00000000 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/TermsTest.php +++ /dev/null @@ -1,39 +0,0 @@ -<?php - -namespace Elastica\Test\Aggregation; - - -use Elastica\Aggregation\Terms; -use Elastica\Document; -use Elastica\Query; - -class TermsTest extends BaseAggregationTest -{ - protected function setUp() - { - parent::setUp(); - $this->_index = $this->_createIndex("terms"); - $docs = array( - new Document("1", array("color" => "blue")), - new Document("2", array("color" => "blue")), - new Document("3", array("color" => "red")), - new Document("4", array("color" => "green")), - ); - $this->_index->getType("test")->addDocuments($docs); - $this->_index->refresh(); - } - - public function testTermsAggregation() - { - $agg = new Terms("terms"); - $agg->setField("color"); - - $query = new Query(); - $query->addAggregation($agg); - $results = $this->_index->search($query)->getAggregation("terms"); - - $this->assertEquals(2, $results['buckets'][0]['doc_count']); - $this->assertEquals("blue", $results['buckets'][0]['key']); - } -} -
\ No newline at end of file diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ValueCountTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ValueCountTest.php deleted file mode 100644 index 5eba9ea4..00000000 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ValueCountTest.php +++ /dev/null @@ -1,38 +0,0 @@ -<?php - -namespace Elastica\Test\Aggregation; - - -use Elastica\Aggregation\ValueCount; -use Elastica\Document; -use Elastica\Query; - -class ValueCountTest extends BaseAggregationTest -{ - protected function setUp() - { - parent::setUp(); - $this->_index = $this->_createIndex('value_count'); - $docs = array( - new Document('1', array('price' => 5)), - new Document('2', array('price' => 8)), - new Document('3', array('price' => 1)), - new Document('4', array('price' => 3)), - new Document('5', array('price' => 3)), - ); - $this->_index->getType('test')->addDocuments($docs); - $this->_index->refresh(); - } - - public function testValueCountAggregation() - { - $agg = new ValueCount("count", "price"); - - $query = new Query(); - $query->addAggregation($agg); - $results = $this->_index->search($query)->getAggregation("count"); - - $this->assertEquals(5, $results['value']); - } -} -
\ No newline at end of file |