@@ -188,31 +188,6 @@ public function testLocalizeURL()
188
188
189
189
public function testGetLocalizedURL ()
190
190
{
191
- $ this ->assertEquals (
192
- $ this ->test_url .'es/acerca ' ,
193
- app ('laravellocalization ' )->getLocalizedURL ('es ' , $ this ->test_url .'en/about ' )
194
- );
195
-
196
- $ this ->assertEquals (
197
- $ this ->test_url .'es/ver/1 ' ,
198
- app ('laravellocalization ' )->getLocalizedURL ('es ' , $ this ->test_url .'view/1 ' )
199
- );
200
-
201
- $ this ->assertEquals (
202
- $ this ->test_url .'es/ver/1/proyecto ' ,
203
- app ('laravellocalization ' )->getLocalizedURL ('es ' , $ this ->test_url .'view/1/project ' )
204
- );
205
-
206
- $ this ->assertEquals (
207
- $ this ->test_url .'es/ver/1/proyecto/1 ' ,
208
- app ('laravellocalization ' )->getLocalizedURL ('es ' , $ this ->test_url .'view/1/project/1 ' )
209
- );
210
-
211
- $ this ->assertEquals (
212
- $ this ->test_url .'en/about ' ,
213
- app ('laravellocalization ' )->getLocalizedURL ('en ' , $ this ->test_url .'about ' )
214
- );
215
-
216
191
$ this ->assertEquals (
217
192
$ this ->test_url .app ('laravellocalization ' )->getCurrentLocale (),
218
193
app ('laravellocalization ' )->getLocalizedURL ()
@@ -221,20 +196,6 @@ public function testGetLocalizedURL()
221
196
app ('config ' )->set ('laravellocalization.hideDefaultLocaleInURL ' , true );
222
197
// testing default language hidden
223
198
224
- $ this ->assertEquals (
225
- $ this ->test_url .'es/acerca ' ,
226
- app ('laravellocalization ' )->getLocalizedURL ('es ' , $ this ->test_url .'about ' )
227
- );
228
- $ this ->assertEquals (
229
- $ this ->test_url .'about ' ,
230
- app ('laravellocalization ' )->getLocalizedURL ('en ' , $ this ->test_url .'about ' )
231
- );
232
-
233
- $ this ->assertEquals (
234
- $ this ->test_url ,
235
- app ('laravellocalization ' )->getLocalizedURL ()
236
- );
237
-
238
199
$ this ->assertNotEquals (
239
200
$ this ->test_url .app ('laravellocalization ' )->getDefaultLocale (),
240
201
app ('laravellocalization ' )->getLocalizedURL ()
@@ -311,6 +272,90 @@ public function testGetLocalizedURL()
311
272
);
312
273
}
313
274
275
+ /**
276
+ * @param bool $hideDefaultLocaleInURL
277
+ * @param bool $forceDefault
278
+ * @param string $locale
279
+ * @param string $path
280
+ * @param string $expectedURL
281
+ *
282
+ * @dataProvider getLocalizedURLDataProvider
283
+ */
284
+ public function testGetLocalizedURLFormat ($ hideDefaultLocaleInURL , $ forceDefault , $ locale , $ path , $ expectedURL )
285
+ {
286
+ app ('config ' )->set ('laravellocalization.hideDefaultLocaleInURL ' , $ hideDefaultLocaleInURL );
287
+ $ this ->assertEquals (
288
+ $ expectedURL ,
289
+ app ('laravellocalization ' )->getLocalizedURL ($ locale , $ path , [], $ forceDefault )
290
+ );
291
+
292
+ }
293
+
294
+ public function getLocalizedURLDataProvider ()
295
+ {
296
+ return [
297
+ // Do not hide default
298
+ [false , false , 'es ' , $ this ->test_url , $ this ->test_url .'es ' ],
299
+ [false , false , 'es ' , $ this ->test_url .'es ' , $ this ->test_url .'es ' ],
300
+ [false , false , 'es ' , $ this ->test_url .'en/about ' , $ this ->test_url .'es/acerca ' ],
301
+ [false , false , 'es ' , $ this ->test_url .'ver/1 ' , $ this ->test_url .'es/ver/1 ' ],
302
+ [false , false , 'es ' , $ this ->test_url .'view/1/project ' , $ this ->test_url .'es/ver/1/proyecto ' ],
303
+ [false , false , 'es ' , $ this ->test_url .'view/1/project/1 ' , $ this ->test_url .'es/ver/1/proyecto/1 ' ],
304
+
305
+ // Do not hide default
306
+ [false , false , 'en ' , $ this ->test_url .'en ' , $ this ->test_url .'en ' ],
307
+ [false , false , 'en ' , $ this ->test_url .'about ' , $ this ->test_url .'en/about ' ],
308
+ [false , false , 'en ' , $ this ->test_url .'ver/1 ' , $ this ->test_url .'en/ver/1 ' ],
309
+ [false , false , 'en ' , $ this ->test_url .'view/1/project ' , $ this ->test_url .'en/view/1/project ' ],
310
+ [false , false , 'en ' , $ this ->test_url .'view/1/project/1 ' , $ this ->test_url .'en/view/1/project/1 ' ],
311
+
312
+ // Hide default
313
+ [true , false , 'es ' , $ this ->test_url , $ this ->test_url .'es ' ],
314
+ [true , false , 'es ' , $ this ->test_url .'es ' , $ this ->test_url .'es ' ],
315
+ [true , false , 'es ' , $ this ->test_url .'en/about ' , $ this ->test_url .'es/acerca ' ],
316
+ [true , false , 'es ' , $ this ->test_url .'ver/1 ' , $ this ->test_url .'es/ver/1 ' ],
317
+ [true , false , 'es ' , $ this ->test_url .'view/1/project ' , $ this ->test_url .'es/ver/1/proyecto ' ],
318
+ [true , false , 'es ' , $ this ->test_url .'view/1/project/1 ' , $ this ->test_url .'es/ver/1/proyecto/1 ' ],
319
+
320
+ // Hide default
321
+ [true , false , 'en ' , $ this ->test_url .'en ' , $ this ->test_url .'' ],
322
+ [true , false , 'en ' , $ this ->test_url .'about ' , $ this ->test_url .'about ' ],
323
+ [true , false , 'en ' , $ this ->test_url .'ver/1 ' , $ this ->test_url .'ver/1 ' ],
324
+ [true , false , 'en ' , $ this ->test_url .'view/1/project ' , $ this ->test_url .'view/1/project ' ],
325
+ [true , false , 'en ' , $ this ->test_url .'view/1/project/1 ' , $ this ->test_url .'view/1/project/1 ' ],
326
+
327
+ // Do not hide default FORCE SHOWING
328
+ [false , true , 'es ' , $ this ->test_url , $ this ->test_url .'es ' ],
329
+ [false , true , 'es ' , $ this ->test_url .'es ' , $ this ->test_url .'es ' ],
330
+ [false , true , 'es ' , $ this ->test_url .'en/about ' , $ this ->test_url .'es/acerca ' ],
331
+ [false , true , 'es ' , $ this ->test_url .'ver/1 ' , $ this ->test_url .'es/ver/1 ' ],
332
+ [false , true , 'es ' , $ this ->test_url .'view/1/project ' , $ this ->test_url .'es/ver/1/proyecto ' ],
333
+ [false , true , 'es ' , $ this ->test_url .'view/1/project/1 ' , $ this ->test_url .'es/ver/1/proyecto/1 ' ],
334
+
335
+ // Do not hide default FORCE SHOWING
336
+ [false , true , 'en ' , $ this ->test_url .'en ' , $ this ->test_url .'en ' ],
337
+ [false , true , 'en ' , $ this ->test_url .'about ' , $ this ->test_url .'en/about ' ],
338
+ [false , true , 'en ' , $ this ->test_url .'ver/1 ' , $ this ->test_url .'en/ver/1 ' ],
339
+ [false , true , 'en ' , $ this ->test_url .'view/1/project ' , $ this ->test_url .'en/view/1/project ' ],
340
+ [false , true , 'en ' , $ this ->test_url .'view/1/project/1 ' , $ this ->test_url .'en/view/1/project/1 ' ],
341
+
342
+ // Hide default FORCE SHOWING
343
+ [true , true , 'es ' , $ this ->test_url , $ this ->test_url .'es ' ],
344
+ [true , true , 'es ' , $ this ->test_url .'es ' , $ this ->test_url .'es ' ],
345
+ [true , true , 'es ' , $ this ->test_url .'en/about ' , $ this ->test_url .'es/acerca ' ],
346
+ [true , true , 'es ' , $ this ->test_url .'ver/1 ' , $ this ->test_url .'es/ver/1 ' ],
347
+ [true , true , 'es ' , $ this ->test_url .'view/1/project ' , $ this ->test_url .'es/ver/1/proyecto ' ],
348
+ [true , true , 'es ' , $ this ->test_url .'view/1/project/1 ' , $ this ->test_url .'es/ver/1/proyecto/1 ' ],
349
+
350
+ // Hide default FORCE SHOWING
351
+ [true , true , 'en ' , $ this ->test_url .'en ' , $ this ->test_url .'en ' ],
352
+ [true , true , 'en ' , $ this ->test_url .'about ' , $ this ->test_url .'en/about ' ],
353
+ [true , true , 'en ' , $ this ->test_url .'ver/1 ' , $ this ->test_url .'en/ver/1 ' ],
354
+ [true , true , 'en ' , $ this ->test_url .'view/1/project ' , $ this ->test_url .'en/view/1/project ' ],
355
+ [true , true , 'en ' , $ this ->test_url .'view/1/project/1 ' , $ this ->test_url .'en/view/1/project/1 ' ],
356
+ ];
357
+ }
358
+
314
359
public function testGetURLFromRouteNameTranslated ()
315
360
{
316
361
$ this ->assertEquals (
0 commit comments