-
Notifications
You must be signed in to change notification settings - Fork 189
/
BooleanFilterTypeTest.php
59 lines (48 loc) · 1.45 KB
/
BooleanFilterTypeTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
namespace Kunstmaan\AdminListBundle\Tests\AdminList\FilterType\ORM;
use Kunstmaan\AdminListBundle\AdminList\FilterType\ORM\BooleanFilterType;
use Symfony\Component\HttpFoundation\Request;
class BooleanFilterTypeTest extends BaseOrmFilterTest
{
/**
* @var BooleanFilterType
*/
protected $object;
protected function setUp(): void
{
$this->object = new BooleanFilterType('boolean', 'b');
}
public function testBindRequest()
{
$request = new Request(['filter_value_boolean' => 'true']);
$data = [];
$uniqueId = 'boolean';
$this->object->bindRequest($request, $data, $uniqueId);
$this->assertEquals(['value' => 'true'], $data);
}
/**
* @param mixed $value
*
* @dataProvider applyDataProvider
*/
public function testApply($value)
{
$qb = $this->getQueryBuilder();
$qb->select('b')
->from('Entity', 'b');
$this->object->setQueryBuilder($qb);
$this->object->apply(['value' => $value], 'boolean');
$this->assertEquals("SELECT b FROM Entity b WHERE b.boolean = $value", $qb->getDQL());
}
public static function applyDataProvider(): array
{
return [
['true'],
['false'],
];
}
public function testGetTemplate()
{
$this->assertEquals('@KunstmaanAdminList/FilterType/booleanFilter.html.twig', $this->object->getTemplate());
}
}