diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2015-12-20 09:00:55 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2015-12-20 09:00:55 +0100 |
commit | a2190ac74dd4d7080b12bab90e552d7aa81209ef (patch) | |
tree | 8b31f38de9882d18df54cf8d9e0de74167a094eb /vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ReverseNestedTest.php | |
parent | 15e69f7b20b6596b9148030acce5b59993b95a45 (diff) | |
parent | 257401d8b2cf661adf36c84b0e3fd1cf85e33c22 (diff) |
Merge branch 'mw-1.26'
Diffstat (limited to 'vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ReverseNestedTest.php')
-rw-r--r-- | vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ReverseNestedTest.php | 88 |
1 files changed, 49 insertions, 39 deletions
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ReverseNestedTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ReverseNestedTest.php index 215dac63..0e2ed2e6 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ReverseNestedTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ReverseNestedTest.php @@ -1,86 +1,96 @@ <?php - namespace Elastica\Test\Aggregation; -use Elastica\Aggregation\Terms; use Elastica\Aggregation\Nested; use Elastica\Aggregation\ReverseNested; +use Elastica\Aggregation\Terms; use Elastica\Document; use Elastica\Query; use Elastica\Type\Mapping; class ReverseNestedTest extends BaseAggregationTest { - protected function setUp() + protected function _getIndexForTest() { - parent::setUp(); - $this->_index = $this->_createIndex("nested"); + $index = $this->_createIndex(); $mapping = new Mapping(); $mapping->setProperties(array( - "comments" => array( - "type" => "nested", - "properties" => array( - "name" => array("type" => "string"), - "body" => array("type" => "string") - ) - ) + 'comments' => array( + 'type' => 'nested', + 'properties' => array( + 'name' => array('type' => 'string'), + 'body' => array('type' => 'string'), + ), + ), )); - $type = $this->_index->getType("test"); + $type = $index->getType('test'); $type->setMapping($mapping); - $docs = array( - new Document("1", array( - "comments" => array( + + $type->addDocuments(array( + new Document(1, array( + 'comments' => array( array( - "name" => "bob", - "body" => "this is bobs comment", + 'name' => 'bob', + 'body' => 'this is bobs comment', ), array( - "name" => "john", - "body" => "this is johns comment", + 'name' => 'john', + 'body' => 'this is johns comment', ), ), - "tags" => array("foo", "bar"), + 'tags' => array('foo', 'bar'), )), - new Document("2", array( - "comments" => array( + new Document(2, array( + 'comments' => array( array( - "name" => "bob", - "body" => "this is another comment from bob", + 'name' => 'bob', + 'body' => 'this is another comment from bob', ), array( - "name" => "susan", - "body" => "this is susans comment", + 'name' => 'susan', + 'body' => 'this is susans comment', ), ), - "tags" => array("foo", "baz"), - )) - ); - $type->addDocuments($docs); - $this->_index->refresh(); + 'tags' => array('foo', 'baz'), + )), + )); + + $index->refresh(); + + return $index; } + /** + * @group unit + */ public function testPathNotSetIfNull() { $agg = new ReverseNested('nested'); $this->assertFalse($agg->hasParam('path')); } + /** + * @group unit + */ public function testPathSetIfNotNull() { $agg = new ReverseNested('nested', 'some_field'); $this->assertEquals('some_field', $agg->getParam('path')); } + /** + * @group functional + */ public function testReverseNestedAggregation() { - $agg = new Nested("comments", "comments"); - $names = new Terms("name"); - $names->setField("comments.name"); + $agg = new Nested('comments', 'comments'); + $names = new Terms('name'); + $names->setField('comments.name'); - $tags = new Terms("tags"); - $tags->setField("tags"); + $tags = new Terms('tags'); + $tags->setField('tags'); - $reverseNested = new ReverseNested("main"); + $reverseNested = new ReverseNested('main'); $reverseNested->addAggregation($tags); $names->addAggregation($reverseNested); @@ -89,7 +99,7 @@ class ReverseNestedTest extends BaseAggregationTest $query = new Query(); $query->addAggregation($agg); - $results = $this->_index->search($query)->getAggregation("comments"); + $results = $this->_getIndexForTest()->search($query)->getAggregation('comments'); $this->assertArrayHasKey('name', $results); $nameResults = $results['name']; |