• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Response\RedirectInterface类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Magento\Framework\App\Response\RedirectInterface的典型用法代码示例。如果您正苦于以下问题:PHP RedirectInterface类的具体用法?PHP RedirectInterface怎么用?PHP RedirectInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: testExecute

 /**
  * @return void
  */
 public function testExecute()
 {
     $customerId = 7;
     $captchaValue = 'some-value';
     $email = '[email protected]';
     $redirectUrl = 'http://magento.com/customer/account/edit/';
     $captcha = $this->getMock('Magento\\Captcha\\Model\\DefaultModel', [], [], '', false);
     $captcha->expects($this->once())->method('isRequired')->willReturn(true);
     $captcha->expects($this->once())->method('isCorrect')->with($captchaValue)->willReturn(false);
     $this->helperMock->expects($this->once())->method('getCaptcha')->with(\Magento\Captcha\Observer\CheckUserEditObserver::FORM_ID)->willReturn($captcha);
     $response = $this->getMock('Magento\\Framework\\App\\Response\\Http', [], [], '', false);
     $request = $this->getMock('Magento\\Framework\\App\\Request\\Http', [], [], '', false);
     $request->expects($this->any())->method('getPost')->with(\Magento\Captcha\Helper\Data::INPUT_NAME_FIELD_VALUE, null)->willReturn([\Magento\Captcha\Observer\CheckUserEditObserver::FORM_ID => $captchaValue]);
     $controller = $this->getMock('Magento\\Framework\\App\\Action\\Action', [], [], '', false);
     $controller->expects($this->any())->method('getRequest')->will($this->returnValue($request));
     $controller->expects($this->any())->method('getResponse')->will($this->returnValue($response));
     $this->captchaStringResolverMock->expects($this->once())->method('resolve')->with($request, \Magento\Captcha\Observer\CheckUserEditObserver::FORM_ID)->willReturn($captchaValue);
     $customerDataMock = $this->getMock('\\Magento\\Customer\\Model\\Data\\Customer', [], [], '', false);
     $this->customerSessionMock->expects($this->once())->method('getCustomerId')->willReturn($customerId);
     $this->customerSessionMock->expects($this->atLeastOnce())->method('getCustomer')->willReturn($customerDataMock);
     $this->authenticationMock->expects($this->once())->method('processAuthenticationFailure')->with($customerId);
     $this->authenticationMock->expects($this->once())->method('isLocked')->with($customerId)->willReturn(true);
     $this->customerSessionMock->expects($this->once())->method('logout');
     $this->customerSessionMock->expects($this->once())->method('start');
     $this->scopeConfigMock->expects($this->once())->method('getValue')->with('contact/email/recipient_email')->willReturn($email);
     $message = __('The account is locked. Please wait and try again or contact %1.', $email);
     $this->messageManagerMock->expects($this->exactly(2))->method('addError')->withConsecutive([$message], [__('Incorrect CAPTCHA')]);
     $this->actionFlagMock->expects($this->once())->method('set')->with('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
     $this->redirectMock->expects($this->once())->method('redirect')->with($response, '*/*/edit')->willReturn($redirectUrl);
     $this->observer->execute(new \Magento\Framework\Event\Observer(['controller_action' => $controller]));
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:34,代码来源:CheckUserEditObserverTest.php


示例2: testSaveActionWithException

 public function testSaveActionWithException()
 {
     $this->formKeyValidatorMock->expects($this->once())->method('validate')->will($this->returnValue(true));
     $this->customerSessionMock->expects($this->any())->method('getCustomerId')->will($this->returnValue(1));
     $this->customerRepositoryMock->expects($this->any())->method('getById')->will($this->throwException(new NoSuchEntityException(__(NoSuchEntityException::MESSAGE_SINGLE_FIELD, ['fieldName' => 'customerId', 'value' => 'value']))));
     $this->redirectMock->expects($this->once())->method('redirect')->with($this->responseMock, 'customer/account/', []);
     $this->messageManagerMock->expects($this->never())->method('addSuccess');
     $this->messageManagerMock->expects($this->once())->method('addError')->with('Something went wrong while saving your subscription.');
     $this->action->execute();
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:10,代码来源:SaveTest.php


示例3: setUp

 public function setUp()
 {
     $this->request = $this->getMockBuilder('Magento\\Framework\\App\\RequestInterface')->disableOriginalConstructor()->getMock();
     $this->response = $this->getMock('Magento\\Framework\\App\\ResponseInterface', [], [], '', false);
     $this->redirect = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Redirect')->setMethods(['setRefererOrBaseUrl'])->disableOriginalConstructor()->getMock();
     $this->redirectFactory = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\RedirectFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock();
     $this->redirectFactory->expects($this->any())->method('create')->willReturn($this->redirect);
     $this->context = $this->getMockBuilder('Magento\\Framework\\App\\Action\\Context')->disableOriginalConstructor()->getMock();
     $this->context->expects($this->any())->method('getResultRedirectFactory')->willReturn($this->redirectFactory);
     $this->action = $this->getMockForAbstractClass('Magento\\Framework\\App\\Action\\AbstractAction', [$this->context]);
 }
开发者ID:opexsw,项目名称:magento2,代码行数:11,代码来源:AbstractActionTest.php


示例4: beforeDispatch

 /**
  * Perform customer authentication and wishlist feature state checks
  *
  * @param \Magento\Framework\App\ActionInterface $subject
  * @param RequestInterface $request
  * @return void
  * @throws \Magento\Framework\Exception\NotFoundException
  */
 public function beforeDispatch(\Magento\Framework\App\ActionInterface $subject, RequestInterface $request)
 {
     if ($this->authenticationState->isEnabled() && !$this->customerSession->authenticate($subject)) {
         $subject->getActionFlag()->set('', 'no-dispatch', true);
         if (!$this->customerSession->getBeforeWishlistUrl()) {
             $this->customerSession->setBeforeWishlistUrl($this->redirector->getRefererUrl());
         }
         $this->customerSession->setBeforeWishlistRequest($request->getParams());
     }
     if (!$this->config->isSetFlag('wishlist/general/active')) {
         throw new NotFoundException(__('Page not found.'));
     }
 }
开发者ID:opexsw,项目名称:magento2,代码行数:21,代码来源:Plugin.php


示例5: execute

 /**
  * Check CAPTCHA on Contact Us page
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $formId = 'contact_us';
     $captcha = $this->_helper->getCaptcha($formId);
     if ($captcha->isRequired()) {
         /** @var \Magento\Framework\App\Action\Action $controller */
         $controller = $observer->getControllerAction();
         if (!$captcha->isCorrect($this->captchaStringResolver->resolve($controller->getRequest(), $formId))) {
             $this->messageManager->addError(__('Incorrect CAPTCHA.'));
             $this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
             $this->redirect->redirect($controller->getResponse(), 'contact/index/index');
         }
     }
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:20,代码来源:CheckContactUsFormObserver.php


示例6: testExecute

 public function testExecute()
 {
     $firstElement = 'firstElement';
     $symbolsDataArray = [$firstElement];
     $redirectUrl = 'redirectUrl';
     $this->requestMock->expects($this->once())->method('getParam')->with('custom_currency_symbol')->willReturn($symbolsDataArray);
     $this->helperMock->expects($this->once())->method('getUrl')->with('*');
     $this->redirectMock->expects($this->once())->method('getRedirectUrl')->willReturn($redirectUrl);
     $this->currencySymbolMock->expects($this->once())->method('setCurrencySymbolsData')->with($symbolsDataArray);
     $this->responseMock->expects($this->once())->method('setRedirect');
     $this->filterManagerMock->expects($this->once())->method('stripTags')->with($firstElement)->willReturn($firstElement);
     $this->objectManagerMock->expects($this->once())->method('create')->with('Magento\\CurrencySymbol\\Model\\System\\Currencysymbol')->willReturn($this->currencySymbolMock);
     $this->objectManagerMock->expects($this->once())->method('get')->with('Magento\\Framework\\Filter\\FilterManager')->willReturn($this->filterManagerMock);
     $this->messageManagerMock->expects($this->once())->method('addSuccess')->with(__('You applied the custom currency symbols.'));
     $this->action->execute();
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:16,代码来源:SaveTest.php


示例7: execute

 /**
  * Check Captcha On Forgot Password Page
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return $this
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $captchaModel = $this->helper->getCaptcha(self::FORM_ID);
     if ($captchaModel->isRequired()) {
         /** @var \Magento\Framework\App\Action\Action $controller */
         $controller = $observer->getControllerAction();
         if (!$captchaModel->isCorrect($this->captchaStringResolver->resolve($controller->getRequest(), self::FORM_ID))) {
             try {
                 $customer = $this->customerRepository->getById($this->customerSession->getCustomerId());
                 $this->accountManagementHelper->processCustomerLockoutData($customer->getId());
                 $this->customerRepository->save($customer);
             } catch (NoSuchEntityException $e) {
                 //do nothing as customer existance is validated later in authenticate method
             }
             $this->workWithLock();
             $this->messageManager->addError(__('Incorrect CAPTCHA'));
             $this->actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
             $this->redirect->redirect($controller->getResponse(), '*/*/edit');
         }
     }
     $customer = $this->customerSession->getCustomer();
     $login = $customer->getEmail();
     $captchaModel->logAttempt($login);
     return $this;
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:31,代码来源:CheckUserEditObserver.php


示例8: execute

 /**
  * Check Captcha On Forgot Password Page
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return $this
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $captchaModel = $this->helper->getCaptcha(self::FORM_ID);
     if ($captchaModel->isRequired()) {
         /** @var \Magento\Framework\App\Action\Action $controller */
         $controller = $observer->getControllerAction();
         if (!$captchaModel->isCorrect($this->captchaStringResolver->resolve($controller->getRequest(), self::FORM_ID))) {
             $customerId = $this->customerSession->getCustomerId();
             $this->authentication->processAuthenticationFailure($customerId);
             if ($this->authentication->isLocked($customerId)) {
                 $this->customerSession->logout();
                 $this->customerSession->start();
                 $message = __('The account is locked. Please wait and try again or contact %1.', $this->scopeConfig->getValue('contact/email/recipient_email'));
                 $this->messageManager->addError($message);
             }
             $this->messageManager->addError(__('Incorrect CAPTCHA'));
             $this->actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
             $this->redirect->redirect($controller->getResponse(), '*/*/edit');
         }
     }
     $customer = $this->customerSession->getCustomer();
     $login = $customer->getEmail();
     $captchaModel->logAttempt($login);
     return $this;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:31,代码来源:CheckUserEditObserver.php


示例9: testCheckContactUsFormRedirectsCustomerWithWarningMessageWhenCaptchaIsRequiredAndInvalid

 public function testCheckContactUsFormRedirectsCustomerWithWarningMessageWhenCaptchaIsRequiredAndInvalid()
 {
     $formId = 'contact_us';
     $captchaValue = 'some-value';
     $warningMessage = 'Incorrect CAPTCHA.';
     $redirectRoutePath = 'contact/index/index';
     $redirectUrl = 'http://magento.com/contacts/';
     $postData = ['name' => 'Some Name'];
     $request = $this->getMock('Magento\\Framework\\App\\Request\\Http', [], [], '', false);
     $response = $this->getMock('Magento\\Framework\\App\\Response\\Http', [], [], '', false);
     $request->expects($this->any())->method('getPost')->with(\Magento\Captcha\Helper\Data::INPUT_NAME_FIELD_VALUE, null)->willReturn([$formId => $captchaValue]);
     $request->expects($this->once())->method('getPostValue')->willReturn($postData);
     $this->redirectMock->expects($this->once())->method('redirect')->with($response, $redirectRoutePath, [])->willReturn($redirectUrl);
     $controller = $this->getMock('Magento\\Framework\\App\\Action\\Action', [], [], '', false);
     $controller->expects($this->any())->method('getRequest')->willReturn($request);
     $controller->expects($this->any())->method('getResponse')->willReturn($response);
     $this->captchaMock->expects($this->any())->method('isRequired')->willReturn(true);
     $this->captchaMock->expects($this->once())->method('isCorrect')->with($captchaValue)->willReturn(false);
     $this->captchaStringResolverMock->expects($this->once())->method('resolve')->with($request, $formId)->willReturn($captchaValue);
     $this->helperMock->expects($this->any())->method('getCaptcha')->with($formId)->willReturn($this->captchaMock);
     $this->messageManagerMock->expects($this->once())->method('addError')->with($warningMessage);
     $this->actionFlagMock->expects($this->once())->method('set')->with('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
     $this->dataPersistorMock->expects($this->once())->method('set')->with($formId, $postData);
     $this->checkContactUsFormObserver->execute(new \Magento\Framework\Event\Observer(['controller_action' => $controller]));
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:25,代码来源:CheckContactUsFormObserverTest.php


示例10: testBeforeDispatch

 /**
  * @expectedException \Magento\Framework\Exception\NotFoundException
  */
 public function testBeforeDispatch()
 {
     $actionFlag = $this->getMock('Magento\\Framework\\App\\ActionFlag', [], [], '', false);
     $indexController = $this->getMock('Magento\\Wishlist\\Controller\\Index\\Index', [], [], '', false);
     $actionFlag->expects($this->once())->method('set')->with('', 'no-dispatch', true)->willReturn(true);
     $indexController->expects($this->once())->method('getActionFlag')->willReturn($actionFlag);
     $this->authenticationState->expects($this->once())->method('isEnabled')->willReturn(true);
     $this->customerSession->expects($this->once())->method('authenticate')->willReturn(false);
     $this->redirector->expects($this->once())->method('getRefererUrl')->willReturn('http://referer-url.com');
     $this->request->expects($this->once())->method('getParams')->willReturn(['product' => 1]);
     $this->customerSession->expects($this->at(1))->method('__call')->with('getBeforeWishlistUrl', [])->willReturn(false);
     $this->customerSession->expects($this->at(2))->method('__call')->with('setBeforeWishlistUrl', ['http://referer-url.com'])->willReturn(false);
     $this->customerSession->expects($this->at(3))->method('__call')->with('setBeforeWishlistRequest', [['product' => 1]])->willReturn(true);
     $this->config->expects($this->once())->method('isSetFlag')->with('wishlist/general/active')->willReturn(false);
     $this->getPlugin()->beforeDispatch($indexController, $this->request);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:19,代码来源:PluginTest.php


示例11: testExecuteWithException

 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testExecuteWithException()
 {
     $productId = 11;
     $categoryId = 5;
     $sender = 'sender';
     $recipients = 'recipients';
     $formData = ['sender' => $sender, 'recipients' => $recipients];
     $redirectUrl = 'redirect_url';
     /** @var \Magento\Framework\Controller\Result\Redirect|\PHPUnit_Framework_MockObject_MockObject $redirectMock */
     $redirectMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Redirect')->disableOriginalConstructor()->getMock();
     $this->resultFactoryMock->expects($this->once())->method('create')->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT, [])->willReturn($redirectMock);
     $this->validatorMock->expects($this->once())->method('validate')->with($this->requestMock)->willReturn(true);
     $this->requestMock->expects($this->exactly(2))->method('getParam')->willReturnMap([['id', null, $productId], ['cat_id', null, $categoryId]]);
     /** @var \Magento\Catalog\Api\Data\ProductInterface|\PHPUnit_Framework_MockObject_MockObject $productMock */
     $productMock = $this->getMockBuilder('Magento\\Catalog\\Api\\Data\\ProductInterface')->setMethods(['isVisibleInCatalog', 'setCategory', 'getProductUrl'])->getMockForAbstractClass();
     $this->productRepositoryMock->expects($this->once())->method('getById')->with($productId, false, null, false)->willReturn($productMock);
     $productMock->expects($this->once())->method('isVisibleInCatalog')->willReturn(true);
     $this->categoryRepositoryMock->expects($this->once())->method('get')->with($categoryId, null)->willThrowException(new \Magento\Framework\Exception\NoSuchEntityException(__('No Category Exception.')));
     $productMock->expects($this->never())->method('setCategory');
     $this->registryMock->expects($this->once())->method('register')->willReturnMap([['product', $productMock, false, null]]);
     $this->requestMock->expects($this->once())->method('getPostValue')->willReturn($formData);
     $this->requestMock->expects($this->exactly(2))->method('getPost')->willReturnMap([['sender', $sender], ['recipients', $recipients]]);
     $this->sendFriendMock->expects($this->once())->method('setSender')->with($sender)->willReturnSelf();
     $this->sendFriendMock->expects($this->once())->method('setRecipients')->with($recipients)->willReturnSelf();
     $this->sendFriendMock->expects($this->once())->method('setProduct')->with($productMock)->willReturnSelf();
     $exception = new \Exception(__('Exception.'));
     $this->sendFriendMock->expects($this->once())->method('validate')->willThrowException($exception);
     $this->sendFriendMock->expects($this->never())->method('send');
     $this->messageManagerMock->expects($this->once())->method('addException')->with($exception, __('Some emails were not sent.'))->willReturnSelf();
     $this->catalogSessionMock->expects($this->once())->method('setSendfriendFormData')->with($formData);
     $this->urlBuilderMock->expects($this->once())->method('getUrl')->with('sendfriend/product/send', ['_current' => true])->willReturn($redirectUrl);
     $this->redirectMock->expects($this->once())->method('error')->with($redirectUrl)->willReturnArgument(0);
     $redirectMock->expects($this->once())->method('setUrl')->with($redirectUrl)->willReturnSelf();
     $this->assertEquals($redirectMock, $this->model->execute());
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:38,代码来源:SendmailTest.php


示例12: testDispatchPostDispatch

 public function testDispatchPostDispatch()
 {
     $this->_requestMock->expects($this->exactly(3))->method('getFullActionName')->will($this->returnValue(self::FULL_ACTION_NAME));
     $this->_requestMock->expects($this->exactly(2))->method('getRouteName')->will($this->returnValue(self::ROUTE_NAME));
     $expectedEventParameters = ['controller_action' => $this->action, 'request' => $this->_requestMock];
     $this->_eventManagerMock->expects($this->at(0))->method('dispatch')->with('controller_action_predispatch', $expectedEventParameters);
     $this->_eventManagerMock->expects($this->at(1))->method('dispatch')->with('controller_action_predispatch_' . self::ROUTE_NAME, $expectedEventParameters);
     $this->_eventManagerMock->expects($this->at(2))->method('dispatch')->with('controller_action_predispatch_' . self::FULL_ACTION_NAME, $expectedEventParameters);
     $this->_requestMock->expects($this->once())->method('isDispatched')->will($this->returnValue(true));
     $this->_actionFlagMock->expects($this->at(0))->method('get')->with('', Action::FLAG_NO_DISPATCH)->will($this->returnValue(false));
     // _forward expectations
     $this->_requestMock->expects($this->once())->method('initForward');
     $this->_requestMock->expects($this->once())->method('setParams')->with(self::$actionParams);
     $this->_requestMock->expects($this->once())->method('setControllerName')->with(self::CONTROLLER_NAME);
     $this->_requestMock->expects($this->once())->method('setModuleName')->with(self::MODULE_NAME);
     $this->_requestMock->expects($this->once())->method('setActionName')->with(self::ACTION_NAME);
     $this->_requestMock->expects($this->once())->method('setDispatched')->with(false);
     // _redirect expectations
     $this->_redirectMock->expects($this->once())->method('redirect')->with($this->_responseMock, self::FULL_ACTION_NAME, self::$actionParams);
     $this->_actionFlagMock->expects($this->at(1))->method('get')->with('', Action::FLAG_NO_POST_DISPATCH)->will($this->returnValue(false));
     $this->_eventManagerMock->expects($this->at(3))->method('dispatch')->with('controller_action_postdispatch_' . self::FULL_ACTION_NAME, $expectedEventParameters);
     $this->_eventManagerMock->expects($this->at(4))->method('dispatch')->with('controller_action_postdispatch_' . self::ROUTE_NAME, $expectedEventParameters);
     $this->_eventManagerMock->expects($this->at(5))->method('dispatch')->with('controller_action_postdispatch', $expectedEventParameters);
     $this->assertEquals($this->_responseMock, $this->action->dispatch($this->_requestMock));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:25,代码来源:ActionTest.php


示例13: execute

 /**
  * Check Captcha On User Login Page
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return $this
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $formId = 'user_create';
     $captchaModel = $this->_helper->getCaptcha($formId);
     if ($captchaModel->isRequired()) {
         /** @var \Magento\Framework\App\Action\Action $controller */
         $controller = $observer->getControllerAction();
         if (!$captchaModel->isCorrect($this->captchaStringResolver->resolve($controller->getRequest(), $formId))) {
             $this->messageManager->addError(__('Incorrect CAPTCHA'));
             $this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
             $this->_session->setCustomerFormData($controller->getRequest()->getPostValue());
             $url = $this->_urlManager->getUrl('*/*/create', ['_nosecret' => true]);
             $controller->getResponse()->setRedirect($this->redirect->error($url));
         }
     }
     return $this;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:23,代码来源:CheckUserCreateObserver.php


示例14: testExecute

 public function testExecute()
 {
     $customerId = 1;
     $refererUrl = 'http://referer.url';
     $this->sessionMock->expects($this->once())->method('getId')->willReturn($customerId);
     $this->sessionMock->expects($this->once())->method('logout')->willReturnSelf();
     $this->redirect->expects($this->once())->method('getRefererUrl')->willReturn($refererUrl);
     $this->sessionMock->expects($this->once())->method('setBeforeAuthUrl')->with($refererUrl)->willReturnSelf();
     $this->sessionMock->expects($this->once())->method('setLastCustomerId')->with($customerId);
     $this->cookieManager->expects($this->once())->method('getCookie')->with('mage-cache-sessid')->willReturn(true);
     $this->cookieMetadataFactory->expects($this->once())->method('createCookieMetadata')->willReturn($this->cookieMetadata);
     $this->cookieMetadata->expects($this->once())->method('setPath')->with('/');
     $this->cookieManager->expects($this->once())->method('deleteCookie')->with('mage-cache-sessid', $this->cookieMetadata);
     $this->redirectFactory->expects($this->once())->method('create')->willReturn($this->resultRedirect);
     $this->resultRedirect->expects($this->once())->method('setPath')->with('*/*/logoutSuccess');
     $this->assertSame($this->resultRedirect, $this->controller->execute());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:17,代码来源:LogoutTest.php


示例15: testExecuteInvalidArgument

    public function testExecuteInvalidArgument()
    {
        $themeId = 1;
        $fileParam = '/path/to/file.ext';
        $fileId = 'fileId';
        $refererUrl = 'referer/url';

        $this->request->expects($this->any())
            ->method('getParam')
            ->willReturnMap(
                [
                    ['theme_id', null, $themeId],
                    ['file', null, $fileParam],
                ]
            );
        $theme = $this->getMockBuilder('Magento\Framework\View\Design\ThemeInterface')
            ->setMethods(['getId', 'load'])
            ->getMockForAbstractClass();
        $urlDecoder = $this->getMockBuilder('Magento\Framework\Url\DecoderInterface')->getMock();
        $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
        $this->objectManager->expects($this->any())
            ->method('get')
            ->willReturnMap(
                [
                    ['Magento\Framework\Url\DecoderInterface', $urlDecoder],
                    ['Psr\Log\LoggerInterface', $logger],
                ]
            );
        $this->objectManager->expects($this->any())
            ->method('create')
            ->with('Magento\Framework\View\Design\ThemeInterface')
            ->willReturn($theme);
        $urlDecoder->expects($this->once())
            ->method('decode')
            ->with($fileParam)
            ->willReturn($fileId);
        $theme->expects($this->once())
            ->method('load')
            ->with($themeId)
            ->willReturnSelf();
        $theme->expects($this->once())
            ->method('getId')
            ->willReturn(null);
        $this->messageManager->expects($this->once())
            ->method('addException');
        $logger->expects($this->once())
            ->method('critical');
        $this->redirect->expects($this->once())
            ->method('getRefererUrl')
            ->willReturn($refererUrl);
        $this->response->expects($this->once())
            ->method('setRedirect')
            ->with($refererUrl);

        $this->controller->executeInternal();
    }
开发者ID:nblair,项目名称:magescotch,代码行数:56,代码来源:DownloadCssTest.php


示例16: prepareExecuteWithQuantityArray

 /**
  * @param bool $isAjax
  * @return array
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function prepareExecuteWithQuantityArray($isAjax = false)
 {
     $itemId = 2;
     $wishlistId = 1;
     $qty = [$itemId => 3];
     $productId = 4;
     $productName = 'product_name';
     $indexUrl = 'index_url';
     $configureUrl = 'configure_url';
     $options = [5 => 'option'];
     $params = ['item' => $itemId, 'qty' => $qty];
     $refererUrl = 'referer_url';
     $itemMock = $this->getMockBuilder('Magento\\Wishlist\\Model\\Item')->disableOriginalConstructor()->setMethods(['load', 'getId', 'getWishlistId', 'setQty', 'setOptions', 'getBuyRequest', 'mergeBuyRequest', 'addToCart', 'getProduct', 'getProductId'])->getMock();
     $this->requestMock->expects($this->at(0))->method('getParam')->with('item', null)->willReturn($itemId);
     $this->itemFactoryMock->expects($this->once())->method('create')->willReturn($itemMock);
     $itemMock->expects($this->once())->method('load')->with($itemId, null)->willReturnSelf();
     $itemMock->expects($this->exactly(2))->method('getId')->willReturn($itemId);
     $itemMock->expects($this->once())->method('getWishlistId')->willReturn($wishlistId);
     $wishlistMock = $this->getMockBuilder('Magento\\Wishlist\\Model\\Wishlist')->disableOriginalConstructor()->getMock();
     $this->wishlistProviderMock->expects($this->once())->method('getWishlist')->with($wishlistId)->willReturn($wishlistMock);
     $this->requestMock->expects($this->at(1))->method('getParam')->with('qty', null)->willReturn($qty);
     $this->quantityProcessorMock->expects($this->once())->method('process')->with($qty[$itemId])->willReturnArgument(0);
     $itemMock->expects($this->once())->method('setQty')->with($qty[$itemId])->willReturnSelf();
     $this->urlMock->expects($this->at(0))->method('getUrl')->with('*/*', null)->willReturn($indexUrl);
     $itemMock->expects($this->once())->method('getProductId')->willReturn($productId);
     $this->urlMock->expects($this->at(1))->method('getUrl')->with('*/*/configure/', ['id' => $itemId, 'product_id' => $productId])->willReturn($configureUrl);
     $optionMock = $this->getMockBuilder('Magento\\Wishlist\\Model\\Item\\Option')->disableOriginalConstructor()->getMock();
     $this->optionFactoryMock->expects($this->once())->method('create')->willReturn($optionMock);
     $optionsMock = $this->getMockBuilder('Magento\\Wishlist\\Model\\Resource\\Item\\Option\\Collection')->disableOriginalConstructor()->getMock();
     $optionMock->expects($this->once())->method('getCollection')->willReturn($optionsMock);
     $optionsMock->expects($this->once())->method('addItemFilter')->with([$itemId])->willReturnSelf();
     $optionsMock->expects($this->once())->method('getOptionsByItem')->with($itemId)->willReturn($options);
     $itemMock->expects($this->once())->method('setOptions')->with($options)->willReturnSelf();
     $this->requestMock->expects($this->once())->method('getParams')->willReturn($params);
     $this->requestMock->expects($this->once())->method('isAjax')->willReturn($isAjax);
     $buyRequestMock = $this->getMockBuilder('Magento\\Framework\\Object')->disableOriginalConstructor()->getMock();
     $itemMock->expects($this->once())->method('getBuyRequest')->willReturn($buyRequestMock);
     $this->productHelperMock->expects($this->once())->method('addParamsToBuyRequest')->with($params, ['current_config' => $buyRequestMock])->willReturn($buyRequestMock);
     $itemMock->expects($this->once())->method('mergeBuyRequest')->with($buyRequestMock)->willReturnSelf();
     $itemMock->expects($this->once())->method('addToCart')->with($this->checkoutCartMock, true)->willReturn(true);
     $this->checkoutCartMock->expects($this->once())->method('save')->willReturnSelf();
     $quoteMock = $this->getMockBuilder('Magento\\Quote\\Model\\Quote')->disableOriginalConstructor()->setMethods(['getHasError', 'collectTotals'])->getMock();
     $this->checkoutCartMock->expects($this->exactly(2))->method('getQuote')->willReturn($quoteMock);
     $quoteMock->expects($this->once())->method('collectTotals')->willReturnSelf();
     $wishlistMock->expects($this->once())->method('save')->willReturnSelf();
     $quoteMock->expects($this->once())->method('getHasError')->willReturn(false);
     $productMock = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->getMock();
     $itemMock->expects($this->once())->method('getProduct')->willReturn($productMock);
     $productMock->expects($this->once())->method('getName')->willReturn($productName);
     $this->escaperMock->expects($this->once())->method('escapeHtml')->with($productName, null)->willReturn($productName);
     $this->messageManagerMock->expects($this->once())->method('addSuccess')->with('You added ' . $productName . ' to your shopping cart.', null)->willReturnSelf();
     $this->cartHelperMock->expects($this->once())->method('getShouldRedirectToCart')->willReturn(false);
     $this->redirectMock->expects($this->once())->method('getRefererUrl')->willReturn($refererUrl);
     $this->helperMock->expects($this->once())->method('calculate')->willReturnSelf();
     return $refererUrl;
 }
开发者ID:vasiljok,项目名称:magento2,代码行数:61,代码来源:CartTest.php


示例17: testExecuteAjaxException

 public function testExecuteAjaxException()
 {
     $redirectPath = 'path/to/redirect';
     $quoteMock = $this->getQuoteMock();
     $quoteMock->expects(self::once())->method('getItemsCount')->willReturn(0);
     $this->requestMock->expects(self::exactly(1))->method('getParam')->willReturnMap([['isAjax', null, false]]);
     $this->checkoutSessionMock->expects(self::once())->method('getQuote')->willReturn($quoteMock);
     $this->shippingMethodUpdaterMock->expects(self::never())->method('execute');
     $this->messageManagerMock->expects(self::once())->method('addExceptionMessage')->with(self::isInstanceOf('\\InvalidArgumentException'), 'We can\'t initialize checkout.');
     $this->urlMock->expects(self::once())->method('getUrl')->with('*/*/review', ['_secure' => true])->willReturn($redirectPath);
     $this->redirectMock->expects(self::once())->method('redirect')->with($this->responseMock, $redirectPath, []);
     $this->saveShippingMethod->execute();
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:13,代码来源:SaveShippingMethodTest.php


示例18: testExecuteInvalidArgument

 public function testExecuteInvalidArgument()
 {
     $themeId = 1;
     $refererUrl = 'referer/url';
     $this->request->expects($this->any())->method('getParam')->with('theme_id')->willReturn($themeId);
     $themeFactory = $this->getMockBuilder('Magento\\Framework\\View\\Design\\Theme\\FlyweightFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock();
     $logger = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock();
     $this->objectManager->expects($this->any())->method('get')->with('Psr\\Log\\LoggerInterface')->willReturn($logger);
     $this->objectManager->expects($this->any())->method('create')->with('Magento\\Framework\\View\\Design\\Theme\\FlyweightFactory')->willReturn($themeFactory);
     $themeFactory->expects($this->once())->method('create')->with($themeId)->willReturn(null);
     $this->messageManager->expects($this->once())->method('addException');
     $logger->expects($this->once())->method('critical');
     $this->redirect->expects($this->once())->method('getRefererUrl')->willReturn($refererUrl);
     $this->response->expects($this->once())->method('setRedirect')->with($refererUrl);
     $this->controller->execute();
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:16,代码来源:DownloadCustomCssTest.php


示例19: testSuccessRedirect

 /**
  * @param $customerId
  * @param $key
  * @param $backUrl
  * @param $successUrl
  * @param $resultUrl
  * @param $isSetFlag
  * @param $successMessage
  *
  * @dataProvider getSuccessRedirectDataProvider
  */
 public function testSuccessRedirect($customerId, $key, $backUrl, $successUrl, $resultUrl, $isSetFlag, $successMessage)
 {
     $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue(false));
     $this->requestMock->expects($this->any())->method('getParam')->willReturnMap([['id', false, $customerId], ['key', false, $key], ['back_url', false, $backUrl]]);
     $this->customerRepositoryMock->expects($this->any())->method('getById')->with($customerId)->will($this->returnValue($this->customerDataMock));
     $email = '[email protected]';
     $this->customerDataMock->expects($this->once())->method('getEmail')->will($this->returnValue($email));
     $this->customerAccountManagementMock->expects($this->once())->method('activate')->with($this->equalTo($email), $this->equalTo($key))->will($this->returnValue($this->customerDataMock));
     $this->customerSessionMock->expects($this->any())->method('setCustomerDataAsLoggedIn')->with($this->equalTo($this->customerDataMock))->willReturnSelf();
     $this->messageManagerMock->expects($this->any())->method('addSuccess')->with($this->stringContains($successMessage))->willReturnSelf();
     $this->storeMock->expects($this->any())->method('getFrontendName')->will($this->returnValue('frontend'));
     $this->storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($this->storeMock));
     $this->urlMock->expects($this->any())->method('getUrl')->with($this->equalTo('*/*/index'), ['_secure' => true])->will($this->returnValue($successUrl));
     $this->redirectMock->expects($this->never())->method('success')->with($this->equalTo($resultUrl))-&g 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Http\FileFactory类代码示例发布时间:2022-05-23
下一篇:
PHP Response\Http类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap