This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
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\NodeSearchBundle\Tests\EventListener; |
||
4 | |||
5 | use Doctrine\ORM\EntityManager; |
||
6 | use Kunstmaan\NodeBundle\Entity\AbstractPage; |
||
7 | use Kunstmaan\NodeBundle\Entity\Node; |
||
8 | use Kunstmaan\NodeBundle\Entity\NodeTranslation; |
||
9 | use Kunstmaan\NodeBundle\Entity\StructureNode; |
||
10 | use Kunstmaan\NodeBundle\Event\NodeEvent; |
||
11 | use Kunstmaan\NodeSearchBundle\Configuration\NodePagesConfiguration; |
||
12 | use Kunstmaan\NodeSearchBundle\EventListener\NodeIndexUpdateEventListener; |
||
13 | use PHPUnit\Framework\TestCase; |
||
14 | |||
15 | class NodeIndexUpdateEventListenerTest extends TestCase |
||
16 | { |
||
17 | View Code Duplication | public function testUpdateOfChildPageWithStructuredNodeParent() |
|
0 ignored issues
–
show
|
|||
18 | { |
||
19 | $parentPage = $this->createMock(StructureNode::class); |
||
20 | |||
21 | $parentNodeTranslation = $this->createMock(NodeTranslation::class); |
||
22 | $parentNodeTranslation->method('getRef')->willReturn($parentPage); |
||
23 | $parentNodeTranslation->method('isOnline')->willReturn(true); |
||
24 | |||
25 | $parentNode = $this->createMock(Node::class); |
||
26 | $parentNode->method('getNodeTranslation')->willReturn($parentNodeTranslation); |
||
0 ignored issues
–
show
The method
method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
27 | |||
28 | $node = $this->createMock(Node::class); |
||
29 | $node->method('getParents')->willReturn([ |
||
0 ignored issues
–
show
The method
method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
30 | $parentNode, |
||
31 | ]); |
||
32 | |||
33 | $nodeTranslation = $this->createMock(NodeTranslation::class); |
||
34 | $nodeTranslation->method('getId')->willReturn(1); |
||
0 ignored issues
–
show
The method
method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
35 | $nodeTranslation->method('getLang')->willReturn('nl'); |
||
0 ignored issues
–
show
The method
method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
36 | $nodeTranslation->method('getNode')->willReturn($node); |
||
0 ignored issues
–
show
The method
method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
37 | |||
38 | $nodeEvent = $this->getMockBuilder(NodeEvent::class)->disableOriginalConstructor()->getMock(); |
||
39 | |||
40 | $nodeEvent->method('getNodeTranslation')->willReturn($nodeTranslation); |
||
0 ignored issues
–
show
The method
method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
41 | |||
42 | $em = $this->createMock(EntityManager::class); |
||
43 | $listener = new NodeIndexUpdateEventListener($this->getSearchConfiguration(true), $em); |
||
44 | $listener->onPostPersist($nodeEvent); |
||
0 ignored issues
–
show
$nodeEvent is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<Kunstmaan\NodeBundle\Event\NodeEvent> .
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...
|
|||
45 | } |
||
46 | |||
47 | public function testUpdateOfChildPageWithStructuredNodeParentAndOfflineParent() |
||
48 | { |
||
49 | $parentPage = $this->createMock(StructureNode::class); |
||
50 | |||
51 | $parentNodeTranslation = $this->createMock(NodeTranslation::class); |
||
52 | $parentNodeTranslation->method('getRef')->willReturn($parentPage); |
||
53 | $parentNodeTranslation->method('isOnline')->willReturn(true); |
||
54 | |||
55 | $parentPageNotStructured = $this->createMock(AbstractPage::class); |
||
56 | $parentNodeTranslation2 = $this->createMock(NodeTranslation::class); |
||
57 | $parentNodeTranslation2->method('isOnline')->willReturn(false); |
||
0 ignored issues
–
show
The method
method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
58 | $parentNodeTranslation->method('getRef')->willReturn($parentPageNotStructured); |
||
59 | |||
60 | $parentNode1 = $this->createMock(Node::class); |
||
61 | $parentNode1->method('getNodeTranslation')->willReturn($parentNodeTranslation); |
||
0 ignored issues
–
show
The method
method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
62 | $parentNode2 = $this->createMock(Node::class); |
||
63 | $parentNode2->method('getNodeTranslation')->willReturn($parentNodeTranslation2); |
||
0 ignored issues
–
show
The method
method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
64 | |||
65 | $node = $this->createMock(Node::class); |
||
66 | $node->method('getParents')->willReturn([ |
||
0 ignored issues
–
show
The method
method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
67 | $parentNode1, |
||
68 | $parentNode2, |
||
69 | ]); |
||
70 | |||
71 | $nodeTranslation = $this->createMock(NodeTranslation::class); |
||
72 | $nodeTranslation->method('getId')->willReturn(1); |
||
0 ignored issues
–
show
The method
method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
73 | $nodeTranslation->method('getLang')->willReturn('nl'); |
||
0 ignored issues
–
show
The method
method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
74 | $nodeTranslation->method('getNode')->willReturn($node); |
||
0 ignored issues
–
show
The method
method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
75 | |||
76 | $nodeEvent = $this->getMockBuilder(NodeEvent::class)->disableOriginalConstructor()->getMock(); |
||
77 | |||
78 | $nodeEvent->method('getNodeTranslation')->willReturn($nodeTranslation); |
||
0 ignored issues
–
show
The method
method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
79 | |||
80 | $em = $this->createMock(EntityManager::class); |
||
81 | $listener = new NodeIndexUpdateEventListener($this->getSearchConfiguration(false), $em); |
||
82 | $listener->onPostPersist($nodeEvent); |
||
0 ignored issues
–
show
$nodeEvent is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<Kunstmaan\NodeBundle\Event\NodeEvent> .
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...
|
|||
83 | } |
||
84 | |||
85 | View Code Duplication | public function testUpdateOfChildPageWithOfflineParent() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
86 | { |
||
87 | $parentPage = $this->createMock(AbstractPage::class); |
||
88 | $parentNodeTranslation = $this->createMock(NodeTranslation::class); |
||
89 | $parentNodeTranslation->method('isOnline')->willReturn(false); |
||
0 ignored issues
–
show
The method
method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
90 | $parentNodeTranslation->method('getRef')->willReturn($parentPage); |
||
91 | |||
92 | $parentNode = $this->createMock(Node::class); |
||
93 | $parentNode->method('getNodeTranslation')->willReturn($parentNodeTranslation); |
||
0 ignored issues
–
show
The method
method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
94 | |||
95 | $node = $this->createMock(Node::class); |
||
96 | $node->method('getParents')->willReturn([$parentNode]); |
||
0 ignored issues
–
show
The method
method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
97 | |||
98 | $nodeTranslation = $this->createMock(NodeTranslation::class); |
||
99 | $nodeTranslation->method('getId')->willReturn(1); |
||
0 ignored issues
–
show
The method
method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
100 | $nodeTranslation->method('getLang')->willReturn('nl'); |
||
0 ignored issues
–
show
The method
method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
101 | $nodeTranslation->method('getNode')->willReturn($node); |
||
0 ignored issues
–
show
The method
method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
102 | |||
103 | $nodeEvent = $this->getMockBuilder(NodeEvent::class)->disableOriginalConstructor()->getMock(); |
||
104 | |||
105 | $nodeEvent->method('getNodeTranslation')->willReturn($nodeTranslation); |
||
0 ignored issues
–
show
The method
method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
106 | |||
107 | $em = $this->createMock(EntityManager::class); |
||
108 | $listener = new NodeIndexUpdateEventListener($this->getSearchConfiguration(false), $em); |
||
109 | $listener->onPostPersist($nodeEvent); |
||
0 ignored issues
–
show
$nodeEvent is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<Kunstmaan\NodeBundle\Event\NodeEvent> .
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...
|
|||
110 | } |
||
111 | |||
112 | View Code Duplication | public function testUpdateOfChildPageWithOnlineParent() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
113 | { |
||
114 | $parentPage = $this->createMock(AbstractPage::class); |
||
115 | $parentNodeTranslation = $this->createMock(NodeTranslation::class); |
||
116 | $parentNodeTranslation->method('isOnline')->willReturn(true); |
||
0 ignored issues
–
show
The method
method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
117 | $parentNodeTranslation->method('getRef')->willReturn($parentPage); |
||
118 | |||
119 | $parentNode = $this->createMock(Node::class); |
||
120 | $parentNode->method('getNodeTranslation')->willReturn($parentNodeTranslation); |
||
0 ignored issues
–
show
The method
method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
121 | |||
122 | $node = $this->createMock(Node::class); |
||
123 | $node->method('getParents')->willReturn([$parentNode]); |
||
0 ignored issues
–
show
The method
method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
124 | |||
125 | $nodeTranslation = $this->createMock(NodeTranslation::class); |
||
126 | $nodeTranslation->method('getId')->willReturn(1); |
||
0 ignored issues
–
show
The method
method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
127 | $nodeTranslation->method('getLang')->willReturn('nl'); |
||
0 ignored issues
–
show
The method
method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
128 | $nodeTranslation->method('getNode')->willReturn($node); |
||
0 ignored issues
–
show
The method
method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
129 | |||
130 | $nodeEvent = $this->getMockBuilder(NodeEvent::class)->disableOriginalConstructor()->getMock(); |
||
131 | |||
132 | $nodeEvent->method('getNodeTranslation')->willReturn($nodeTranslation); |
||
0 ignored issues
–
show
The method
method() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
133 | |||
134 | $em = $this->createMock(EntityManager::class); |
||
135 | $listener = new NodeIndexUpdateEventListener($this->getSearchConfiguration(true), $em); |
||
136 | $listener->onPostPersist($nodeEvent); |
||
0 ignored issues
–
show
$nodeEvent is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<Kunstmaan\NodeBundle\Event\NodeEvent> .
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...
|
|||
137 | } |
||
138 | |||
139 | /** |
||
140 | * @group legacy |
||
141 | * @expectedDeprecation Passing the container as the first argument of "Kunstmaan\NodeSearchBundle\EventListener\NodeIndexUpdateEventListener" is deprecated in KunstmaanNodeSearchBundle 5.2 and will be removed in KunstmaanNodeSearchBundle 6.0. Inject the "kunstmaan_node_search.search_configuration.node" service instead. |
||
142 | */ |
||
143 | public function testContainerDeprecation() |
||
144 | { |
||
145 | $em = $this->createMock(EntityManager::class); |
||
146 | new NodeIndexUpdateEventListener($this->getContainer($this->getSearchConfiguration(false)), $em); |
||
147 | } |
||
148 | |||
149 | private function getContainer($searchConfigMock) |
||
150 | { |
||
151 | $container = $this->createMock('Symfony\Component\DependencyInjection\ContainerInterface'); |
||
152 | |||
153 | $container |
||
154 | ->expects($this->any()) |
||
155 | ->method('get') |
||
156 | ->with($this->equalTo('kunstmaan_node_search.search_configuration.node')) |
||
157 | ->willReturn($searchConfigMock) |
||
158 | ; |
||
159 | |||
160 | return $container; |
||
161 | } |
||
162 | |||
163 | private function getSearchConfiguration($expectCall) |
||
164 | { |
||
165 | $searchConfig = $this->createMock(NodePagesConfiguration::class); |
||
166 | $searchConfig |
||
167 | ->expects($expectCall ? $this->once() : $this->never()) |
||
168 | ->method('indexNodeTranslation') |
||
169 | ->willReturn(null) |
||
170 | ; |
||
171 | |||
172 | return $searchConfig; |
||
173 | } |
||
174 | } |
||
175 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.