These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Kunstmaan\NodeBundle\Tests\Helper; |
||
4 | |||
5 | use Doctrine\Common\Persistence\ObjectRepository; |
||
6 | use Doctrine\ORM\EntityManager; |
||
7 | use Doctrine\ORM\EntityManagerInterface; |
||
8 | use Kunstmaan\AdminBundle\Entity\User; |
||
9 | use Kunstmaan\AdminBundle\Helper\CloneHelper; |
||
10 | use Kunstmaan\AdminBundle\Helper\FormWidgets\Tabs\TabPane; |
||
11 | use Kunstmaan\NodeBundle\Entity\AbstractPage; |
||
12 | use Kunstmaan\NodeBundle\Entity\HasNodeInterface; |
||
13 | use Kunstmaan\NodeBundle\Entity\Node; |
||
14 | use Kunstmaan\NodeBundle\Entity\NodeTranslation; |
||
15 | use Kunstmaan\NodeBundle\Entity\NodeVersion; |
||
16 | use Kunstmaan\NodeBundle\Entity\PageTabInterface; |
||
17 | use Kunstmaan\NodeBundle\Event\AdaptFormEvent; |
||
18 | use Kunstmaan\NodeBundle\Event\CopyPageTranslationNodeEvent; |
||
19 | use Kunstmaan\NodeBundle\Event\Events; |
||
20 | use Kunstmaan\NodeBundle\Event\NodeEvent; |
||
21 | use Kunstmaan\NodeBundle\Event\RecopyPageTranslationNodeEvent; |
||
22 | use Kunstmaan\NodeBundle\EventListener\NodeTabListener; |
||
23 | use Kunstmaan\NodeBundle\Helper\NodeAdmin\NodeAdminPublisher; |
||
24 | use Kunstmaan\NodeBundle\Helper\NodeHelper; |
||
25 | use Kunstmaan\NodeBundle\Repository\NodeRepository; |
||
26 | use Kunstmaan\NodeBundle\Repository\NodeTranslationRepository; |
||
27 | use Kunstmaan\NodeBundle\Repository\NodeVersionRepository; |
||
28 | use Kunstmaan\NodeBundle\ValueObject\PageTab; |
||
29 | use PHPUnit\Framework\TestCase; |
||
30 | use Symfony\Component\EventDispatcher\EventDispatcher; |
||
31 | use Symfony\Component\Form\AbstractType; |
||
32 | use Symfony\Component\Form\Extension\Core\Type\HiddenType; |
||
33 | use Symfony\Component\Form\FormBuilderInterface; |
||
34 | use Symfony\Component\Form\FormFactory; |
||
35 | use Symfony\Component\HttpFoundation\ParameterBag; |
||
36 | use Symfony\Component\HttpFoundation\Request; |
||
37 | use Symfony\Component\OptionsResolver\OptionsResolver; |
||
38 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; |
||
39 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; |
||
40 | use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; |
||
41 | |||
42 | class TestPage extends AbstractPage implements HasNodeInterface, PageTabInterface |
||
43 | { |
||
44 | /** |
||
45 | * @return array |
||
46 | */ |
||
47 | public function getPossibleChildTypes() |
||
48 | { |
||
49 | return []; |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * @return PageTab[] |
||
54 | */ |
||
55 | public function getTabs() |
||
56 | { |
||
57 | return [ |
||
58 | new PageTab('tab1_name', 'tab1_title', TestType::class), |
||
59 | ]; |
||
60 | } |
||
61 | } |
||
62 | |||
63 | class TestType extends AbstractType |
||
64 | { |
||
65 | /** |
||
66 | * @param FormBuilderInterface $builder |
||
67 | * @param array $options |
||
68 | */ |
||
69 | public function buildForm(FormBuilderInterface $builder, array $options) |
||
70 | { |
||
71 | $builder->add('id', HiddenType::class); |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * @return string |
||
76 | */ |
||
77 | public function getBlockPrefix() |
||
78 | { |
||
79 | return 'test'; |
||
80 | } |
||
81 | |||
82 | public function configureOptions(OptionsResolver $resolver) |
||
83 | { |
||
84 | $resolver->setDefaults(array( |
||
85 | 'data_class' => TestPage::class, |
||
86 | )); |
||
87 | } |
||
88 | } |
||
89 | |||
90 | class NodeHelperTest extends TestCase |
||
91 | { |
||
92 | /** @var \PHPUnit_Framework_MockObject_MockObject|EntityManagerInterface */ |
||
93 | private $em; |
||
94 | |||
95 | /** @var \PHPUnit_Framework_MockObject_MockObject|NodeRepository */ |
||
96 | private $repository; |
||
97 | |||
98 | /** @var NodeHelper */ |
||
99 | private $nodeHelper; |
||
100 | |||
101 | /** @var \PHPUnit_Framework_MockObject_MockObject|NodeAdminPublisher */ |
||
102 | private $nodeAdminPublisher; |
||
103 | |||
104 | /** @var \PHPUnit_Framework_MockObject_MockObject|EventDispatcher */ |
||
105 | private $eventDispatcher; |
||
106 | |||
107 | /** @var \PHPUnit_Framework_MockObject_MockObject|TokenStorageInterface */ |
||
108 | private $tokenStorage; |
||
109 | |||
110 | /** @var \PHPUnit_Framework_MockObject_MockObject|CloneHelper */ |
||
111 | private $cloneHelper; |
||
112 | |||
113 | /** @var string */ |
||
114 | private $locale = 'en'; |
||
0 ignored issues
–
show
Comprehensibility
introduced
by
Loading history...
|
|||
115 | |||
116 | /** @var User */ |
||
117 | private $user; |
||
118 | |||
119 | public function setUp() |
||
120 | { |
||
121 | $this->createORM(); |
||
122 | $this->nodeHelper = $this->createNodeHelper(); |
||
123 | } |
||
124 | |||
125 | public function testUpdatePage() |
||
126 | { |
||
127 | /** |
||
128 | * @var TestPage |
||
129 | * @var NodeTranslation $nodeTranslation |
||
130 | */ |
||
131 | list($page, $nodeTranslation, $node) = $this->createNodeEntities(); |
||
132 | $nodeVersion = $nodeTranslation->getPublicNodeVersion(); |
||
133 | |||
134 | $this->em |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Doctrine\ORM\EntityManagerInterface .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
135 | ->expects($this->exactly(3)) |
||
136 | ->method('persist') |
||
137 | ->withConsecutive( |
||
138 | [$this->equalTo($nodeTranslation)], |
||
139 | [$this->equalTo($nodeVersion)], |
||
140 | [$this->equalTo($node)] |
||
141 | ); |
||
142 | |||
143 | $this->eventDispatcher |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Symfony\Component\EventDispatcher\EventDispatcher .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
144 | ->expects($this->exactly(2)) |
||
145 | ->method('dispatch') |
||
146 | ->withConsecutive( |
||
147 | [$this->equalTo(Events::PRE_PERSIST), $this->equalTo(new NodeEvent($node, $nodeTranslation, $nodeVersion, $page))], |
||
148 | [$this->equalTo(Events::POST_PERSIST), $this->equalTo(new NodeEvent($node, $nodeTranslation, $nodeVersion, $page))] |
||
149 | ); |
||
150 | |||
151 | $this->nodeHelper->updatePage( |
||
152 | $node, |
||
153 | $nodeTranslation, |
||
154 | $nodeTranslation->getPublicNodeVersion(), |
||
155 | $page, |
||
156 | false, |
||
157 | null |
||
158 | ); |
||
159 | } |
||
160 | |||
161 | public function testCreatePage() |
||
162 | { |
||
163 | $title = 'Test page'; |
||
164 | $user = new User(); |
||
165 | |||
166 | list($homePage, , $nodeHomePage) = $this->createNodeEntities('Homepage'); |
||
167 | |||
168 | /** |
||
169 | * @var TestPage |
||
170 | * @var NodeTranslation $nodeTranslationChildPage |
||
171 | */ |
||
172 | list(, $nodeTranslationChildPage, $nodeChildPage) = $this->createNodeEntities($title); |
||
173 | |||
174 | $expectedTestPageCreateNodeFor = new TestPage(); |
||
175 | $expectedTestPageCreateNodeFor->setTitle($title); |
||
176 | $expectedTestPageCreateNodeFor->setParent($homePage); |
||
177 | |||
178 | $nodeRepository = $this->getMockBuilder(NodeRepository::class) |
||
179 | ->disableOriginalConstructor() |
||
180 | ->getMock(); |
||
181 | $nodeRepository |
||
182 | ->expects($this->once()) |
||
183 | ->method('createNodeFor') |
||
184 | ->with( |
||
185 | $this->equalTo($expectedTestPageCreateNodeFor), |
||
186 | $this->equalTo($this->locale), |
||
187 | $this->equalTo($user) |
||
188 | ) |
||
189 | ->willReturn($nodeChildPage); |
||
190 | |||
191 | $nodeTranslationRepository = $this->getMockBuilder(NodeTranslationRepository::class) |
||
192 | ->disableOriginalConstructor() |
||
193 | ->getMock(); |
||
194 | $nodeTranslationRepository |
||
195 | ->expects($this->once()) |
||
196 | ->method('getMaxChildrenWeight') |
||
197 | ->willReturn(1); |
||
198 | |||
199 | $this->em |
||
200 | ->method('getRepository') |
||
201 | ->withConsecutive( |
||
202 | [$this->equalTo(Node::class)], |
||
203 | [$this->equalTo(NodeTranslation::class)] |
||
204 | ) |
||
205 | ->willReturnOnConsecutiveCalls( |
||
206 | $nodeRepository, |
||
207 | $nodeTranslationRepository |
||
208 | ); |
||
209 | |||
210 | $expectedEvent = new NodeEvent( |
||
211 | $nodeChildPage, $nodeTranslationChildPage, $nodeTranslationChildPage->getPublicNodeVersion(), $expectedTestPageCreateNodeFor |
||
212 | ); |
||
213 | $this->eventDispatcher |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Symfony\Component\EventDispatcher\EventDispatcher .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
214 | ->expects($this->once()) |
||
215 | ->method('dispatch') |
||
216 | ->with($this->equalTo(Events::ADD_NODE), $this->equalTo($expectedEvent)) |
||
217 | ; |
||
218 | |||
219 | $result = $this->nodeHelper->createPage(TestPage::class, $title, $this->locale, $nodeHomePage); |
||
220 | |||
221 | $this->assertInstanceOf(NodeTranslation::class, $result); |
||
222 | $this->assertEquals(2, $result->getWeight()); |
||
223 | $this->assertEquals($title, $result->getTitle()); |
||
224 | } |
||
225 | |||
226 | public function testDeletePage() |
||
227 | { |
||
228 | /** |
||
229 | * @var Node |
||
230 | * @var NodeTranslation $nodeTranslationHomePage |
||
231 | */ |
||
232 | list($homePage, $nodeTranslationHomePage, $nodeHomePage) = $this->createNodeEntities('Homepage'); |
||
233 | $nodeVersionHomePage = $nodeTranslationHomePage->getPublicNodeVersion(); |
||
234 | |||
235 | /** |
||
236 | * @var TestPage |
||
237 | * @var NodeTranslation $nodeTranslationChildPage |
||
238 | */ |
||
239 | list($page, $nodeTranslationChildPage, $nodeChildPage) = $this->createNodeEntities('Test page'); |
||
240 | $nodeVersionChildPage = $nodeTranslationChildPage->getPublicNodeVersion(); |
||
241 | $nodeHomePage->addNode($nodeChildPage); |
||
242 | |||
243 | $this->eventDispatcher |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Symfony\Component\EventDispatcher\EventDispatcher .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
244 | ->expects($this->exactly(4)) |
||
245 | ->method('dispatch') |
||
246 | ->withConsecutive( |
||
247 | [$this->equalTo(Events::PRE_DELETE), $this->equalTo(new NodeEvent($nodeHomePage, $nodeTranslationHomePage, $nodeVersionHomePage, $homePage))], |
||
248 | [$this->equalTo(Events::PRE_DELETE), $this->equalTo(new NodeEvent($nodeChildPage, $nodeTranslationChildPage, $nodeVersionChildPage, $page))], |
||
249 | [$this->equalTo(Events::POST_DELETE), $this->equalTo(new NodeEvent($nodeChildPage, $nodeTranslationChildPage, $nodeVersionChildPage, $page))], |
||
250 | [$this->equalTo(Events::POST_DELETE), $this->equalTo(new NodeEvent($nodeHomePage, $nodeTranslationHomePage, $nodeVersionHomePage, $homePage))] |
||
251 | ); |
||
252 | |||
253 | $result = $this->nodeHelper->deletePage($nodeHomePage, $this->locale); |
||
254 | |||
255 | $this->assertTrue($result->getNode()->isDeleted()); |
||
256 | $this->assertTrue($nodeHomePage->isDeleted()); |
||
257 | $this->assertTrue($nodeChildPage->isDeleted()); |
||
258 | } |
||
259 | |||
260 | public function testPrepareNodeVersionForPublic() |
||
261 | { |
||
262 | $user = new User(); |
||
263 | |||
264 | $page = new TestPage(); |
||
265 | $page->setTitle('Test'); |
||
266 | $page->setId(1); |
||
267 | |||
268 | $nodeVersion = new NodeVersion(); |
||
269 | $nodeVersion->setType(NodeVersion::PUBLIC_VERSION); |
||
270 | $nodeVersion->setRef($page); |
||
271 | |||
272 | $nodeVersion = $this->getMockBuilder(NodeVersion::class)->getMock(); |
||
273 | $nodeVersion |
||
274 | ->method('getType') |
||
275 | ->willReturn(NodeVersion::PUBLIC_VERSION); |
||
276 | $nodeVersion |
||
277 | ->expects($this->once()) |
||
278 | ->method('getRef') |
||
279 | ->willReturn($page); |
||
280 | $nodeVersion |
||
281 | ->method('getUpdated') |
||
282 | ->willReturn(new \DateTime('-1 hour')); |
||
283 | |||
284 | $nodeTranslation = new NodeTranslation(); |
||
285 | $nodeTranslation->setLang($this->locale); |
||
286 | $nodeTranslation->addNodeVersion($nodeVersion); |
||
0 ignored issues
–
show
$nodeVersion is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<Kunstmaan\NodeBundle\Entity\NodeVersion> .
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...
|
|||
287 | |||
288 | $this->nodeAdminPublisher |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Kunstmaan\NodeBundle\Hel...dmin\NodeAdminPublisher .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
289 | ->expects($this->once()) |
||
290 | ->method('createPublicVersion') |
||
291 | ->with( |
||
292 | $this->equalTo($page), |
||
293 | $this->equalTo($nodeTranslation), |
||
294 | $this->equalTo($nodeVersion), |
||
295 | $this->equalTo($user) |
||
296 | ); |
||
297 | |||
298 | $this->nodeHelper->prepareNodeVersion($nodeVersion, $nodeTranslation, 10, true); |
||
0 ignored issues
–
show
$nodeVersion is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<Kunstmaan\NodeBundle\Entity\NodeVersion> .
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...
|
|||
299 | } |
||
300 | |||
301 | public function testPrepareNodeVersionForDraft() |
||
302 | { |
||
303 | $page = new TestPage(); |
||
304 | $page->setTitle('Test'); |
||
305 | $page->setId(1); |
||
306 | |||
307 | $nodeVersion = new NodeVersion(); |
||
308 | $nodeVersion->setType(NodeVersion::PUBLIC_VERSION); |
||
309 | $nodeVersion->setRef($page); |
||
310 | |||
311 | $nodeVersion = $this->getMockBuilder(NodeVersion::class)->getMock(); |
||
312 | $nodeVersion |
||
313 | ->method('getType') |
||
314 | ->willReturn(NodeVersion::DRAFT_VERSION); |
||
315 | $nodeVersion |
||
316 | ->expects($this->once()) |
||
317 | ->method('getRef') |
||
318 | ->willReturn($page); |
||
319 | $nodeVersion |
||
320 | ->method('getUpdated') |
||
321 | ->willReturn(new \DateTime('-1 hour')); |
||
322 | |||
323 | $nodeTranslation = new NodeTranslation(); |
||
324 | $nodeTranslation->setLang($this->locale); |
||
325 | $nodeTranslation->addNodeVersion($nodeVersion); |
||
0 ignored issues
–
show
$nodeVersion is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<Kunstmaan\NodeBundle\Entity\NodeVersion> .
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...
|
|||
326 | |||
327 | /** @var \PHPUnit_Framework_MockObject_MockObject|NodeHelper $nodeHelper */ |
||
328 | $nodeHelper = $this->getMockBuilder(NodeHelper::class) |
||
329 | ->setConstructorArgs([ |
||
330 | $this->em, |
||
331 | $this->nodeAdminPublisher, |
||
332 | $this->tokenStorage, |
||
333 | $this->cloneHelper, |
||
334 | $this->eventDispatcher, |
||
335 | ]) |
||
336 | ->setMethods(['createDraftVersion']) |
||
337 | ->getMock(); |
||
338 | $nodeHelper |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Kunstmaan\NodeBundle\Helper\NodeHelper .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
339 | ->expects($this->once()) |
||
340 | ->method('createDraftVersion') |
||
341 | ->willReturn(true); |
||
342 | |||
343 | $nodeHelper->prepareNodeVersion($nodeVersion, $nodeTranslation, 10, true); |
||
0 ignored issues
–
show
$nodeVersion is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<Kunstmaan\NodeBundle\Entity\NodeVersion> .
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...
The method
prepareNodeVersion does only exist in Kunstmaan\NodeBundle\Helper\NodeHelper , but not in PHPUnit_Framework_MockObject_MockObject .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
344 | } |
||
345 | |||
346 | public function testCreateDraftVersion() |
||
347 | { |
||
348 | /** |
||
349 | * @var TestPage |
||
350 | * @var NodeTranslation $nodeTranslation |
||
351 | */ |
||
352 | list($page, $nodeTranslation, $node) = $this->createNodeEntities(); |
||
353 | $originalNodeVersion = new NodeVersion(); |
||
354 | |||
355 | $this->cloneHelper |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Kunstmaan\AdminBundle\Helper\CloneHelper .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
356 | ->expects($this->once()) |
||
357 | ->method('deepCloneAndSave') |
||
358 | ->willReturn($page); |
||
359 | |||
360 | $publicNodeVersion = new NodeVersion(); |
||
361 | $publicNodeVersion->setRef($page); |
||
362 | $publicNodeVersion->setType(NodeVersion::PUBLIC_VERSION); |
||
363 | |||
364 | $nodeVersionRepository = $this->getMockBuilder(NodeVersionRepository::class) |
||
365 | ->disableOriginalConstructor() |
||
366 | ->getMock(); |
||
367 | $nodeVersionRepository |
||
368 | ->method('createNodeVersionFor') |
||
369 | ->willReturn($publicNodeVersion); |
||
370 | |||
371 | $this->em->method('getRepository') |
||
372 | ->with(NodeVersion::class) |
||
373 | ->willReturn($nodeVersionRepository); |
||
374 | |||
375 | $this->eventDispatcher |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Symfony\Component\EventDispatcher\EventDispatcher .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
376 | ->expects($this->once()) |
||
377 | ->method('dispatch') |
||
378 | ->with($this->equalTo(Events::CREATE_DRAFT_VERSION), $this->equalTo(new NodeEvent($node, $nodeTranslation, $originalNodeVersion, $page))); |
||
379 | |||
380 | $result = $this->nodeHelper->createDraftVersion($page, $nodeTranslation, $originalNodeVersion); |
||
381 | |||
382 | $this->assertInstanceOf(NodeVersion::class, $result); |
||
383 | $this->assertEquals(NodeVersion::DRAFT_VERSION, $result->getType()); |
||
384 | $this->assertEquals($publicNodeVersion, $result->getOrigin()); |
||
385 | } |
||
386 | |||
387 | public function testGetPageWithNodeInterface() |
||
388 | { |
||
389 | $refId = 10; |
||
390 | |||
391 | $page = new TestPage(); |
||
392 | $page->setTitle('Test'); |
||
393 | $page->setId($refId); |
||
394 | |||
395 | $nodeVersion = new NodeVersion(); |
||
396 | $nodeVersion->setType(NodeVersion::PUBLIC_VERSION); |
||
397 | $nodeVersion->setRef($page); |
||
398 | |||
399 | $nodeTranslation = new NodeTranslation(); |
||
400 | $nodeTranslation->setLang($this->locale); |
||
401 | $nodeTranslation->addNodeVersion($nodeVersion); |
||
402 | |||
403 | $node = new Node(); |
||
404 | $node->addNodeTranslation($nodeTranslation); |
||
405 | |||
406 | $repository = $this->getMockBuilder(ObjectRepository::class)->getMock(); |
||
407 | $repository |
||
408 | ->expects($this->once()) |
||
409 | ->method('find') |
||
410 | ->with($refId) |
||
411 | ->willReturn($page); |
||
412 | |||
413 | $this->em |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Doctrine\ORM\EntityManagerInterface .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
414 | ->expects($this->once()) |
||
415 | ->method('getRepository') |
||
416 | ->with($this->equalTo(TestPage::class)) |
||
417 | ->willReturn($repository); |
||
418 | |||
419 | $this->nodeHelper->getPageWithNodeInterface($node, $this->locale); |
||
420 | } |
||
421 | |||
422 | public function testCopyPageFromOtherLanguage() |
||
423 | { |
||
424 | $targetLocale = 'nl'; |
||
425 | $targetPage = new TestPage(); |
||
426 | |||
427 | /** |
||
428 | * @var TestPage |
||
429 | * @var NodeTranslation $sourceNodeTranslation |
||
430 | */ |
||
431 | list($sourcePage, $sourceNodeTranslation, $node) = $this->createNodeEntities(); |
||
432 | $sourceNodeNodeVersion = $sourceNodeTranslation->getPublicNodeVersion(); |
||
433 | |||
434 | $this->cloneHelper |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Kunstmaan\AdminBundle\Helper\CloneHelper .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
435 | ->expects($this->once()) |
||
436 | ->method('deepCloneAndSave') |
||
437 | ->with($sourcePage) |
||
438 | ->willReturn($targetPage); |
||
439 | |||
440 | $expectedNodeVersion = new NodeVersion(); |
||
441 | $expectedNodeVersion->setType(NodeVersion::PUBLIC_VERSION); |
||
442 | $expectedNodeVersion->setRef($targetPage); |
||
443 | |||
444 | $expectedNodeTranslation = new NodeTranslation(); |
||
445 | $expectedNodeTranslation->setNode($node); |
||
446 | $expectedNodeTranslation->setLang($targetLocale); |
||
447 | $expectedNodeTranslation->setPublicNodeVersion($expectedNodeVersion); |
||
448 | |||
449 | $repository = $this->getMockBuilder(NodeTranslationRepository::class) |
||
450 | ->disableOriginalConstructor() |
||
451 | ->getMock(); |
||
452 | $repository |
||
453 | ->expects($this->once()) |
||
454 | ->method('createNodeTranslationFor') |
||
455 | ->with($this->equalTo($targetPage), $this->equalTo($targetLocale), $this->equalTo($node), $this->equalTo($this->user)) |
||
456 | ->willReturn($expectedNodeTranslation); |
||
457 | |||
458 | $this->em |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Doctrine\ORM\EntityManagerInterface .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
459 | ->expects($this->once()) |
||
460 | ->method('getRepository') |
||
461 | ->with(NodeTranslation::class) |
||
462 | ->willReturn($repository); |
||
463 | |||
464 | $this->eventDispatcher |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Symfony\Component\EventDispatcher\EventDispatcher .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
465 | ->expects($this->once()) |
||
466 | ->method('dispatch') |
||
467 | ->with($this->equalTo(Events::COPY_PAGE_TRANSLATION), $this->equalTo(new CopyPageTranslationNodeEvent( |
||
468 | $node, |
||
469 | $expectedNodeTranslation, |
||
470 | $expectedNodeVersion, |
||
471 | $targetPage, |
||
472 | $sourceNodeTranslation, |
||
473 | $sourceNodeNodeVersion, |
||
474 | $sourcePage, |
||
475 | $this->locale))); |
||
476 | |||
477 | $result = $this->nodeHelper->copyPageFromOtherLanguage($node, $this->locale, $targetLocale); |
||
478 | |||
479 | $this->assertInstanceOf(NodeTranslation::class, $result); |
||
480 | $this->assertEquals($expectedNodeTranslation, $result); |
||
481 | } |
||
482 | |||
483 | public function testDuplicatePage() |
||
484 | { |
||
485 | $targetPage = new TestPage(); |
||
486 | |||
487 | list(, , $nodeHomePage) = $this->createNodeEntities('Homepage'); |
||
488 | |||
489 | /** |
||
490 | * @var TestPage |
||
491 | * @var NodeTranslation $sourceNodeTranslation |
||
492 | * @var Node $node |
||
493 | */ |
||
494 | list($sourcePage, , $node) = $this->createNodeEntities(); |
||
495 | $node->setParent($nodeHomePage); |
||
496 | |||
497 | $this->cloneHelper |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Kunstmaan\AdminBundle\Helper\CloneHelper .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
498 | ->expects($this->once()) |
||
499 | ->method('deepCloneAndSave') |
||
500 | ->with($sourcePage) |
||
501 | ->willReturn($targetPage); |
||
502 | |||
503 | $expectedNodeTranslation = new NodeTranslation(); |
||
504 | $expectedNodeTranslation->setLang($this->locale); |
||
505 | |||
506 | $expectedNode = new Node(); |
||
507 | $expectedNode->addNodeTranslation($expectedNodeTranslation); |
||
508 | |||
509 | $repository = $this->getMockBuilder(NodeRepository::class) |
||
510 | ->disableOriginalConstructor() |
||
511 | ->getMock(); |
||
512 | $repository |
||
513 | ->expects($this->once()) |
||
514 | ->method('createNodeFor') |
||
515 | ->willReturn($expectedNode); |
||
516 | |||
517 | $this->em |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Doctrine\ORM\EntityManagerInterface .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
518 | ->expects($this->once()) |
||
519 | ->method('getRepository') |
||
520 | ->with(Node::class) |
||
521 | ->willReturn($repository); |
||
522 | |||
523 | $result = $this->nodeHelper->duplicatePage($node, $this->locale); |
||
524 | |||
525 | $this->assertInstanceOf(NodeTranslation::class, $result); |
||
526 | } |
||
527 | |||
528 | public function testCreatePageDraftFromOtherLanguage() |
||
529 | { |
||
530 | $targetLocale = 'nl'; |
||
531 | $targetPage = new TestPage(); |
||
532 | |||
533 | /** |
||
534 | * @var TestPage |
||
535 | * @var NodeTranslation $sourceNodeTranslation |
||
536 | */ |
||
537 | list($sourcePage, $sourceNodeTranslation, $node) = $this->createNodeEntities(); |
||
538 | $sourceNodeNodeVersion = $sourceNodeTranslation->getPublicNodeVersion(); |
||
539 | |||
540 | $this->cloneHelper |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Kunstmaan\AdminBundle\Helper\CloneHelper .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
541 | ->expects($this->once()) |
||
542 | ->method('deepCloneAndSave') |
||
543 | ->with($sourcePage) |
||
544 | ->willReturn($targetPage); |
||
545 | |||
546 | $expectedNodeVersion = new NodeVersion(); |
||
547 | $expectedNodeVersion->setType(NodeVersion::PUBLIC_VERSION); |
||
548 | $expectedNodeVersion->setRef($targetPage); |
||
549 | |||
550 | $expectedNodeTranslation = new NodeTranslation(); |
||
551 | $expectedNodeTranslation->setNode($node); |
||
552 | $expectedNodeTranslation->setLang($targetLocale); |
||
553 | $expectedNodeTranslation->setPublicNodeVersion($expectedNodeVersion); |
||
554 | |||
555 | $repository = $this->getMockBuilder(NodeTranslationRepository::class) |
||
556 | ->disableOriginalConstructor() |
||
557 | ->getMock(); |
||
558 | $repository |
||
559 | ->expects($this->once()) |
||
560 | ->method('find') |
||
561 | ->with($this->equalTo(1)) |
||
562 | ->willReturn($sourceNodeTranslation); |
||
563 | $repository |
||
564 | ->expects($this->once()) |
||
565 | ->method('addDraftNodeVersionFor') |
||
566 | ->with($this->equalTo($targetPage), $this->equalTo($targetLocale), $this->equalTo($node), $this->equalTo($this->user)) |
||
567 | ->willReturn($expectedNodeTranslation); |
||
568 | |||
569 | $this->em |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Doctrine\ORM\EntityManagerInterface .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
570 | ->expects($this->exactly(2)) |
||
571 | ->method('getRepository') |
||
572 | ->with(NodeTranslation::class) |
||
573 | ->willReturn($repository); |
||
574 | |||
575 | $this->eventDispatcher |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Symfony\Component\EventDispatcher\EventDispatcher .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
576 | ->expects($this->once()) |
||
577 | ->method('dispatch') |
||
578 | ->with($this->equalTo(Events::RECOPY_PAGE_TRANSLATION), $this->equalTo(new RecopyPageTranslationNodeEvent( |
||
579 | $node, |
||
580 | $expectedNodeTranslation, |
||
581 | $expectedNodeVersion, |
||
582 | $targetPage, |
||
583 | $sourceNodeTranslation, |
||
584 | $sourceNodeNodeVersion, |
||
585 | $sourcePage, |
||
586 | $this->locale))); |
||
587 | |||
588 | $result = $this->nodeHelper->createPageDraftFromOtherLanguage($node, 1, $targetLocale); |
||
589 | |||
590 | $this->assertInstanceOf(NodeTranslation::class, $result); |
||
591 | $this->assertEquals($expectedNodeTranslation, $result); |
||
592 | } |
||
593 | |||
594 | public function testCreateEmptyPage() |
||
595 | { |
||
596 | $targetPage = new TestPage(); |
||
597 | $targetPage->setTitle('No title'); |
||
598 | $node = new Node(); |
||
599 | $node->setRef($targetPage); |
||
600 | |||
601 | $expectedNodeVersion = new NodeVersion(); |
||
602 | $expectedNodeVersion->setType(NodeVersion::PUBLIC_VERSION); |
||
603 | $expectedNodeVersion->setRef($targetPage); |
||
604 | |||
605 | $expectedNodeTranslation = new NodeTranslation(); |
||
606 | $expectedNodeTranslation->setNode($node); |
||
607 | $expectedNodeTranslation->setLang($this->locale); |
||
608 | $expectedNodeTranslation->setPublicNodeVersion($expectedNodeVersion); |
||
609 | |||
610 | $repository = $this->getMockBuilder(NodeTranslationRepository::class) |
||
611 | ->disableOriginalConstructor() |
||
612 | ->getMock(); |
||
613 | $repository |
||
614 | ->expects($this->once()) |
||
615 | ->method('createNodeTranslationFor') |
||
616 | ->with($this->equalTo($targetPage), $this->equalTo($this->locale), $this->equalTo($node), $this->equalTo($this->user)) |
||
617 | ->willReturn($expectedNodeTranslation); |
||
618 | |||
619 | $this->em |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Doctrine\ORM\EntityManagerInterface .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
620 | ->expects($this->once()) |
||
621 | ->method('getRepository') |
||
622 | ->with(NodeTranslation::class) |
||
623 | ->willReturn($repository); |
||
624 | |||
625 | $this->eventDispatcher |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Symfony\Component\EventDispatcher\EventDispatcher .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
626 | ->expects($this->once()) |
||
627 | ->method('dispatch') |
||
628 | ->with($this->equalTo(Events::ADD_EMPTY_PAGE_TRANSLATION), $this->equalTo(new NodeEvent( |
||
629 | $node, |
||
630 | $expectedNodeTranslation, |
||
631 | $expectedNodeVersion, |
||
632 | $targetPage))); |
||
633 | |||
634 | $result = $this->nodeHelper->createEmptyPage($node, $this->locale); |
||
635 | |||
636 | $this->assertInstanceOf(NodeTranslation::class, $result); |
||
637 | $this->assertEquals($expectedNodeTranslation, $result); |
||
638 | } |
||
639 | |||
640 | private function createORM() |
||
641 | { |
||
642 | $this->repository = $this->getMockBuilder(ObjectRepository::class) |
||
643 | ->disableOriginalConstructor() |
||
644 | ->getMock(); |
||
645 | |||
646 | $this->em = $this->getMockBuilder(EntityManager::class) |
||
647 | ->disableOriginalConstructor() |
||
648 | ->getMock(); |
||
649 | } |
||
650 | |||
651 | /** |
||
652 | * @return NodeHelper |
||
653 | */ |
||
654 | private function createNodeHelper() |
||
655 | { |
||
656 | $this->user = new User(); |
||
657 | |||
658 | $token = $this->getMockBuilder(TokenInterface::class)->getMock(); |
||
659 | $token->method('getUser')->willReturn($this->user); |
||
660 | |||
661 | $this->tokenStorage = $this->getMockBuilder(TokenStorage::class) |
||
662 | ->disableOriginalConstructor() |
||
663 | ->getMock(); |
||
664 | $this->tokenStorage->method('getToken')->willReturn($token); |
||
665 | $this->nodeAdminPublisher = $this->getMockBuilder(NodeAdminPublisher::class) |
||
666 | ->disableOriginalConstructor() |
||
667 | ->getMock(); |
||
668 | $this->cloneHelper = $this->getMockBuilder(CloneHelper::class) |
||
669 | ->disableOriginalConstructor() |
||
670 | ->getMock(); |
||
671 | $this->eventDispatcher = $this->getMockBuilder(EventDispatcher::class) |
||
672 | ->disableOriginalConstructor() |
||
673 | ->getMock(); |
||
674 | |||
675 | return new NodeHelper( |
||
676 | $this->em, |
||
677 | $this->nodeAdminPublisher, |
||
0 ignored issues
–
show
$this->nodeAdminPublisher is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<Kunstmaan\NodeBun...min\NodeAdminPublisher> .
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...
|
|||
678 | $this->tokenStorage, |
||
0 ignored issues
–
show
$this->tokenStorage is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<Symfony\Component...\TokenStorageInterface> .
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...
|
|||
679 | $this->cloneHelper, |
||
0 ignored issues
–
show
$this->cloneHelper is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<Kunstmaan\AdminBundle\Helper\CloneHelper> .
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...
|
|||
680 | $this->eventDispatcher |
||
0 ignored issues
–
show
$this->eventDispatcher of type object<PHPUnit\Framework\MockObject\MockObject> is not a sub-type of object<Symfony\Component...entDispatcherInterface> . It seems like you assume a child interface of the interface PHPUnit\Framework\MockObject\MockObject to be always present.
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass. Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.
Loading history...
|
|||
681 | ); |
||
682 | } |
||
683 | |||
684 | /** |
||
685 | * @param string $title |
||
686 | * |
||
687 | * @return array |
||
0 ignored issues
–
show
|
|||
688 | */ |
||
689 | private function createNodeEntities($title = 'Test page') |
||
690 | { |
||
691 | $testPage = new TestPage(); |
||
692 | $testPage->setTitle($title); |
||
693 | |||
694 | $nodeVersionNewPage = $this->getMockBuilder(NodeVersion::class)->getMock(); |
||
695 | $nodeVersionNewPage |
||
696 | ->method('getRef') |
||
697 | ->with($this->em) |
||
698 | ->willReturn($testPage); |
||
699 | $nodeVersionNewPage |
||
700 | ->method('getType') |
||
701 | ->willReturn(NodeVersion::PUBLIC_VERSION); |
||
702 | |||
703 | $nodeTranslationNewPage = new NodeTranslation(); |
||
704 | $nodeTranslationNewPage->setTitle($title); |
||
705 | $nodeTranslationNewPage->setLang($this->locale); |
||
706 | $nodeTranslationNewPage->addNodeVersion($nodeVersionNewPage); |
||
0 ignored issues
–
show
$nodeVersionNewPage is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<Kunstmaan\NodeBundle\Entity\NodeVersion> .
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...
|
|||
707 | $nodeTranslationNewPage->setOnline(true); |
||
708 | |||
709 | $nodeNewPage = new Node(); |
||
710 | $nodeNewPage->setDeleted(false); |
||
711 | $nodeNewPage->addNodeTranslation($nodeTranslationNewPage); |
||
712 | |||
713 | return [$testPage, $nodeTranslationNewPage, $nodeNewPage]; |
||
714 | } |
||
715 | |||
716 | public function testPageShouldHaveTab() |
||
717 | { |
||
718 | $request = new Request(); |
||
719 | $request->request = new ParameterBag(); |
||
720 | |||
721 | $formFactory = $this->getMockBuilder(FormFactory::class) |
||
722 | ->disableOriginalConstructor() |
||
723 | ->getMock(); |
||
724 | |||
725 | $entity = new TestPage(); |
||
726 | |||
727 | $tabPane = new TabPane('id', $request, $formFactory); |
||
728 | $adaptFormEvent = new AdaptFormEvent($request, $tabPane, $entity); |
||
729 | |||
730 | $nodeTabListener = new NodeTabListener(); |
||
731 | $nodeTabListener->adaptForm($adaptFormEvent); |
||
732 | |||
733 | $tabs = $adaptFormEvent->getTabPane()->getTabs(); |
||
734 | $title = null; |
||
735 | |||
736 | if (isset($tabs[0])) { |
||
737 | $title = $tabs[0]->getTitle(); |
||
738 | } |
||
739 | |||
740 | $this->assertEquals('tab1_title', $title); |
||
741 | } |
||
742 | } |
||
743 |