コード例 #1
0
 /**
  * @return void
  */
 public function testExecute()
 {
     $titleMock = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Title')->disableOriginalConstructor()->getMock();
     $titleMock->expects($this->once())->method('prepend')->with(new Phrase('Account Activity'));
     $this->viewMock->expects($this->any())->method('getPage')->willReturn(new DataObject(['config' => new DataObject(['title' => $titleMock])]));
     $this->controller->execute();
 }
コード例 #2
0
 /**
  * Push `trackSiteSearch' to tracker on search result page
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return \Henhed\Piwik\Observer\SearchResultObserver
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     if (!$this->_dataHelper->isTrackingEnabled()) {
         return $this;
     }
     $query = $this->_queryFactory->get();
     $piwikBlock = $this->_view->getLayout()->getBlock('piwik.tracker');
     /* @var $query \Magento\Search\Model\Query */
     /* @var $piwikBlock \Henhed\Piwik\Block\Piwik */
     $keyword = $query->getQueryText();
     $resultsCount = $query->getNumResults();
     if (is_null($resultsCount)) {
         // If this is a new search query the result count hasn't been saved
         // yet so we have to fetch it from the search result block instead.
         $resultBock = $this->_view->getLayout()->getBlock('search.result');
         /* @var $resultBock \Magento\CatalogSearch\Block\Result */
         if ($resultBock) {
             $resultsCount = $resultBock->getResultCount();
         }
     }
     if (is_null($resultsCount)) {
         $this->_piwikTracker->trackSiteSearch($keyword);
     } else {
         $this->_piwikTracker->trackSiteSearch($keyword, false, (int) $resultsCount);
     }
     if ($piwikBlock) {
         // Don't push `trackPageView' when `trackSiteSearch' is set
         $piwikBlock->setSkipTrackPageView(true);
     }
     return $this;
 }
コード例 #3
0
ファイル: GridTest.php プロジェクト: nblair/magescotch
 public function testExecuteInternal()
 {
     $this->view->expects($this->once())
         ->method('loadLayout')
         ->with(false);
     $this->view->expects($this->once())
         ->method('renderLayout');
     $this->controller->executeInternal();
 }
コード例 #4
0
ファイル: IndexTest.php プロジェクト: nja78/magento2
 public function testExecute()
 {
     $layout = $this->getMock('\\Magento\\Framework\\View\\Layout', ['getBlock', 'initMessages'], [], '', false);
     $block = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\Element\\AbstractBlock', ['setFormAction'], '', false);
     $layout->expects($this->once())->method('getBlock')->with('contactForm')->will($this->returnValue($block));
     $this->_view->expects($this->once())->method('loadLayout');
     $this->_view->expects($this->exactly(1))->method('getLayout')->will($this->returnValue($layout));
     $this->_view->expects($this->once())->method('renderLayout');
     $this->_controller->execute();
 }
コード例 #5
0
ファイル: Data.php プロジェクト: steegi/paystand-magento2
 /**
  * Get payment method step html
  *
  * @param \Magento\Framework\App\ViewInterface $view
  * @return string
  */
 public function getPaymentMethodsHtml(\Magento\Framework\App\ViewInterface $view)
 {
     $layout = $view->getLayout();
     $update = $layout->getUpdate();
     $update->load('checkout_onepage_paymentmethod');
     $layout->generateXml();
     $layout->generateElements();
     $output = $layout->getOutput();
     return $output;
 }
コード例 #6
0
 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();
 }
コード例 #7
0
 /**
  * test getCustomer method, method returns depersonalized customer Data
  */
 public function testGetCustomerDepersonalizeCustomerData()
 {
     $this->requestMock->expects($this->once())->method('isAjax')->will($this->returnValue(false));
     $this->layoutMock->expects($this->once())->method('isCacheable')->will($this->returnValue(true));
     $this->viewMock->expects($this->once())->method('isLayoutLoaded')->will($this->returnValue(true));
     $this->moduleManagerMock->expects($this->once())->method('isEnabled')->with($this->equalTo('Magento_PageCache'))->will($this->returnValue(true));
     $this->customerSessionMock->expects($this->once())->method('getCustomerGroupId')->will($this->returnValue($this->customerGroupId));
     $this->customerInterfaceFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->customerDataMock));
     $this->customerDataMock->expects($this->once())->method('setGroupId')->with($this->equalTo($this->customerGroupId))->will($this->returnSelf());
     $this->assertEquals($this->customerDataMock, $this->currentCustomer->getCustomer());
 }
コード例 #8
0
 /**
  * @covers \Magento\Authorizenet\Controller\Directpost\Payment\Redirect::execute
  */
 public function testExecute()
 {
     $url = 'http://test.com/redirect?=test';
     $params = ['order_success' => $url];
     $this->request->expects(static::once())->method('getParams')->willReturn($params);
     $this->coreRegistry->expects(static::once())->method('register')->with(Iframe::REGISTRY_KEY, []);
     $this->view->expects(static::once())->method('addPageLayoutHandles');
     $this->view->expects(static::once())->method('loadLayout')->with(false)->willReturnSelf();
     $this->view->expects(static::once())->method('renderLayout');
     $this->controller->execute();
 }
コード例 #9
0
 /**
  * Get wishlist items
  *
  * @return array
  */
 protected function getItems()
 {
     $this->view->loadLayout();
     $collection = $this->wishlistHelper->getWishlistItemCollection();
     $collection->clear()->setPageSize(self::SIDEBAR_ITEMS_NUMBER)->setInStockFilter(true)->setOrder('added_at');
     $items = [];
     foreach ($collection as $wishlistItem) {
         $items[] = $this->getItemData($wishlistItem);
     }
     return $items;
 }
コード例 #10
0
ファイル: GridTest.php プロジェクト: nja78/magento2
 public function testExecute()
 {
     $layout = $this->getMock('\\Magento\\Framework\\View\\LayoutInterface');
     $block = $this->getMockBuilder('Magento\\Bundle\\Block\\Adminhtml\\Catalog\\Product\\Edit\\Tab\\Bundle\\Option\\Search\\Grid')->disableOriginalConstructor()->setMethods(['setIndex', 'toHtml'])->getMock();
     $this->response->expects($this->once())->method('setBody')->willReturnSelf();
     $this->request->expects($this->once())->method('getParam')->with('index')->willReturn('index');
     $this->view->expects($this->once())->method('getLayout')->willReturn($layout);
     $layout->expects($this->once())->method('createBlock')->willReturn($block);
     $block->expects($this->once())->method('setIndex')->willReturnSelf();
     $block->expects($this->once())->method('toHtml')->willReturnSelf();
     $this->assertEquals($this->response, $this->controller->execute());
 }
