diff --git a/Aggregation/CardinalityAggregationTest.php b/Aggregation/CardinalityAggregationTest.php index 3a03e480761f474471a0cbc6701ddca7fee3b832..1c5d26a69d2aecd62602fb31295dd6f33bbe0099 100644 --- a/Aggregation/CardinalityAggregationTest.php +++ b/Aggregation/CardinalityAggregationTest.php @@ -65,4 +65,14 @@ class CardinalityAggregationTest extends \PHPUnit_Framework_TestCase $aggregation = new CardinalityAggregation('bar'); $aggregation->getArray(); } + + /** + * Tests getType method. + */ + public function testCardinallyAggregationGetType() + { + $aggregation = new CardinalityAggregation('foo'); + $result = $aggregation->getType(); + $this->assertEquals('cardinality', $result); + } } diff --git a/Aggregation/ChildrenAggregationTest.php b/Aggregation/ChildrenAggregationTest.php index e050d87ad77a969898e7d7120613deeedd479192..11e4446099eb0c48fb110edcc80205535cb1d9bc 100644 --- a/Aggregation/ChildrenAggregationTest.php +++ b/Aggregation/ChildrenAggregationTest.php @@ -49,6 +49,9 @@ class ChildrenAggregationTest extends \PHPUnit_Framework_TestCase ->getMockForAbstractClass(); $aggregation = new ChildrenAggregation('foo'); $aggregation->addAggregation($mock); - $aggregation->getArray(); + $aggregation->setChildren('question'); + $result = $aggregation->getArray(); + $expected = ['type' => 'question']; + $this->assertEquals($expected, $result); } } diff --git a/Aggregation/TermsAggregationTest.php b/Aggregation/TermsAggregationTest.php index 4d3b3418479e58f4ea2958f147164c52b3e98ccd..25f551ba9211b225b810803aed9e6d3d53975d93 100644 --- a/Aggregation/TermsAggregationTest.php +++ b/Aggregation/TermsAggregationTest.php @@ -16,14 +16,10 @@ use ONGR\ElasticsearchBundle\DSL\Aggregation\TermsAggregation; class TermsAggregationTest extends \PHPUnit_Framework_TestCase { /** - * Data provider for testToArray(). - * - * @return array + * Tests setField method. */ - public function getToArrayData() + public function testTermsAggregationSetField() { - $out = []; - // Case #0 terms aggregation. $aggregation = new TermsAggregation('test_agg'); $aggregation->setField('test_field'); @@ -34,11 +30,14 @@ class TermsAggregationTest extends \PHPUnit_Framework_TestCase ], ]; - $out[] = [ - $aggregation, - $result, - ]; + $this->assertEquals($aggregation->toArray(), $result); + } + /** + * Tests setSize method. + */ + public function testTermsAggregationSetSize() + { // Case #1 terms aggregation with size. $aggregation = new TermsAggregation('test_agg'); $aggregation->setField('test_field'); @@ -53,11 +52,14 @@ class TermsAggregationTest extends \PHPUnit_Framework_TestCase ], ]; - $out[] = [ - $aggregation, - $result, - ]; + $this->assertEquals($aggregation->toArray(), $result); + } + /** + * Tests minDocumentCount method. + */ + public function testTermsAggregationMinDocumentCount() + { // Case #2 terms aggregation with size and min document count. $aggregation = new TermsAggregation('test_agg'); $aggregation->setField('test_field'); @@ -74,11 +76,14 @@ class TermsAggregationTest extends \PHPUnit_Framework_TestCase ], ]; - $out[] = [ - $aggregation, - $result, - ]; + $this->assertEquals($aggregation->toArray(), $result); + } + /** + * Tests include, exclude method. + */ + public function testTermsAggregationSimpleIncludeExclude() + { // Case #3 terms aggregation with simple include, exclude. $aggregation = new TermsAggregation('test_agg'); $aggregation->setField('test_field'); @@ -95,11 +100,14 @@ class TermsAggregationTest extends \PHPUnit_Framework_TestCase ], ]; - $out[] = [ - $aggregation, - $result, - ]; + $this->assertEquals($aggregation->toArray(), $result); + } + /** + * Tests include, exclude with flags method. + */ + public function testTermsAggregationIncludeExcludeFlags() + { // Case #4 terms aggregation with include, exclude and flags. $aggregation = new TermsAggregation('test_agg'); $aggregation->setField('test_field'); @@ -122,11 +130,14 @@ class TermsAggregationTest extends \PHPUnit_Framework_TestCase ], ]; - $out[] = [ - $aggregation, - $result, - ]; + $this->assertEquals($aggregation->toArray(), $result); + } + /** + * Tests setOrder method. + */ + public function testTermsAggregationSetOrder() + { // Case #5 terms aggregation with order default direction. $aggregation = new TermsAggregation('test_agg'); $aggregation->setField('test_field'); @@ -141,11 +152,14 @@ class TermsAggregationTest extends \PHPUnit_Framework_TestCase ], ]; - $out[] = [ - $aggregation, - $result, - ]; + $this->assertEquals($aggregation->toArray(), $result); + } + /** + * Tests setOrder DESC method. + */ + public function testTermsAggregationSetOrderDESC() + { // Case #6 terms aggregation with order term mode, desc direction. $aggregation = new TermsAggregation('test_agg'); $aggregation->setField('test_field'); @@ -160,24 +174,16 @@ class TermsAggregationTest extends \PHPUnit_Framework_TestCase ], ]; - $out[] = [ - $aggregation, - $result, - ]; - - return $out; + $this->assertEquals($aggregation->toArray(), $result); } /** - * Test for toArray(). - * - * @param TermsAggregation $aggregation - * @param array $expectedResults - * - * @dataProvider getToArrayData + * Tests getType method. */ - public function testToArray($aggregation, $expectedResults) + public function testTermsAggregationGetType() { - $this->assertEquals($expectedResults, $aggregation->toArray()); + $aggregation = new TermsAggregation('foo'); + $result = $aggregation->getType(); + $this->assertEquals('terms', $result); } }