Example #1
0
 /**
  * @covers \Magento\Cms\Helper\Page::renderPageExtended
  * @param integer|null $pageId
  * @param integer|null $internalPageId
  * @param integer $pageLoadResultIndex
  * @param string $customPageLayout
  * @param string $handle
  * @param string $customLayoutUpdateXml
  * @param string $layoutUpdate
  * @param boolean $expectedResult
  *
  * @dataProvider renderPageExtendedDataProvider
  *
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testRenderPageExtended($pageId, $internalPageId, $pageLoadResultIndex, $customPageLayout, $handle, $customLayoutUpdateXml, $layoutUpdate, $expectedResult)
 {
     $storeId = 321;
     $customThemeFrom = 'customThemeFrom';
     $customThemeTo = 'customThemeTo';
     $isScopeDateInInterval = true;
     $customTheme = 'customTheme';
     $pageLayout = 'pageLayout';
     $pageIdentifier = 111;
     $layoutUpdateXml = 'layoutUpdateXml';
     $contentHeading = 'contentHeading';
     $escapedContentHeading = 'escapedContentHeading';
     $defaultGroup = 'defaultGroup';
     $pageLoadResultCollection = [null, $this->pageMock];
     $this->pageMock->expects($this->any())->method('getId')->willReturn($internalPageId);
     $this->storeManagerMock->expects($this->any())->method('getStore')->willReturn($this->storeMock);
     $this->storeMock->expects($this->any())->method('getId')->willReturn($storeId);
     $this->pageMock->expects($this->any())->method('setStoreId')->with($storeId)->willReturnSelf();
     $this->pageMock->expects($this->any())->method('load')->with($pageId)->willReturn($pageLoadResultCollection[$pageLoadResultIndex]);
     $this->pageMock->expects($this->any())->method('getCustomThemeFrom')->willReturn($customThemeFrom);
     $this->pageMock->expects($this->any())->method('getCustomThemeTo')->willReturn($customThemeTo);
     $this->localeDateMock->expects($this->any())->method('isScopeDateInInterval')->with(null, $customThemeFrom, $customThemeTo)->willReturn($isScopeDateInInterval);
     $this->pageMock->expects($this->any())->method('getCustomTheme')->willReturn($customTheme);
     $this->designMock->expects($this->any())->method('setDesignTheme')->with($customTheme)->willReturnSelf();
     $this->pageMock->expects($this->any())->method('getPageLayout')->willReturn($pageLayout);
     $this->pageMock->expects($this->any())->method('getCustomPageLayout')->willReturn($customPageLayout);
     $this->resultPageMock->expects($this->any())->method('getConfig')->willReturn($this->pageConfigMock);
     $this->pageConfigMock->expects($this->any())->method('setPageLayout')->with($handle)->willReturnSelf();
     $this->viewMock->expects($this->any())->method('getPage')->willReturn($this->resultPageMock);
     $this->resultPageMock->expects($this->any())->method('initLayout')->willReturnSelf();
     $this->resultPageMock->expects($this->any())->method('getLayout')->willReturn($this->layoutMock);
     $this->layoutMock->expects($this->any())->method('getUpdate')->willReturn($this->layoutProcessorMock);
     $this->layoutProcessorMock->expects($this->any())->method('addHandle')->with('cms_page_view')->willReturnSelf();
     $this->pageMock->expects($this->any())->method('getIdentifier')->willReturn($pageIdentifier);
     $this->viewMock->expects($this->any())->method('addPageLayoutHandles')->with(['id' => $pageIdentifier])->willReturn(true);
     $this->eventManagerMock->expects($this->any())->method('dispatch')->with('cms_page_render', ['page' => $this->pageMock, 'controller_action' => $this->actionMock]);
     $this->viewMock->expects($this->any())->method('loadLayoutUpdates')->willReturnSelf();
     $this->pageMock->expects($this->any())->method('getCustomLayoutUpdateXml')->willReturn($customLayoutUpdateXml);
     $this->pageMock->expects($this->any())->method('getLayoutUpdateXml')->willReturn($layoutUpdateXml);
     $this->layoutProcessorMock->expects($this->any())->method('addUpdate')->with($layoutUpdate)->willReturnSelf();
     $this->viewMock->expects($this->any())->method('generateLayoutXml')->willReturnSelf();
     $this->viewMock->expects($this->any())->method('generateLayoutBlocks')->willReturnSelf();
     $this->layoutMock->expects($this->any())->method('getBlock')->with('page_content_heading')->willReturn($this->blockMock);
     $this->pageMock->expects($this->any())->method('getContentHeading')->willReturn($contentHeading);
     $this->escaperMock->expects($this->any())->method('escapeHtml')->with($contentHeading)->willReturn($escapedContentHeading);
     $this->blockMock->expects($this->any())->method('setContentHeading')->with($escapedContentHeading)->willReturnSelf();
     $this->layoutMock->expects($this->any())->method('getMessagesBlock')->willReturn($this->messagesBlockMock);
     $this->messageManagerMock->expects($this->any())->method('getDefaultGroup')->willReturn($defaultGroup);
     $this->messagesBlockMock->expects($this->any())->method('addStorageType')->with($defaultGroup);
     $this->messageManagerMock->expects($this->any())->method('getMessages')->with(true)->willReturn($this->messageCollectionMock);
     $this->messagesBlockMock->expects($this->any())->method('addMessages')->with($this->messageCollectionMock)->willReturnSelf();
     $this->viewMock->expects($this->any())->method('renderLayout')->willReturnSelf();
     $this->assertEquals($expectedResult, $this->object->renderPageExtended($this->actionMock, $pageId));
 }