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() |
|
18 | { |
||
19 | $parentPage = $this->createMock(StructureNode::class); |
||
20 | |||
21 | $parentNodeTranslation = $this->createMock(NodeTranslation::class); |
||
22 | $parentNodeTranslation->method('getRef')->willReturn($parentPage); |
||
0 ignored issues
–
show
|
|||
23 | $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...
|
|||
24 | |||
25 | $parentNode = $this->createMock(Node::class); |
||
26 | $parentNode->method('getNodeTranslation')->willReturn($parentNodeTranslation); |
||
27 | |||
28 | $node = $this->createMock(Node::class); |
||
29 | $node->method('getParents')->willReturn([ |
||
30 | $parentNode, |
||
31 | ]); |
||
32 | |||
33 | $nodeTranslation = $this->createMock(NodeTranslation::class); |
||
34 | $nodeTranslation->method('getId')->willReturn(1); |
||
35 | $nodeTranslation->method('getLang')->willReturn('nl'); |
||
36 | $nodeTranslation->method('getNode')->willReturn($node); |
||
37 | |||
38 | $nodeEvent = $this->getMockBuilder(NodeEvent::class)->disableOriginalConstructor()->getMock(); |
||
39 | |||
40 | $nodeEvent->method('getNodeTranslation')->willReturn($nodeTranslation); |
||
41 | |||
42 | $em = $this->createMock(EntityManager::class); |
||
43 | $listener = new NodeIndexUpdateEventListener($this->getSearchConfiguration(true), $em); |
||
44 | $listener->onPostPersist($nodeEvent); |
||
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); |
||
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...
|
|||
53 | $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...
|
|||
54 | |||
55 | $parentPageNotStructured = $this->createMock(AbstractPage::class); |
||
56 | $parentNodeTranslation2 = $this->createMock(NodeTranslation::class); |
||
57 | $parentNodeTranslation2->method('isOnline')->willReturn(false); |
||
58 | $parentNodeTranslation->method('getRef')->willReturn($parentPageNotStructured); |
||
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...
|
|||
59 | |||
60 | $parentNode1 = $this->createMock(Node::class); |
||
61 | $parentNode1->method('getNodeTranslation')->willReturn($parentNodeTranslation); |
||
62 | $parentNode2 = $this->createMock(Node::class); |
||
63 | $parentNode2->method('getNodeTranslation')->willReturn($parentNodeTranslation2); |
||
64 | |||
65 | $node = $this->createMock(Node::class); |
||
66 | $node->method('getParents')->willReturn([ |
||
67 | $parentNode1, |
||
68 | $parentNode2, |
||
69 | ]); |
||
70 | |||
71 | $nodeTranslation = $this->createMock(NodeTranslation::class); |
||
72 | $nodeTranslation->method('getId')->willReturn(1); |
||
73 | $nodeTranslation->method('getLang')->willReturn('nl'); |
||
74 | $nodeTranslation->method('getNode')->willReturn($node); |
||
75 | |||
76 | $nodeEvent = $this->getMockBuilder(NodeEvent::class)->disableOriginalConstructor()->getMock(); |
||
77 | |||
78 | $nodeEvent->method('getNodeTranslation')->willReturn($nodeTranslation); |
||
79 | |||
80 | $em = $this->createMock(EntityManager::class); |
||
81 | $listener = new NodeIndexUpdateEventListener($this->getSearchConfiguration(false), $em); |
||
82 | $listener->onPostPersist($nodeEvent); |
||
83 | } |
||
84 | |||
85 | View Code Duplication | public function testUpdateOfChildPageWithOfflineParent() |
|
86 | { |
||
87 | $parentPage = $this->createMock(AbstractPage::class); |
||
88 | $parentNodeTranslation = $this->createMock(NodeTranslation::class); |
||
89 | $parentNodeTranslation->method('isOnline')->willReturn(false); |
||
90 | $parentNodeTranslation->method('getRef')->willReturn($parentPage); |
||
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...
|
|||
91 | |||
92 | $parentNode = $this->createMock(Node::class); |
||
93 | $parentNode->method('getNodeTranslation')->willReturn($parentNodeTranslation); |
||
94 | |||
95 | $node = $this->createMock(Node::class); |
||
96 | $node->method('getParents')->willReturn([$parentNode]); |
||
97 | |||
98 | $nodeTranslation = $this->createMock(NodeTranslation::class); |
||
99 | $nodeTranslation->method('getId')->willReturn(1); |
||
100 | $nodeTranslation->method('getLang')->willReturn('nl'); |
||
101 | $nodeTranslation->method('getNode')->willReturn($node); |
||
102 | |||
103 | $nodeEvent = $this->getMockBuilder(NodeEvent::class)->disableOriginalConstructor()->getMock(); |
||
104 | |||
105 | $nodeEvent->method('getNodeTranslation')->willReturn($nodeTranslation); |
||
106 | |||
107 | $em = $this->createMock(EntityManager::class); |
||
108 | $listener = new NodeIndexUpdateEventListener($this->getSearchConfiguration(false), $em); |
||
109 | $listener->onPostPersist($nodeEvent); |
||
110 | } |
||
111 | |||
112 | View Code Duplication | public function testUpdateOfChildPageWithOnlineParent() |
|
113 | { |
||
114 | $parentPage = $this->createMock(AbstractPage::class); |
||
115 | $parentNodeTranslation = $this->createMock(NodeTranslation::class); |
||
116 | $parentNodeTranslation->method('isOnline')->willReturn(true); |
||
117 | $parentNodeTranslation->method('getRef')->willReturn($parentPage); |
||
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...
|
|||
118 | |||
119 | $parentNode = $this->createMock(Node::class); |
||
120 | $parentNode->method('getNodeTranslation')->willReturn($parentNodeTranslation); |
||
121 | |||
122 | $node = $this->createMock(Node::class); |
||
123 | $node->method('getParents')->willReturn([$parentNode]); |
||
124 | |||
125 | $nodeTranslation = $this->createMock(NodeTranslation::class); |
||
126 | $nodeTranslation->method('getId')->willReturn(1); |
||
127 | $nodeTranslation->method('getLang')->willReturn('nl'); |
||
128 | $nodeTranslation->method('getNode')->willReturn($node); |
||
129 | |||
130 | $nodeEvent = $this->getMockBuilder(NodeEvent::class)->disableOriginalConstructor()->getMock(); |
||
131 | |||
132 | $nodeEvent->method('getNodeTranslation')->willReturn($nodeTranslation); |
||
133 | |||
134 | $em = $this->createMock(EntityManager::class); |
||
135 | $listener = new NodeIndexUpdateEventListener($this->getSearchConfiguration(true), $em); |
||
136 | $listener->onPostPersist($nodeEvent); |
||
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 |
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.