Example #1
0
 /**
  * Include RequireJs configuration as an asset on the page
  *
  * @return $this
  */
 protected function _prepareLayout()
 {
     $requireJsConfig = $this->fileManager->createRequireJsConfigAsset();
     $requireJsMixinsConfig = $this->fileManager->createRequireJsMixinsAsset();
     $assetCollection = $this->pageConfig->getAssetCollection();
     $after = RequireJsConfig::REQUIRE_JS_FILE_NAME;
     if ($this->minification->isEnabled('js')) {
         $minResolver = $this->fileManager->createMinResolverAsset();
         $assetCollection->insert($minResolver->getFilePath(), $minResolver, $after);
         $after = $minResolver->getFilePath();
     }
     if ($this->bundleConfig->isBundlingJsFiles()) {
         $bundleAssets = $this->fileManager->createBundleJsPool();
         $staticAsset = $this->fileManager->createStaticJsAsset();
         /** @var \Magento\Framework\View\Asset\File $bundleAsset */
         if (!empty($bundleAssets) && $staticAsset !== false) {
             $bundleAssets = array_reverse($bundleAssets);
             foreach ($bundleAssets as $bundleAsset) {
                 $assetCollection->insert($bundleAsset->getFilePath(), $bundleAsset, $after);
             }
             $assetCollection->insert($staticAsset->getFilePath(), $staticAsset, reset($bundleAssets)->getFilePath());
             $after = $staticAsset->getFilePath();
         }
     }
     $assetCollection->insert($requireJsConfig->getFilePath(), $requireJsConfig, $after);
     $assetCollection->insert($requireJsMixinsConfig->getFilePath(), $requireJsMixinsConfig, $after);
     return parent::_prepareLayout();
 }
Example #2
0
 /**
  * @return void
  */
 protected function _construct()
 {
     parent::_construct();
     $orders = $this->_orderCollectionFactory->create()->addFieldToSelect('*')->addFieldToFilter('customer_id', $this->_customerSession->getCustomerId())->addFieldToFilter('status', array('in' => $this->_orderConfig->getVisibleOnFrontStatuses()))->setOrder('created_at', 'desc');
     $this->setOrders($orders);
     $this->pageConfig->setTitle(__('My Orders'));
 }
Example #3
0
 /**
  * @return void
  */
 public function testGetPageHeading()
 {
     $title = 'some title';
     $this->pageTitleMock->expects($this->once())->method('getShortHeading')->willReturn($title);
     $this->pageConfigMock->expects($this->once())->method('getTitle')->willReturn($this->pageTitleMock);
     $this->assertEquals($title, $this->htmlTitle->getPageHeading());
 }
Example #4
0
 /**
  * @return void
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function setUp()
 {
     $this->registryMock = $this->getMockBuilder('Magento\\Framework\\Registry')->disableOriginalConstructor()->setMethods(['registry', 'register'])->getMock();
     $this->requestMock = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->disableOriginalConstructor()->getMock();
     $this->viewMock = $this->getMockBuilder('Magento\\Framework\\App\\View')->disableOriginalConstructor()->setMethods(['loadLayout', 'getLayout', 'getPage', 'renderLayout'])->getMock();
     $this->layoutMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout')->disableOriginalConstructor()->setMethods(['getBlock', 'createBlock', 'setChild'])->getMock();
     $this->menuBlockMock = $this->getMockBuilder('\\Magento\\Backend\\Block\\Menu')->disableOriginalConstructor()->setMethods(['setActive', 'getMenuModel', 'getParentItems'])->getMock();
     $this->breadcrumbsBlockMock = $this->getMockBuilder('\\Magento\\Backend\\Block\\Widget\\Breadcrumbs')->disableOriginalConstructor()->setMethods(['addLink'])->getMock();
     $this->editBlockMock = $this->getMockBuilder('\\Magento\\Backend\\Block\\Widget\\Breadcrumbs')->disableOriginalConstructor()->setMethods(['setEditMode'])->getMock();
     $this->resultPageMock = $this->getMockBuilder('Magento\\Framework\\View\\Result\\Page')->disableOriginalConstructor()->setMethods(['setActiveMenu', 'getConfig', 'addBreadcrumb'])->getMock();
     $this->pageConfigMock = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Config')->disableOriginalConstructor()->getMock();
     $this->pageTitleMock = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Title')->disableOriginalConstructor()->getMock();
     $this->viewMock->expects($this->atLeastOnce())->method('getLayout')->willReturn($this->layoutMock);
     $this->layoutMock->expects($this->any())->method('getBlock')->willReturnMap([['menu', $this->menuBlockMock], ['breadcrumbs', $this->breadcrumbsBlockMock], ['edit', $this->editBlockMock]]);
     $this->menuBlockMock->expects($this->any())->method('getMenuModel')->will($this->returnSelf());
     $this->menuBlockMock->expects($this->any())->method('getParentItems')->will($this->returnValue([]));
     $this->viewMock->expects($this->any())->method('getPage')->willReturn($this->resultPageMock);
     $this->resultPageMock->expects($this->any())->method('getConfig')->willReturn($this->pageConfigMock);
     $this->pageConfigMock->expects($this->any())->method('getTitle')->willReturn($this->pageTitleMock);
     $this->layoutMock->expects($this->once())->method('createBlock')->with('Magento\\Email\\Block\\Adminhtml\\Template\\Edit', 'template_edit', [])->willReturn($this->editBlockMock);
     $this->editBlockMock->expects($this->once())->method('setEditMode')->willReturnSelf();
     $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $templateMock = $this->getMockBuilder('Magento\\Email\\Model\\Template')->disableOriginalConstructor()->getMock();
     $templateMock->expects($this->once())->method('getId')->willReturn(1);
     $templateMock->expects($this->any())->method('getTemplateCode')->willReturn('My Template');
     $objectManagerMock = $this->getMockBuilder('Magento\\Framework\\App\\ObjectManager')->disableOriginalConstructor()->getMock();
     $objectManagerMock->expects($this->once())->method('create')->with('Magento\\Email\\Model\\BackendTemplate')->willReturn($templateMock);
     $this->context = $objectManager->getObject('Magento\\Backend\\App\\Action\\Context', ['request' => $this->requestMock, 'objectManager' => $objectManagerMock, 'view' => $this->viewMock]);
     $this->editController = $objectManager->getObject('Magento\\Email\\Controller\\Adminhtml\\Email\\Template\\Edit', ['context' => $this->context, 'coreRegistry' => $this->registryMock]);
 }
Example #5
0
 /**
  * Include RequireJs inline translation configuration as an asset on the page
  * @return void
  */
 private function addInlineTranslationConfig()
 {
     if ($this->inline->isAllowed()) {
         $after = RequireJsConfig::REQUIRE_JS_FILE_NAME;
         $tConfig = $this->fileManager->createTranslateConfigAsset();
         $assetCollection = $this->pageConfig->getAssetCollection();
         $assetCollection->insert($tConfig->getFilePath(), $tConfig, $after);
     }
 }
 /**
  * Golbal Prepare Layout
  *
  * @return $this
  */
 public function _prepareLayout()
 {
     $this->_addBreadcrumbs();
     $this->pageConfig->getTitle()->set("Blog");
     $pager = $this->getLayout()->createBlock('Magento\\Theme\\Block\\Html\\Pager');
     $pager->setShowPerPage("2");
     $pager->setCollection($this->getPostCollection());
     $this->setChild("posts.pager", $pager);
     parent::_prepareLayout();
 }
 public function testExecute()
 {
     $this->view->expects($this->any())->method('loadLayout')->will($this->returnValue(1));
     $this->view->expects($this->any())->method('getPage')->will($this->returnValue($this->page));
     $this->page->expects($this->any())->method('getConfig')->will($this->returnValue($this->config));
     $this->config->expects($this->any())->method('getTitle')->will($this->returnValue($this->title));
     $this->title->expects($this->any())->method('prepend')->with(__('Index Management'))->will($this->returnValue(1));
     $this->view->expects($this->any())->method('renderLayout')->will($this->returnValue(1));
     $this->object->execute();
 }
Example #8
0
 public function testProcess()
 {
     $generatorContextMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout\\Generator\\Context')->disableOriginalConstructor()->getMock();
     $structureMock = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Config\\Structure')->disableOriginalConstructor()->getMock();
     $readerContextMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout\\Reader\\Context')->disableOriginalConstructor()->getMock();
     $readerContextMock->expects($this->any())->method('getPageConfigStructure')->willReturn($structureMock);
     $bodyClasses = ['class_1', 'class_2'];
     $structureMock->expects($this->once())->method('getBodyClasses')->will($this->returnValue($bodyClasses));
     $this->pageConfigMock->expects($this->exactly(2))->method('addBodyClass')->withConsecutive(['class_1'], ['class_2']);
     $this->assertEquals($this->bodyGenerator, $this->bodyGenerator->process($readerContextMock, $generatorContextMock));
 }
 /**
  * @covers \Magento\Customer\Controller\Adminhtml\Index\Index::execute
  */
 public function testExecute()
 {
     $this->prepareExecute();
     $this->resultPageFactoryMock->expects($this->once())->method('create')->willReturn($this->resultPageMock);
     $this->resultPageMock->expects($this->once())->method('setActiveMenu')->with('Magento_Customer::customer_manage');
     $this->resultPageMock->expects($this->once())->method('getConfig')->willReturn($this->pageConfigMock);
     $this->pageConfigMock->expects($this->once())->method('getTitle')->willReturn($this->pageTitleMock);
     $this->pageTitleMock->expects($this->once())->method('prepend')->with('Customers');
     $this->resultPageMock->expects($this->atLeastOnce())->method('addBreadcrumb')->withConsecutive(['Customers', 'Customers'], ['Manage Customers', 'Manage Customers']);
     $this->sessionMock->expects($this->once())->method('unsCustomerData');
     $this->assertInstanceOf('Magento\\Framework\\View\\Result\\Page', $this->indexController->execute());
 }
Example #10
0
 public function _prepareLayout()
 {
     $brand = $this->getBrand();
     $pageMainTitle = $this->getLayout()->getBlock('page.main.title');
     if ($pageMainTitle) {
         $pageMainTitle->setPageTitle($brand->getName());
     }
     $this->pageConfig->getTitle()->set($brand->getTitle());
     $this->pageConfig->setKeywords($brand->getTitle());
     $this->pageConfig->setDescription($brand->getTitle());
     return parent::_prepareLayout();
 }
Example #11
0
 public function testSetLayout()
 {
     $filePath = 'require_js_fie_path';
     $asset = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\Asset\\LocalInterface');
     $asset->expects($this->atLeastOnce())->method('getFilePath')->willReturn($filePath);
     $this->fileManager->expects($this->once())->method('createRequireJsAsset')->will($this->returnValue($asset));
     $layout = $this->getMock('Magento\\Framework\\View\\LayoutInterface');
     $assetCollection = $this->getMockBuilder('Magento\\Framework\\View\\Asset\\GroupedCollection')->disableOriginalConstructor()->getMock();
     $assetCollection->expects($this->once())->method('add')->with($filePath, $asset);
     $this->pageConfig->expects($this->atLeastOnce())->method('getAssetCollection')->willReturn($assetCollection);
     $object = new Config($this->context, $this->config, $this->fileManager, $this->pageConfig);
     $object->setLayout($layout);
 }
Example #12
0
 /**
  * test setup
  */
 public function setUp()
 {
     $this->pageConfig = $this->getMockBuilder('\\Magento\\Framework\\View\\Page\\Config')->disableOriginalConstructor()->setMethods(['set', 'getTitle'])->getMock();
     $this->resultPageFactory = $this->getMockBuilder('\\Magento\\Framework\\View\\Result\\PageFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->resultPage = $this->getMockBuilder('\\Magento\\Framework\\View\\Result\\Page')->disableOriginalConstructor()->getMock();
     $this->block = $this->getMockBuilder('\\Magento\\Framework\\View\\Element\\AbstractBlock')->disableOriginalConstructor()->getMock();
     $this->pageLayout = $this->getMockBuilder('\\Magento\\Framework\\View\\Layout')->disableOriginalConstructor()->getMock();
     $this->resultPageFactory->expects($this->once())->method('create')->willReturn($this->resultPage);
     $this->resultPage->expects($this->any())->method('getLayout')->willReturn($this->pageLayout);
     $this->pageLayout->expects($this->any())->method('getBlock')->willReturn($this->block);
     $this->pageConfig->expects($this->once())->method('getTitle')->willReturnSelf();
     $this->resultPage->expects($this->any())->method('getConfig')->willReturn($this->pageConfig);
 }
Example #13
0
 /**
  * Executes the controller action and asserts non exception logic
  */
 public function testExecute()
 {
     $objectManager = new ObjectManagerHelper($this);
     $this->vault->expects($this->once())->method('storedCard')->willReturn(true);
     $this->request->expects($this->any())->method('getParam')->willReturn('token');
     $this->resultRedirectFactory->expects($this->never())->method('create')->willReturn($this->resultRedirect);
     $this->resultPageFactory->expects($this->once())->method('create')->willReturn($this->resultPage);
     $this->resultPage->expects($this->any())->method('getLayout')->willReturn($this->pageLayout);
     $this->pageLayout->expects($this->any())->method('getBlock')->willReturn($this->block);
     $this->pageConfig->expects($this->once())->method('getTitle')->willReturnSelf();
     $this->resultPage->expects($this->any())->method('getConfig')->willReturn($this->pageConfig);
     $notification = $objectManager->getObject('Magento\\Braintree\\Controller\\Creditcard\\Delete', ['request' => $this->request, 'resultPageFactory' => $this->resultPageFactory, 'vault' => $this->vault]);
     $this->assertSame($this->resultPage, $notification->execute());
 }
Example #14
0
 /**
  * @covers \Magento\Email\Controller\Adminhtml\Email\Template\Index::execute
  */
 public function testExecute()
 {
     $this->prepareExecute();
     $this->viewMock->expects($this->atLeastOnce())->method('getLayout')->willReturn($this->layoutMock);
     $this->layoutMock->expects($this->at(0))->method('getBlock')->with('menu')->will($this->returnValue($this->menuBlockMock));
     $this->menuBlockMock->expects($this->any())->method('getMenuModel')->will($this->returnSelf());
     $this->menuBlockMock->expects($this->any())->method('getParentItems')->will($this->returnValue([]));
     $this->viewMock->expects($this->once())->method('getPage')->willReturn($this->resultPageMock);
     $this->resultPageMock->expects($this->once())->method('getConfig')->willReturn($this->pageConfigMock);
     $this->pageConfigMock->expects($this->once())->method('getTitle')->willReturn($this->pageTitleMock);
     $this->pageTitleMock->expects($this->once())->method('prepend')->with('Email Templates');
     $this->layoutMock->expects($this->at(1))->method('getBlock')->with('breadcrumbs')->will($this->returnValue($this->breadcrumbsBlockMock));
     $this->breadcrumbsBlockMock->expects($this->any())->method('addLink')->willReturnSelf();
     $this->assertNull($this->indexController->execute());
 }
Example #15
0
 protected function setUp()
 {
     $this->_eventManagerMock = $this->getMock('Magento\\Framework\\Event\\ManagerInterface', [], [], '', false);
     $this->_actionFlagMock = $this->getMock('Magento\\Framework\\App\\ActionFlag', [], [], '', false);
     $this->_redirectMock = $this->getMock('Magento\\Framework\\App\\Response\\RedirectInterface', [], [], '', false);
     $this->_requestMock = $this->getMock('Magento\\Framework\\App\\RequestInterface', ['getFullActionName', 'getRouteName', 'isDispatched', 'initForward', 'setParams', 'setControllerName', 'setDispatched', 'getModuleName', 'setModuleName', 'getActionName', 'setActionName', 'getParam', 'getCookie'], [], '', false);
     $this->_responseMock = $this->getMock('Magento\\Framework\\App\\ResponseInterface', [], [], '', false);
     $this->pageConfigMock = $this->getMock('Magento\\Framework\\View\\Page\\Config', ['getConfig'], [], '', false);
     $this->viewMock = $this->getMock('Magento\\Framework\\App\\ViewInterface');
     $this->viewMock->expects($this->any())->method('getPage')->will($this->returnValue($this->pageConfigMock));
     $this->pageConfigMock->expects($this->any())->method('getConfig')->will($this->returnValue(1));
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->action = $this->objectManagerHelper->getObject('Magento\\Framework\\App\\Action\\ActionFake', ['request' => $this->_requestMock, 'response' => $this->_responseMock, 'eventManager' => $this->_eventManagerMock, 'redirect' => $this->_redirectMock, 'actionFlag' => $this->_actionFlagMock, 'view' => $this->viewMock]);
     \Magento\Framework\Profiler::disable();
 }
Example #16
0
 public function testExecute()
 {
     $this->menuMock->expects($this->once())->method('getParentItems')->willReturn([$this->menuItemMock]);
     $this->titleMock->expects($this->atLeastOnce())->method('prepend');
     $this->pageConfigMock->expects($this->atLeastOnce())->method('getTitle')->willReturn($this->titleMock);
     $this->pageMock->expects($this->atLeastOnce())->method('getConfig')->willReturn($this->pageConfigMock);
     $this->blockMock->expects($this->atLeastOnce())->method('addLink');
     $this->blockMock->expects($this->once())->method('setActive');
     $this->blockMock->expects($this->once())->method('getMenuModel')->willReturn($this->menuMock);
     $this->layoutMock->expects($this->atLeastOnce())->method('getBlock')->willReturn($this->blockMock);
     $this->viewMock->expects($this->once())->method('loadLayout')->willReturnSelf();
     $this->viewMock->expects($this->atLeastOnce())->method('getLayout')->willReturn($this->layoutMock);
     $this->viewMock->expects($this->atLeastOnce())->method('getPage')->willReturn($this->pageMock);
     $this->action->executeInternal();
 }
Example #17
0
 protected function setUp()
 {
     $this->_eventManagerMock = $this->getMock('Magento\\Framework\\Event\\ManagerInterface', [], [], '', false);
     $this->_actionFlagMock = $this->getMock('Magento\\Framework\\App\\ActionFlag', [], [], '', false);
     $this->_redirectMock = $this->getMock('Magento\\Framework\\App\\Response\\RedirectInterface', [], [], '', false);
     $this->_requestMock = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->disableOriginalConstructor()->getMock();
     $this->_responseMock = $this->getMock('Magento\\Framework\\App\\ResponseInterface', [], [], '', false);
     $this->pageConfigMock = $this->getMock('Magento\\Framework\\View\\Page\\Config', ['getConfig'], [], '', false);
     $this->viewMock = $this->getMock('Magento\\Framework\\App\\ViewInterface');
     $this->viewMock->expects($this->any())->method('getPage')->will($this->returnValue($this->pageConfigMock));
     $this->pageConfigMock->expects($this->any())->method('getConfig')->will($this->returnValue(1));
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->action = $this->objectManagerHelper->getObject('Magento\\Framework\\App\\Test\\Unit\\Action\\ActionFake', ['request' => $this->_requestMock, 'response' => $this->_responseMock, 'eventManager' => $this->_eventManagerMock, 'redirect' => $this->_redirectMock, 'actionFlag' => $this->_actionFlagMock, 'view' => $this->viewMock]);
     \Magento\Framework\Profiler::disable();
 }
Example #18
0
 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function setUp()
 {
     $titleMock = $this->getMockBuilder('Magento\\Framework\\App\\Action\\Title')->disableOriginalConstructor()->getMock();
     $this->invoiceMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Invoice')->disableOriginalConstructor()->getMock();
     $this->creditmemoMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Creditmemo')->disableOriginalConstructor()->setMethods(['getInvoice', 'getOrder', 'cancel', 'getId', '__wakeup'])->getMock();
     $this->requestMock = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->disableOriginalConstructor()->getMock();
     $this->responseMock = $this->getMockBuilder('Magento\\Framework\\App\\Response\\Http')->disableOriginalConstructor()->getMock();
     $this->objectManagerMock = $this->getMock('Magento\\Framework\\ObjectManagerInterface');
     $this->messageManagerMock = $this->getMockBuilder('Magento\\Framework\\Message\\Manager')->disableOriginalConstructor()->getMock();
     $this->sessionMock = $this->getMockBuilder('Magento\\Backend\\Model\\Session')->disableOriginalConstructor()->getMock();
     $this->helperMock = $this->getMockBuilder('Magento\\Backend\\Helper\\Data')->disableOriginalConstructor()->getMock();
     $this->contextMock = $this->getMockBuilder('Magento\\Backend\\App\\Action\\Context')->disableOriginalConstructor()->getMock();
     $this->contextMock->expects($this->any())->method('getHelper')->will($this->returnValue($this->helperMock));
     $this->actionFlagMock = $this->getMockBuilder('Magento\\Framework\\App\\ActionFlag')->disableOriginalConstructor()->getMock();
     $this->loaderMock = $this->getMockBuilder('Magento\\Sales\\Controller\\Adminhtml\\Order\\CreditmemoLoader')->disableOriginalConstructor()->getMock();
     $this->pageConfigMock = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Config')->disableOriginalConstructor()->getMock();
     $this->pageTitleMock = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Title')->disableOriginalConstructor()->getMock();
     $this->resultPageFactoryMock = $this->getMockBuilder('Magento\\Framework\\View\\Result\\PageFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->resultPageMock = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Page')->disableOriginalConstructor()->getMock();
     $this->resultForwardFactoryMock = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\ForwardFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->resultForwardMock = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Forward')->disableOriginalConstructor()->getMock();
     $this->contextMock->expects($this->any())->method('getSession')->will($this->returnValue($this->sessionMock));
     $this->contextMock->expects($this->any())->method('getActionFlag')->will($this->returnValue($this->actionFlagMock));
     $this->contextMock->expects($this->any())->method('getRequest')->will($this->returnValue($this->requestMock));
     $this->contextMock->expects($this->any())->method('getResponse')->will($this->returnValue($this->responseMock));
     $this->contextMock->expects($this->any())->method('getObjectManager')->will($this->returnValue($this->objectManagerMock));
     $this->contextMock->expects($this->any())->method('getTitle')->will($this->returnValue($titleMock));
     $this->contextMock->expects($this->any())->method('getMessageManager')->will($this->returnValue($this->messageManagerMock));
     $this->resultPageMock->expects($this->any())->method('getConfig')->willReturn($this->pageConfigMock);
     $this->pageConfigMock->expects($this->any())->method('getTitle')->willReturn($this->pageTitleMock);
     $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->controller = $objectManager->getObject('Magento\\Sales\\Controller\\Adminhtml\\Order\\Creditmemo\\View', ['context' => $this->contextMock, 'creditmemoLoader' => $this->loaderMock, 'resultPageFactory' => $this->resultPageFactoryMock, 'resultForwardFactory' => $this->resultForwardFactoryMock]);
 }
Example #19
0
 /**
  * @param $groupOne
  * @param $groupTwo
  * @param $expectedResult
  * @dataProvider dataProviderRenderAssets
  */
 public function testRenderAssets($groupOne, $groupTwo, $expectedResult)
 {
     $assetUrl = 'url';
     $assetNoRoutUrl = 'no_route_url';
     $exception = new \Magento\Framework\Exception('my message');
     $assetMockOne = $this->getMock('Magento\\Framework\\View\\Asset\\AssetInterface');
     $assetMockOne->expects($this->exactly(2))->method('getUrl')->willReturn($assetUrl);
     $groupAssetsOne = [$assetMockOne, $assetMockOne];
     $groupMockOne = $this->getMockBuilder('Magento\\Framework\\View\\Asset\\PropertyGroup')->disableOriginalConstructor()->getMock();
     $groupMockOne->expects($this->once())->method('getAll')->willReturn($groupAssetsOne);
     $groupMockOne->expects($this->any())->method('getProperty')->willReturnMap([[GroupedCollection::PROPERTY_CAN_MERGE, true], [GroupedCollection::PROPERTY_CONTENT_TYPE, $groupOne['type']], ['attributes', $groupOne['attributes']], ['ie_condition', $groupOne['condition']]]);
     $assetMockTwo = $this->getMock('Magento\\Framework\\View\\Asset\\AssetInterface');
     $assetMockTwo->expects($this->once())->method('getUrl')->willThrowException($exception);
     $groupAssetsTwo = [$assetMockTwo];
     $groupMockTwo = $this->getMockBuilder('Magento\\Framework\\View\\Asset\\PropertyGroup')->disableOriginalConstructor()->getMock();
     $groupMockTwo->expects($this->once())->method('getAll')->willReturn($groupAssetsTwo);
     $groupMockTwo->expects($this->any())->method('getProperty')->willReturnMap([[GroupedCollection::PROPERTY_CAN_MERGE, true], [GroupedCollection::PROPERTY_CONTENT_TYPE, $groupTwo['type']], ['attributes', $groupTwo['attributes']], ['ie_condition', $groupTwo['condition']]]);
     $this->pageConfigMock->expects($this->once())->method('getAssetCollection')->willReturn($this->assetsCollection);
     $this->assetsCollection->expects($this->once())->method('getGroups')->willReturn([$groupMockOne, $groupMockTwo]);
     $this->assetMinifyServiceMock->expects($this->exactly(2))->method('getAssets')->willReturnArgument(0);
     $this->assetMergeServiceMock->expects($this->exactly(1))->method('getMergedAssets')->willReturnArgument(0);
     $this->loggerMock->expects($this->once())->method('critical')->with($exception);
     $this->urlBuilderMock->expects($this->once())->method('getUrl')->with('', ['_direct' => 'core/index/notFound'])->willReturn($assetNoRoutUrl);
     $this->assertEquals($expectedResult, $this->renderer->renderAssets($this->renderer->getAvailableResultGroups()));
 }
Example #20
0
    /**
     * @covers \Magento\Sales\Controller\Adminhtml\Order\View::executeInternal
     */
    public function testExecute()
    {
        $id = 111;
        $titlePart = '#111';
        $this->initOrder();
        $this->initOrderSuccess($id);
        $this->prepareRedirect();
        $this->initAction();

        $this->resultPageMock->expects($this->atLeastOnce())
            ->method('getConfig')
            ->willReturn($this->pageConfigMock);
        $this->pageConfigMock->expects($this->atLeastOnce())
            ->method('getTitle')
            ->willReturn($this->pageTitleMock);
        $this->orderMock->expects($this->atLeastOnce())
            ->method('getIncrementId')
            ->willReturn($id);
        $this->pageTitleMock->expects($this->exactly(2))
            ->method('prepend')
            ->withConsecutive(
                ['Orders'],
                [$titlePart]
            )
            ->willReturnSelf();

        $this->assertInstanceOf(
            'Magento\Backend\Model\View\Result\Page',
            $this->viewAction->executeInternal()
        );
    }
Example #21
0
 public function setUp()
 {
     $objectManager = new ObjectManager($this);
     $this->requestMock = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->disableOriginalConstructor()->setMethods([])->getMock();
     $this->responseMock = $this->getMockBuilder('Magento\\Framework\\App\\Response\\Http')->disableOriginalConstructor()->setMethods([])->getMock();
     $this->titleMock = $this->getMockBuilder('Magento\\Framework\\App\\Action\\Title')->disableOriginalConstructor()->setMethods([])->getMock();
     $this->viewMock = $this->getMockBuilder('Magento\\Framework\\App\\View')->disableOriginalConstructor()->setMethods([])->getMock();
     $this->actionFlagMock = $this->getMockBuilder('Magento\\Framework\\App\\ActionFlag')->disableOriginalConstructor()->setMethods([])->getMock();
     $this->sessionMock = $this->getMockBuilder('Magento\\Backend\\Model\\Session')->disableOriginalConstructor()->setMethods(['getCommentText', 'setIsUrlNotice'])->getMock();
     $this->objectManagerMock = $this->getMock('Magento\\Framework\\ObjectManagerInterface');
     $this->resultPageMock = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Page')->disableOriginalConstructor()->getMock();
     $this->pageConfigMock = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Config')->disableOriginalConstructor()->getMock();
     $this->pageTitleMock = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Title')->disableOriginalConstructor()->getMock();
     $contextMock = $this->getMockBuilder('Magento\\Backend\\App\\Action\\Context')->disableOriginalConstructor()->setMethods([])->getMock();
     $contextMock->expects($this->any())->method('getRequest')->will($this->returnValue($this->requestMock));
     $contextMock->expects($this->any())->method('getResponse')->will($this->returnValue($this->responseMock));
     $contextMock->expects($this->any())->method('getTitle')->will($this->returnValue($this->titleMock));
     $contextMock->expects($this->any())->method('getView')->will($this->returnValue($this->viewMock));
     $contextMock->expects($this->any())->method('getActionFlag')->will($this->returnValue($this->actionFlagMock));
     $contextMock->expects($this->any())->method('getSession')->will($this->returnValue($this->sessionMock));
     $contextMock->expects($this->any())->method('getObjectManager')->will($this->returnValue($this->objectManagerMock));
     $this->viewMock->expects($this->any())->method('getPage')->willReturn($this->resultPageMock);
     $this->resultPageMock->expects($this->any())->method('getConfig')->willReturn($this->pageConfigMock);
     $this->pageConfigMock->expects($this->any())->method('getTitle')->willReturn($this->pageTitleMock);
     $this->resultPageFactoryMock = $this->getMockBuilder('Magento\\Framework\\View\\Result\\PageFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->resultForwardFactoryMock = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\ForwardFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->controller = $objectManager->getObject('Magento\\Sales\\Controller\\Adminhtml\\Order\\Invoice\\View', ['context' => $contextMock, 'resultPageFactory' => $this->resultPageFactoryMock, 'resultForwardFactory' => $this->resultForwardFactoryMock]);
 }
Example #22
0
 public function testSetLayoutWithoutAddress()
 {
     $addressId = 1;
     $customerPrefix = 'prefix';
     $customerFirstName = 'firstname';
     $customerMiddlename = 'middlename';
     $customerLastname = 'lastname';
     $customerSuffix = 'suffix';
     $title = 'title';
     $layoutMock = $this->getMockBuilder('Magento\\Framework\\View\\LayoutInterface')->getMock();
     $this->requestMock->expects($this->once())->method('getParam')->with('id', null)->willReturn($addressId);
     $this->addressRepositoryMock->expects($this->once())->method('getById')->with($addressId)->willThrowException(\Magento\Framework\Exception\NoSuchEntityException::singleField('addressId', $addressId));
     $newAddressMock = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\AddressInterface')->getMock();
     $this->addressDataFactoryMock->expects($this->once())->method('create')->willReturn($newAddressMock);
     $customerMock = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\CustomerInterface')->getMock();
     $this->currentCustomerMock->expects($this->once())->method('getCustomer')->willReturn($customerMock);
     $customerMock->expects($this->once())->method('getPrefix')->willReturn($customerPrefix);
     $customerMock->expects($this->once())->method('getFirstname')->willReturn($customerFirstName);
     $customerMock->expects($this->once())->method('getMiddlename')->willReturn($customerMiddlename);
     $customerMock->expects($this->once())->method('getLastname')->willReturn($customerLastname);
     $customerMock->expects($this->once())->method('getSuffix')->willReturn($customerSuffix);
     $newAddressMock->expects($this->once())->method('setPrefix')->with($customerPrefix)->willReturnSelf();
     $newAddressMock->expects($this->once())->method('setFirstname')->with($customerFirstName)->willReturnSelf();
     $newAddressMock->expects($this->once())->method('setMiddlename')->with($customerMiddlename)->willReturnSelf();
     $newAddressMock->expects($this->once())->method('setLastname')->with($customerLastname)->willReturnSelf();
     $newAddressMock->expects($this->once())->method('setSuffix')->with($customerSuffix)->willReturnSelf();
     $pageTitleMock = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Title')->disableOriginalConstructor()->getMock();
     $this->pageConfigMock->expects($this->once())->method('getTitle')->willReturn($pageTitleMock);
     $this->model->setData('title', $title);
     $pageTitleMock->expects($this->once())->method('set')->with($title)->willReturnSelf();
     $this->assertEquals($this->model, $this->model->setLayout($layoutMock));
     $this->assertEquals($layoutMock, $this->model->getLayout());
 }
 /**
  * @param string $actionName
  * @return \Magento\Integration\Controller\Adminhtml\Integration
  */
 protected function _createIntegrationController($actionName)
 {
     // Mock Layout passed into constructor
     $this->_viewMock = $this->getMockBuilder('Magento\\Framework\\App\\ViewInterface')->getMock();
     $this->_layoutMock = $this->getMock('Magento\\Framework\\View\\LayoutInterface');
     $this->_layoutMergeMock = $this->getMockBuilder('Magento\\Framework\\View\\Model\\Layout\\Merge')->disableOriginalConstructor()->getMock();
     $this->_layoutMock->expects($this->any())->method('getUpdate')->will($this->returnValue($this->_layoutMergeMock));
     $testElement = new \Magento\Framework\Simplexml\Element('<test>test</test>');
     $this->_layoutMock->expects($this->any())->method('getNode')->will($this->returnValue($testElement));
     // for _setActiveMenu
     $this->_viewMock->expects($this->any())->method('getLayout')->will($this->returnValue($this->_layoutMock));
     $blockMock = $this->getMockBuilder('Magento\\Backend\\Block\\Menu')->disableOriginalConstructor()->getMock();
     $menuMock = $this->getMock('Magento\\Backend\\Model\\Menu', [], [$this->getMock('Psr\\Log\\LoggerInterface')]);
     $loggerMock = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock();
     $loggerMock->expects($this->any())->method('critical')->will($this->returnSelf());
     $menuMock->expects($this->any())->method('getParentItems')->will($this->returnValue([]));
     $blockMock->expects($this->any())->method('getMenuModel')->will($this->returnValue($menuMock));
     $this->_layoutMock->expects($this->any())->method('getMessagesBlock')->will($this->returnValue($blockMock));
     $this->_layoutMock->expects($this->any())->method('getBlock')->will($this->returnValue($blockMock));
     $this->_viewMock->expects($this->any())->method('getPage')->willReturn($this->resultPageMock);
     $this->resultPageMock->expects($this->any())->method('getConfig')->willReturn($this->viewConfigMock);
     $this->viewConfigMock->expects($this->any())->method('getTitle')->willReturn($this->pageTitleMock);
     $this->_escaper->expects($this->any())->method('escapeHtml')->will($this->returnArgument(0));
     $contextParameters = ['view' => $this->_viewMock, 'objectManager' => $this->_objectManagerMock, 'session' => $this->_backendSessionMock, 'translator' => $this->_translateModelMock, 'request' => $this->_requestMock, 'response' => $this->_responseMock, 'messageManager' => $this->_messageManager];
     $this->_backendActionCtxMock = $this->_objectManagerHelper->getObject('Magento\\Backend\\App\\Action\\Context', $contextParameters);
     $integrationCollection = $this->getMockBuilder('\\Magento\\Integration\\Model\\Resource\\Integration\\Collection')->disableOriginalConstructor()->setMethods(['addUnsecureUrlsFilter', 'getSize'])->getMock();
     $integrationCollection->expects($this->any())->method('addUnsecureUrlsFilter')->will($this->returnValue($integrationCollection));
     $integrationCollection->expects($this->any())->method('getSize')->will($this->returnValue(0));
     $subControllerParams = ['context' => $this->_backendActionCtxMock, 'integrationService' => $this->_integrationSvcMock, 'oauthService' => $this->_oauthSvcMock, 'registry' => $this->_registryMock, 'logger' => $loggerMock, 'integrationData' => $this->_integrationHelperMock, 'escaper' => $this->_escaper, 'integrationCollection' => $integrationCollection];
     /** Create IntegrationController to test */
     $controller = $this->_objectManagerHelper->getObject('\\Magento\\Integration\\Controller\\Adminhtml\\Integration\\' . $actionName, $subControllerParams);
     return $controller;
 }
 public function testExecute()
 {
     $shipmentId = 1000012;
     $orderId = 10003;
     $tracking = [];
     $shipmentData = ['items' => [], 'send_email' => ''];
     $shipment = $this->getMock('Magento\\Sales\\Model\\Order\\Shipment', ['load', 'save', 'register', 'getOrder', 'getOrderId', '__wakeup'], [], '', false);
     $this->request->expects($this->any())->method('getParam')->will($this->returnValueMap([['order_id', null, $orderId], ['shipment_id', null, $shipmentId], ['shipment', null, $shipmentData], ['tracking', null, $tracking]]));
     $this->shipmentLoader->expects($this->any())->method('setShipmentId')->with($shipmentId);
     $this->shipmentLoader->expects($this->any())->method('setOrderId')->with($orderId);
     $this->shipmentLoader->expects($this->any())->method('setShipment')->with($shipmentData);
     $this->shipmentLoader->expects($this->any())->method('setTracking')->with($tracking);
     $this->shipmentLoader->expects($this->once())->method('load')->will($this->returnValue($shipment));
     $this->session->expects($this->once())->method('getCommentText')->with(true)->will($this->returnValue(''));
     $this->objectManager->expects($this->atLeastOnce())->method('get')->with('Magento\\Backend\\Model\\Session')->will($this->returnValue($this->session));
     $this->view->expects($this->once())->method('loadLayout')->will($this->returnSelf());
     $this->view->expects($this->once())->method('renderLayout')->will($this->returnSelf());
     $this->view->expects($this->any())->method('getPage')->willReturn($this->resultPageMock);
     $this->resultPageMock->expects($this->any())->method('getConfig')->willReturn($this->pageConfigMock);
     $this->pageConfigMock->expects($this->any())->method('getTitle')->willReturn($this->pageTitleMock);
     $layout = $this->getMock('Magento\\Framework\\View\\Layout\\Element\\Layout', ['getBlock'], [], '', false);
     $menuBlock = $this->getMock('Magento\\Framework\\View\\Element\\BlockInterface', ['toHtml', 'setActive', 'getMenuModel'], [], '', false);
     $menuModel = $this->getMockBuilder('Magento\\Backend\\Model\\Menu')->disableOriginalConstructor()->getMock();
     $itemId = 'Magento_Sales::sales_order';
     $parents = [new \Magento\Framework\DataObject(['title' => 'title1']), new \Magento\Framework\DataObject(['title' => 'title2']), new \Magento\Framework\DataObject(['title' => 'title3'])];
     $menuModel->expects($this->once())->method('getParentItems')->with($itemId)->will($this->returnValue($parents));
     $menuBlock->expects($this->once())->method('setActive')->with($itemId);
     $menuBlock->expects($this->once())->method('getMenuModel')->will($this->returnValue($menuModel));
     $this->view->expects($this->once())->method('getLayout')->will($this->returnValue($layout));
     $layout->expects($this->once())->method('getBlock')->with('menu')->will($this->returnValue($menuBlock));
     $this->assertNull($this->newAction->execute());
 }
Example #25
0
 public function testProcess()
 {
     $generatorContextMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout\\Generator\\Context')->disableOriginalConstructor()->getMock();
     $this->title->expects($this->any())->method('set')->with()->will($this->returnSelf());
     $structureMock = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Config\\Structure')->disableOriginalConstructor()->getMock();
     $readerContextMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout\\Reader\\Context')->disableOriginalConstructor()->getMock();
     $readerContextMock->expects($this->any())->method('getPageConfigStructure')->willReturn($structureMock);
     $structureMock->expects($this->once())->method('processRemoveAssets');
     $structureMock->expects($this->once())->method('processRemoveElementAttributes');
     $assets = ['remoteCss' => ['src' => 'file-url', 'src_type' => 'url', 'media' => "all", 'content_type' => 'css'], 'remoteLink' => ['src' => 'file-url', 'src_type' => 'url', 'media' => "all"], 'name' => ['src' => 'file-path', 'ie_condition' => 'lt IE 7', 'media' => "print", 'content_type' => 'css']];
     $this->pageConfigMock->expects($this->at(0))->method('addRemotePageAsset')->with('remoteCss', 'css', ['attributes' => ['media' => 'all']]);
     $this->pageConfigMock->expects($this->at(1))->method('addRemotePageAsset')->with('remoteLink', Head::VIRTUAL_CONTENT_TYPE_LINK, ['attributes' => ['media' => 'all']]);
     $this->pageConfigMock->expects($this->once())->method('addPageAsset')->with('name', ['attributes' => ['media' => 'print'], 'ie_condition' => 'lt IE 7']);
     $structureMock->expects($this->once())->method('getAssets')->will($this->returnValue($assets));
     $title = 'Page title';
     $structureMock->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title));
     $this->pageConfigMock->expects($this->any())->method('getTitle')->will($this->returnValue($this->title));
     $metadata = ['name1' => 'content1', 'name2' => 'content2'];
     $structureMock->expects($this->once())->method('getMetadata')->will($this->returnValue($metadata));
     $this->pageConfigMock->expects($this->exactly(2))->method('setMetadata')->withConsecutive(['name1', 'content1'], ['name2', 'content2']);
     $elementAttributes = [PageConfig::ELEMENT_TYPE_BODY => ['body_attr_1' => 'body_value_1', 'body_attr_2' => 'body_value_2'], PageConfig::ELEMENT_TYPE_HTML => ['html_attr_1' => 'html_attr_1']];
     $structureMock->expects($this->once())->method('getElementAttributes')->will($this->returnValue($elementAttributes));
     $this->pageConfigMock->expects($this->exactly(3))->method('setElementAttribute')->withConsecutive([PageConfig::ELEMENT_TYPE_BODY, 'body_attr_1', 'body_value_1'], [PageConfig::ELEMENT_TYPE_BODY, 'body_attr_2', 'body_value_2'], [PageConfig::ELEMENT_TYPE_HTML, 'html_attr_1', 'html_attr_1']);
     $this->assertEquals($this->headGenerator, $this->headGenerator->process($readerContextMock, $generatorContextMock));
 }
Example #26
0
 /**
  * Process all element attributes
  *
  * @param \Magento\Framework\View\Page\Config\Structure $pageStructure
  * @return $this
  */
 protected function processElementAttributes(Structure $pageStructure)
 {
     foreach ($pageStructure->getElementAttributes() as $element => $attributes) {
         foreach ($attributes as $name => $value) {
             $this->pageConfig->setElementAttribute($element, $name, $value);
         }
     }
     return $this;
 }
Example #27
0
 public function testConstructMethod()
 {
     $data = [];
     $customerId = 25;
     $this->customerSession->expects($this->once())->method('getCustomerId')->will($this->returnValue($customerId));
     $statuses = ['pending', 'processing', 'comlete'];
     $this->orderConfig->expects($this->once())->method('getVisibleOnFrontStatuses')->will($this->returnValue($statuses));
     $orderCollection = $this->getMock('Magento\\Sales\\Model\\ResourceModel\\Order\\Collection', ['addFieldToSelect', 'addFieldToFilter', 'setOrder'], [], '', false, false);
     $this->context->expects($this->any())->method('getPageConfig')->willReturn($this->pageConfig);
     $orderCollection->expects($this->at(0))->method('addFieldToSelect')->with($this->equalTo('*'))->will($this->returnSelf());
     $orderCollection->expects($this->at(1))->method('addFieldToFilter')->with('status', $this->equalTo(['in' => $statuses]))->will($this->returnSelf());
     $orderCollection->expects($this->at(2))->method('setOrder')->with('created_at', 'desc')->will($this->returnSelf());
     $this->orderCollectionFactoryInterface->expects($this->atLeastOnce())->method('create')->will($this->returnValue($orderCollection));
     $this->pageConfig->expects($this->atLeastOnce())->method('getTitle')->willReturn($this->pageTitleMock);
     $this->pageTitleMock->expects($this->atLeastOnce())->method('set')->willReturnSelf();
     $this->model = new \Magento\Sales\Block\Order\History($this->context, $this->orderCollectionFactory, $this->customerSession, $this->orderConfig, $data);
     $this->assertEquals($orderCollection, $this->model->getOrders());
 }
Example #28
0
 public function testSetLayout()
 {
     $this->bundleConfig->expects($this->once())->method('isBundlingJsFiles')->willReturn(true);
     $filePath = 'require_js_fie_path';
     $asset = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\Asset\\LocalInterface');
     $asset->expects($this->atLeastOnce())->method('getFilePath')->willReturn($filePath);
     $requireJsAsset = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\Asset\\LocalInterface');
     $requireJsAsset->expects($this->atLeastOnce())->method('getFilePath')->willReturn('/path/to/require/require.js');
     $this->fileManager->expects($this->once())->method('createRequireJsConfigAsset')->will($this->returnValue($requireJsAsset));
     $this->fileManager->expects($this->once())->method('createStaticJsAsset')->will($this->returnValue($requireJsAsset));
     $this->fileManager->expects($this->once())->method('createBundleJsPool')->will($this->returnValue([$asset]));
     $layout = $this->getMock('Magento\\Framework\\View\\LayoutInterface');
     $assetCollection = $this->getMockBuilder('Magento\\Framework\\View\\Asset\\GroupedCollection')->disableOriginalConstructor()->getMock();
     $this->pageConfig->expects($this->atLeastOnce())->method('getAssetCollection')->willReturn($assetCollection);
     $assetCollection->expects($this->atLeastOnce())->method('insert')->willReturn(true);
     $object = new Config($this->context, $this->config, $this->fileManager, $this->pageConfig, $this->bundleConfig);
     $object->setLayout($layout);
 }
