@@ -60,6 +60,11 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase
60
60
*/
61
61
protected $ resultLayoutFactoryMock ;
62
62
63
+ /**
64
+ * @var \Magento\Framework\View\Result\Layout|\PHPUnit_Framework_MockObject_MockObject
65
+ */
66
+ protected $ resultLayoutMock ;
67
+
63
68
/**
64
69
* @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject
65
70
*/
@@ -109,7 +114,7 @@ protected function setUp()
109
114
);
110
115
$ this ->resultLayoutFactoryMock = $ this ->getMock (
111
116
'Magento\Framework\View\Result\LayoutFactory ' ,
112
- [],
117
+ [' create ' ],
113
118
[],
114
119
'' ,
115
120
false
@@ -202,15 +207,19 @@ public function testExecute()
202
207
$ shipment = [];
203
208
$ tracking = [];
204
209
205
- $ layoutMock = $ this ->getMock ('Magento\Framework\View\Layout ' , ['getBlock ' ], [], '' , false );
206
- $ blockMock = $ this ->getMock ('Magento\Shipping\Block\Adminhtml\View\Comments ' , ['toHtml ' ], [], '' , false );
210
+ $ this ->resultLayoutMock = $ this ->getMock (
211
+ 'Magento\Framework\View\Result\Layout ' ,
212
+ ['getBlock ' , 'getDefaultLayoutHandle ' , 'addDefaultHandle ' , 'getLayout ' ],
213
+ [],
214
+ '' ,
215
+ false
216
+ );
207
217
208
218
$ this ->requestMock ->expects ($ this ->once ())->method ('setParam ' )->with ('shipment_id ' , $ shipmentId );
209
219
$ this ->requestMock ->expects ($ this ->once ())
210
220
->method ('getPost ' )
211
221
->with ('comment ' )
212
222
->will ($ this ->returnValue ($ data ));
213
- $ this ->titleMock ->expects ($ this ->once ())->method ('prepend ' );
214
223
$ this ->requestMock ->expects ($ this ->any ())
215
224
->method ('getParam ' )
216
225
->will (
@@ -234,10 +243,13 @@ public function testExecute()
234
243
$ this ->shipmentMock ->expects ($ this ->once ())->method ('addComment ' );
235
244
$ this ->shipmentSenderMock ->expects ($ this ->once ())->method ('send ' );
236
245
$ this ->shipmentMock ->expects ($ this ->once ())->method ('save ' );
237
- $ this ->viewInterfaceMock ->expects ($ this ->once ())->method ('loadLayout ' )->with (false );
238
- $ this ->viewInterfaceMock ->expects ($ this ->once ())->method ('getLayout ' )->will ($ this ->returnValue ($ layoutMock ));
239
- $ layoutMock ->expects ($ this ->once ())->method ('getBlock ' )->will ($ this ->returnValue ($ blockMock ));
240
- $ blockMock ->expects ($ this ->once ())->method ('toHtml ' )->will ($ this ->returnValue ($ result ));
246
+ $ layoutMock = $ this ->getMock ('Magento\Framework\View\Layout ' , ['getBlock ' ], [], '' , false );
247
+ $ blockMock = $ this ->getMock ('Magento\Shipping\Block\Adminhtml\View\Comments ' , ['toHtml ' ], [], '' , false );
248
+ $ blockMock ->expects ($ this ->once ())->method ('toHtml ' )->willReturn ($ result );
249
+ $ layoutMock ->expects ($ this ->once ())->method ('getBlock ' )->with ('shipment_comments ' )->willReturn ($ blockMock );
250
+ $ this ->resultLayoutMock ->expects ($ this ->once ())->method ('getLayout ' )->willReturn ($ layoutMock );
251
+ $ this ->resultLayoutMock ->expects ($ this ->once ())->method ('addDefaultHandle ' );
252
+ $ this ->resultLayoutFactoryMock ->expects ($ this ->once ())->method ('create ' )->will ($ this ->returnValue ($ this ->resultLayoutMock ));
241
253
$ this ->responseMock ->expects ($ this ->once ())->method ('setBody ' )->with ($ result );
242
254
243
255
$ this ->assertNull ($ this ->controller ->execute ());
0 commit comments