11
11
use Magento \Customer \Model \Account \Redirect ;
12
12
use Magento \Customer \Model \Url as CustomerUrl ;
13
13
use Magento \Framework \Controller \ResultFactory ;
14
+ use Magento \Framework \TestFramework \Unit \Helper \ObjectManager ;
14
15
use Magento \Framework \Url \HostChecker ;
15
16
use Magento \Store \Model \ScopeInterface ;
16
- use Magento \Framework \TestFramework \Unit \Helper \ObjectManager ;
17
17
18
18
/**
19
19
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -147,15 +147,15 @@ protected function setUp()
147
147
$ this ->model = $ objectManager ->getObject (
148
148
\Magento \Customer \Model \Account \Redirect::class,
149
149
[
150
- 'request ' => $ this ->request ,
151
- 'customerSession ' => $ this ->customerSession ,
152
- 'scopeConfig ' => $ this ->scopeConfig ,
153
- 'storeManager ' => $ this ->storeManager ,
154
- 'url ' => $ this ->url ,
155
- 'urlDecoder ' => $ this ->urlDecoder ,
156
- 'customerUrl ' => $ this ->customerUrl ,
157
- 'resultFactory ' => $ this ->resultFactory ,
158
- 'hostChecker ' => $ this ->hostChecker
150
+ 'request ' => $ this ->request ,
151
+ 'customerSession ' => $ this ->customerSession ,
152
+ 'scopeConfig ' => $ this ->scopeConfig ,
153
+ 'storeManager ' => $ this ->storeManager ,
154
+ 'url ' => $ this ->url ,
155
+ 'urlDecoder ' => $ this ->urlDecoder ,
156
+ 'customerUrl ' => $ this ->customerUrl ,
157
+ 'resultFactory ' => $ this ->resultFactory ,
158
+ 'hostChecker ' => $ this ->hostChecker ,
159
159
]
160
160
);
161
161
}
@@ -191,57 +191,31 @@ public function testGetRedirect(
191
191
$ redirectToDashboard
192
192
) {
193
193
// Preparations for method updateLastCustomerId()
194
- $ this ->customerSession ->expects ($ this ->once ())
195
- ->method ('getLastCustomerId ' )
196
- ->willReturn ($ customerId );
197
- $ this ->customerSession ->expects ($ this ->any ())
198
- ->method ('isLoggedIn ' )
199
- ->willReturn ($ customerLoggedIn );
200
- $ this ->customerSession ->expects ($ this ->any ())
201
- ->method ('getId ' )
202
- ->willReturn ($ lastCustomerId );
203
- $ this ->customerSession ->expects ($ this ->any ())
204
- ->method ('unsBeforeAuthUrl ' )
205
- ->willReturnSelf ();
194
+ $ this ->customerSession ->expects ($ this ->once ())->method ('getLastCustomerId ' )->willReturn ($ customerId );
195
+ $ this ->customerSession ->expects ($ this ->any ())->method ('isLoggedIn ' )->willReturn ($ customerLoggedIn );
196
+ $ this ->customerSession ->expects ($ this ->any ())->method ('getId ' )->willReturn ($ lastCustomerId );
197
+ $ this ->customerSession ->expects ($ this ->any ())->method ('unsBeforeAuthUrl ' )->willReturnSelf ();
206
198
$ this ->customerSession ->expects ($ this ->any ())
207
199
->method ('setLastCustomerId ' )
208
200
->with ($ lastCustomerId )
209
201
->willReturnSelf ();
210
202
211
203
// Preparations for method prepareRedirectUrl()
212
- $ this ->store ->expects ($ this ->once ())
213
- ->method ('getBaseUrl ' )
214
- ->willReturn ($ baseUrl );
204
+ $ this ->store ->expects ($ this ->once ())->method ('getBaseUrl ' )->willReturn ($ baseUrl );
215
205
216
- $ this ->customerSession ->expects ($ this ->any ())
217
- ->method ('getBeforeAuthUrl ' )
218
- ->willReturn ($ beforeAuthUrl );
219
- $ this ->customerSession ->expects ($ this ->any ())
220
- ->method ('setBeforeAuthUrl ' )
221
- ->willReturnSelf ();
222
- $ this ->customerSession ->expects ($ this ->any ())
223
- ->method ('getAfterAuthUrl ' )
224
- ->willReturn ($ afterAuthUrl );
206
+ $ this ->customerSession ->expects ($ this ->any ())->method ('getBeforeAuthUrl ' )->willReturn ($ beforeAuthUrl );
207
+ $ this ->customerSession ->expects ($ this ->any ())->method ('setBeforeAuthUrl ' )->willReturnSelf ();
208
+ $ this ->customerSession ->expects ($ this ->any ())->method ('getAfterAuthUrl ' )->willReturn ($ afterAuthUrl );
225
209
$ this ->customerSession ->expects ($ this ->any ())
226
210
->method ('setAfterAuthUrl ' )
227
211
->with ($ beforeAuthUrl )
228
212
->willReturnSelf ();
229
- $ this ->customerSession ->expects ($ this ->any ())
230
- ->method ('getBeforeRequestParams ' )
231
- ->willReturn (false );
232
-
233
- $ this ->customerUrl ->expects ($ this ->any ())
234
- ->method ('getAccountUrl ' )
235
- ->willReturn ($ accountUrl );
236
- $ this ->customerUrl ->expects ($ this ->any ())
237
- ->method ('getLoginUrl ' )
238
- ->willReturn ($ loginUrl );
239
- $ this ->customerUrl ->expects ($ this ->any ())
240
- ->method ('getLogoutUrl ' )
241
- ->willReturn ($ logoutUrl );
242
- $ this ->customerUrl ->expects ($ this ->any ())
243
- ->method ('getDashboardUrl ' )
244
- ->willReturn ($ dashboardUrl );
213
+ $ this ->customerSession ->expects ($ this ->any ())->method ('getBeforeRequestParams ' )->willReturn (false );
214
+
215
+ $ this ->customerUrl ->expects ($ this ->any ())->method ('getAccountUrl ' )->willReturn ($ accountUrl );
216
+ $ this ->customerUrl ->expects ($ this ->any ())->method ('getLoginUrl ' )->willReturn ($ loginUrl );
217
+ $ this ->customerUrl ->expects ($ this ->any ())->method ('getLogoutUrl ' )->willReturn ($ logoutUrl );
218
+ $ this ->customerUrl ->expects ($ this ->any ())->method ('getDashboardUrl ' )->willReturn ($ dashboardUrl );
245
219
246
220
$ this ->scopeConfig ->expects ($ this ->any ())
247
221
->method ('isSetFlag ' )
@@ -253,25 +227,19 @@ public function testGetRedirect(
253
227
->with (CustomerUrl::REFERER_QUERY_PARAM_NAME )
254
228
->willReturn ($ referer );
255
229
256
- $ this ->urlDecoder ->expects ($ this ->any ())
257
- ->method ('decode ' )
258
- ->with ($ referer )
259
- ->willReturn ($ referer );
230
+ $ this ->urlDecoder ->expects ($ this ->any ())->method ('decode ' )->with ($ referer )->willReturn ($ referer );
260
231
261
- $ this ->url ->expects ($ this ->any ())
262
- ->method ('isOwnOriginUrl ' )
263
- ->willReturn (true );
232
+ $ this ->url ->expects ($ this ->any ())->method ('isOwnOriginUrl ' )->willReturn (true );
264
233
265
- $ this ->resultRedirect ->expects ($ this ->once ())
266
- ->method ('setUrl ' )
267
- ->with ($ beforeAuthUrl )
268
- ->willReturnSelf ();
234
+ $ this ->resultRedirect ->expects ($ this ->once ())->method ('setUrl ' )->with ($ beforeAuthUrl )->willReturnSelf ();
269
235
270
236
$ this ->resultFactory ->expects ($ this ->once ())
271
237
->method ('create ' )
272
238
->with (ResultFactory::TYPE_REDIRECT )
273
239
->willReturn ($ this ->resultRedirect );
274
240
241
+ $ this ->hostChecker ->expects ($ this ->any ())->method ('isOwnOrigin ' )->willReturn (true );
242
+
275
243
$ this ->model ->getRedirect ();
276
244
}
277
245
@@ -306,6 +274,21 @@ public function getRedirectDataProvider()
306
274
[1 , 2 , 'referer ' , 'base ' , 'logout ' , '' , 'account ' , 'login ' , 'logout ' , 'dashboard ' , false , true ],
307
275
// Default redirect
308
276
[1 , 2 , 'referer ' , 'base ' , 'defined ' , '' , 'account ' , 'login ' , 'logout ' , 'dashboard ' , true , true ],
277
+ // Logout, Without Redirect to Dashboard
278
+ [
279
+ 'customer_id ' => 1 ,
280
+ 'last_customer_id ' => 2 ,
281
+ 'referer ' => 'http://base.com/customer/account/logoutSuccess/ ' ,
282
+ 'base_url ' => 'http://base.com/ ' ,
283
+ 'before_auth_url ' => 'http://base.com/ ' ,
284
+ 'after_auth_url ' => 'http://base.com/customer/account/ ' ,
285
+ 'account_url ' => 'account ' ,
286
+ 'login_url ' => 'login ' ,
287
+ 'logout_url ' => 'logout ' ,
288
+ 'dashboard_url ' => 'dashboard ' ,
289
+ 'is_customer_logged_id_flag ' => true ,
290
+ 'redirect_to_dashboard_flag ' => false ,
291
+ ],
309
292
];
310
293
}
311
294
0 commit comments