Пример #1
0
 /**
  * Blog Index, shows a list of recent blog posts.
  *
  * @return \Magento\Framework\View\Result\PageFactory
  */
 public function execute()
 {
     /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
     $resultPage = $this->resultPageFactory->create();
     $resultPage->getConfig()->getTitle()->prepend(__('Store locations'));
     return $resultPage;
 }
Пример #2
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]);
 }
Пример #3
0
 /**
  * Blog Index, shows a list of recent blog posts.
  *
  * @return \Magento\Framework\View\Result\PageFactory
  */
 public function execute()
 {
     //$post_id = $this->getRequest()->getParam('post_id', $this->getRequest()->getParam('id', false));
     $user_id = $this->getRequest()->getParam('user_id', false);
     $survey_id = $this->getRequest()->getParam('survey_id', false);
     $resultPage = $this->resultPageFactory->create();
     // We can add our own custom page handles for layout easily.
     //$resultPage->addHandle('surevey_view_index');
     if ($survey_id !== false) {
         $this->_survey->load($survey_id);
     } else {
         $this->_survey->load(1);
     }
     //$shippingInfoModel = $this->_shippingInfoFactory->create()->loadByHash($this->getRequest()->getParam('hash'));
     $this->_coreRegistry->register('current_survey', $this->_survey);
     $this->_coreRegistry->register('current_survey_user', $user_id);
     //echo $this->_survey->getName();
     // This will generate a layout handle like: blog_post_view_id_1
     // giving us a unique handle to target specific blog posts if we wish to.
     //$this->_survey->getId()
     $resultPage->addPageLayoutHandles(['id' => $survey_id]);
     // /** @var \Ashsmith\Blog\Helper\Post $post_helper */
     // //$post_helper = $this->_objectManager->get('Ashsmith\Blog\Helper\Post');
     $result_page = $resultPage;
     //$post_helper->prepareResultPost($this, $post_id);
     if (!$result_page) {
         $resultForward = $this->resultForwardFactory->create();
         return $resultForward->forward('noroute');
     }
     return $result_page;
 }
Пример #4
0
    protected function setUp()
    {
        $this->context = $this->getMock('Magento\Framework\App\Action\Context', [], [], '', false);
        $this->request = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false);
        $this->response = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false);
        $this->wishlistProvider = $this->getMock('Magento\Wishlist\Controller\WishlistProvider', [], [], '', false);
        $this->redirect = $this->getMock('\Magento\Store\App\Response\Redirect', [], [], '', false);
        $this->resultFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\ResultFactory')
            ->disableOriginalConstructor()
            ->getMock();
        $this->resultPageMock = $this->getMockBuilder('Magento\Framework\View\Result\Page')
            ->disableOriginalConstructor()
            ->getMock();
        $this->layoutMock = $this->getMockBuilder('Magento\Framework\View\Layout')
            ->disableOriginalConstructor()
            ->getMock();

        $this->resultFactoryMock->expects($this->any())
            ->method('create')
            ->with(ResultFactory::TYPE_PAGE, [])
            ->willReturn($this->resultPageMock);
        $this->resultPageMock->expects($this->any())
            ->method('getLayout')
            ->willReturn($this->layoutMock);
    }
Пример #5
0
 public function testExecuteResultPage()
 {
     $this->resultPageMock->expects($this->at(0))->method('setStatusHeader')->with(404, '1.1', 'Not Found')->will($this->returnSelf());
     $this->resultPageMock->expects($this->at(1))->method('setHeader')->with('Status', '404 File not found')->will($this->returnSelf());
     $this->_cmsHelperMock->expects($this->once())->method('prepareResultPage')->will($this->returnValue($this->resultPageMock));
     $this->assertSame($this->resultPageMock, $this->_controller->execute());
 }
Пример #6
0
 public function testExecuteInternal()
 {
     $this->viewMock->expects($this->once())->method('getPage')->willReturn($this->pageMock);
     $this->pageMock->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')->willReturnSelf();
     $this->assertNull($this->object->executeInternal());
 }
Пример #7
0
 /**
  * Blog Index, shows a list of recent blog posts.
  *
  * @return \Magento\Framework\View\Result\PageFactory
  */
 public function execute()
 {
     $this->_logger->addDebug('DDDDDDDDDDDDDDDDDDDDDDD');
     $this->_logger->addInfo('DDDDDDDDDDDDDDDDDDDDDDD');
     $resultPage = $this->resultPageFactory->create();
     $resultPage->getConfig()->getTitle()->prepend(__('TurboInternational_SetupEnvironment'));
     return $resultPage;
 }
 public function afterAddPageLayoutHandles(Page $subject)
 {
     $group = $this->groupFactory->create()->load($this->customerSession->getCustomerGroupId());
     if ($group->getId() >= 0) {
         $handle = sprintf("customer_group_%s", strtolower(preg_replace("/[^A-Za-z0-9]/", '_', $group->getName())));
         $subject->addHandle($handle);
     }
     return $subject;
 }
Пример #9
0
 /**
  * @return void
  */
 public function testCreateActionRegistrationDisabled()
 {
     $this->customerSession->expects($this->once())->method('isLoggedIn')->will($this->returnValue(false));
     $this->registrationMock->expects($this->once())->method('isAllowed')->will($this->returnValue(false));
     $this->redirectFactoryMock->expects($this->once())->method('create')->willReturn($this->redirectResultMock);
     $this->redirectResultMock->expects($this->once())->method('setPath')->with('*/*')->willReturnSelf();
     $this->resultPageMock->expects($this->never())->method('getLayout');
     $this->object->execute();
 }
Пример #10
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();
 }
Пример #11
0
 /**
  * Show payment page
  * @return \Magento\Framework\View\Result\PageFactory
  */
 public function execute()
 {
     $result = $this->payment->createPaymentRequest();
     $resultPage = $this->resultPageFactory->create();
     $code = $result->getCode();
     $resultPage->getLayout()->getBlock('pagseguro.payment.checkout')->setCode($code);
     $resultPage->getLayout()->getBlock('pagseguro.payment.checkout')->setPaymentJs($this->getPagSeguroPaymentJs());
     $resultPage->getLayout()->getBlock('pagseguro.payment.checkout')->setPaymentUrl($this->payment->checkoutUrl($code, 'paymentService'));
     return $resultPage;
 }
Пример #12
0
 /**
  * @return void
  */
 public function testCreateActionRegistrationEnabled()
 {
     $this->customerSession->expects($this->once())->method('isLoggedIn')->will($this->returnValue(false));
     $this->registrationMock->expects($this->once())->method('isAllowed')->will($this->returnValue(true));
     $this->redirectMock->expects($this->never())->method('redirect');
     $layoutMock = $this->getMock('Magento\\Framework\\View\\Layout', [], [], '', false);
     $layoutMock->expects($this->once())->method('initMessages')->willReturnSelf();
     $this->pageFactoryMock->expects($this->once())->method('create')->willReturn($this->resultPageMock);
     $this->resultPageMock->expects($this->once())->method('getLayout')->will($this->returnValue($layoutMock));
     $this->object->execute();
 }
Пример #13
0
 /**
  * @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());
 }
Пример #14
0
 public function testExecutePageReload()
 {
     $this->request->expects($this->any())->method('getParam')->with('filters')->willReturn(null);
     $this->request->expects($this->any())->method('getParams')->willReturn([]);
     $this->attributeHelper->expects($this->any())->method('getProductIds')->willReturn([1, 2, 3]);
     $this->attributeHelper->expects($this->any())->method('setProductIds')->with([1, 2, 3]);
     $title = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Title')->setMethods(['prepend'])->disableOriginalConstructor()->getMock();
     $config = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Config')->setMethods(['getTitle'])->disableOriginalConstructor()->getMock();
     $config->expects($this->any())->method('getTitle')->willReturn($title);
     $this->resultPage->expects($this->any())->method('getConfig')->willReturn($config);
     $this->assertSame($this->resultPage, $this->object->execute());
 }
Пример #15
0
 /**
  * Show payment page
  * @return \Magento\Framework\View\Result\PageFactory
  */
 public function execute()
 {
     /** @var \Magento\Framework\View\Result\PageFactory $resultPage */
     $resultPage = $this->_resultPageFactory->create();
     if ($this->link()) {
         $resultPage->getLayout()->getBlock('pagseguro.payment.success')->setPaymentLink($this->link());
     }
     $resultPage->getLayout()->getBlock('pagseguro.payment.success')->setPaymentType($this->type());
     $resultPage->getLayout()->getBlock('pagseguro.payment.success')->setOrderId($this->order()->getIncrementId());
     $resultPage->getLayout()->getBlock('pagseguro.payment.success')->setCanViewOrder(true);
     $this->clearSession();
     return $resultPage;
 }
Пример #16
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);
 }
Пример #17
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());
 }
Пример #18
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();
 }
Пример #19
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());
 }
Пример #20
0
 /**
  * Test execute
  *
  * @return void
  */
 public function testExecute()
 {
     $data = ['comment' => 'test comment'];
     $invoiceId = 2;
     $response = 'some result';
     $this->requestMock->expects($this->at(0))->method('getParam')->with('id')->willReturn($invoiceId);
     $this->requestMock->expects($this->at(1))->method('setParam');
     $this->requestMock->expects($this->at(2))->method('getPost')->with('comment')->willReturn($data);
     $this->requestMock->expects($this->at(3))->method('getParam')->with('invoice_id')->willReturn($invoiceId);
     $invoiceMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Invoice')->disableOriginalConstructor()->setMethods([])->getMock();
     $invoiceMock->expects($this->once())->method('addComment')->with($data['comment'], false, false);
     $invoiceMock->expects($this->once())->method('save');
     $invoiceMock->expects($this->once())->method('load')->willReturnSelf();
     $this->objectManagerMock->expects($this->once())->method('create')->with('Magento\\Sales\\Model\\Order\\Invoice')->willReturn($invoiceMock);
     $commentsBlockMock = $this->getMockBuilder('Magento\\Sales\\Block\\Adminhtml\\Order\\Invoice\\View\\Comments')->disableOriginalConstructor()->setMethods([])->getMock();
     $commentsBlockMock->expects($this->once())->method('toHtml')->will($this->returnValue($response));
     $layoutMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout')->disableOriginalConstructor()->setMethods([])->getMock();
     $layoutMock->expects($this->once())->method('getBlock')->with('invoice_comments')->will($this->returnValue($commentsBlockMock));
     $this->resultPageFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->resultPageMock));
     $this->resultPageMock->expects($this->any())->method('getLayout')->will($this->returnValue($layoutMock));
     $this->commentSenderMock->expects($this->once())->method('send')->with($invoiceMock, false, $data['comment']);
     $resultRaw = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Raw')->disableOriginalConstructor()->setMethods([])->getMock();
     $resultRaw->expects($this->once())->method('setContents')->with($response);
     $this->resultRawFactoryMock->expects($this->once())->method('create')->will($this->returnValue($resultRaw));
     $this->assertSame($resultRaw, $this->controller->execute());
 }
Пример #21
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());
 }
Пример #22
0
 /**
  * @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;
 }
Пример #23
0
 public function testRenderLayoutWhenOutputEmpty()
 {
     $this->_actionFlagMock->expects($this->once())->method('get')->with('', 'no-renderLayout')->will($this->returnValue(false));
     $this->_layoutMock->expects($this->never())->method('addOutputElement');
     $this->resultPage->expects($this->once())->method('renderResult')->with($this->response);
     $this->_view->renderLayout();
 }
Пример #24
0
 protected function initResultPage()
 {
     if (!is_null($this->resultPage)) {
         return;
     }
     $this->resultPage = $this->resultPageFactory->create();
     $this->resultPage->addHandle($this->getLayoutType());
     $this->resultPage->getConfig()->getTitle()->set($this->__('M2ePro'));
 }
Пример #25
0
 /**
  * {@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);
     }
 }
Пример #26
0
 public function testAddPageLayoutHandlesWithDefaultHandle()
 {
     $defaultHandle = 'default_handle';
     $parameters = ['key_one' => 'val_one', 'key_two' => 'val_two'];
     $expected = ['default_handle', 'default_handle_key_one_val_one', 'default_handle_key_two_val_two'];
     $this->request->expects($this->never())->method('getFullActionName');
     $this->layoutMerge->expects($this->any())->method('addHandle')->with($expected)->willReturnSelf();
     $this->page->addPageLayoutHandles($parameters, $defaultHandle);
 }
Пример #27
0
 /**
  * Show payment page
  * @return \Magento\Framework\View\Result\PageFactory
  */
 public function execute()
 {
     $resultPage = $this->_resultPageFactory->create();
     $resultPage->getLayout()->getBlock('pagseguro.direct.payment')->setData('order', $this->_checkoutSession->getLastRealOrder()->getId());
     try {
         $this->_library->setEnvironment();
         $resultPage->getLayout()->getBlock('pagseguro.direct.payment')->setData('sessionCode', $this->_library->getSession());
         $resultPage->getLayout()->getBlock('pagseguro.direct.payment')->setData('paymentUrl', $this->_library->getDirectPaymentUrl());
     } catch (\Exception $exc) {
         /** @var \Magento\Sales\Model\Order $order */
         $order = $this->_objectManager->create('\\Magento\\Sales\\Model\\Order')->load($this->_checkoutSession->getLastRealOrder()->getId());
         /** change payment status in magento */
         $order->addStatusToHistory('pagseguro_cancelada', null, true);
         /** save order */
         $order->save();
         return $this->_redirect('pagseguro/payment/failure');
     }
     return $resultPage;
 }
