@@ 14-38 (lines=25) @@ | ||
11 | ||
12 | class NodeIndexUpdateEventListenerTest extends \PHPUnit_Framework_TestCase |
|
13 | { |
|
14 | public function testUpdateOfChildPageWithStructuredNodeParent() |
|
15 | { |
|
16 | $parentNodeTranslation = $this->createMock(StructureNode::class); |
|
17 | $parentNodeTranslation->method('isOnline')->willReturn(false); |
|
18 | ||
19 | $parentNode = $this->createMock(Node::class); |
|
20 | $parentNode->method('getNodeTranslation')->willReturn($parentNodeTranslation); |
|
21 | ||
22 | $node = $this->createMock(Node::class); |
|
23 | $node->method('getParents')->willReturn([ |
|
24 | $parentNode |
|
25 | ]); |
|
26 | ||
27 | $nodeTranslation = $this->createMock(NodeTranslation::class); |
|
28 | $nodeTranslation->method('getId')->willReturn(1); |
|
29 | $nodeTranslation->method('getLang')->willReturn('nl'); |
|
30 | $nodeTranslation->method('getNode')->willReturn($node); |
|
31 | ||
32 | $nodeEvent = $this->getMockBuilder(NodeEvent::class)->disableOriginalConstructor()->getMock(); |
|
33 | ||
34 | $nodeEvent->method('getNodeTranslation')->willReturn($nodeTranslation); |
|
35 | ||
36 | $listener = new NodeIndexUpdateEventListener($this->getContainer($this->getSearchConfiguration(true))); |
|
37 | $listener->onPostPersist($nodeEvent); |
|
38 | } |
|
39 | ||
40 | public function testUpdateOfChildPageWithStructuredNodeParentAndOfflineParent() |
|
41 | { |
|
@@ 72-94 (lines=23) @@ | ||
69 | $listener->onPostPersist($nodeEvent); |
|
70 | } |
|
71 | ||
72 | public function testUpdateOfChildPageWithOfflineParent() |
|
73 | { |
|
74 | $parentNodeTranslation = $this->createMock(NodeTranslation::class); |
|
75 | $parentNodeTranslation->method('isOnline')->willReturn(false); |
|
76 | ||
77 | $parentNode = $this->createMock(Node::class); |
|
78 | $parentNode->method('getNodeTranslation')->willReturn($parentNodeTranslation); |
|
79 | ||
80 | $node = $this->createMock(Node::class); |
|
81 | $node->method('getParents')->willReturn([$parentNode]); |
|
82 | ||
83 | $nodeTranslation = $this->createMock(NodeTranslation::class); |
|
84 | $nodeTranslation->method('getId')->willReturn(1); |
|
85 | $nodeTranslation->method('getLang')->willReturn('nl'); |
|
86 | $nodeTranslation->method('getNode')->willReturn($node); |
|
87 | ||
88 | $nodeEvent = $this->getMockBuilder(NodeEvent::class)->disableOriginalConstructor()->getMock(); |
|
89 | ||
90 | $nodeEvent->method('getNodeTranslation')->willReturn($nodeTranslation); |
|
91 | ||
92 | $listener = new NodeIndexUpdateEventListener($this->getContainer($this->getSearchConfiguration(false))); |
|
93 | $listener->onPostPersist($nodeEvent); |
|
94 | } |
|
95 | ||
96 | ||
97 | public function testUpdateOfChildPageWithOnlineParent() |
|
@@ 97-119 (lines=23) @@ | ||
94 | } |
|
95 | ||
96 | ||
97 | public function testUpdateOfChildPageWithOnlineParent() |
|
98 | { |
|
99 | $parentNodeTranslation = $this->createMock(NodeTranslation::class); |
|
100 | $parentNodeTranslation->method('isOnline')->willReturn(true); |
|
101 | ||
102 | $parentNode = $this->createMock(Node::class); |
|
103 | $parentNode->method('getNodeTranslation')->willReturn($parentNodeTranslation); |
|
104 | ||
105 | $node = $this->createMock(Node::class); |
|
106 | $node->method('getParents')->willReturn([$parentNode]); |
|
107 | ||
108 | $nodeTranslation = $this->createMock(NodeTranslation::class); |
|
109 | $nodeTranslation->method('getId')->willReturn(1); |
|
110 | $nodeTranslation->method('getLang')->willReturn('nl'); |
|
111 | $nodeTranslation->method('getNode')->willReturn($node); |
|
112 | ||
113 | $nodeEvent = $this->getMockBuilder(NodeEvent::class)->disableOriginalConstructor()->getMock(); |
|
114 | ||
115 | $nodeEvent->method('getNodeTranslation')->willReturn($nodeTranslation); |
|
116 | ||
117 | $listener = new NodeIndexUpdateEventListener($this->getContainer($this->getSearchConfiguration(true))); |
|
118 | $listener->onPostPersist($nodeEvent); |
|
119 | } |
|
120 | ||
121 | private function getContainer($searchConfigMock) |
|
122 | { |