コード例 #11
0
 public function testExecute()
 {
     $product = $this->getMockBuilder('\\Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->setMethods(['_wakeup', 'getId'])->getMock();
     $layout = $this->getMock('\\Magento\\Framework\\View\\LayoutInterface');
     $block = $this->getMockBuilder('Magento\\Bundle\\Block\\Adminhtml\\Catalog\\Product\\Edit\\Tab\\Bundle')->disableOriginalConstructor()->setMethods(['setIndex', 'toHtml'])->getMock();
     $this->productBuilder->expects($this->once())->method('build')->with($this->request)->willReturn($product);
     $this->initializationHelper->expects($this->any())->method('initialize')->willReturn($product);
     $this->response->expects($this->once())->method('setBody')->willReturnSelf();
     $this->view->expects($this->once())->method('getLayout')->willReturn($layout);
     $layout->expects($this->once())->method('createBlock')->willReturn($block);
     $block->expects($this->once())->method('toHtml')->willReturnSelf();
     $this->controller->execute();
 }
コード例 #12
0
 public function testExecute()
 {
     $product = $this->getMockBuilder('\\Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->setMethods(['_wakeup', 'getId'])->getMock();
     $layout = $this->getMock('\\Magento\\Framework\\View\\LayoutInterface');
     $block = $this->getMockBuilder('Magento\\ConfigurableProduct\\Block\\Adminhtml\\Product\\Attribute\\NewAttribute\\Product\\Created')->disableOriginalConstructor()->setMethods(['setIndex', 'toHtml'])->getMock();
     $this->view->expects($this->once())->method('loadLayout')->with('popup')->willReturnSelf();
     $this->productBuilder->expects($this->once())->method('build')->with($this->request)->willReturn($product);
     $this->view->expects($this->any())->method('getLayout')->willReturn($layout);
     $layout->expects($this->once())->method('createBlock')->willReturn($block);
     $layout->expects($this->once())->method('setChild')->willReturnSelf();
     $this->view->expects($this->any())->method('renderLayout')->willReturnSelf();
     $this->controller->execute();
 }
コード例 #13
0
ファイル: ContentsTest.php プロジェクト: nblair/magescotch
    public function testExecute()
    {
        $layout = $this->getMockForAbstractClass('Magento\Framework\View\LayoutInterface', [], '', false);
        $storage = $this->getMock('Magento\Theme\Model\Wysiwyg\Storage', [], [], '', false);
        $block = $this->getMockForAbstractClass(
            'Magento\Framework\View\Element\BlockInterface',
            [],
            '',
            false,
            false,
            true,
            ['setStorage']
        );

        $this->view->expects($this->once())
            ->method('loadLayout')
            ->with('empty');
        $this->view->expects($this->once())
            ->method('getLayout')
            ->willReturn($layout);
        $layout->expects($this->once())
            ->method('getBlock')
            ->with('wysiwyg_files.files')
            ->willReturn($block);
        $block->expects($this->once())
            ->method('setStorage')
            ->with($storage);
        $this->objectManager->expects($this->at(0))
            ->method('get')
            ->with('Magento\Theme\Model\Wysiwyg\Storage')
            ->willReturn($storage);
        $this->storage->expects($this->once())
            ->method('getCurrentPath')
            ->willThrowException(new \Exception('Message'));

        $jsonData = $this->getMock('Magento\Framework\Json\Helper\Data', [], [], '', false);
        $jsonData->expects($this->once())
            ->method('jsonEncode')
            ->with(['error' => true, 'message' => 'Message'])
            ->willReturn('{"error":"true","message":"Message"}');

        $this->objectManager->expects($this->at(1))
            ->method('get')
            ->with('Magento\Framework\Json\Helper\Data')
            ->willReturn($jsonData);

        $this->response->expects($this->once())
            ->method('representJson');

        $this->controller->executeInternal();
    }
コード例 #14
0
ファイル: Wishlist.php プロジェクト: vasiljok/magento2
 /**
  * Get wishlist items
  *
  * @return array
  */
 protected function getItems()
 {
     $this->view->loadLayout();
     $collection = $this->wishlistHelper->getWishlistItemCollection();
     $collection->clear()->setPageSize(self::SIDEBAR_ITEMS_NUMBER)->setInStockFilter(true)->setOrder('added_at');
     $items = [];
     foreach ($collection as $wishlistItem) {
         /** @var \Magento\Catalog\Model\Product $product */
         $product = $wishlistItem->getProduct();
         $this->productImageView->init($product, 'wishlist_sidebar_block', 'Magento_Catalog');
         $items[] = ['image' => ['src' => $this->productImageView->getUrl(), 'alt' => $this->productImageView->getLabel(), 'width' => $this->productImageView->getWidth(), 'height' => $this->productImageView->getHeight()], 'product_url' => $this->wishlistHelper->getProductUrl($wishlistItem), 'product_name' => $product->getName(), 'product_price' => $this->block->getProductPriceHtml($product, \Magento\Catalog\Pricing\Price\ConfiguredPriceInterface::CONFIGURED_PRICE_CODE, \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST, ['item' => $wishlistItem]), 'product_is_saleable_and_visible' => $product->isSaleable() && $product->isVisibleInSiteVisibility(), 'product_has_required_options' => $product->getTypeInstance()->hasRequiredOptions($product), 'add_to_cart_params' => $this->wishlistHelper->getAddToCartParams($wishlistItem), 'delete_item_params' => $this->wishlistHelper->getRemoveParams($wishlistItem)];
     }
     return $items;
 }
コード例 #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->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();
 }
コード例 #16
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();
 }
コード例 #17
0
ファイル: IndexTest.php プロジェクト: nblair/magescotch
 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();
 }
コード例 #18
0
 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());
 }
コード例 #19
0
 /**
  * @param string $actionName
  * @return \Magento\Integration\Controller\Adminhtml\Integration
  */
 protected function _createIntegrationController($actionName)
 {
     // Mock Layout passed into constructor
     $this->_viewMock = $this->getMock('Magento\\Framework\\App\\ViewInterface');
     $this->_layoutMock = $this->getMock('Magento\\Framework\\View\\LayoutInterface');
     $this->_layoutMergeMock = $this->getMockBuilder('Magento\\Core\\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('Magento\\Framework\\Logger', [], [], '', false)]);
     $loggerMock = $this->getMockBuilder('Magento\\Framework\\Logger')->disableOriginalConstructor()->getMock();
     $loggerMock->expects($this->any())->method('logException')->will($this->returnSelf());
     $menuMock->expects($this->any())->method('getParentItems')->will($this->returnValue(array()));
     $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->_escaper->expects($this->any())->method('escapeHtml')->will($this->returnArgument(0));
     $contextParameters = array('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 = array('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;
 }
コード例 #20
0
 public function testExecute()
 {
     $carrier = 'carrier';
     $number = 'number';
     $title = 'title';
     $shipmentId = 1000012;
     $orderId = 10003;
     $tracking = [];
     $shipmentData = ['items' => [], 'send_email' => ''];
     $shipment = $this->getMock('Magento\\Sales\\Model\\Order\\Shipment', ['addTrack', '__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->request->expects($this->any())->method('getPost')->will($this->returnValueMap([['carrier', $carrier], ['number', $number], ['title', $title]]));
     $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->title->expects($this->any())->method('add')->with('Shipments')->will($this->returnSelf());
     $track = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Shipment\\Track')->disableOriginalConstructor()->setMethods(['__wakeup', 'setNumber', 'setCarrierCode', 'setTitle'])->getMock();
     $this->objectManager->expects($this->atLeastOnce())->method('create')->with('Magento\\Sales\\Model\\Order\\Shipment\\Track')->will($this->returnValue($track));
     $track->expects($this->once())->method('setNumber')->with($number)->will($this->returnSelf());
     $track->expects($this->once())->method('setCarrierCode')->with($carrier)->will($this->returnSelf());
     $track->expects($this->once())->method('setTitle')->with($title)->will($this->returnSelf());
     $this->view->expects($this->once())->method('loadLayout')->will($this->returnSelf());
     $layout = $this->getMock('Magento\\Framework\\View\\Layout\\Element\\Layout', ['getBlock'], [], '', false);
     $menuBlock = $this->getMock('Magento\\Framework\\View\\Element\\BlockInterface', ['toHtml'], [], '', false);
     $html = 'html string';
     $this->view->expects($this->once())->method('getLayout')->will($this->returnValue($layout));
     $layout->expects($this->once())->method('getBlock')->with('shipment_tracking')->will($this->returnValue($menuBlock));
     $menuBlock->expects($this->once())->method('toHtml')->will($this->returnValue($html));
     $shipment->expects($this->once())->method('addTrack')->with($this->equalTo($track))->will($this->returnSelf());
     $shipment->expects($this->any())->method('save')->will($this->returnSelf());
     $this->response->expects($this->once())->method('setBody')->with($html);
     $this->assertNull($this->controller->execute());
 }
コード例 #21
0
 /**
  * Run test execute method
  */
 public function testExecute()
 {
     $data = ['comment' => 'comment'];
     $result = 'result-html';
     $orderId = 1;
     $shipmentId = 1;
     $shipment = [];
     $tracking = [];
     $layoutMock = $this->getMock('Magento\\Framework\\View\\Layout', ['getBlock'], [], '', false);
     $blockMock = $this->getMock('Magento\\Shipping\\Block\\Adminhtml\\View\\Comments', ['toHtml'], [], '', false);
     $this->requestMock->expects($this->once())->method('setParam')->with('shipment_id', $shipmentId);
     $this->requestMock->expects($this->once())->method('getPost')->with('comment')->will($this->returnValue($data));
     $this->titleMock->expects($this->once())->method('prepend');
     $this->requestMock->expects($this->any())->method('getParam')->will($this->returnValueMap([['id', null, $shipmentId], ['order_id', null, $orderId], ['shipment_id', null, $shipmentId], ['shipment', null, $shipment], ['tracking', null, $tracking]]));
     $this->shipmentLoaderMock->expects($this->once())->method('setOrderId')->with($orderId);
     $this->shipmentLoaderMock->expects($this->once())->method('setShipmentId')->with($shipmentId);
     $this->shipmentLoaderMock->expects($this->once())->method('setShipment')->with($shipment);
     $this->shipmentLoaderMock->expects($this->once())->method('setTracking')->with($tracking);
     $this->shipmentLoaderMock->expects($this->once())->method('load')->will($this->returnValue($this->shipmentMock));
     $this->shipmentMock->expects($this->once())->method('addComment');
     $this->shipmentSenderMock->expects($this->once())->method('send');
     $this->shipmentMock->expects($this->once())->method('save');
     $this->viewInterfaceMock->expects($this->once())->method('loadLayout')->with(false);
     $this->viewInterfaceMock->expects($this->once())->method('getLayout')->will($this->returnValue($layoutMock));
     $layoutMock->expects($this->once())->method('getBlock')->will($this->returnValue($blockMock));
     $blockMock->expects($this->once())->method('toHtml')->will($this->returnValue($result));
     $this->responseMock->expects($this->once())->method('setBody')->with($result);
     $this->assertNull($this->controller->execute());
 }
コード例 #22
0
 /**
  * Set up before test
  *
  * @return void
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function setUp()
 {
     $this->_objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
     $this->_installerMock = $this->getMock('\\Magento\\Install\\Model\\Installer', array('isApplicationInstalled'), array(), '', false);
     $this->_installerMock->expects($this->any())->method('isApplicationInstalled')->will($this->returnValue(true));
     $this->_blockMock = $this->getMock('\\Magento\\Install\\Block\\Locale', array(), array(), '', false);
     $this->_layoutMock = $this->getMock('\\Magento\\Framework\\View\\Layout', array('getBlock', 'initMessages', 'addBlock'), array(), '', false);
     $this->_layoutMock->expects($this->any())->method('initMessages')->withAnyParameters()->will($this->returnValue(true));
     $this->_layoutMock->expects($this->any())->method('addBlock')->withAnyParameters()->will($this->returnValue(true));
     $this->_viewMock = $this->getMockForAbstractClass('\\Magento\\Framework\\App\\ViewInterface', array(), '', false, false, true, array('getLayout'));
     $this->_viewMock->expects($this->any())->method('getLayout')->withAnyParameters()->will($this->returnValue($this->_layoutMock));
     $this->_requestMock = $this->_getClearMock('\\Magento\\Framework\\App\\RequestInterface');
     $this->_responseMock = $this->_getClearMock('\\Magento\\Framework\\App\\ResponseInterface');
     $this->_actionFlagMock = $this->_getClearMock('\\Magento\\Framework\\App\\ActionFlag');
     $this->_contextMock = $this->getMock('\\Magento\\Framework\\App\\Action\\Context', array('getView', 'getRequest', 'getResponse', 'getActionFlag'), array(), '', false);
     $this->_contextMock->expects($this->any())->method('getView')->will($this->returnValue($this->_viewMock));
     $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('getActionFlag')->will($this->returnValue($this->_actionFlagMock));
     $this->_blockContextMock = $this->getMock('\\Magento\\Framework\\View\\Element\\Template\\Context', array(), array(), '', false);
     $this->_wizardMock = $this->getMock('\\Magento\\Install\\Model\\Wizard', array('getStepByRequest'), array(), '', false);
     $this->_wizardMock->expects($this->any())->method('getStepByRequest')->withAnyParameters()->will($this->returnValue(false));
     $this->_sessionMock = $this->getMock('\\Magento\\Framework\\Session\\Generic', array('getLocale'), array(), '', false);
     $this->_sessionMock->expects($this->any())->method('getLocale')->will($this->returnValue(self::LOCALE));
     $this->_block = $this->_objectManager->getObject('Magento\\Install\\Block\\Locale', array('context' => $this->_blockContextMock, 'installer' => $this->_installerMock, 'installWizard' => $this->_wizardMock, 'session' => $this->_sessionMock, 'data' => array()));
     $this->_layoutMock->expects($this->any())->method('getBlock')->with('install.locale')->will($this->returnValue($this->_block));
     $this->_controller = $this->_objectManager->getObject('Magento\\Install\\Controller\\Wizard\\Locale', array('context' => $this->_contextMock, 'configScope' => $this->_getClearMock('Magento\\Framework\\Config\\Scope'), 'installer' => $this->_getClearMock('Magento\\Install\\Model\\Installer'), 'wizard' => $this->_wizardMock, 'session' => $this->_sessionMock, 'dbUpdater' => $this->_getClearMock('Magento\\Framework\\Module\\UpdaterInterface'), 'storeManager' => $this->_getClearMock('Magento\\Store\\Model\\StoreManagerInterface'), 'appState' => $this->_getClearMock('Magento\\Framework\\App\\State')));
 }
コード例 #23
0
ファイル: View.php プロジェクト: aiesh/magento2
 /**
  * Prepares product view page - inits layout and all needed stuff
  *
  * $params can have all values as $params in \Magento\Catalog\Helper\Product - initProduct().
  * Plus following keys:
  *   - 'buy_request' - \Magento\Framework\Object holding buyRequest to configure product
  *   - 'specify_options' - boolean, whether to show 'Specify options' message
  *   - 'configure_mode' - boolean, whether we're in Configure-mode to edit product configuration
  *
  * @param int $productId
  * @param \Magento\Framework\App\Action\Action $controller
  * @param null|\Magento\Framework\Object $params
  *
  * @return \Magento\Catalog\Helper\Product\View
  * @throws \Magento\Framework\Model\Exception
  */
 public function prepareAndRender($productId, $controller, $params = null)
 {
     // Prepare data
     $productHelper = $this->_catalogProduct;
     if (!$params) {
         $params = new \Magento\Framework\Object();
     }
     // Standard algorithm to prepare and render product view page
     $product = $productHelper->initProduct($productId, $controller, $params);
     if (!$product) {
         throw new \Magento\Framework\Model\Exception(__('Product is not loaded'), $this->ERR_NO_PRODUCT_LOADED);
     }
     $buyRequest = $params->getBuyRequest();
     if ($buyRequest) {
         $productHelper->prepareProductOptions($product, $buyRequest);
     }
     if ($params->hasConfigureMode()) {
         $product->setConfigureMode($params->getConfigureMode());
     }
     $this->_eventManager->dispatch('catalog_controller_product_view', array('product' => $product));
     $this->_catalogSession->setLastViewedProductId($product->getId());
     $this->initProductLayout($product, $controller, $params);
     if ($controller instanceof \Magento\Catalog\Controller\Product\View\ViewInterface) {
         $this->_view->getLayout()->initMessages($this->messageGroups);
     } else {
         throw new \Magento\Framework\Model\Exception(__('Bad controller interface for showing product'), $this->ERR_BAD_CONTROLLER_INTERFACE);
     }
     $this->_view->renderLayout();
     return $this;
 }
コード例 #24
0
ファイル: ViewTest.php プロジェクト: Atlis/docker-magento2
 public function setUp()
 {
     $this->request = $this->getMock('Magento\\Framework\\App\\RequestInterface');
     $this->response = $this->getMock('Magento\\Framework\\App\\ResponseInterface');
     $this->categoryHelper = $this->getMock('Magento\\Catalog\\Helper\\Category', [], [], '', false);
     $this->objectManager = $this->getMock('Magento\\Framework\\ObjectManager', [], [], '', false);
     $this->eventManager = $this->getMock('Magento\\Framework\\Event\\ManagerInterface');
     $this->update = $this->getMock('Magento\\Framework\\View\\Layout\\ProcessorInterface');
     $this->layout = $this->getMock('Magento\\Framework\\View\\Layout', [], [], '', false);
     $this->layout->expects($this->any())->method('getUpdate')->will($this->returnValue($this->update));
     $this->view = $this->getMock('Magento\\Framework\\App\\ViewInterface');
     $this->view->expects($this->any())->method('getLayout')->will($this->returnValue($this->layout));
     $this->context = $this->getMock('Magento\\Backend\\App\\Action\\Context', [], [], '', false);
     $this->context->expects($this->any())->method('getRequest')->will($this->returnValue($this->request));
     $this->context->expects($this->any())->method('getResponse')->will($this->returnValue($this->response));
     $this->context->expects($this->any())->method('getObjectManager')->will($this->returnValue($this->objectManager));
     $this->context->expects($this->any())->method('getEventManager')->will($this->returnValue($this->eventManager));
     $this->context->expects($this->any())->method('getView')->will($this->returnValue($this->view));
     $this->category = $this->getMock('Magento\\Catalog\\Model\\Category', [], [], '', false);
     $this->categoryFactory = $this->getMock('Magento\\Catalog\\Model\\CategoryFactory', ['create'], [], '', false);
     $this->store = $this->getMock('Magento\\Store\\Model\\Store', [], [], '', false);
     $this->storeManager = $this->getMock('Magento\\Store\\Model\\StoreManagerInterface');
     $this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($this->store));
     $this->catalogDesign = $this->getMock('Magento\\Catalog\\Model\\Design', [], [], '', false);
     $this->layoutHelper = $this->getMock('Magento\\Theme\\Helper\\Layout', [], [], '', false);
     $this->action = (new ObjectManager($this))->getObject('Magento\\Catalog\\Controller\\Category\\View', ['context' => $this->context, 'catalogDesign' => $this->catalogDesign, 'categoryFactory' => $this->categoryFactory, 'storeManager' => $this->storeManager]);
 }
コード例 #25
0
ファイル: CurrentCustomer.php プロジェクト: aiesh/magento2
 /**
  * Returns current customer according to session and context
  *
  * @return \Magento\Customer\Service\V1\Data\Customer
  */
 public function getCustomer()
 {
     if ($this->moduleManager->isEnabled('Magento_PageCache') && !$this->request->isAjax() && $this->view->isLayoutLoaded() && $this->layout->isCacheable()) {
         return $this->getDepersonalizedCustomer();
     } else {
         return $this->getCustomerFromService();
     }
 }
コード例 #26
0
ファイル: Page.php プロジェクト: pavelnovitsky/magento2
 /**
  * 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;
 }
コード例 #27
0
 /**
  * Set data for response of frontend saveOrder action
  *
  * @param EventObserver $observer
  * @return void
  */
 public function execute(EventObserver $observer)
 {
     /* @var $order \Magento\Sales\Model\Order */
     $order = $this->_coreRegistry->registry('hss_order');
     if ($order && $order->getId()) {
         $payment = $order->getPayment();
         if ($payment && in_array($payment->getMethod(), $this->_paypalHss->getHssMethods())) {
             $result = $observer->getData('result')->getData();
             if (empty($result['error'])) {
                 $this->_view->loadLayout('checkout_onepage_review', true, true, false);
                 $html = $this->_view->getLayout()->getBlock('paypal.iframe')->toHtml();
                 $result['update_section'] = ['name' => 'paypaliframe', 'html' => $html];
                 $result['redirect'] = false;
                 $result['success'] = false;
                 $observer->getData('result')->setData($result);
             }
         }
     }
 }
コード例 #28
0
 protected function setUp()
 {
     $this->shipmentLoaderMock = $this->getMock('Magento\\Shipping\\Controller\\Adminhtml\\Order\\ShipmentLoader', ['setOrderId', 'setShipmentId', 'setShipment', 'setTracking', 'load', '__wakeup'], [], '', false);
     $this->shipmentCommentSenderMock = $this->getMock('Magento\\Sales\\Model\\Order\\Email\\Sender\\ShipmentCommentSender', ['send', '__wakeup'], [], '', false);
     $this->requestMock = $this->getMock('Magento\\Framework\\App\\Request\\Http', ['getParam', 'getPost', 'setParam', '__wakeup'], [], '', false);
     $this->responseMock = $this->getMock('Magento\\Framework\\App\\Response\\Http', ['setBody', 'representJson', '__wakeup'], [], '', false);
     $this->resultLayoutFactoryMock = $this->getMock('Magento\\Framework\\View\\Result\\LayoutFactory', ['create'], [], '', false);
     $this->resultPageMock = $this->getMockBuilder('Magento\\Framework\\View\\Result\\Page')->disableOriginalConstructor()->getMock();
     $this->shipmentMock = $this->getMock('Magento\\Sales\\Model\\Order\\Shipment', ['save', 'addComment', '__wakeup'], [], '', false);
     $this->viewInterfaceMock = $this->getMock('Magento\\Framework\\App\\ViewInterface', [], [], '', false);
     $this->objectManagerMock = $this->getMock('Magento\\Framework\\ObjectManagerInterface');
     $contextMock = $this->getMock('Magento\\Backend\\App\\Action\\Context', ['getRequest', 'getResponse', 'getTitle', 'getView', 'getObjectManager', '__wakeup'], [], '', false);
     $this->viewInterfaceMock->expects($this->any())->method('getPage')->will($this->returnValue($this->resultPageMock));
     $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('getView')->will($this->returnValue($this->viewInterfaceMock));
     $contextMock->expects($this->any())->method('getObjectManager')->will($this->returnValue($this->objectManagerMock));
     $this->controller = new \Magento\Shipping\Controller\Adminhtml\Order\Shipment\AddComment($contextMock, $this->shipmentLoaderMock, $this->shipmentCommentSenderMock, $this->resultLayoutFactoryMock);
 }
コード例 #29
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));
 }
コード例 #30
0
 /**
  * {@inheritDoc}
  */
 protected function setUp()
 {
     $this->requestMock = $this->getMockForAbstractClassBuilder('Magento\\Framework\\App\\RequestInterface', ['isDispatched', 'initForward', 'setDispatched', 'isForwarded']);
     $this->breadcrumbsBlockMock = $this->getMockForAbstractClassBuilder('Magento\\Framework\\View\\Element\\BlockInterface', ['addLink']);
     $this->menuBlockMock = $this->getMockForAbstractClassBuilder('Magento\\Framework\\View\\Element\\BlockInterface', ['setActive', 'getMenuModel']);
     $this->viewMock = $this->getMockForAbstractClassBuilder('Magento\\Framework\\App\\ViewInterface');
     $this->layoutMock = $this->getMockBuilder('Magento\\Framework\\View\\LayoutInterface')->disableOriginalConstructor()->getMock();
     $this->switcherBlockMock = $this->getMockBuilder('Magento\\Framework\\View\\Element\\BlockInterface')->disableOriginalConstructor()->getMock();
     $this->contextMock = $this->getMockBuilder('Magento\\Backend\\App\\Action\\Context')->disableOriginalConstructor()->getMock();
     $this->fileFactoryMock = $this->getMockBuilder('Magento\\Framework\\App\\Response\\Http\\FileFactory')->disableOriginalConstructor()->getMock();
     $this->menuModelMock = $this->getMockBuilder('Magento\\Backend\\Model\\Menu')->disableOriginalConstructor()->getMock();
     $this->abstractBlockMock = $this->getMockBuilder('Magento\\Framework\\View\\Element\\AbstractBlock')->setMethods(['getCsvFile', 'getExcelFile', 'setSaveParametersInSession', 'getCsv', 'getExcel'])->disableOriginalConstructor()->getMock();
     $this->menuModelMock->expects($this->any())->method('getParentItems')->willReturn([]);
     $this->menuBlockMock->expects($this->any())->method('getMenuModel')->willReturn($this->menuModelMock);
     $this->viewMock->expects($this->any())->method('getLayout')->willReturn($this->layoutMock);
     $this->contextMock->expects($this->any())->method('getRequest')->willReturn($this->requestMock);
     $this->contextMock->expects($this->any())->method('getView')->willReturn($this->viewMock);
     $this->layoutMock->expects($this->any())->method('getBlock')->will($this->returnValueMap([['breadcrumbs', $this->breadcrumbsBlockMock], ['menu', $this->menuBlockMock], ['store_switcher', $this->switcherBlockMock]]));
     $this->layoutMock->expects($this->any())->method('getChildBlock')->willReturn($this->abstractBlockMock);
 }