Пример #28
0
 /**
  * @magentoDataFixture Magento/Catalog/_files/multiple_products.php
  * @magentoAppIsolation enabled
  * @magentoAppArea frontend
  */
 public function testPrepareAndRender()
 {
     // need for \Magento\Review\Block\Form::getProductInfo()
     $this->objectManager->get('Magento\\Framework\\App\\RequestInterface')->setParam('id', 10);
     $this->_helper->prepareAndRender($this->page, 10, $this->_controller);
     /** @var \Magento\TestFramework\Response $response */
     $response = $this->objectManager->get('Magento\\TestFramework\\Response');
     $this->page->renderResult($response);
     $this->assertNotEmpty($response->getBody());
     $this->assertEquals(10, $this->objectManager->get('Magento\\Catalog\\Model\\Session')->getLastViewedProductId());
 }
Пример #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
 protected function setUp()
 {
     $this->requestMock = $this->getMock('Magento\\Framework\\App\\Request\\Http', ['getParam'], [], '', false);
     $this->objectManagerMock = $this->getMock('Magento\\Framework\\ObjectManagerInterface');
     $this->shipmentTrackMock = $this->getMock('Magento\\Sales\\Model\\Order\\Shipment\\Track', ['load', 'getId', 'delete', '__wakeup'], [], '', false);
     $this->shipmentMock = $this->getMock('Magento\\Sales\\Model\\Order\\Shipment', ['getIncrementId', '__wakeup'], [], '', false);
     $this->viewMock = $this->getMock('Magento\\Backend\\Model\\View', ['loadLayout', 'getLayout', 'getPage'], [], '', false);
     $this->responseMock = $this->getMock('Magento\\Framework\\App\\Response\\Http', [], [], '', false);
     $this->shipmentLoaderMock = $this->getMock('Magento\\Shipping\\Controller\\Adminhtml\\Order\\ShipmentLoader', ['setOrderId', 'setShipmentId', 'setShipment', 'setTracking', 'load'], [], '', false);
     $this->resultPageMock = $this->getMockBuilder('Magento\\Framework\\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->getMock('Magento\\Backend\\App\\Action\\Context', ['getRequest', 'getObjectManager', 'getTitle', 'getView', 'getResponse'], [], '', false);
     $this->objectManagerMock->expects($this->once())->method('create')->with('Magento\\Sales\\Model\\Order\\Shipment\\Track')->will($this->returnValue($this->shipmentTrackMock));
     $contextMock->expects($this->any())->method('getRequest')->will($this->returnValue($this->requestMock));
     $contextMock->expects($this->any())->method('getObjectManager')->will($this->returnValue($this->objectManagerMock));
     $contextMock->expects($this->any())->method('getView')->will($this->returnValue($this->viewMock));
     $contextMock->expects($this->any())->method('getResponse')->will($this->returnValue($this->responseMock));
     $this->controller = new \Magento\Shipping\Controller\Adminhtml\Order\Shipment\RemoveTrack($contextMock, $this->shipmentLoaderMock);
     $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);
 }