testIsFilterValidForScalar()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 29

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 9.456
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
4
namespace Mdiyakov\DoctrineSolrBundle\Tests\Filter\Field;
5
6
7
use Mdiyakov\DoctrineSolrBundle\Filter\Field\EntityFieldGteFilter;
8
9
class EntityFieldGteFilterTest extends \PHPUnit_Framework_TestCase
10
{
11
12
    public function testIsFilterValidForScalar()
13
    {
14
        $string = 'abcd';
15
        $int = 123;
16
        $bool = true;
17
        $null = null;
18
19
        $entity = new \stdClass();
20
        $filter = new EntityFieldGteFilter();
21
        $filter->setEntityFieldName('title');
22
23
        $entity->title = $int;
24
        $filter->setEntityFieldValue(124);
25
        $this->assertEquals(false, $filter->isFilterValid($entity));
26
        $filter->setEntityFieldValue(122);
27
        $this->assertEquals(true, $filter->isFilterValid($entity));
28
29
        $entity->title = $string;
30
        $filter->setEntityFieldValue('abc');
31
        $this->assertEquals(true, $filter->isFilterValid($entity));
32
33
        $entity->title = $bool;
34
        $filter->setEntityFieldValue($bool);
35
        $this->assertEquals(true, $filter->isFilterValid($entity));
36
37
38
        $entity->title = $null;
39
        $filter->setEntityFieldValue(1);
40
        $this->assertEquals(false, $filter->isFilterValid($entity));
41
    }
42
}