13 use \InvalidArgumentException;
62 $this->storeManagerMock = $this->getMockBuilder(\
Magento\
Store\Model\StoreManagerInterface::class)
63 ->disableOriginalConstructor()
67 $this->storeCookieManagerMock = $this->getMockBuilder(\
Magento\
Store\Api\StoreCookieManagerInterface::class)
68 ->disableOriginalConstructor()
72 $this->storeMock = $this->getMockBuilder(\
Magento\
Store\Model\Store::class)
73 ->disableOriginalConstructor()
77 $this->subjectMock = $this->getMockBuilder(\
Magento\Framework\
App\FrontController::class)
78 ->disableOriginalConstructor()
82 $this->requestMock = $this->getMockBuilder(\
Magento\Framework\
App\RequestInterface::class)
83 ->disableOriginalConstructor()
87 $this->storeRepositoryMock = $this->getMockBuilder(\
Magento\
Store\Api\StoreRepositoryInterface::class)
88 ->disableOriginalConstructor()
95 'storeManager' => $this->storeManagerMock,
96 'storeCookieManager' => $this->storeCookieManagerMock,
97 'storeRepository' => $this->storeRepositoryMock
108 $this->storeManagerMock->expects($this->once())
109 ->method(
'getDefaultStoreView')
110 ->willReturn($this->storeMock);
111 $this->storeCookieManagerMock->expects($this->atLeastOnce())
112 ->method(
'getStoreCodeFromCookie')
114 $this->storeRepositoryMock->expects($this->once())
115 ->method(
'getActiveStoreByCode')
117 $this->storeCookieManagerMock->expects($this->once())
118 ->method(
'deleteStoreCookie')
119 ->with($this->storeMock);
121 $this->plugin->beforeDispatch($this->subjectMock, $this->requestMock);
130 $this->storeManagerMock->expects($this->once())
131 ->method(
'getDefaultStoreView')
132 ->willReturn($this->storeMock);
133 $this->storeCookieManagerMock->expects($this->atLeastOnce())
134 ->method(
'getStoreCodeFromCookie')
136 $this->storeRepositoryMock->expects($this->once())
137 ->method(
'getActiveStoreByCode')
139 $this->storeCookieManagerMock->expects($this->once())
140 ->method(
'deleteStoreCookie')
141 ->with($this->storeMock);
143 $this->plugin->beforeDispatch($this->subjectMock, $this->requestMock);
152 $this->storeManagerMock->expects($this->once())
153 ->method(
'getDefaultStoreView')
154 ->willReturn($this->storeMock);
155 $this->storeCookieManagerMock->expects($this->atLeastOnce())
156 ->method(
'getStoreCodeFromCookie')
158 $this->storeRepositoryMock->expects($this->once())
159 ->method(
'getActiveStoreByCode')
160 ->willThrowException(
new InvalidArgumentException);
161 $this->storeCookieManagerMock->expects($this->once())
162 ->method(
'deleteStoreCookie')
163 ->with($this->storeMock);
165 $this->plugin->beforeDispatch($this->subjectMock, $this->requestMock);
174 $this->storeCookieManagerMock->expects($this->atLeastOnce())
175 ->method(
'getStoreCodeFromCookie')
177 $this->storeManagerMock->expects($this->never())
178 ->method(
'getDefaultStoreView')
179 ->willReturn($this->storeMock);
180 $this->storeRepositoryMock->expects($this->never())
181 ->method(
'getActiveStoreByCode');
182 $this->storeCookieManagerMock->expects($this->never())
183 ->method(
'deleteStoreCookie')
184 ->with($this->storeMock);
186 $this->plugin->beforeDispatch($this->subjectMock, $this->requestMock);
195 $this->storeCookieManagerMock->expects($this->atLeastOnce())
196 ->method(
'getStoreCodeFromCookie')
198 $this->storeRepositoryMock->expects($this->atLeastOnce())
199 ->method(
'getActiveStoreByCode')
200 ->willReturn($this->storeMock);
201 $this->storeCookieManagerMock->expects($this->never())
202 ->method(
'deleteStoreCookie')
203 ->with($this->storeMock);
205 $this->plugin->beforeDispatch($this->subjectMock, $this->requestMock);
testBeforeDispatchWithStoreRequestParam()
testBeforeDispatchStoreIsInactive()
testBeforeDispatchNoStoreCookie()
testBeforeDispatchNoSuchEntity()
testBeforeDispatchInvalidArgument()