39 $this->_actionFlag = $this->getMockBuilder(
41 )->disableOriginalConstructor()->setMethods(
45 $this->_objectManager = $this->createMock(\
Magento\Framework\ObjectManagerInterface::class);
47 $this->_customerSession = $this->getMockBuilder(
48 \
Magento\Customer\Model\Session::class
49 )->disableOriginalConstructor()->setMethods(
53 $this->_context = $this->getMockBuilder(\
Magento\Framework\
App\Helper\Context::class)
54 ->disableOriginalConstructor()
57 $this->_helper = new \Magento\Checkout\Helper\ExpressRedirect(
59 $this->_objectManager,
60 $this->_customerSession,
71 public function testRedirectLogin($actionFlagList, $customerBeforeAuthUrl, $customerBeforeAuthUrlDefault)
73 $expressRedirectMock = $this->getMockBuilder(
74 \
Magento\Checkout\Controller\Express\RedirectLoginInterface::class
75 )->disableOriginalConstructor()->setMethods(
79 'getCustomerBeforeAuthUrl',
81 'getRedirectActionName',
84 $expressRedirectMock->expects(
89 $this->returnValue($actionFlagList)
93 $actionFlagList = array_merge([
'no-dispatch' =>
true], $actionFlagList);
94 foreach ($actionFlagList as $actionKey => $actionFlag) {
95 $this->_actionFlag->expects($this->at($atIndex))->method(
'set')->with(
'', $actionKey, $actionFlag);
99 $expectedLoginUrl =
'loginURL';
100 $expressRedirectMock->expects(
105 $this->returnValue($expectedLoginUrl)
108 $urlMock = $this->getMockBuilder(
110 )->disableOriginalConstructor()->setMethods(
119 [
'context' =>
'checkout']
121 $this->returnValue($expectedLoginUrl)
124 $this->_objectManager->expects(
131 $this->returnValue($urlMock)
134 $responseMock = $this->getMockBuilder(
136 )->disableOriginalConstructor()->setMethods(
137 [
'setRedirect',
'__wakeup']
139 $responseMock->expects($this->once())->method(
'setRedirect')->with($expectedLoginUrl);
141 $expressRedirectMock->expects($this->once())->method(
'getResponse')->will($this->returnValue($responseMock));
143 $expressRedirectMock->expects(
146 'getCustomerBeforeAuthUrl' 148 $this->returnValue($customerBeforeAuthUrl)
150 $expectedCustomerBeforeAuthUrl = $customerBeforeAuthUrl !==
null 151 ? $customerBeforeAuthUrl : $customerBeforeAuthUrlDefault;
152 if ($expectedCustomerBeforeAuthUrl) {
153 $this->_customerSession->expects(
158 $expectedCustomerBeforeAuthUrl
161 $this->_helper->redirectLogin($expressRedirectMock, $customerBeforeAuthUrlDefault);
171 [[],
'beforeCustomerUrl',
'beforeCustomerUrlDEFAULT'],
172 [[
'actionKey' =>
true],
null,
'beforeCustomerUrlDEFAULT'],
173 [[],
'beforeCustomerUrl',
null]
testRedirectLogin($actionFlagList, $customerBeforeAuthUrl, $customerBeforeAuthUrlDefault)
redirectLoginDataProvider()