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') |
|
|
|
|
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(): void |
45
|
|
|
{ |
46
|
|
|
$this->object->buildFields(); |
47
|
|
|
$fields = $this->object->getFields(); |
48
|
|
|
$this->assertCount(5, $fields); |
|
|
|
|
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); |
|
|
|
|
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
|
|
|
|
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..