1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kunstmaan\RedirectBundle\Tests\Form; |
4
|
|
|
|
5
|
|
|
use Kunstmaan\AdminBundle\Helper\DomainConfigurationInterface; |
6
|
|
|
use Kunstmaan\RedirectBundle\Form\RedirectAdminType; |
7
|
|
|
use PHPUnit\Framework\TestCase; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class RedirectAdminTypeTest |
11
|
|
|
*/ |
12
|
|
|
class RedirectAdminTypeTest extends TestCase |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @var RedirectAdminType |
16
|
|
|
*/ |
17
|
|
|
protected $objectMultiDomain; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @var RedirectAdminType |
21
|
|
|
*/ |
22
|
|
|
protected $objectSingleDomain; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var DomainConfigurationInterface |
26
|
|
|
*/ |
27
|
|
|
protected $multiDomainConfiguration; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var DomainConfigurationInterface |
31
|
|
|
*/ |
32
|
|
|
protected $singleDomainConfiguration; |
33
|
|
|
|
34
|
|
|
protected function setUp(): void |
35
|
|
|
{ |
36
|
|
|
$multiDomainConfiguration = $this->getMockBuilder('Kunstmaan\AdminBundle\Helper\DomainConfigurationInterface') |
37
|
|
|
->disableOriginalConstructor()->getMock(); |
38
|
|
|
$multiDomainConfiguration->expects($this->any())->method('isMultiDomainHost')->willReturn(true); |
39
|
|
|
$multiDomainConfiguration->expects($this->any())->method('getHosts')->willReturn(['domain.com', 'domain.be']); |
40
|
|
|
|
41
|
|
|
$singleDomainConfiguration = $this->getMockBuilder('Kunstmaan\AdminBundle\Helper\DomainConfigurationInterface') |
42
|
|
|
->disableOriginalConstructor()->getMock(); |
43
|
|
|
$singleDomainConfiguration->expects($this->any())->method('isMultiDomainHost')->willReturn(false); |
44
|
|
|
$singleDomainConfiguration->expects($this->any())->method('getHosts')->willReturn(array()); |
45
|
|
|
|
46
|
|
|
$this->multiDomainConfiguration = $multiDomainConfiguration; |
47
|
|
|
$this->singleDomainConfiguration = $singleDomainConfiguration; |
48
|
|
|
|
49
|
|
|
$this->objectMultiDomain = new RedirectAdminType(); |
50
|
|
|
$this->objectSingleDomain = new RedirectAdminType(); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function testBuildForm() |
54
|
|
|
{ |
55
|
|
|
$builder = $this->createMock('Symfony\Component\Form\Test\FormBuilderInterface'); |
56
|
|
|
|
57
|
|
|
$builder |
58
|
|
|
->expects($this->at(0)) |
59
|
|
|
->method('add') |
60
|
|
|
->with('domain'); |
61
|
|
|
$builder |
62
|
|
|
->expects($this->at(1)) |
63
|
|
|
->method('add') |
64
|
|
|
->with('origin'); |
65
|
|
|
$builder |
66
|
|
|
->expects($this->at(2)) |
67
|
|
|
->method('add') |
68
|
|
|
->with('target'); |
69
|
|
|
$builder |
70
|
|
|
->expects($this->at(3)) |
71
|
|
|
->method('add') |
72
|
|
|
->with('permanent'); |
73
|
|
|
|
74
|
|
|
$this->objectSingleDomain->buildForm($builder, array('domainConfiguration' => $this->singleDomainConfiguration)); |
|
|
|
|
75
|
|
|
|
76
|
|
|
$builder = $this->createMock('Symfony\Component\Form\Test\FormBuilderInterface'); |
77
|
|
|
$builder |
78
|
|
|
->expects($this->at(0)) |
79
|
|
|
->method('add') |
80
|
|
|
->with('domain'); |
81
|
|
|
$builder |
82
|
|
|
->expects($this->at(1)) |
83
|
|
|
->method('add') |
84
|
|
|
->with('origin'); |
85
|
|
|
$builder |
86
|
|
|
->expects($this->at(2)) |
87
|
|
|
->method('add') |
88
|
|
|
->with('target'); |
89
|
|
|
$builder |
90
|
|
|
->expects($this->at(3)) |
91
|
|
|
->method('add') |
92
|
|
|
->with('permanent'); |
93
|
|
|
|
94
|
|
|
$this->objectMultiDomain->buildForm($builder, array('domainConfiguration' => $this->multiDomainConfiguration)); |
|
|
|
|
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
|
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: