1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Sonata Project package. |
5
|
|
|
* |
6
|
|
|
* (c) Thomas Rabaix <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Sonata\DoctrineORMAdminBundle\Tests\Filter; |
13
|
|
|
|
14
|
|
|
use PHPUnit\Framework\TestCase; |
15
|
|
|
use Sonata\DoctrineORMAdminBundle\Datagrid\ProxyQuery; |
16
|
|
|
use Sonata\DoctrineORMAdminBundle\Filter\DateTimeFilter; |
17
|
|
|
use Symfony\Component\Form\Extension\Core\Type\DateTimeType; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @author Marko Kunic <[email protected]> |
21
|
|
|
*/ |
22
|
|
|
class DateTimeFilterTest extends TestCase |
23
|
|
|
{ |
24
|
|
|
public function testEmpty() |
25
|
|
|
{ |
26
|
|
|
$filter = new DateTimeFilter(); |
27
|
|
|
$filter->initialize('field_name', ['field_options' => ['class' => 'FooBar']]); |
28
|
|
|
|
29
|
|
|
$builder = new ProxyQuery(new QueryBuilder()); |
|
|
|
|
30
|
|
|
|
31
|
|
|
$filter->filter($builder, 'alias', 'field', null); |
|
|
|
|
32
|
|
|
$filter->filter($builder, 'alias', 'field', ''); |
|
|
|
|
33
|
|
|
$filter->filter($builder, 'alias', 'field', ['value' => '']); |
34
|
|
|
|
35
|
|
|
$this->assertEquals([], $builder->query); |
|
|
|
|
36
|
|
|
$this->assertFalse($filter->isActive()); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function testGetType() |
40
|
|
|
{ |
41
|
|
|
$this->assertSame(DateTimeType::class, (new DateTimeFilter())->getFieldType()); |
42
|
|
|
} |
43
|
|
|
} |
44
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: