/** * Build response for ajax request * * @param \Magento\Catalog\Model\Category $category * @param \Magento\Backend\Model\View\Result\Page $resultPage * * @return \Magento\Framework\Controller\Result\Json * * @deprecated */ protected function ajaxRequestResponse($category, $resultPage) { // prepare breadcrumbs of selected category, if any $breadcrumbsPath = $category->getPath(); if (empty($breadcrumbsPath)) { // but if no category, and it is deleted - prepare breadcrumbs from path, saved in session $breadcrumbsPath = $this->_objectManager->get('Magento\\Backend\\Model\\Auth\\Session')->getDeletedPath(true); if (!empty($breadcrumbsPath)) { $breadcrumbsPath = explode('/', $breadcrumbsPath); // no need to get parent breadcrumbs if deleting category level 1 if (count($breadcrumbsPath) <= 1) { $breadcrumbsPath = ''; } else { array_pop($breadcrumbsPath); $breadcrumbsPath = implode('/', $breadcrumbsPath); } } } $eventResponse = new \Magento\Framework\DataObject(['content' => $resultPage->getLayout()->getUiComponent('category_form')->getFormHtml() . $resultPage->getLayout()->getBlock('category.tree')->getBreadcrumbsJavascript($breadcrumbsPath, 'editingCategoryBreadcrumbs'), 'messages' => $resultPage->getLayout()->getMessagesBlock()->getGroupedHtml(), 'toolbar' => $resultPage->getLayout()->getBlock('page.actions.toolbar')->toHtml()]); $this->_eventManager->dispatch('category_prepare_ajax_response', ['response' => $eventResponse, 'controller' => $this]); /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = $this->_objectManager->get('Magento\\Framework\\Controller\\Result\\Json'); $resultJson->setHeader('Content-type', 'application/json', true); $resultJson->setData($eventResponse->getData()); return $resultJson; }
protected function setUp() { $this->productBuilder = $this->getMock('Magento\\Catalog\\Controller\\Adminhtml\\Product\\Builder', ['build'], [], '', false); $this->product = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->setMethods(['addData', 'getSku', 'getTypeId', 'getStoreId', '__sleep', '__wakeup', 'getAttributes', 'setAttributeSetId'])->getMock(); $this->product->expects($this->any())->method('getTypeId')->will($this->returnValue('simple')); $this->product->expects($this->any())->method('getStoreId')->will($this->returnValue('1')); $this->product->expects($this->any())->method('getAttributes')->will($this->returnValue([])); $this->productBuilder->expects($this->any())->method('build')->will($this->returnValue($this->product)); $this->resultPage = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Page')->disableOriginalConstructor()->getMock(); $resultPageFactory = $this->getMockBuilder('Magento\\Framework\\View\\Result\\PageFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock(); $resultPageFactory->expects($this->any())->method('create')->willReturn($this->resultPage); $this->resultForward = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Forward')->disableOriginalConstructor()->getMock(); $resultForwardFactory = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\ForwardFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock(); $resultForwardFactory->expects($this->any())->method('create')->willReturn($this->resultForward); $this->resultPage->expects($this->any())->method('getLayout')->willReturn($this->layout); $this->resultRedirectFactory = $this->getMock('Magento\\Backend\\Model\\View\\Result\\RedirectFactory', ['create'], [], '', false); $this->resultRedirect = $this->getMock('Magento\\Backend\\Model\\View\\Result\\Redirect', [], [], '', false); $this->resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirect); $this->initializationHelper = $this->getMock('Magento\\Catalog\\Controller\\Adminhtml\\Product\\Initialization\\Helper', [], [], '', false); $this->productFactory = $this->getMockBuilder('Magento\\Catalog\\Model\\ProductFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock(); $this->productFactory->expects($this->any())->method('create')->willReturn($this->product); $this->resultJson = $this->getMock('Magento\\Framework\\Controller\\Result\\Json', [], [], '', false); $this->resultJsonFactory = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\JsonFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock(); $this->resultJsonFactory->expects($this->any())->method('create')->willReturn($this->resultJson); $additionalParams = ['resultRedirectFactory' => $this->resultRedirectFactory]; $this->action = (new ObjectManagerHelper($this))->getObject('Magento\\Catalog\\Controller\\Adminhtml\\Product\\Validate', ['context' => $this->initContext($additionalParams), 'productBuilder' => $this->productBuilder, 'resultPageFactory' => $resultPageFactory, 'resultForwardFactory' => $resultForwardFactory, 'initializationHelper' => $this->initializationHelper, 'resultJsonFactory' => $this->resultJsonFactory, 'productFactory' => $this->productFactory]); }
/** * {@inheritdoc} * @param \Magento\Backend\Model\View\Result\Page $resultPage * @return \Magento\Backend\Model\View\Result\Page\Interceptor */ protected function initPage($resultPage) { $resultPage->setActiveMenu('Mirasvit_Blog::blog'); $resultPage->getConfig()->getTitle()->prepend(__('Mirasvit Blog MX')); $resultPage->getConfig()->getTitle()->prepend(__('Categories')); return $resultPage; }
public function execute() { $this->resultPage = $this->resultPageFactory->create(); $this->resultPage->setActiveMenu('YourCompanyName_GridController::modelname'); $this->resultPage->getConfig()->getTitle()->set(__('GridController')); return $this->resultPage; }
public function testAddBreadcrumbNoBlock() { $label = 'label'; $title = 'title'; $this->layoutMock->expects($this->once())->method('getBlock')->with('breadcrumbs')->willReturn(false); $this->breadcrumbsBlockMock->expects($this->never())->method('addLink'); $this->assertSame($this->resultPage, $this->resultPage->addBreadcrumb($label, $title)); }
public function testExecute() { $pageTitle = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Title')->disableOriginalConstructor()->getMock(); $pageTitle->expects($this->once())->method('prepend')->with(__('Design Configuration'))->willReturnSelf(); $pageConfig = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Config')->disableOriginalConstructor()->getMock(); $pageConfig->expects($this->once())->method('getTitle')->willReturn($pageTitle); $this->resultPage->expects($this->once())->method('setActiveMenu')->with('Magento_Theme::design_config')->willReturnSelf(); $this->resultPage->expects($this->once())->method('getConfig')->willReturn($pageConfig); $this->assertSame($this->resultPage, $this->controller->execute()); }
/** * Run test execute method * * @param int|bool $categoryId * @param int $storeId * @return void * * @dataProvider dataProviderExecute * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function testExecute($categoryId, $storeId) { $rootCategoryId = 2; $this->requestMock->expects($this->atLeastOnce())->method('getParam')->will($this->returnValueMap([['id', false, $categoryId], ['store', null, $storeId]])); $this->requestMock->expects($this->atLeastOnce())->method('getQuery')->with('isAjax')->will($this->returnValue(false)); $this->mockInitCategoryCall(); $this->sessionMock->expects($this->once())->method('__call')->will($this->returnValue([])); if (!$categoryId) { if ($storeId) { $this->storeManagerInterfaceMock->expects($this->once())->method('getStore')->with($storeId)->will($this->returnSelf()); } else { $this->storeManagerInterfaceMock->expects($this->once())->method('getDefaultStoreView')->will($this->returnSelf()); } $this->storeManagerInterfaceMock->expects($this->once())->method('getRootCategoryId')->will($this->returnValue($rootCategoryId)); $categoryId = $rootCategoryId; } $this->requestMock->expects($this->atLeastOnce())->method('setParam')->with('id', $categoryId)->will($this->returnValue(true)); $this->categoryMock->expects($this->atLeastOnce())->method('getId')->will($this->returnValue($categoryId)); /** * @var \Magento\Framework\View\Element\Template * |\PHPUnit_Framework_MockObject_MockObject $blockMock */ $blockMock = $this->getMock('Magento\\Framework\\View\\Element\\Template', ['setStoreId'], [], '', false); $blockMock->expects($this->once())->method('setStoreId')->with($storeId); $this->resultPageMock->expects($this->once())->method('getLayout')->will($this->returnSelf()); $this->resultPageMock->expects($this->once())->method('getBlock')->willReturn($blockMock); $this->edit->execute(); }
protected function setUp() { $this->productBuilder = $this->getMock('Magento\\Catalog\\Controller\\Adminhtml\\Product\\Builder', ['build'], [], '', false); $this->product = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->setMethods(['addData', 'getTypeId', 'getStoreId', '__sleep', '__wakeup'])->getMock(); $this->product->expects($this->any())->method('getTypeId')->will($this->returnValue('simple')); $this->product->expects($this->any())->method('getStoreId')->will($this->returnValue('1')); $this->productBuilder->expects($this->any())->method('build')->will($this->returnValue($this->product)); $this->resultPage = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Page')->disableOriginalConstructor()->getMock(); $resultPageFactory = $this->getMockBuilder('Magento\\Framework\\View\\Result\\PageFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock(); $resultPageFactory->expects($this->atLeastOnce())->method('create')->willReturn($this->resultPage); $this->resultForward = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Forward')->disableOriginalConstructor()->getMock(); $resultForwardFactory = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\ForwardFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock(); $resultForwardFactory->expects($this->any())->method('create')->willReturn($this->resultForward); $this->action = new \Magento\Catalog\Controller\Adminhtml\Product\NewAction($this->initContext(), $this->productBuilder, $this->getMockBuilder('Magento\\Catalog\\Controller\\Adminhtml\\Product\\Initialization\\StockDataFilter')->disableOriginalConstructor()->getMock(), $resultPageFactory, $resultForwardFactory); $this->resultPage->expects($this->atLeastOnce())->method('getLayout')->willReturn($this->layout); }
public function testExecute() { $orderId = 1; $invoiceData = []; $commentText = 'comment test'; $this->requestMock->expects($this->at(0))->method('getParam')->with('order_id')->will($this->returnValue($orderId)); $this->requestMock->expects($this->at(1))->method('getParam')->with('invoice', [])->will($this->returnValue($invoiceData)); $invoiceMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Invoice')->disableOriginalConstructor()->setMethods([])->getMock(); $invoiceMock->expects($this->once())->method('getTotalQty')->willReturn(2); $orderMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->setMethods(['load', 'getId', 'canInvoice'])->getMock(); $orderMock->expects($this->once())->method('load')->with($orderId)->willReturnSelf(); $orderMock->expects($this->once())->method('getId')->willReturn($orderId); $orderMock->expects($this->once())->method('canInvoice')->willReturn(true); $orderService = $this->getMockBuilder('Magento\\Sales\\Model\\Service\\Order')->disableOriginalConstructor()->setMethods([])->getMock(); $orderService->expects($this->once())->method('prepareInvoice')->willReturn($invoiceMock); $menuBlockMock = $this->getMockBuilder('Magento\\Backend\\Block\\Menu')->disableOriginalConstructor()->setMethods(['getParentItems', 'getMenuModel'])->getMock(); $menuBlockMock->expects($this->any())->method('getMenuModel')->will($this->returnSelf()); $menuBlockMock->expects($this->any())->method('getParentItems')->with('Magento_Sales::sales_order')->will($this->returnValue([])); $this->sessionMock->expects($this->once())->method('getCommentText')->with(true)->will($this->returnValue($commentText)); $this->objectManagerMock->expects($this->at(0))->method('create')->with('Magento\\Sales\\Model\\Order')->willReturn($orderMock); $this->objectManagerMock->expects($this->at(1))->method('create')->with('Magento\\Sales\\Model\\Service\\Order')->willReturn($orderService); $this->objectManagerMock->expects($this->at(2))->method('get')->with('Magento\\Backend\\Model\\Session')->will($this->returnValue($this->sessionMock)); $this->resultPageMock->expects($this->once())->method('setActiveMenu')->with('Magento_Sales::sales_order'); $this->resultPageFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->resultPageMock)); $this->assertSame($this->resultPageMock, $this->controller->execute()); }
/** * Test execute * * @return void */ public function testExecute() { $comment = 'Test comment'; $data = ['comment' => $comment]; $html = 'test output'; $creditmemoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') ->disableOriginalConstructor() ->getMock(); $commentMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo\Comment') ->disableOriginalConstructor() ->getMock(); $layoutMock = $this->getMockBuilder('Magento\Framework\View\Layout') ->disableOriginalConstructor() ->getMock(); $blockMock = $this->getMockBuilder('Magento\Sales\Block\Adminhtml\Order\Creditmemo\View\Comments') ->disableOriginalConstructor() ->getMock(); $this->requestMock->expects($this->once()) ->method('getPost') ->with('comment') ->willReturn($data); $this->requestMock->expects($this->any()) ->method('getParam') ->willReturnArgument(0); $creditmemoMock->expects($this->once()) ->method('addComment') ->willReturn($commentMock); $this->loaderMock->expects($this->once()) ->method('load') ->willReturn($creditmemoMock); $this->resultPageFactoryMock->expects($this->once()) ->method('create') ->willReturn($this->resultPageMock); $this->resultPageMock->expects($this->atLeastOnce()) ->method('getLayout') ->willReturn($layoutMock); $layoutMock->expects($this->once()) ->method('getBlock') ->with('creditmemo_comments') ->willReturn($blockMock); $blockMock->expects($this->once()) ->method('toHtml') ->willReturn($html); $this->resultRawFactoryMock->expects($this->once()) ->method('create') ->willReturn($this->resultRawMock); $this->resultRawMock->expects($this->once()) ->method('setContents') ->with($html) ->willReturnSelf(); $this->assertInstanceOf( 'Magento\Framework\Controller\Result\Raw', $this->controller->executeInternal() ); }
/** * {@inheritdoc} */ public function renderResult(\Magento\Framework\App\ResponseInterface $response) { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'renderResult'); if (!$pluginInfo) { return parent::renderResult($response); } else { return $this->___callPlugins('renderResult', func_get_args(), $pluginInfo); } }
/** * Test execute * * @return void */ public function testExecute() { $response = 'output'; $this->requestMock->expects($this->any())->method('getParam')->withAnyParameters()->willReturnArgument(0); $layoutMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout')->disableOriginalConstructor()->getMock(); $blockMock = $this->getMockBuilder('Magento\\Sales\\Block\\Order\\Items')->disableOriginalConstructor()->getMock(); $this->resultPageFactoryMock->expects($this->once())->method('create')->willReturn($this->resultPageMock); $this->resultPageMock->expects($this->atLeastOnce())->method('getLayout')->willReturn($layoutMock); $blockMock->expects($this->once())->method('toHtml')->willReturn($response); $layoutMock->expects($this->once())->method('getBlock')->with('order_items')->willReturn($blockMock); $this->resultRawFactoryMock->expects($this->once())->method('create')->willReturn($this->resultRawMock); $this->resultRawMock->expects($this->once())->method('setContents')->with($response)->willReturnSelf(); $this->assertInstanceOf('Magento\\Framework\\Controller\\Result\\Raw', $this->controller->execute()); }
/** * @dataProvider testExecuteDataProvider */ public function testExecute($invoice) { $layoutMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout')->disableOriginalConstructor()->getMock(); $blockMock = $this->getMockBuilder('Magento\\Sales\\Block\\Adminhtml\\Order\\Creditmemo\\View')->disableOriginalConstructor()->getMock(); $this->requestMock->expects($this->any())->method('getParam')->withAnyParameters()->willReturnArgument(0); $this->loaderMock->expects($this->once())->method('load')->willReturn($this->creditmemoMock); $this->creditmemoMock->expects($this->any())->method('getInvoice')->willReturn($invoice); $layoutMock->expects($this->once())->method('getBlock')->with('sales_creditmemo_view')->willReturn($blockMock); $this->resultPageFactoryMock->expects($this->once())->method('create')->willReturn($this->resultPageMock); $this->resultPageMock->expects($this->atLeastOnce())->method('getLayout')->willReturn($layoutMock); $this->resultPageMock->expects($this->once())->method('setActiveMenu')->with('Magento_Sales::sales_creditmemo')->willReturnSelf(); $this->resultPageMock->expects($this->atLeastOnce())->method('getConfig')->willReturn($this->pageConfigMock); $this->assertInstanceOf('Magento\\Backend\\Model\\View\\Result\\Page', $this->controller->execute()); }
public function testScopeDefault() { $scope = 'default'; $scopeId = 0; $scopeName = 'Global'; $this->request->expects($this->exactly(4))->method('getParam')->willReturnMap([['scope', null, $scope], ['scope_id', null, $scopeId]]); $this->scopeValidator->expects($this->once())->method('isValidScope')->with($scope, $scopeId)->willReturn(true); $pageTitle = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Title')->disableOriginalConstructor()->getMock(); $pageTitle->expects($this->once())->method('prepend')->with(__('%1', $scopeName))->willReturnSelf(); $pageConfig = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Config')->disableOriginalConstructor()->getMock(); $pageConfig->expects($this->once())->method('getTitle')->willReturn($pageTitle); $this->resultPage->expects($this->once())->method('setActiveMenu')->with('Magento_Theme::design_config')->willReturnSelf(); $this->resultPage->expects($this->once())->method('getConfig')->willReturn($pageConfig); $this->assertSame($this->resultPage, $this->controller->execute()); }
/** * Run test execute method */ public function testExecute() { $orderId = 1; $shipmentId = 1; $shipment = []; $tracking = []; $incrementId = '10000001'; $comeFrom = true; $this->loadShipment($orderId, $shipmentId, $shipment, $tracking, $comeFrom, $this->shipmentMock); $this->shipmentMock->expects($this->once())->method('getIncrementId')->willReturn($incrementId); $this->resultPageFactoryMock->expects($this->once()) ->method('create') ->willReturn($this->resultPageMock); $layoutMock = $this->getMock('Magento\Framework\View\Layout', ['getBlock', '__wakeup'], [], '', false); $this->resultPageMock->expects($this->once()) ->method('getLayout') ->willReturn($layoutMock); $layoutMock->expects($this->once()) ->method('getBlock') ->with('sales_shipment_view') ->willReturn($this->blockMock); $this->blockMock->expects($this->once()) ->method('updateBackButtonUrl') ->with($comeFrom) ->willReturnSelf(); $this->resultPageMock->expects($this->once()) ->method('setActiveMenu') ->with('Magento_Sales::sales_shipment') ->willReturnSelf(); $this->resultPageMock->expects($this->atLeastOnce()) ->method('getConfig') ->willReturn($this->pageConfigMock); $this->pageConfigMock->expects($this->atLeastOnce()) ->method('getTitle') ->willReturn($this->pageTitleMock); $this->pageTitleMock->expects($this->exactly(2)) ->method('prepend') ->withConsecutive( ['Shipments'], ["#" . $incrementId] ) ->willReturnSelf(); $this->assertEquals($this->resultPageMock, $this->controller->executeInternal()); }
protected function initAction() { $this->resultPageFactoryMock->expects($this->once()) ->method('create') ->willReturn($this->resultPageMock); $this->resultPageMock->expects($this->once()) ->method('setActiveMenu') ->with('Magento_Sales::sales_order') ->willReturnSelf(); $this->resultPageMock->expects($this->exactly(2)) ->method('addBreadcrumb') ->withConsecutive( ['Sales', 'Sales'], ['Orders', 'Orders'] ) ->willReturnSelf(); }
public function testExecute() { $invoiceId = 2; $this->requestMock->expects($this->at(0))->method('getParam')->with('invoice_id')->will($this->returnValue($invoiceId)); $this->requestMock->expects($this->at(1))->method('getParam')->with('come_from')->willReturn('anything'); $menuBlockMock = $this->getMockBuilder('Magento\\Backend\\Block\\Menu')->disableOriginalConstructor()->setMethods(['getParentItems', 'getMenuModel'])->getMock(); $menuBlockMock->expects($this->any())->method('getMenuModel')->will($this->returnSelf()); $menuBlockMock->expects($this->any())->method('getParentItems')->with('Magento_Sales::sales_order')->will($this->returnValue([])); $invoiceViewBlockMock = $this->getMockBuilder('Magento\\Sales\\Block\\Adminhtml\\Order\\Invoice\\View')->disableOriginalConstructor()->setMethods(['updateBackButtonUrl'])->getMock(); $layoutMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout')->disableOriginalConstructor()->setMethods([])->getMock(); $layoutMock->expects($this->at(0))->method('getBlock')->with('sales_invoice_view')->will($this->returnValue($invoiceViewBlockMock)); $this->resultPageMock->expects($this->any())->method('getLayout')->will($this->returnValue($layoutMock)); $invoiceMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Invoice')->disableOriginalConstructor()->setMethods([])->getMock(); $this->invoiceRepository->expects($this->once())->method('get')->willReturn($invoiceMock); $this->resultPageMock->expects($this->once())->method('setActiveMenu')->with('Magento_Sales::sales_order'); $this->resultPageFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->resultPageMock)); $this->assertSame($this->resultPageMock, $this->controller->execute()); }
public function testExecuteNoPopup() { $attributesData = ['frontend_label' => '']; $this->request->expects($this->any())->method('getParam')->willReturnMap([['attribute_id', null, null], ['attribute', null, $attributesData], ['popup', null, false]]); $this->objectManagerMock->expects($this->any())->method('create')->with('Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute')->willReturn($this->eavAttribute); $this->objectManagerMock->expects($this->any())->method('get')->with('Magento\\Backend\\Model\\Session')->willReturn($this->session); $this->eavAttribute->expects($this->once())->method('setEntityTypeId')->willReturnSelf(); $this->eavAttribute->expects($this->once())->method('addData')->with($attributesData)->willReturnSelf(); $this->registry->expects($this->any())->method('register')->with('entity_attribute', $this->eavAttribute); $this->resultPage->expects($this->any())->method('addBreadcrumb')->willReturnSelf(); $this->resultPage->expects($this->once())->method('setActiveMenu')->with('Magento_Catalog::catalog_attributes_attributes')->willReturnSelf(); $this->resultPage->expects($this->any())->method('getConfig')->willReturn($this->pageConfig); $this->resultPage->expects($this->once())->method('getLayout')->willReturn($this->layout); $this->resultPageFactory->expects($this->atLeastOnce())->method('create')->willReturn($this->resultPage); $this->pageConfig->expects($this->any())->method('getTitle')->willReturn($this->pageTitle); $this->pageTitle->expects($this->any())->method('prepend')->willReturnSelf(); $this->eavAttribute->expects($this->any())->method('getName')->willReturn(null); $this->layout->expects($this->once())->method('getBlock')->willReturn($this->blockTemplate); $this->blockTemplate->expects($this->any())->method('setIsPopup')->willReturnSelf(); $this->assertSame($this->resultPage, $this->editController->execute()); }
/** * test execute method */ public function testExecute() { $this->requestMock->expects($this->exactly(4))->method('getParam')->will($this->returnValueMap([['order_id', null, 'order_id'], ['creditmemo_id', null, 'creditmemo_id'], ['creditmemo', null, 'creditmemo'], ['invoice_id', null, 'invoice_id']])); $this->creditmemoLoaderMock->expects($this->once())->method('setOrderId')->with($this->equalTo('order_id')); $this->creditmemoLoaderMock->expects($this->once())->method('setCreditmemoId')->with($this->equalTo('creditmemo_id')); $this->creditmemoLoaderMock->expects($this->once())->method('setCreditmemo')->with($this->equalTo('creditmemo')); $this->creditmemoLoaderMock->expects($this->once())->method('setInvoiceId')->with($this->equalTo('invoice_id')); $this->creditmemoLoaderMock->expects($this->once())->method('load')->will($this->returnValue($this->creditmemoMock)); $this->creditmemoMock->expects($this->exactly(2))->method('getInvoice')->will($this->returnValue($this->invoiceMock)); $this->invoiceMock->expects($this->once())->method('getIncrementId')->will($this->returnValue('invoice-increment-id')); $this->titleMock->expects($this->exactly(2))->method('prepend')->will($this->returnValueMap([['Credit Memos', null], ['New Memo for #invoice-increment-id', null], ['item-title', null]])); $this->objectManagerMock->expects($this->once())->method('get')->with($this->equalTo('Magento\\Backend\\Model\\Session'))->will($this->returnValue($this->backendSessionMock)); $this->backendSessionMock->expects($this->once())->method('getCommentText')->with($this->equalTo(true))->will($this->returnValue('comment')); $this->creditmemoMock->expects($this->once())->method('setCommentText')->with($this->equalTo('comment')); $this->resultPageMock->expects($this->any())->method('getConfig')->will($this->returnValue($this->pageConfigMock)); $this->pageConfigMock->expects($this->any())->method('getTitle')->willReturn($this->titleMock); $this->resultPageFactoryMock->expects($this->once())->method('create')->willReturn($this->resultPageMock); $this->resultPageMock->expects($this->once())->method('setActiveMenu')->with('Magento_Sales::sales_order')->willReturnSelf(); $this->resultPageMock->expects($this->atLeastOnce())->method('getConfig')->willReturn($this->pageConfigMock); $this->assertInstanceOf('Magento\\Backend\\Model\\View\\Result\\Page', $this->controller->execute()); }
/** * Init page * * @param \Magento\Backend\Model\View\Result\Page $resultPage * @return \Magento\Backend\Model\View\Result\Page */ protected function initPage($resultPage) { $resultPage->setActiveMenu('Magento_Cms::cms_block')->addBreadcrumb(__('CMS'), __('CMS'))->addBreadcrumb(__('Static Blocks'), __('Static Blocks')); return $resultPage; }
/** * Init page * * @param \Magento\Backend\Model\View\Result\Page $resultPage * @return \Magento\Backend\Model\View\Result\Page */ protected function initPage($resultPage) { $resultPage->setActiveMenu('Mirasvit_Search::search'); $resultPage->getConfig()->getTitle()->prepend(__('Manage Synonyms')); return $resultPage; }
/** * Prepare customer default title * * @param \Magento\Backend\Model\View\Result\Page $resultPage * @return void */ protected function prepareDefaultCustomerTitle(\Magento\Backend\Model\View\Result\Page $resultPage) { $resultPage->getConfig()->getTitle()->prepend(__('Customers')); }
/** * {@inheritdoc} */ public function setStatusHeader($httpCode, $version = null, $phrase = null) { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'setStatusHeader'); if (!$pluginInfo) { return parent::setStatusHeader($httpCode, $version, $phrase); } else { return $this->___callPlugins('setStatusHeader', func_get_args(), $pluginInfo); } }
/** * Init page * * @param \Magento\Backend\Model\View\Result\Page $resultPage * @return \Magento\Backend\Model\View\Result\Page */ protected function initPage($resultPage) { $resultPage->setActiveMenu('Fastgento_Storelocator::location')->addBreadcrumb(__('Storelocator'), __('Storelocator'))->addBreadcrumb(__('Locations'), __('Locations')); return $resultPage; }
/** * Init page * * @param Page $resultPage * @return Page */ protected function initPage(Page $resultPage) { $resultPage->setActiveMenu('DavidVerholen_Teaser::teaser_item')->addBreadcrumb(__('Teaser'), __('Teaser'))->addBreadcrumb(__('Items'), __('Items')); return $resultPage; }