BooleanFieldTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
dl 0
loc 24
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A testGetDocumentValueForScalar() 0 21 1
1
<?php
2
3
4
namespace Mdiyakov\DoctrineSolrBundle\Tests\Schema\Field\Entity;
5
6
7
use Mdiyakov\DoctrineSolrBundle\Schema\Field\Entity\BooleanField;
8
9
class BooleanFieldTest extends \PHPUnit_Framework_TestCase
10
{
11
12
    public function testGetDocumentValueForScalar()
13
    {
14
        $string = 'string';
15
        $int = 123;
16
        $bool = false;
17
18
        $entity = new \stdClass();
19
        $field = new BooleanField('enabled', 'd_enabled', false, 10, false);
0 ignored issues
show
Bug introduced by
false of type false is incompatible with the type string expected by parameter $suggester of Mdiyakov\DoctrineSolrBun...eanField::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

19
        $field = new BooleanField('enabled', 'd_enabled', false, 10, /** @scrutinizer ignore-type */ false);
Loading history...
20
21
        $entity->enabled = $string;
22
        $fieldValue = $field->getDocumentFieldValue($entity);
23
        $this->assertEquals(true ,$fieldValue);
24
25
        $entity->enabled = $int;
26
        $fieldValue = $field->getDocumentFieldValue($entity);
27
        $this->assertEquals(true ,$fieldValue);
28
29
30
        $entity->enabled = $bool;
31
        $fieldValue = $field->getDocumentFieldValue($entity);
32
        $this->assertEquals(false, $fieldValue);
33
    }
34
}