Completed
Push — master ( 4c1af7...741b75 )
by Ruud
21:53
created

EnumerationFilterTypeTest::testGetTemplate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Kunstmaan\AdminListBundle\Tests\AdminList\FilterType\ORM;
4
5
use Kunstmaan\AdminListBundle\AdminList\FilterType\ORM\EnumerationFilterType;
6
use Kunstmaan\AdminListBundle\Tests\unit\AdminList\FilterType\ORM\BaseOrmFilterTest;
7
use Symfony\Component\HttpFoundation\Request;
8
9
/**
10
 * Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-02-26 at 15:06:50.
11
 */
12
class EnumerationFilterTypeTest extends BaseOrmFilterTest
13
{
14
    /**
15
     * @var \UnitTester
16
     */
17
    protected $tester;
18
19
    /**
20
     * @var EnumerationFilterType
21
     */
22
    protected $object;
23
24
    protected function setUp()
25
    {
26
        $this->object = new EnumerationFilterType('enumeration', 'b');
27
    }
28
29 View Code Duplication
    public function testBindRequest()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
30
    {
31
        $request = new Request(array('filter_comparator_enumeration' => 'in', 'filter_value_enumeration' => array(1, 2)));
32
33
        $data = array();
34
        $uniqueId = 'enumeration';
35
        $this->object->bindRequest($request, $data, $uniqueId);
36
37
        $this->assertEquals(array('comparator' => 'in', 'value' => array(1, 2)), $data);
38
    }
39
40
    /**
41
     * @param string $comparator  The comparator
42
     * @param string $whereClause The where clause
43
     * @param mixed  $value       The value
44
     * @param mixed  $testValue   The test value
45
     *
46
     * @dataProvider applyDataProvider
47
     */
48
    public function testApply($comparator, $whereClause, $value, $testValue)
49
    {
50
        $qb = $this->getQueryBuilder();
51
        $qb->select('b')
52
          ->from('Entity', 'b');
53
        $this->object->setQueryBuilder($qb);
54
        $this->object->apply(array('comparator' => $comparator, 'value' => $value), 'enumeration');
55
56
        $this->assertEquals("SELECT b FROM Entity b WHERE b.enumeration $whereClause", $qb->getDQL());
57
        if ($testValue) {
58
            $this->assertEquals($value, $qb->getParameter('var_enumeration')->getValue());
59
        }
60
    }
61
62
    /**
63
     * @return array
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use array<string|integer[]|boolean>[].

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
64
     */
65 View Code Duplication
    public static function applyDataProvider()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
66
    {
67
        return array(
68
          array('in', 'IN(:var_enumeration)', array(1, 2), true),
69
          array('notin', 'NOT IN(:var_enumeration)', array(1, 2), true),
70
        );
71
    }
72
73
    public function testGetTemplate()
74
    {
75
        $this->assertEquals('KunstmaanAdminListBundle:FilterType:enumerationFilter.html.twig', $this->object->getTemplate());
76
    }
77
}
78