Skip to content

Commit fff1b46

Browse files
authored
Do not override global config when setting scoped options (#104)
1 parent f05f3f8 commit fff1b46

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/LocalizedRoutesRegistrar.php

-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ public function register(Closure $closure, array $options = []): void
2626
return;
2727
}
2828

29-
LocaleConfig::setSupportedLocales($locales);
30-
LocaleConfig::setOmittedLocale($omittedLocale);
31-
3229
$localeRouteAction = LocaleConfig::getRouteAction();
3330
$usingDomains = LocaleConfig::hasCustomDomains();
3431
$usingCustomSlugs = LocaleConfig::hasCustomSlugs();

tests/Feature/Middleware/SetLocaleTest.php

+20
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace CodeZero\LocalizedRoutes\Tests\Feature\Middleware;
44

5+
use CodeZero\LocalizedRoutes\Facades\LocaleConfig;
56
use CodeZero\LocalizedRoutes\Middleware\SetLocale;
67
use CodeZero\LocalizedRoutes\Tests\TestCase;
78
use Illuminate\Database\Eloquent\Model;
@@ -299,4 +300,23 @@ public function it_sets_the_locale_of_routes_with_scoped_config()
299300
$response = $this->get('de/with-scoped-config');
300301
$this->assertEquals('de', $response->original);
301302
}
303+
304+
/** @test */
305+
public function that_scoped_config_does_not_override_global_config(): void
306+
{
307+
$this->setSupportedLocales(['en']);
308+
309+
Route::localized(function () {
310+
Route::get('with-scoped-config', function () {
311+
return App::getLocale();
312+
})->middleware(['web', SetLocale::class]);
313+
}, [
314+
'supported_locales' => ['en', 'nl'],
315+
]);
316+
317+
$this->assertEquals(
318+
['en'],
319+
LocaleConfig::getSupportedLocales()
320+
);
321+
}
302322
}

0 commit comments

Comments
 (0)