Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mcamara/laravel-localization
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 097d1c4e71ebe84a7ed3d604ff7cc2bbbef10f39
Choose a base ref
..
head repository: mcamara/laravel-localization
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0c3ba96a43a1b835184a5e181c619e081a67d11f
Choose a head ref
Showing with 36 additions and 0 deletions.
  1. +36 −0 tests/LaravelLocalizationTest.php
36 changes: 36 additions & 0 deletions tests/LaravelLocalizationTest.php
Original file line number Diff line number Diff line change
@@ -861,4 +861,40 @@ public function testSetLocaleWithMapping(): void
$this->assertEquals('http://localhost/custom/some-route', app('laravellocalization')->localizeURL('some-route', 'custom'));
$this->assertEquals('http://localhost/custom', app('laravellocalization')->localizeURL('http://localhost/custom', 'en'));
}



public function testRedirectWithHiddenDefaultLocaleInUrlAndSavedLocale()
{
app('router')->group([
'prefix' => app('laravellocalization')->setLocale(),
'middleware' => [
'Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRedirectFilter',
'Mcamara\LaravelLocalization\Middleware\LocaleCookieRedirect',
],
], function (){
app('router')->get('/', ['as'=> 'index', function () {
return 'Index page';
}, ]);
});

app('config')->set('laravellocalization.hideDefaultLocaleInURL', true);

$savedLocale = 'es';

$crawler = $this->call(
'GET',
$this->test_url,
[],
['locale' => $savedLocale],
[],
[]
);

$this->assertResponseStatus(302);
$this->assertRedirectedTo($this->test_url . $savedLocale);

$localeCookie = $crawler->headers->getCookies()[0];
$this->assertEquals($savedLocale, $localeCookie->getValue());
}
}