1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kunstmaan\RedirectBundle\Tests\Entity; |
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') |
37
|
|
|
->disableOriginalConstructor()->getMock(); |
38
|
|
|
$this->aclHelper = $this->getMockBuilder('Kunstmaan\AdminBundle\Helper\Security\Acl\AclHelper') |
39
|
|
|
->disableOriginalConstructor()->getMock(); |
40
|
|
|
|
41
|
|
|
$this->object = new RedirectAdminListConfigurator($this->em, $this->aclHelper, $domainConfiguration); |
|
|
|
|
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function testBuildFields() |
45
|
|
|
{ |
46
|
|
|
$this->object->buildFields(); |
47
|
|
|
$fields = $this->object->getFields(); |
48
|
|
|
$this->assertCount(4, $fields); |
49
|
|
|
$fieldNames = array_map( |
50
|
|
|
function (Field $field) { |
51
|
|
|
return $field->getName(); |
52
|
|
|
}, |
53
|
|
|
$fields |
54
|
|
|
); |
55
|
|
|
$this->assertEquals(array('origin', 'target', 'permanent', 'note'), $fieldNames); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function testBuildFilters() |
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
|
|
|
$this->object->setFilterBuilder($filterBuilder); |
78
|
|
|
$this->object->buildFilters(); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
public function testGetBundleName() |
82
|
|
|
{ |
83
|
|
|
$this->assertEquals('KunstmaanRedirectBundle', $this->object->getBundleName()); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function testGetEntityName() |
87
|
|
|
{ |
88
|
|
|
$this->assertEquals('Redirect', $this->object->getEntityName()); |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|
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: