diff --git a/Filter/AndFilterTest.php b/Filter/AndFilterTest.php index 6767f08adff9139c6a6320aef23ac5fc871ac3f1..a7fe5153ef5bf8a659380bde47a57edd744e0938 100644 --- a/Filter/AndFilterTest.php +++ b/Filter/AndFilterTest.php @@ -20,7 +20,7 @@ class AndFilterTest extends \PHPUnit_Framework_TestCase */ public function testGetType() { - $filter = new AndFilter('', []); + $filter = new AndFilter([], []); $result = $filter->getType(); $this->assertEquals('and', $result); } @@ -56,12 +56,10 @@ class AndFilterTest extends \PHPUnit_Framework_TestCase [$mockBuildeFfirstFilter], [], [ - 'filters' => [ - 0 => [ - 'term' => [ - 'test_field' => [ - 'test_value' => 'test', - ], + [ + 'term' => [ + 'test_field' => [ + 'test_value' => 'test', ], ], ], @@ -72,19 +70,17 @@ class AndFilterTest extends \PHPUnit_Framework_TestCase [$mockBuildeFfirstFilter, $mockBuilderSecondFilter], [], [ - 'filters' => [ - 0 => [ - 'term' => [ - 'test_field' => [ - 'test_value' => 'test', - ], + [ + 'term' => [ + 'test_field' => [ + 'test_value' => 'test', ], ], - 1 => [ - 'prefix' => [ - 'test_field' => [ - 'test_value' => 'test', - ], + ], + [ + 'prefix' => [ + 'test_field' => [ + 'test_value' => 'test', ], ], ], diff --git a/Filter/NotFilterTest.php b/Filter/NotFilterTest.php index 5edf07d7a50270227073d98c3cda6a0e73c56511..211bba186681125151e5d67095a963f46ad34fed 100644 --- a/Filter/NotFilterTest.php +++ b/Filter/NotFilterTest.php @@ -20,7 +20,7 @@ class NotFilterTest extends \PHPUnit_Framework_TestCase */ public function testGetType() { - $filter = new NotFilter('', []); + $filter = new NotFilter(); $this->assertEquals('not', $filter->getType()); } diff --git a/Filter/OrFilterTest.php b/Filter/OrFilterTest.php index 44f8117d335ad871164dcc31dcbe373d9df9e9d7..4e6e5fc9b64015c4af5c3b8152105676923c7e55 100644 --- a/Filter/OrFilterTest.php +++ b/Filter/OrFilterTest.php @@ -20,7 +20,7 @@ class OrFilterTest extends \PHPUnit_Framework_TestCase */ public function testGetType() { - $filter = new OrFilter('', []); + $filter = new OrFilter(); $result = $filter->getType(); $this->assertEquals('or', $result); } @@ -56,12 +56,10 @@ class OrFilterTest extends \PHPUnit_Framework_TestCase [$mockBuilderFirstFilter], [], [ - 'filters' => [ - 0 => [ - 'term' => [ - 'test_field' => [ - 'test_value' => 'test', - ], + [ + 'term' => [ + 'test_field' => [ + 'test_value' => 'test', ], ], ], @@ -72,19 +70,17 @@ class OrFilterTest extends \PHPUnit_Framework_TestCase [$mockBuilderFirstFilter, $mockBuilderSecondFilter], [], [ - 'filters' => [ - 0 => [ - 'term' => [ - 'test_field' => [ - 'test_value' => 'test', - ], + [ + 'term' => [ + 'test_field' => [ + 'test_value' => 'test', ], ], - 1 => [ - 'prefix' => [ - 'test_field' => [ - 'test_value' => 'test', - ], + ], + [ + 'prefix' => [ + 'test_field' => [ + 'test_value' => 'test', ], ], ], diff --git a/Filter/PostFilterTest.php b/Filter/PostFilterTest.php index 747f2cedd899e2be07280f8aa26385a3afab3a11..9b60ff1e15c3fa6622589057b00f81f3a473bf3d 100644 --- a/Filter/PostFilterTest.php +++ b/Filter/PostFilterTest.php @@ -39,33 +39,19 @@ class PostFilterTest extends \PHPUnit_Framework_TestCase public function testAddFilter() { $missingFilterMock = $this->getMockBuilder('ONGR\ElasticsearchBundle\DSL\Filter\MissingFilter') - ->setMethods(['addToBool']) ->disableOriginalConstructor() ->getMock(); - $missingFilterMock->expects($this->once()) - ->method('addToBool') - ->withAnyParameters(); + $missingFilterMock + ->expects($this->once()) + ->method('toArray') + ->willReturn([]); + $missingFilterMock + ->expects($this->once()) + ->method('getType') + ->willReturn('test_type'); $postFilter = new PostFilter(); $postFilter->setFilter($missingFilterMock); - $postFilter->addFilter($missingFilterMock, 'test'); - } - - /** - * Test setBoolParameters method. - */ - public function testSetBoolParameters() - { - $missingFilterMock = $this->getMockBuilder('ONGR\ElasticsearchBundle\DSL\Filter\MissingFilter') - ->setMethods(['setParameters']) - ->disableOriginalConstructor() - ->getMock(); - $missingFilterMock->expects($this->once()) - ->method('setParameters') - ->withAnyParameters(); - - $postFilter = new PostFilter(); - $postFilter->setFilter($missingFilterMock); - $postFilter->setBoolParameters(['test_param']); + $this->assertEquals(['test_type' => []], $postFilter->toArray()); } } diff --git a/Query/QueryTest.php b/Query/QueryTest.php index b90070261a476c4a2fc2617b32ae0a404767ff9d..e2ffd57fd2108cc3428ec895b59419941c58d09f 100644 --- a/Query/QueryTest.php +++ b/Query/QueryTest.php @@ -36,14 +36,17 @@ class QueryTest extends \PHPUnit_Framework_TestCase */ public function testAddQuery() { - $missingFilterMock = $this->getMockBuilder('ONGR\ElasticsearchBundle\DSL\Filter\MissingFilter') + $missingFilterMock = $this + ->getMockBuilder('ONGR\ElasticsearchBundle\DSL\Filter\MissingFilter') ->disableOriginalConstructor() - ->setMethods(['addToBool']) + ->setMethods(['add']) ->getMock(); - $missingFilterMock->expects($this->once()) - ->method('addToBool') + $missingFilterMock + ->expects($this->once()) + ->method('add') ->withAnyParameters(); - $postFilterMock = $this->getMockBuilder('ONGR\ElasticsearchBundle\DSL\Filter\PostFilter') + $postFilterMock = $this + ->getMockBuilder('ONGR\ElasticsearchBundle\DSL\Filter\PostFilter') ->disableOriginalConstructor() ->getMock();