Completed
Pull Request — master (#2831)
by
unknown
11:27 queued 10s
created

RedirectAdminListConfiguratorTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 6
dl 0
loc 81
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 12 1
A testBuildFields() 0 13 1
A testBuildFilters() 0 26 1
A testGetBundleName() 0 4 1
A testGetEntityName() 0 4 1
1
<?php
2
3
namespace Kunstmaan\RedirectBundle\Tests\unit\AdminList;
4
5
use Doctrine\ORM\EntityManager;
6
use Kunstmaan\AdminBundle\Helper\Security\Acl\AclHelper;
7
use Kunstmaan\AdminListBundle\AdminList\Field;
8
use Kunstmaan\RedirectBundle\AdminList\RedirectAdminListConfigurator;
9
use PHPUnit\Framework\TestCase;
10
11
/**
12
 * Class RedirectAdminListConfiguratorTest
13
 */
14
class RedirectAdminListConfiguratorTest extends TestCase
15
{
16
    /**
17
     * @var EntityManager
18
     */
19
    protected $em;
20
21
    /**
22
     * @var AclHelper
23
     */
24
    protected $aclHelper;
25
26
    /**
27
     * @var RedirectAdminListConfigurator
28
     */
29
    protected $object;
30
31
    protected function setUp(): void
32
    {
33
        $domainConfiguration = $this->getMockBuilder('Kunstmaan\AdminBundle\Helper\DomainConfigurationInterface')
34
            ->disableOriginalConstructor()->getMock();
35
36
        $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->getMockBuilder('D...onstructor()->getMock() of type object<PHPUnit\Framework\MockObject\MockObject> is incompatible with the declared type object<Doctrine\ORM\EntityManager> of property $em.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
37
            ->disableOriginalConstructor()->getMock();
38
        $this->aclHelper = $this->getMockBuilder('Kunstmaan\AdminBundle\Helper\Security\Acl\AclHelper')
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->getMockBuilder('K...onstructor()->getMock() of type object<PHPUnit\Framework\MockObject\MockObject> is incompatible with the declared type object<Kunstmaan\AdminBu...Security\Acl\AclHelper> of property $aclHelper.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
39
            ->disableOriginalConstructor()->getMock();
40
41
        $this->object = new RedirectAdminListConfigurator($this->em, $this->aclHelper, $domainConfiguration);
0 ignored issues
show
Documentation introduced by
$this->em is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Doctrine\ORM\EntityManager>.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
$this->aclHelper is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a null|object<Kunstmaan\Ad...Security\Acl\AclHelper>.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
$domainConfiguration is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Kunstmaan\AdminBu...ConfigurationInterface>.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
42
    }
43
44
    public function testBuildFields(): void
45
    {
46
        $this->object->buildFields();
47
        $fields = $this->object->getFields();
48
        $this->assertCount(5, $fields);
0 ignored issues
show
Documentation introduced by
$fields is of type array<integer,object<Kun...undle\AdminList\Field>>, but the function expects a object<Countable>|object...nit\Framework\iterable>.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
49
        $fieldNames = array_map(
50
            function (Field $field) {
51
                return $field->getName();
52
            },
53
            $fields
54
        );
55
        $this->assertEquals(['origin', 'target', 'permanent', 'note', 'isAutoRedirect'], $fieldNames);
56
    }
57
58
    public function testBuildFilters(): void
59
    {
60
        $filterBuilder = $this->createMock('Kunstmaan\AdminListBundle\AdminList\FilterBuilder');
61
        $filterBuilder
62
            ->expects($this->at(0))
63
            ->method('add')
64
            ->with('origin');
65
        $filterBuilder
66
            ->expects($this->at(1))
67
            ->method('add')
68
            ->with('target');
69
        $filterBuilder
70
            ->expects($this->at(2))
71
            ->method('add')
72
            ->with('permanent');
73
        $filterBuilder
74
            ->expects($this->at(3))
75
            ->method('add')
76
            ->with('note');
77
        $filterBuilder
78
            ->expects($this->at(4))
79
            ->method('add')
80
            ->with('isAutoRedirect');
81
        $this->object->setFilterBuilder($filterBuilder);
0 ignored issues
show
Documentation introduced by
$filterBuilder is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Kunstmaan\AdminLi...dminList\FilterBuilder>.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
82
        $this->object->buildFilters();
83
    }
84
85
    public function testGetBundleName(): void
86
    {
87
        $this->assertEquals('KunstmaanRedirectBundle', $this->object->getBundleName());
88
    }
89
90
    public function testGetEntityName(): void
91
    {
92
        $this->assertEquals('Redirect', $this->object->getEntityName());
93
    }
94
}
95