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\DBAL; |
||
4 | |||
5 | use Kunstmaan\AdminListBundle\AdminList\FilterType\DBAL\BooleanFilterType; |
||
6 | use Symfony\Component\HttpFoundation\Request; |
||
7 | |||
8 | /** |
||
9 | * Class BooleanFilterTypeTest |
||
10 | */ |
||
11 | View Code Duplication | class BooleanFilterTypeTest extends BaseDbalFilterTest |
|
0 ignored issues
–
show
|
|||
12 | { |
||
13 | /** |
||
14 | * @var BooleanFilterType |
||
15 | */ |
||
16 | protected $object; |
||
17 | |||
18 | protected function setUp() |
||
19 | { |
||
20 | $this->object = new BooleanFilterType('boolean', 'e'); |
||
21 | } |
||
22 | |||
23 | public function testBindRequest() |
||
24 | { |
||
25 | $request = new Request(array('filter_value_boolean' => 'true')); |
||
26 | |||
27 | $data = array(); |
||
28 | $uniqueId = 'boolean'; |
||
29 | $this->object->bindRequest($request, $data, $uniqueId); |
||
30 | |||
31 | $this->assertEquals(array('value' => 'true'), $data); |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * @param mixed $value |
||
36 | * |
||
37 | * @dataProvider applyDataProvider |
||
38 | */ |
||
39 | public function testApply($value) |
||
40 | { |
||
41 | $qb = $this->getQueryBuilder(); |
||
42 | $qb->select('*') |
||
43 | ->from('entity', 'e'); |
||
44 | $this->object->setQueryBuilder($qb); |
||
45 | $this->object->apply(array('value' => $value), 'boolean'); |
||
46 | |||
47 | $this->assertEquals("SELECT * FROM entity e WHERE e.boolean = $value", $qb->getSQL()); |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * @return array |
||
52 | */ |
||
53 | public static function applyDataProvider() |
||
54 | { |
||
55 | return array( |
||
56 | array('true'), |
||
57 | array('false'), |
||
58 | ); |
||
59 | } |
||
60 | |||
61 | public function testGetTemplate() |
||
62 | { |
||
63 | $this->assertEquals('KunstmaanAdminListBundle:FilterType:booleanFilter.html.twig', $this->object->getTemplate()); |
||
64 | } |
||
65 | } |
||
66 |
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.