@@ -565,7 +565,7 @@ public function it_generates_non_absolute_urls_for_non_existing_routes()
565565 }
566566
567567 /** @test */
568- public function it_returns_a_url_with_query_string ()
568+ public function it_returns_a_url_with_query_string_for_existing_non_localized_unnamed_routes ()
569569 {
570570 $ this ->setSupportedLocales (['en ' , 'nl ' ]);
571571
@@ -586,6 +586,80 @@ public function it_returns_a_url_with_query_string()
586586 ], $ response ->original );
587587 }
588588
589+ /** @test */
590+ public function it_returns_a_url_with_query_string_for_existing_localized_unnamed_routes ()
591+ {
592+ $ this ->setSupportedLocales (['en ' , 'nl ' ]);
593+ $ this ->setUseLocaleMiddleware (true );
594+ $ this ->setAppLocale ('en ' );
595+
596+ Route::localized (function () {
597+ Route::get ('route ' , function () {
598+ return [
599+ 'current ' => Route::localizedUrl (),
600+ 'en ' => Route::localizedUrl ('en ' ),
601+ 'nl ' => Route::localizedUrl ('nl ' ),
602+ ];
603+ });
604+ });
605+
606+ $ response = $ this ->call ('GET ' , '/nl/route?another=one¶m=value ' );
607+ $ response ->assertOk ();
608+ $ this ->assertEquals ([
609+ 'current ' => url ('/nl/route?another=one¶m=value ' ),
610+ 'en ' => url ('/en/route?another=one¶m=value ' ),
611+ 'nl ' => url ('/nl/route?another=one¶m=value ' ),
612+ ], $ response ->original );
613+ }
614+
615+ /** @test */
616+ public function it_returns_a_url_with_query_string_for_existing_non_localized_named_routes ()
617+ {
618+ $ this ->setSupportedLocales (['en ' , 'nl ' ]);
619+
620+ Route::get ('route ' , function () {
621+ return [
622+ 'current ' => Route::localizedUrl (),
623+ 'en ' => Route::localizedUrl ('en ' ),
624+ 'nl ' => Route::localizedUrl ('nl ' ),
625+ ];
626+ })->name ('route ' );
627+
628+ $ response = $ this ->call ('GET ' , '/route?another=one¶m=value ' );
629+ $ response ->assertOk ();
630+ $ this ->assertEquals ([
631+ 'current ' => url ('/route?another=one¶m=value ' ),
632+ 'en ' => url ('/route?another=one¶m=value ' ),
633+ 'nl ' => url ('/route?another=one¶m=value ' ),
634+ ], $ response ->original );
635+ }
636+
637+ /** @test */
638+ public function it_returns_a_url_with_query_string_for_existing_localized_named_routes ()
639+ {
640+ $ this ->setSupportedLocales (['en ' , 'nl ' ]);
641+ $ this ->setUseLocaleMiddleware (true );
642+ $ this ->setAppLocale ('en ' );
643+
644+ Route::localized (function () {
645+ Route::get ('route ' , function () {
646+ return [
647+ 'current ' => Route::localizedUrl (),
648+ 'en ' => Route::localizedUrl ('en ' ),
649+ 'nl ' => Route::localizedUrl ('nl ' ),
650+ ];
651+ })->name ('route ' );
652+ });
653+
654+ $ response = $ this ->call ('GET ' , '/nl/route?another=one¶m=value ' );
655+ $ response ->assertOk ();
656+ $ this ->assertEquals ([
657+ 'current ' => url ('/nl/route?another=one¶m=value ' ),
658+ 'en ' => url ('/en/route?another=one¶m=value ' ),
659+ 'nl ' => url ('/nl/route?another=one¶m=value ' ),
660+ ], $ response ->original );
661+ }
662+
589663 /**
590664 * Set a custom view path so Laravel will find our custom 440 error view.
591665 *
0 commit comments