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 Kunstmaan\AdminListBundle\AdminList\FilterType\ORM\StringFilterType; |
||
6 | use Kunstmaan\AdminListBundle\Tests\unit\AdminList\FilterType\ORM\BaseOrmFilterTest; |
||
7 | use Symfony\Component\HttpFoundation\Request; |
||
8 | |||
9 | /** |
||
10 | * Generated by PHPUnit_SkeletonGenerator on 2012-09-26 at 13:21:34. |
||
11 | */ |
||
12 | View Code Duplication | class StringFilterTypeTest extends BaseOrmFilterTest |
|
13 | { |
||
14 | /** |
||
15 | * @var StringFilterType |
||
16 | */ |
||
17 | protected $object; |
||
18 | |||
19 | protected function setUp() |
||
20 | { |
||
21 | $this->object = new StringFilterType('string', 'b'); |
||
22 | } |
||
23 | |||
24 | public function testBindRequest() |
||
25 | { |
||
26 | $request = new Request(array('filter_comparator_string' => 'equals', 'filter_value_string' => 'TheStringValue')); |
||
27 | |||
28 | $data = array(); |
||
29 | $uniqueId = 'string'; |
||
30 | $this->object->bindRequest($request, $data, $uniqueId); |
||
31 | |||
32 | $this->assertEquals(array('comparator' => 'equals', 'value' => 'TheStringValue'), $data); |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * @param string $comparator The comparator |
||
37 | * @param string $whereClause The where clause |
||
38 | * @param mixed $value The value |
||
39 | * @param mixed $testValue The test value |
||
40 | * |
||
41 | * @dataProvider applyDataProvider |
||
42 | */ |
||
43 | public function testApply($comparator, $whereClause, $value, $testValue) |
||
44 | { |
||
45 | $qb = $this->getQueryBuilder(); |
||
46 | $qb->select('b') |
||
47 | ->from('Entity', 'b'); |
||
48 | $this->object->setQueryBuilder($qb); |
||
49 | $this->object->apply(array('comparator' => $comparator, 'value' => $value), 'string'); |
||
50 | |||
51 | $this->assertEquals("SELECT b FROM Entity b WHERE b.string $whereClause", $qb->getDQL()); |
||
52 | $this->assertEquals($testValue, $qb->getParameter('var_string')->getValue()); |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * @return array |
||
0 ignored issues
–
show
|
|||
57 | */ |
||
58 | public static function applyDataProvider() |
||
59 | { |
||
60 | return array( |
||
61 | array('equals', '= :var_string', 'AStringValue1', 'AStringValue1'), |
||
62 | array('notequals', '<> :var_string', 'AStringValue2', 'AStringValue2'), |
||
63 | array('contains', 'LIKE :var_string', 'AStringValue3', '%AStringValue3%'), |
||
64 | array('doesnotcontain', 'NOT LIKE :var_string', 'AStringValue4', '%AStringValue4%'), |
||
65 | array('startswith', 'LIKE :var_string', 'AStringValue5', 'AStringValue5%'), |
||
66 | array('endswith', 'LIKE :var_string', 'AStringValue6', '%AStringValue6'), |
||
67 | ); |
||
68 | } |
||
69 | |||
70 | public function testGetTemplate() |
||
71 | { |
||
72 | $this->assertEquals('@KunstmaanAdminList/FilterType/stringFilter.html.twig', $this->object->getTemplate()); |
||
73 | } |
||
74 | } |
||
75 |
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.