These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Kunstmaan\AdminListBundle\Tests\AdminList\FilterType\ORM; |
||
4 | |||
5 | use Codeception\Test\Unit; |
||
6 | use Kunstmaan\AdminListBundle\AdminList\FilterType\ORM\BooleanFilterType; |
||
7 | use Kunstmaan\AdminListBundle\Tests\UnitTester; |
||
8 | use Symfony\Component\HttpFoundation\Request; |
||
9 | |||
10 | View Code Duplication | class BooleanFilterTypeTest extends Unit |
|
0 ignored issues
–
show
|
|||
11 | { |
||
12 | /** |
||
13 | * @var UnitTester |
||
14 | */ |
||
15 | protected $tester; |
||
16 | |||
17 | /** |
||
18 | * @var BooleanFilterType |
||
19 | */ |
||
20 | protected $object; |
||
21 | |||
22 | /** |
||
23 | * Sets up the fixture, for example, opens a network connection. |
||
24 | * This method is called before a test is executed. |
||
25 | */ |
||
26 | protected function _before() |
||
27 | { |
||
28 | $this->object = new BooleanFilterType('boolean', 'b'); |
||
29 | } |
||
30 | |||
31 | public function testBindRequest() |
||
32 | { |
||
33 | $request = new Request(array('filter_value_boolean' => 'true')); |
||
34 | |||
35 | $data = array(); |
||
36 | $uniqueId = 'boolean'; |
||
37 | $this->object->bindRequest($request, $data, $uniqueId); |
||
38 | |||
39 | $this->assertEquals(array('value' => 'true'), $data); |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * @param mixed $value |
||
44 | * |
||
45 | * @dataProvider applyDataProvider |
||
46 | */ |
||
47 | public function testApply($value) |
||
48 | { |
||
49 | $qb = $this->tester->getORMQueryBuilder(); |
||
50 | $qb->select('b') |
||
51 | ->from('Entity', 'b'); |
||
52 | $this->object->setQueryBuilder($qb); |
||
53 | $this->object->apply(array('value' => $value), 'boolean'); |
||
54 | |||
55 | $this->assertEquals("SELECT b FROM Entity b WHERE b.boolean = $value", $qb->getDQL()); |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * @return array |
||
60 | */ |
||
61 | public static function applyDataProvider() |
||
62 | { |
||
63 | return array( |
||
64 | array('true'), |
||
65 | array('false'), |
||
66 | ); |
||
67 | } |
||
68 | |||
69 | public function testGetTemplate() |
||
70 | { |
||
71 | $this->assertEquals('KunstmaanAdminListBundle:FilterType:booleanFilter.html.twig', $this->object->getTemplate()); |
||
72 | } |
||
73 | } |
||
74 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.