diff --git a/Aggregation/CardinalityAggregationTest.php b/Aggregation/CardinalityAggregationTest.php index f0f4af24e005d1ddfc7c1256ce66bbb0abd51e7c..68a03056113dabb13d2191b14234b79eb05700c4 100644 --- a/Aggregation/CardinalityAggregationTest.php +++ b/Aggregation/CardinalityAggregationTest.php @@ -18,6 +18,42 @@ use ONGR\ElasticsearchBundle\DSL\Aggregation\CardinalityAggregation; */ class CardinalityAggregationTest extends \PHPUnit_Framework_TestCase { + /** + * Tests getArray method. + */ + public function testGetArray() + { + $aggregation = new CardinalityAggregation('bar'); + + // When $script is set. + $aggregation->setScript('foo'); + $result = $aggregation->getArray(); + + $this->assertArrayHasKey('script', $result); + $this->assertEquals('foo', $result['script']); + + // When $field is set. + $aggregation->setField('foo'); + $result = $aggregation->getArray(); + + $this->assertArrayHasKey('field', $result); + $this->assertEquals('foo', $result['field']); + + // When $precisionThreshold is set. + $aggregation->setPrecisionThreshold(10); + $result = $aggregation->getArray(); + + $this->assertArrayHasKey('precision_threshold', $result); + $this->assertEquals(10, $result['precision_threshold']); + + // When $rehash is set. + $aggregation->setRehash(true); + $result = $aggregation->getArray(); + + $this->assertArrayHasKey('rehash', $result); + $this->assertEquals(true, $result['rehash']); + } + /** * Tests if CardinalityAggregation#getArray throws exception when expected. * @@ -29,4 +65,6 @@ class CardinalityAggregationTest extends \PHPUnit_Framework_TestCase $aggregation = new CardinalityAggregation('bar'); $aggregation->getArray(); } + + }