diff --git a/src/Facades/LocalizationRoute.php b/src/Facades/LocalizationRoute.php new file mode 100644 index 0000000..37b53d1 --- /dev/null +++ b/src/Facades/LocalizationRoute.php @@ -0,0 +1,20 @@ +names()->parameter)) + ->name($this->names()->parameter . '.') + ->middleware(LocalizationByParameter::class) + ->group($callback); + + BaseRoute::middleware([ + LocalizationByCookie::class, + LocalizationByHeader::class, + LocalizationBySession::class, + ])->group($callback); + } +} diff --git a/tests/Concerns/Routes.php b/tests/Concerns/Routes.php index a252640..665d625 100644 --- a/tests/Concerns/Routes.php +++ b/tests/Concerns/Routes.php @@ -5,6 +5,7 @@ namespace Tests\Concerns; use Closure; +use LaravelLang\Routes\Facades\LocalizationRoute; use LaravelLang\Routes\Middlewares\LocalizationByCookie; use LaravelLang\Routes\Middlewares\LocalizationByHeader; use LaravelLang\Routes\Middlewares\LocalizationByParameter; @@ -63,6 +64,13 @@ public function setUpRoutes(): void ->get('clean/{foo}', $this->jsonResponse()) ->name('clean'); }); + + LocalizationRoute::group(function () { + app('router') + ->middleware('web') + ->get('grouped', $this->jsonResponse()) + ->name('via.group'); + }); } protected function jsonResponse(): Closure diff --git a/tests/Feature/Facades/RouteTest.php b/tests/Feature/Facades/RouteTest.php new file mode 100644 index 0000000..c291cc6 --- /dev/null +++ b/tests/Feature/Facades/RouteTest.php @@ -0,0 +1,10 @@ +has('via.group'))->toBeTrue(); + expect(app('router')->has(Name::parameter() . '.via.group'))->toBeTrue(); +}); diff --git a/tests/Feature/CookieTest.php b/tests/Feature/Middlewares/CookieTest.php similarity index 100% rename from tests/Feature/CookieTest.php rename to tests/Feature/Middlewares/CookieTest.php diff --git a/tests/Feature/HeaderTest.php b/tests/Feature/Middlewares/HeaderTest.php similarity index 100% rename from tests/Feature/HeaderTest.php rename to tests/Feature/Middlewares/HeaderTest.php diff --git a/tests/Feature/ParameterRedirectTest.php b/tests/Feature/Middlewares/ParameterRedirectTest.php similarity index 100% rename from tests/Feature/ParameterRedirectTest.php rename to tests/Feature/Middlewares/ParameterRedirectTest.php diff --git a/tests/Feature/ParameterTest.php b/tests/Feature/Middlewares/ParameterTest.php similarity index 100% rename from tests/Feature/ParameterTest.php rename to tests/Feature/Middlewares/ParameterTest.php diff --git a/tests/Feature/SessionTest.php b/tests/Feature/Middlewares/SessionTest.php similarity index 100% rename from tests/Feature/SessionTest.php rename to tests/Feature/Middlewares/SessionTest.php diff --git a/tests/Feature/WithoutTest.php b/tests/Feature/Middlewares/WithoutTest.php similarity index 100% rename from tests/Feature/WithoutTest.php rename to tests/Feature/Middlewares/WithoutTest.php