@@ -53,11 +53,6 @@ class PageTest extends \PHPUnit_Framework_TestCase
53
53
*/
54
54
protected $ pageConfigMock ;
55
55
56
- /**
57
- * @var \Magento\Framework\App\ViewInterface|\PHPUnit_Framework_MockObject_MockObject
58
- */
59
- protected $ viewMock ;
60
-
61
56
/**
62
57
* @var \Magento\Framework\Escaper|\PHPUnit_Framework_MockObject_MockObject
63
58
*/
@@ -113,6 +108,11 @@ class PageTest extends \PHPUnit_Framework_TestCase
113
108
*/
114
109
protected $ messageCollectionMock ;
115
110
111
+ /**
112
+ * @var \Magento\Framework\View\Result\PageFactory|\PHPUnit_Framework_MockObject_MockObject
113
+ */
114
+ protected $ resultPageFactory ;
115
+
116
116
protected function setUp ()
117
117
{
118
118
$ this ->actionMock = $ this ->getMockBuilder ('Magento\Framework\App\Action\Action ' )
@@ -150,8 +150,6 @@ protected function setUp()
150
150
$ this ->pageConfigMock = $ this ->getMockBuilder ('Magento\Framework\View\Page\Config ' )
151
151
->disableOriginalConstructor ()
152
152
->getMock ();
153
- $ this ->viewMock = $ this ->getMockBuilder ('Magento\Framework\App\ViewInterface ' )
154
- ->getMockForAbstractClass ();
155
153
$ this ->escaperMock = $ this ->getMockBuilder ('Magento\Framework\Escaper ' )
156
154
->disableOriginalConstructor ()
157
155
->getMock ();
@@ -189,6 +187,9 @@ protected function setUp()
189
187
'urlBuilder ' => $ this ->urlBuilderMock
190
188
]
191
189
);
190
+
191
+ $ this ->resultPageFactory = $ this ->getMock ('Magento\Framework\View\Result\PageFactory ' , [], [], '' , false );
192
+
192
193
$ this ->object = $ objectManager ->getObject (
193
194
'Magento\Cms\Helper\Page ' ,
194
195
[
@@ -199,9 +200,9 @@ protected function setUp()
199
200
'localeDate ' => $ this ->localeDateMock ,
200
201
'design ' => $ this ->designMock ,
201
202
'pageConfig ' => $ this ->pageConfigMock ,
202
- 'view ' => $ this ->viewMock ,
203
203
'escaper ' => $ this ->escaperMock ,
204
- 'messageManager ' => $ this ->messageManagerMock
204
+ 'messageManager ' => $ this ->messageManagerMock ,
205
+ 'resultPageFactory ' => $ this ->resultPageFactory
205
206
]
206
207
);
207
208
}
@@ -221,7 +222,7 @@ protected function setUp()
221
222
*
222
223
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
223
224
*/
224
- public function testRenderPageExtended (
225
+ public function testPrepareResultPage (
225
226
$ pageId ,
226
227
$ internalPageId ,
227
228
$ pageLoadResultIndex ,
@@ -287,16 +288,15 @@ public function testRenderPageExtended(
287
288
$ this ->pageMock ->expects ($ this ->any ())
288
289
->method ('getCustomPageLayout ' )
289
290
->willReturn ($ customPageLayout );
291
+ $ this ->resultPageFactory ->expects ($ this ->any ())->method ('create ' )
292
+ ->will ($ this ->returnValue ($ this ->resultPageMock ));
290
293
$ this ->resultPageMock ->expects ($ this ->any ())
291
294
->method ('getConfig ' )
292
295
->willReturn ($ this ->pageConfigMock );
293
296
$ this ->pageConfigMock ->expects ($ this ->any ())
294
297
->method ('setPageLayout ' )
295
298
->with ($ handle )
296
299
->willReturnSelf ();
297
- $ this ->viewMock ->expects ($ this ->any ())
298
- ->method ('getPage ' )
299
- ->willReturn ($ this ->resultPageMock );
300
300
$ this ->resultPageMock ->expects ($ this ->any ())
301
301
->method ('initLayout ' )
302
302
->willReturnSelf ();
@@ -313,10 +313,6 @@ public function testRenderPageExtended(
313
313
$ this ->pageMock ->expects ($ this ->any ())
314
314
->method ('getIdentifier ' )
315
315
->willReturn ($ pageIdentifier );
316
- $ this ->viewMock ->expects ($ this ->any ())
317
- ->method ('addPageLayoutHandles ' )
318
- ->with (['id ' => $ pageIdentifier ])
319
- ->willReturn (true );
320
316
$ this ->eventManagerMock ->expects ($ this ->any ())
321
317
->method ('dispatch ' )
322
318
->with (
@@ -326,9 +322,6 @@ public function testRenderPageExtended(
326
322
'controller_action ' => $ this ->actionMock
327
323
]
328
324
);
329
- $ this ->viewMock ->expects ($ this ->any ())
330
- ->method ('loadLayoutUpdates ' )
331
- ->willReturnSelf ();
332
325
$ this ->pageMock ->expects ($ this ->any ())
333
326
->method ('getCustomLayoutUpdateXml ' )
334
327
->willReturn ($ customLayoutUpdateXml );
@@ -339,12 +332,6 @@ public function testRenderPageExtended(
339
332
->method ('addUpdate ' )
340
333
->with ($ layoutUpdate )
341
334
->willReturnSelf ();
342
- $ this ->viewMock ->expects ($ this ->any ())
343
- ->method ('generateLayoutXml ' )
344
- ->willReturnSelf ();
345
- $ this ->viewMock ->expects ($ this ->any ())
346
- ->method ('generateLayoutBlocks ' )
347
- ->willReturnSelf ();
348
335
$ this ->layoutMock ->expects ($ this ->any ())
349
336
->method ('getBlock ' )
350
337
->with ('page_content_heading ' )
@@ -377,13 +364,14 @@ public function testRenderPageExtended(
377
364
->method ('addMessages ' )
378
365
->with ($ this ->messageCollectionMock )
379
366
->willReturnSelf ();
380
- $ this ->viewMock ->expects ($ this ->any ())
381
- ->method ('renderLayout ' )
382
- ->willReturnSelf ();
383
367
384
- $ this ->assertEquals (
368
+ if ($ expectedResult ) {
369
+ $ expectedResult = $ this ->resultPageMock ;
370
+ }
371
+
372
+ $ this ->assertSame (
385
373
$ expectedResult ,
386
- $ this ->object ->renderPageExtended ($ this ->actionMock , $ pageId )
374
+ $ this ->object ->prepareResultPage ($ this ->actionMock , $ pageId )
387
375
);
388
376
}
389
377
0 commit comments