Code Duplication    Length = 55-60 lines in 2 locations

src/Kunstmaan/AdminListBundle/Tests/unit/AdminList/FilterType/DBAL/BooleanFilterTypeTest.php 1 location

@@ 11-65 (lines=55) @@
8
/**
9
 * Class BooleanFilterTypeTest
10
 */
11
class BooleanFilterTypeTest extends BaseDbalFilterTest
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

src/Kunstmaan/AdminListBundle/Tests/unit/AdminList/FilterType/ORM/BooleanFilterTypeTest.php 1 location

@@ 10-69 (lines=60) @@
7
use Kunstmaan\AdminListBundle\Tests\UnitTester;
8
use Symfony\Component\HttpFoundation\Request;
9
10
class BooleanFilterTypeTest extends BaseOrmFilterTest
11
{
12
    /**
13
     * @var UnitTester
14
     */
15
    protected $tester;
16
17
    /**
18
     * @var BooleanFilterType
19
     */
20
    protected $object;
21
22
    protected function setUp()
23
    {
24
        $this->object = new BooleanFilterType('boolean', 'b');
25
    }
26
27
    public function testBindRequest()
28
    {
29
        $request = new Request(array('filter_value_boolean' => 'true'));
30
31
        $data = array();
32
        $uniqueId = 'boolean';
33
        $this->object->bindRequest($request, $data, $uniqueId);
34
35
        $this->assertEquals(array('value' => 'true'), $data);
36
    }
37
38
    /**
39
     * @param mixed $value
40
     *
41
     * @dataProvider applyDataProvider
42
     */
43
    public function testApply($value)
44
    {
45
        $qb = $this->getQueryBuilder();
46
        $qb->select('b')
47
            ->from('Entity', 'b');
48
        $this->object->setQueryBuilder($qb);
49
        $this->object->apply(array('value' => $value), 'boolean');
50
51
        $this->assertEquals("SELECT b FROM Entity b WHERE b.boolean = $value", $qb->getDQL());
52
    }
53
54
    /**
55
     * @return array
56
     */
57
    public static function applyDataProvider()
58
    {
59
        return array(
60
            array('true'),
61
            array('false'),
62
        );
63
    }
64
65
    public function testGetTemplate()
66
    {
67
        $this->assertEquals('KunstmaanAdminListBundle:FilterType:booleanFilter.html.twig', $this->object->getTemplate());
68
    }
69
}
70