From cee08fe0a9ae96187fa35cc15fa78f6925c5f17e Mon Sep 17 00:00:00 2001 From: Martynas Sudintas <martynas.sudintas@ongr.io> Date: Fri, 27 Mar 2015 13:25:00 +0200 Subject: [PATCH] fixed hasQuery method in QueryAwareTrait --- QueryAwareTraitTest.php | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 QueryAwareTraitTest.php diff --git a/QueryAwareTraitTest.php b/QueryAwareTraitTest.php new file mode 100644 index 0000000..9ceed36 --- /dev/null +++ b/QueryAwareTraitTest.php @@ -0,0 +1,39 @@ +<?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; + +/** + * Tests query aware trait provided methods. + */ +class QueryAwareTraitTest extends \PHPUnit_Framework_TestCase +{ + /** + * Tests hasQuery method without any queries loaded. + */ + public function testHasQueryMethodWithoutQueries() + { + $mock = $this->getMockForTrait('ONGR\ElasticsearchBundle\DSL\Query\QueryAwareTrait'); + $this->assertFalse($mock->hasQuery('some_type')); + } + + /** + * Tests hasQuery method with one query loaded. + */ + public function testHasQueryMethodWithQueries() + { + $builder = $this->getMock('ONGR\ElasticsearchBundle\DSL\BuilderInterface'); + $builder->expects($this->once())->method('getType')->willReturn('foo_type'); + $mock = $this->getMockForTrait('ONGR\ElasticsearchBundle\DSL\Query\QueryAwareTrait'); + $mock->addQuery($builder); + $this->assertTrue($mock->hasQuery('foo_type')); + } +} -- GitLab