当前位置: 首页>>代码示例>>PHP>>正文


PHP Session::expects方法代码示例

本文整理汇总了PHP中Magento\Backend\Model\Session::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::expects方法的具体用法?PHP Session::expects怎么用?PHP Session::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Backend\Model\Session的用法示例。


在下文中一共展示了Session::expects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 /**
  * Set up test
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function setUp()
 {
     $this->contextMock = $this->getMock('Magento\\Backend\\App\\Action\\Context', ['getAuthorization', 'getSession', 'getActionFlag', 'getAuth', 'getView', 'getHelper', 'getBackendUrl', 'getFormKeyValidator', 'getLocaleResolver', 'getCanUseBaseUrl', 'getRequest', 'getResponse', 'getObjectManager', 'getMessageManager'], [], '', false);
     $this->response = $this->getMock('Magento\\Framework\\App\\ResponseInterface', ['setRedirect', 'sendResponse'], [], '', false);
     $this->view = $this->getMock('\\Magento\\Framework\\App\\ViewInterface', ['loadLayout', 'getPage', 'getConfig', 'getTitle', 'renderLayout', 'loadLayoutUpdates', 'getDefaultLayoutHandle', 'addPageLayoutHandles', 'generateLayoutBlocks', 'generateLayoutXml', 'getLayout', 'addActionLayoutHandles', 'setIsLayoutLoaded', 'isLayoutLoaded'], [], '', false);
     $this->session = $this->getMock('\\Magento\\Backend\\Model\\Session', ['setIsUrlNotice'], [], '', false);
     $this->session->expects($this->any())->method('setIsUrlNotice')->willReturn($this->objectManager);
     $this->actionFlag = $this->getMock('\\Magento\\Framework\\App\\ActionFlag', ['get'], [], '', false);
     $this->actionFlag->expects($this->any())->method("get")->willReturn($this->objectManager);
     $this->objectManager = $this->getMock('Magento\\Framework\\TestFramework\\Unit\\Helper\\ObjectManager', ['get'], [], '', false);
     $this->request = $this->getMockForAbstractClass('\\Magento\\Framework\\App\\RequestInterface', ['getParam', 'getRequest'], '', false);
     $this->response->expects($this->any())->method("setRedirect")->willReturn(1);
     $this->page = $this->getMock('\\Magento\\Framework\\View\\Result\\Page', [], [], '', false);
     $this->config = $this->getMock('\\Magento\\Framework\\View\\Result\\Page', [], [], '', false);
     $this->title = $this->getMock('\\Magento\\Framework\\View\\Page\\Title', [], [], '', false);
     $this->messageManager = $this->getMockForAbstractClass('\\Magento\\Framework\\Message\\ManagerInterface', ['addError', 'addSuccess'], '', false);
     $this->indexReg = $this->getMock('Magento\\Framework\\Indexer\\IndexerRegistry', ['get', 'setScheduled'], [], '', false);
     $this->helper = $this->getMock('\\Magento\\Backend\\Helper\\Data', ['getUrl'], [], '', false);
     $this->contextMock->expects($this->any())->method("getObjectManager")->willReturn($this->objectManager);
     $this->contextMock->expects($this->any())->method("getRequest")->willReturn($this->request);
     $this->contextMock->expects($this->any())->method("getResponse")->willReturn($this->response);
     $this->contextMock->expects($this->any())->method("getMessageManager")->willReturn($this->messageManager);
     $this->contextMock->expects($this->any())->method("getSession")->willReturn($this->session);
     $this->contextMock->expects($this->any())->method("getActionFlag")->willReturn($this->actionFlag);
     $this->contextMock->expects($this->any())->method("getHelper")->willReturn($this->helper);
 }
开发者ID:nblair,项目名称:magescotch,代码行数:30,代码来源:MassChangelogTest.php

示例2: testExecute

 /**
  * @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());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:15,代码来源:IndexTest.php

示例3: redirectSection

 /**
  * Redirect into response section
  *
  * @return void
  */
 protected function redirectSection()
 {
     $this->actionFlag->expects($this->once())->method('get')->with('', \Magento\Backend\App\AbstractAction::FLAG_IS_URLS_CHECKED)->will($this->returnValue(true));
     $this->sessionMock->expects($this->once())->method('setIsUrlNotice')->with(true);
     $this->helperMock->expects($this->once())->method('getUrl')->will($this->returnValue('redirect-path'));
     $this->responseMock->expects($this->once())->method('setRedirect');
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:12,代码来源:PrintLabelTest.php

示例4: testExecute

 /**
  * 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();
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:38,代码来源:EditTest.php

示例5: testExecute

 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());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:32,代码来源:NewActionTest.php

示例6: prepareRedirect

 /**
  * @param string $path
  * @param array $arguments
  * @param int $index
  */
 protected function prepareRedirect($path, $arguments, $index)
 {
     $this->actionFlag->expects($this->any())->method('get')->with('', 'check_url_settings')->will($this->returnValue(true));
     $this->session->expects($this->any())->method('setIsUrlNotice')->with(true);
     $url = $path . '/' . (!empty($arguments) ? $arguments['shipment_id'] : '');
     $this->helper->expects($this->at($index))->method('getUrl')->with($path, $arguments)->will($this->returnValue($url));
     $this->response->expects($this->at($index))->method('setRedirect')->with($url);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:13,代码来源:EmailTest.php

示例7: testExecute

 public function testExecute()
 {
     $data = ['tmp_name' => 'tmp_name', 'path' => 'path', 'file' => 'file'];
     $uploader = $this->getMockBuilder('Magento\\MediaStorage\\Model\\File\\Uploader')->disableOriginalConstructor()->getMock();
     $resultJson = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Json')->disableOriginalConstructor()->setMethods(['setData'])->getMock();
     $this->request->expects($this->once())->method('getParam')->with('type')->willReturn('samples');
     $this->sample->expects($this->once())->method('getBaseTmpPath')->willReturn('base_tmp_path');
     $this->uploaderFactory->expects($this->once())->method('create')->willReturn($uploader);
     $this->fileHelper->expects($this->once())->method('uploadFromTmp')->willReturn($data);
     $this->storageDatabase->expects($this->once())->method('saveFile');
     $this->session->expects($this->once())->method('getName')->willReturn('Name');
     $this->session->expects($this->once())->method('getSessionId')->willReturn('SessionId');
     $this->session->expects($this->once())->method('getCookieLifetime')->willReturn('CookieLifetime');
     $this->session->expects($this->once())->method('getCookiePath')->willReturn('CookiePath');
     $this->session->expects($this->once())->method('getCookieDomain')->willReturn('CookieDomain');
     $this->resultFactory->expects($this->once())->method('create')->willReturn($resultJson);
     $resultJson->expects($this->once())->method('setData')->willReturnSelf();
     $this->assertEquals($resultJson, $this->upload->execute());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:19,代码来源:UploadTest.php

示例8: testUpdateNavigationMode

 public function testUpdateNavigationMode()
 {
     $this->_setAdditionalExpectations();
     $request = $this->getMock('Magento\\Framework\\App\\Request\\Http', [], [], '', false);
     $request->expects($this->once())->method('getPathInfo')->will($this->returnValue('/'));
     $this->_backendSession->expects($this->at(0))->method('setData')->with('vde_current_url', '/');
     $this->_backendSession->expects($this->at(1))->method('setData')->with('vde_current_mode', \Magento\DesignEditor\Model\State::MODE_NAVIGATION);
     $this->_urlModelFactory->expects($this->once())->method('replaceClassName')->with(self::URL_MODEL_NAVIGATION_MODE_CLASS_NAME);
     $this->_areaEmulator->expects($this->once())->method('emulateLayoutArea')->with(self::AREA_CODE);
     $controller = $this->getMock('Magento\\Backend\\App\\Action', [], [], '', false);
     $this->_model->update(self::AREA_CODE, $request, $controller);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:12,代码来源:StateTest.php

示例9: prepareRedirect

 /**
  * @param string $path
  * @param array $arguments
  * @param int $index
  */
 protected function prepareRedirect($path, $arguments, $index)
 {
     $this->actionFlag->expects($this->any())
         ->method('get')
         ->with('', 'check_url_settings')
         ->will($this->returnValue(true));
     $this->session->expects($this->any())
         ->method('setIsUrlNotice')
         ->with(true);
     $this->resultRedirect->expects($this->at($index))
         ->method('setPath')
         ->with($path, ['shipment_id' => $arguments['shipment_id']]);
 }
开发者ID:nblair,项目名称:magescotch,代码行数:18,代码来源:EmailTest.php

示例10: testExecuteException

 public function testExecuteException()
 {
     $queryId = 1;
     $queryText = 'search';
     $this->mockGetRequestData($queryText, $queryId);
     $this->request->expects($this->at(4))->method('getPost')->with('store_id', false)->willReturn(1);
     $this->query->expects($this->once())->method('setStoreId');
     $this->query->expects($this->once())->method('loadByQueryText')->willThrowException(new \Exception());
     $this->messageManager->expects($this->once())->method('addException');
     $this->session->expects($this->once())->method('setPageData');
     $this->redirect->expects($this->once())->method('setPath')->willReturnSelf();
     $this->assertSame($this->redirect, $this->controller->execute());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:13,代码来源:SaveTest.php

示例11: testForceAdminPasswordChange

 public function testForceAdminPasswordChange()
 {
     /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserverMock */
     $eventObserverMock = $this->getMockBuilder('Magento\\Framework\\Event\\Observer')->disableOriginalConstructor()->setMethods([])->getMock();
     /** @var \Magento\Framework\Event|\PHPUnit_Framework_MockObject_MockObject */
     $eventMock = $this->getMockBuilder('Magento\\Framework\\Event')->disableOriginalConstructor()->setMethods(['getControllerAction', 'getRequest'])->getMock();
     $this->configInterfaceMock->expects($this->atLeastOnce())->method('getValue')->willReturn(1);
     $this->authSessionMock->expects($this->once())->method('isLoggedIn')->willReturn(true);
     $eventObserverMock->expects($this->atLeastOnce())->method('getEvent')->willReturn($eventMock);
     /** @var \Magento\Framework\App\Action\Action $controllerMock */
     $controllerMock = $this->getMockBuilder('Magento\\Framework\\App\\Action\\AbstractAction')->disableOriginalConstructor()->setMethods(['getRedirect', 'getRequest'])->getMockForAbstractClass();
     /** @var \Magento\Framework\App\RequestInterface $requestMock */
     $requestMock = $this->getMockBuilder('Magento\\Framework\\App\\RequestInterface')->disableOriginalConstructor()->setMethods(['getFullActionName', 'setDispatched'])->getMockForAbstractClass();
     $eventMock->expects($this->once())->method('getControllerAction')->willReturn($controllerMock);
     $eventMock->expects($this->once())->method('getRequest')->willReturn($requestMock);
     $this->authSessionMock->expects($this->once())->method('getPciAdminUserIsPasswordExpired')->willReturn(true);
     $requestMock->expects($this->once())->method('getFullActionName')->willReturn('not_in_array');
     $this->authSessionMock->expects($this->once())->method('clearStorage');
     $this->sessionMock->expects($this->once())->method('clearStorage');
     $this->managerInterfaceMock->expects($this->once())->method('addErrorMessage');
     $controllerMock->expects($this->once())->method('getRequest')->willReturn($requestMock);
     $requestMock->expects($this->once())->method('setDispatched')->willReturn(false);
     $this->model->execute($eventObserverMock);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:24,代码来源:ForceAdminPasswordChangeObserverTest.php

示例12: testSaveActionThrowsException

 public function testSaveActionThrowsException()
 {
     $this->requestMock->expects($this->any())->method('getPostValue')->willReturn(['block_id' => 1]);
     $this->requestMock->expects($this->atLeastOnce())->method('getParam')->willReturnMap([['block_id', null, 1], ['back', null, true]]);
     $this->objectManagerMock->expects($this->atLeastOnce())->method('create')->with($this->equalTo('Magento\\Cms\\Model\\Block'))->willReturn($this->blockMock);
     $this->objectManagerMock->expects($this->atLeastOnce())->method('get')->willReturnMap([['Magento\\Backend\\Model\\Session', $this->sessionMock]]);
     $this->blockMock->expects($this->any())->method('load')->willReturnSelf();
     $this->blockMock->expects($this->any())->method('getId')->willReturn(true);
     $this->blockMock->expects($this->once())->method('setData');
     $this->blockMock->expects($this->once())->method('save')->willThrowException(new \Exception('Error message.'));
     $this->messageManagerMock->expects($this->any())->method('addSuccess')->with(__('You saved the block.'));
     $this->messageManagerMock->expects($this->once())->method('addError');
     $this->sessionMock->expects($this->atLeastOnce())->method('setFormData')->with(['block_id' => 1]);
     $this->resultRedirect->expects($this->atLeastOnce())->method('setPath')->with('*/*/edit', ['block_id' => $this->blockId])->willReturnSelf();
     $this->assertSame($this->resultRedirect, $this->saveController->execute());
 }
开发者ID:hientruong90,项目名称:magento2_installer,代码行数:16,代码来源:SaveTest.php

示例13: _createIntegrationController

 /**
  * @param string $actionName
  * @return \Magento\Integration\Controller\Adminhtml\Integration
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 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));
     $this->resultRedirectFactory = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\RedirectFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->resultFactory = $this->getMockBuilder('Magento\\Framework\\Controller\\ResultFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->_authMock->expects($this->any())->method('getUser')->will($this->returnValue($this->_userMock));
     $this->_userMock->expects($this->any())->method('load')->willReturn($this->_userMock);
     $this->_backendSessionMock->expects($this->any())->method('getIntegrationData')->willReturn(['all_resources' => 1]);
     $contextParameters = ['view' => $this->_viewMock, 'objectManager' => $this->_objectManagerMock, 'session' => $this->_backendSessionMock, 'translator' => $this->_translateModelMock, 'request' => $this->_requestMock, 'response' => $this->_responseMock, 'messageManager' => $this->_messageManager, 'resultRedirectFactory' => $this->resultRedirectFactory, 'resultFactory' => $this->resultFactory, 'auth' => $this->_authMock, 'eventManager' => $this->_eventManagerMock];
     $this->_backendActionCtxMock = $this->_objectManagerHelper->getObject('Magento\\Backend\\App\\Action\\Context', $contextParameters);
     $integrationCollection = $this->getMockBuilder('\\Magento\\Integration\\Model\\ResourceModel\\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);
     if ($actionName == 'Save') {
         $reflection = new \ReflectionClass(get_class($controller));
         $reflectionProperty = $reflection->getProperty('securityCookie');
         $reflectionProperty->setAccessible(true);
         $reflectionProperty->setValue($controller, $this->securityCookieMock);
     }
     return $controller;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:49,代码来源:IntegrationTest.php

示例14: testExecuteWithTaxClassAndException

 public function testExecuteWithTaxClassAndException()
 {
     $taxClass = '3';
     $groupId = 0;
     $code = 'NOT LOGGED IN';
     $this->request->expects($this->exactly(3))->method('getParam')->withConsecutive(['tax_class'], ['id'], ['code'])->willReturnOnConsecutiveCalls($taxClass, $groupId, null);
     $this->resultRedirectFactory->expects($this->once())->method('create')->willReturn($this->resultRedirect);
     $this->groupRepositoryMock->expects($this->once())->method('getById')->with($groupId)->willReturn($this->group);
     $this->group->expects($this->once())->method('getCode')->willReturn($code);
     $this->group->expects($this->once())->method('setCode')->with($code);
     $this->group->expects($this->once())->method('setTaxClassId')->with($taxClass);
     $this->groupRepositoryMock->expects($this->once())->method('save')->with($this->group);
     $this->messageManager->expects($this->once())->method('addSuccess')->with(__('You saved the customer group.'));
     $exception = new \Exception('Exception');
     $this->resultRedirect->expects($this->at(0))->method('setPath')->with('customer/group')->willThrowException($exception);
     $this->messageManager->expects($this->once())->method('addError')->with('Exception');
     $this->dataObjectProcessorMock->expects($this->once())->method('buildOutputDataArray')->with($this->group, '\\Magento\\Customer\\Api\\Data\\GroupInterface')->willReturn(['code' => $code]);
     $this->session->expects($this->once())->method('setCustomerGroupData')->with(['customer_group_code' => $code]);
     $this->resultRedirect->expects($this->at(1))->method('setPath')->with('customer/group/edit', ['id' => $groupId]);
     $this->assertSame($this->resultRedirect, $this->controller->execute());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:21,代码来源:SaveTest.php

示例15: testExecute

 /**
  *  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());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:24,代码来源:NewActionTest.php


注:本文中的Magento\Backend\Model\Session::expects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。