public function testPreventExpressCheckoutEmpty() { $this->_customerSession->expects($this->any())->method('isLoggedIn')->will($this->returnValue(false)); $this->_persistentSession->expects($this->any())->method('isPersistent')->will($this->returnValue(true)); $this->_event->setControllerAction(null); $this->_model->execute($this->_observer); $this->_event->setControllerAction(new \StdClass()); $this->_model->execute($this->_observer); $expectedActionName = 'realAction'; $unexpectedActionName = 'notAction'; $request = new \Magento\Framework\Object(); $request->setActionName($unexpectedActionName); $expressRedirectMock = $this->getMockBuilder('Magento\\Checkout\\Controller\\Express\\RedirectLoginInterface')->disableOriginalConstructor()->setMethods(['getActionFlagList', 'getResponse', 'getCustomerBeforeAuthUrl', 'getLoginUrl', 'getRedirectActionName', 'getRequest'])->getMock(); $expressRedirectMock->expects($this->any())->method('getRequest')->will($this->returnValue($request)); $expressRedirectMock->expects($this->any())->method('getRedirectActionName')->will($this->returnValue($expectedActionName)); $this->_event->setControllerAction($expressRedirectMock); $this->_model->execute($this->_observer); $expectedAuthUrl = 'expectedAuthUrl'; $request->setActionName($expectedActionName); $this->_url->expects($this->once())->method('getUrl')->will($this->returnValue($expectedAuthUrl)); $this->_expressRedirectHelper->expects($this->once())->method('redirectLogin')->with($expressRedirectMock, $expectedAuthUrl); $this->_model->execute($this->_observer); }