Skip to content

Commit a2c1941

Browse files
Merge pull request #18 from Laravel-Lang/1.x
Removed extra trait from tests
2 parents cab7708 + 219a88b commit a2c1941

File tree

2 files changed

+92
-103
lines changed

2 files changed

+92
-103
lines changed

tests/Concerns/Routes.php

-101
This file was deleted.

tests/TestCase.php

+92-2
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,24 @@
22

33
namespace Tests;
44

5+
use Closure;
56
use LaravelLang\Config\Enums\Name;
67
use LaravelLang\Config\ServiceProvider as ConfigServiceProvider;
78
use LaravelLang\Locales\ServiceProvider as LocalesServiceProvider;
9+
use LaravelLang\Routes\Facades\LocalizationRoute;
10+
use LaravelLang\Routes\Middlewares\LocalizationByCookie;
11+
use LaravelLang\Routes\Middlewares\LocalizationByHeader;
12+
use LaravelLang\Routes\Middlewares\LocalizationByModel;
13+
use LaravelLang\Routes\Middlewares\LocalizationByParameter;
14+
use LaravelLang\Routes\Middlewares\LocalizationByParameterWithRedirect;
15+
use LaravelLang\Routes\Middlewares\LocalizationBySession;
816
use LaravelLang\Routes\ServiceProvider;
917
use Orchestra\Testbench\TestCase as BaseTestCase;
1018
use Tests\Concerns\Locales;
11-
use Tests\Concerns\Routes;
1219
use Tests\Constants\LocaleValue;
1320

1421
abstract class TestCase extends BaseTestCase
1522
{
16-
use Routes;
1723
use Locales;
1824

1925
protected function getPackageProviders($app): array
@@ -46,4 +52,88 @@ protected function defineDatabaseMigrations(): void
4652
{
4753
$this->loadMigrationsFrom(__DIR__ . '/database/migrations');
4854
}
55+
56+
/**
57+
* Define routes setup.
58+
*
59+
* @param \Illuminate\Routing\Router $router
60+
*/
61+
protected function defineRoutes($router): void
62+
{
63+
$router
64+
->middleware('web')
65+
->group(function () use ($router) {
66+
$router
67+
->middleware(LocalizationByParameter::class)
68+
->get('path/{foo}/{locale?}', $this->jsonResponse())
69+
->name('via.parameter');
70+
71+
$router
72+
->middleware(LocalizationByParameterWithRedirect::class)
73+
->get('redirect/{foo}/{locale?}', $this->jsonResponse())
74+
->name('via.parameter.redirect');
75+
76+
$router
77+
->middleware(LocalizationByParameterWithRedirect::class)
78+
->get('not-named/redirect/{foo}/{locale?}', $this->jsonResponse());
79+
80+
$router
81+
->middleware(LocalizationByHeader::class)
82+
->get('header/{foo}', $this->jsonResponse())
83+
->name('via.header');
84+
85+
$router
86+
->middleware(LocalizationByCookie::class)
87+
->get('cookie/{foo}', $this->jsonResponse())
88+
->name('via.cookie');
89+
90+
$router
91+
->middleware(LocalizationBySession::class)
92+
->get('session/{foo}', $this->jsonResponse())
93+
->name('via.session');
94+
95+
$router
96+
->middleware(LocalizationByModel::class)
97+
->get('model/default/{foo}', $this->jsonResponse())
98+
->name('via.model.default');
99+
100+
$router
101+
->middleware(LocalizationByModel::class . ':foo')
102+
->get('model/guard/{foo}', $this->jsonResponse())
103+
->name('via.model.guard');
104+
105+
$router
106+
->middleware([
107+
LocalizationByParameter::class,
108+
LocalizationByParameterWithRedirect::class,
109+
LocalizationByHeader::class,
110+
LocalizationByCookie::class,
111+
LocalizationBySession::class,
112+
LocalizationByModel::class,
113+
])
114+
->get('clean/{foo}', $this->jsonResponse())
115+
->name('clean');
116+
});
117+
118+
$router->localizedGroup(function () use ($router) {
119+
$router
120+
->middleware('web')
121+
->get('group/macro/{foo}', $this->jsonResponse())
122+
->name('via.group.macro');
123+
});
124+
125+
LocalizationRoute::group(function () use ($router) {
126+
$router
127+
->middleware('web')
128+
->get('group/facade/{foo}', $this->jsonResponse())
129+
->name('via.group.facade');
130+
});
131+
}
132+
133+
protected function jsonResponse(): Closure
134+
{
135+
return fn (string $foo) => response()->json([
136+
$foo => __(LocaleValue::TranslationKey),
137+
]);
138+
}
49139
}

0 commit comments

Comments
 (0)