Skip to content

Commit a116e43

Browse files
committed
Add localized fallback test
1 parent 26506fb commit a116e43

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/Unit/Macros/LocalizedUrlMacroTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,4 +218,28 @@ public function the_macro_does_not_blow_up_on_a_default_404_error()
218218
$response->assertNotFound();
219219
$response->assertResponseHasNoView();
220220
}
221+
222+
/** @test */
223+
public function it_returns_localized_urls_for_non_existing_routes_that_have_a_supported_locale_in_their_url_if_you_register_a_fallback_route()
224+
{
225+
$this->setSupportedLocales(['en', 'nl']);
226+
227+
Route::localized(function () {
228+
Route::fallback(function () {
229+
return response([
230+
'current' => Route::localizedUrl(),
231+
'en' => Route::localizedUrl('en'),
232+
'nl' => Route::localizedUrl('nl'),
233+
], 404);
234+
})->name('404');
235+
});
236+
237+
$response = $this->call('GET', '/nl/non/existing/route');
238+
$response->assertNotFound();
239+
$this->assertEquals([
240+
'current' => url('/nl/non/existing/route'),
241+
'en' => url('/en/non/existing/route'),
242+
'nl' => url('/nl/non/existing/route'),
243+
], $response->original);
244+
}
221245
}

0 commit comments

Comments
 (0)