Example #29
0
 /**
  * Renders CMS page
  *
  * @param Action $action
  * @param int $pageId
  * @param bool $renderLayout
  * @return bool
  */
 protected function _renderPage(Action $action, $pageId = null, $renderLayout = true)
 {
     if (!is_null($pageId) && $pageId !== $this->_page->getId()) {
         $delimiterPosition = strrpos($pageId, '|');
         if ($delimiterPosition) {
             $pageId = substr($pageId, 0, $delimiterPosition);
         }
         $this->_page->setStoreId($this->_storeManager->getStore()->getId());
         if (!$this->_page->load($pageId)) {
             return false;
         }
     }
     if (!$this->_page->getId()) {
         return false;
     }
     $inRange = $this->_localeDate->isScopeDateInInterval(null, $this->_page->getCustomThemeFrom(), $this->_page->getCustomThemeTo());
     if ($this->_page->getCustomTheme()) {
         if ($inRange) {
             $this->_design->setDesignTheme($this->_page->getCustomTheme());
         }
     }
     if ($this->_page->getPageLayout()) {
         if ($this->_page->getCustomPageLayout() && $this->_page->getCustomPageLayout() != 'empty' && $inRange) {
             $handle = $this->_page->getCustomPageLayout();
         } else {
             $handle = $this->_page->getPageLayout();
         }
         $this->pageConfig->setPageLayout($handle);
     }
     $this->_view->getPage()->initLayout();
     $this->_view->getLayout()->getUpdate()->addHandle('cms_page_view');
     $this->_view->addPageLayoutHandles(array('id' => $this->_page->getIdentifier()));
     $this->_eventManager->dispatch('cms_page_render', array('page' => $this->_page, 'controller_action' => $action));
     $this->_view->loadLayoutUpdates();
     if ($this->_page->getCustomLayoutUpdateXml() && $inRange) {
         $layoutUpdate = $this->_page->getCustomLayoutUpdateXml();
     } else {
         $layoutUpdate = $this->_page->getLayoutUpdateXml();
     }
     if (!empty($layoutUpdate)) {
         $this->_view->getLayout()->getUpdate()->addUpdate($layoutUpdate);
     }
     $this->_view->generateLayoutXml()->generateLayoutBlocks();
     $contentHeadingBlock = $this->_view->getLayout()->getBlock('page_content_heading');
     if ($contentHeadingBlock) {
         $contentHeading = $this->_escaper->escapeHtml($this->_page->getContentHeading());
         $contentHeadingBlock->setContentHeading($contentHeading);
     }
     /* @TODO: Move catalog and checkout storage types to appropriate modules */
     $messageBlock = $this->_view->getLayout()->getMessagesBlock();
     $messageBlock->addStorageType($this->messageManager->getDefaultGroup());
     $messageBlock->addMessages($this->messageManager->getMessages(true));
     if ($renderLayout) {
         $this->_view->renderLayout();
     }
     return true;
 }
Example #30
0
 public function testGetIncludes()
 {
     $xml = '
         <script type="text/javascript">
             Fieldset.addToPrefix(1);
         </script>
         ';
     $this->scopeConfig->expects($this->once())->method('getValue')->with('design/head/includes', 'store')->will($this->returnValue($xml));
     $this->assertEquals($xml, $this->model->getIncludes());
 }