20 private $eventManagerMock;
30 private $responseMock;
35 private $redirectResponseMock;
49 $this->eventManagerMock = $this->getMockBuilder(\
Magento\Framework\Event\ManagerInterface::class)->getMock();
50 $this->requestMock = $this->getMockBuilder(\
Magento\Framework\
App\Request\Http::class)
51 ->disableOriginalConstructor()
53 $this->responseMock = $this->getMockBuilder(\
Magento\Framework\
App\
Response\Http::class)
54 ->disableOriginalConstructor()
56 $this->redirectResponseMock = $this->getMockBuilder(\
Magento\Framework\
App\
Response\RedirectInterface::class)
58 $this->viewMock = $this->createMock(\
Magento\Framework\
App\ViewInterface::class);
61 \
Magento\Cookie\Controller\Index\NoCookies::class,
63 'eventManager' => $this->eventManagerMock,
64 'request' => $this->requestMock,
65 'response' => $this->responseMock,
66 'redirect' => $this->redirectResponseMock,
67 'view' => $this->viewMock,
75 $this->eventManagerMock->expects($this->once())
78 $this->equalTo(
'controller_action_nocookies'),
80 function ($dataArray) {
81 $redirect = $dataArray[
'redirect'];
82 $this->assertInstanceOf(\
Magento\Framework\DataObject::class, $redirect);
83 $redirect->setRedirectUrl(self::REDIRECT_URL);
90 $this->responseMock->expects($this->once())
91 ->method(
'setRedirect')
92 ->with(self::REDIRECT_URL);
95 $this->requestMock->expects($this->once())->method(
'setDispatched')->with($this->isTrue());
98 $this->controller->execute();
104 $this->eventManagerMock->expects($this->once())
107 $this->equalTo(
'controller_action_nocookies'),
109 function ($dataArray) {
110 $redirect = $dataArray[
'redirect'];
111 $this->assertInstanceOf(\
Magento\Framework\DataObject::class, $redirect);
112 $redirect->setArguments(self::REDIRECT_ARGUMENTS);
113 $redirect->setPath(self::REDIRECT_PATH);
114 $redirect->setRedirect(self::REDIRECT_URL);
121 $this->redirectResponseMock->expects($this->once())
123 ->with($this->responseMock, $this->equalTo(
'\a\path'), $this->equalTo(
'&arg1key=arg1value'));
126 $this->requestMock->expects($this->once())->method(
'setDispatched')->with($this->isTrue());
129 $this->controller->execute();
135 $this->viewMock->expects($this->once())->method(
'loadLayout')->with([
'default',
'noCookie']);
136 $this->viewMock->expects($this->once())->method(
'renderLayout');
139 $this->requestMock->expects($this->once())->method(
'setDispatched')->with($this->isTrue());
142 $this->controller->execute();
testExecuteRedirectPath()