@@ -49,6 +49,11 @@ class RenderTest extends \PHPUnit\Framework\TestCase
49
49
*/
50
50
protected $ layoutProcessorMock ;
51
51
52
+ /**
53
+ * @var \Magento\Framework\View\Layout\LayoutCacheKeyInterface|\PHPUnit_Framework_MockObject_MockObject
54
+ */
55
+ protected $ layoutCacheKeyMock ;
56
+
52
57
/**
53
58
* Set up before test
54
59
*/
@@ -58,6 +63,7 @@ protected function setUp()
58
63
->disableOriginalConstructor ()->getMock ();
59
64
60
65
$ this ->layoutProcessorMock = $ this ->getMockForAbstractClass (\Magento \Framework \View \Layout \ProcessorInterface::class);
66
+ $ this ->layoutCacheKeyMock = $ this ->getMockForAbstractClass (\Magento \Framework \View \Layout \LayoutCacheKeyInterface::class);
61
67
62
68
$ contextMock = $ this ->getMockBuilder (\Magento \Framework \App \Action \Context::class)
63
69
->disableOriginalConstructor ()->getMock ();
@@ -86,7 +92,8 @@ protected function setUp()
86
92
'context ' => $ contextMock ,
87
93
'translateInline ' => $ this ->translateInline ,
88
94
'jsonSerializer ' => new \Magento \Framework \Serialize \Serializer \Json (),
89
- 'base64jsonSerializer ' => new \Magento \Framework \Serialize \Serializer \Base64Json ()
95
+ 'base64jsonSerializer ' => new \Magento \Framework \Serialize \Serializer \Base64Json (),
96
+ 'layoutCacheKey ' => $ this ->layoutCacheKeyMock
90
97
]
91
98
);
92
99
}
@@ -96,6 +103,8 @@ public function testExecuteNotAjax()
96
103
$ this ->requestMock ->expects ($ this ->once ())->method ('isAjax ' )->will ($ this ->returnValue (false ));
97
104
$ this ->requestMock ->expects ($ this ->once ())->method ('setActionName ' )->will ($ this ->returnValue ('noroute ' ));
98
105
$ this ->requestMock ->expects ($ this ->once ())->method ('setDispatched ' )->will ($ this ->returnValue (false ));
106
+ $ this ->layoutCacheKeyMock ->expects ($ this ->never ())
107
+ ->method ('addCacheKeys ' );
99
108
$ this ->action ->execute ();
100
109
}
101
110
@@ -113,6 +122,8 @@ public function testExecuteNoParams()
113
122
->method ('getParam ' )
114
123
->with ($ this ->equalTo ('handles ' ), $ this ->equalTo ('' ))
115
124
->will ($ this ->returnValue ('' ));
125
+ $ this ->layoutCacheKeyMock ->expects ($ this ->never ())
126
+ ->method ('addCacheKeys ' );
116
127
$ this ->action ->execute ();
117
128
}
118
129
@@ -158,17 +169,15 @@ public function testExecute()
158
169
->will ($ this ->returnValue (base64_encode (json_encode ($ handles ))));
159
170
$ this ->viewMock ->expects ($ this ->once ())->method ('loadLayout ' )->with ($ this ->equalTo ($ handles ));
160
171
$ this ->viewMock ->expects ($ this ->any ())->method ('getLayout ' )->will ($ this ->returnValue ($ this ->layoutMock ));
172
+ $ this ->layoutMock ->expects ($ this ->never ())
173
+ ->method ('getUpdate ' );
174
+ $ this ->layoutCacheKeyMock ->expects ($ this ->atLeastOnce ())
175
+ ->method ('addCacheKeys ' );
161
176
$ this ->layoutMock ->expects ($ this ->at (0 ))
162
- ->method ('getUpdate ' )
163
- ->will ($ this ->returnValue ($ this ->layoutProcessorMock ));
164
- $ this ->layoutProcessorMock ->expects ($ this ->at (0 ))
165
- ->method ('addCacheKey ' )
166
- ->willReturnSelf ();
167
- $ this ->layoutMock ->expects ($ this ->at (1 ))
168
177
->method ('getBlock ' )
169
178
->with ($ this ->equalTo ($ blocks [0 ]))
170
179
->will ($ this ->returnValue ($ blockInstance1 ));
171
- $ this ->layoutMock ->expects ($ this ->at (2 ))
180
+ $ this ->layoutMock ->expects ($ this ->at (1 ))
172
181
->method ('getBlock ' )
173
182
->with ($ this ->equalTo ($ blocks [1 ]))
174
183
->will ($ this ->returnValue ($ blockInstance2 ));
0 commit comments