From 439d8211b55eaad3ad871fbc4122728017503e8a Mon Sep 17 00:00:00 2001 From: LTRocky <rokasvaliukas@gmail.com> Date: Tue, 10 Mar 2015 11:45:29 +0200 Subject: [PATCH] Fix code standart & test DSL/Aggregation --- Aggregation/CardinalityAggregationTest.php | 2 -- Aggregation/ChildrenAggregationTest.php | 31 ++++++++++++++++++++++ Aggregation/FilterAggregationTest.php | 13 +++++++++ Suggester/PhraseTest.php | 3 +-- 4 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 Aggregation/ChildrenAggregationTest.php diff --git a/Aggregation/CardinalityAggregationTest.php b/Aggregation/CardinalityAggregationTest.php index 68a0305..3a03e48 100644 --- a/Aggregation/CardinalityAggregationTest.php +++ b/Aggregation/CardinalityAggregationTest.php @@ -65,6 +65,4 @@ class CardinalityAggregationTest extends \PHPUnit_Framework_TestCase $aggregation = new CardinalityAggregation('bar'); $aggregation->getArray(); } - - } diff --git a/Aggregation/ChildrenAggregationTest.php b/Aggregation/ChildrenAggregationTest.php new file mode 100644 index 0000000..fc264d6 --- /dev/null +++ b/Aggregation/ChildrenAggregationTest.php @@ -0,0 +1,31 @@ +<?php + +/* + * This file is part of the ONGR package. + * + * (c) NFQ Technologies UAB <info@nfq.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace ONGR\ElasticsearchBundle\Tests\Unit\DSL\Aggregation; + +use ONGR\ElasticsearchBundle\DSL\Aggregation\ChildrenAggregation; + +/** + * Unit test for children aggregation. + */ +class ChildrenAggregationTest extends \PHPUnit_Framework_TestCase +{ + /** + * Tests if ChildrenAggregation#getArray throws exception when expected. + * + * @expectedException \LogicException + */ + public function testGetArrayException() + { + $aggregation = new ChildrenAggregation('foo'); + $aggregation->getArray(); + } +} diff --git a/Aggregation/FilterAggregationTest.php b/Aggregation/FilterAggregationTest.php index 0b45a48..520c18b 100644 --- a/Aggregation/FilterAggregationTest.php +++ b/Aggregation/FilterAggregationTest.php @@ -12,6 +12,8 @@ namespace ONGR\ElasticsearchBundle\Tests\Unit\DSL\Aggregation; use ONGR\ElasticsearchBundle\DSL\Aggregation\FilterAggregation; +use ONGR\ElasticsearchBundle\DSL\Filter\AndFilter; +use ONGR\ElasticsearchBundle\DSL\Filter\MissingFilter; class FilterAggregationTest extends \PHPUnit_Framework_TestCase { @@ -130,4 +132,15 @@ class FilterAggregationTest extends \PHPUnit_Framework_TestCase $aggregation = new FilterAggregation('test_agg'); $aggregation->toArray(); } + + /** + * Test for toArray() with setting a filter. + */ + public function testToArrayWithFilter() + { + $aggregation = new FilterAggregation('test_agg'); + + $aggregation->setFilter(new MissingFilter('test')); + $aggregation->toArray(); + } } diff --git a/Suggester/PhraseTest.php b/Suggester/PhraseTest.php index 623f7a0..bef3d3d 100644 --- a/Suggester/PhraseTest.php +++ b/Suggester/PhraseTest.php @@ -109,7 +109,6 @@ class PhraseTest extends \PHPUnit_Framework_TestCase { $this->setStub(new Phrase('foo', 'bar')); - return 'ONGR\ElasticsearchBundle\DSL\Suggester\Phrase'; } @@ -130,4 +129,4 @@ class PhraseTest extends \PHPUnit_Framework_TestCase ['size'], ]; } -} \ No newline at end of file +} -- GitLab