Skip to content
Snippets Groups Projects
Commit 1fd0f880 authored by LTRocky's avatar LTRocky
Browse files

unit tests

parent 6df1fe74
No related branches found
No related tags found
No related merge requests found
......@@ -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();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment