Skip to content

Commit 6f9e9cc

Browse files
committed
Restructure tests
1 parent dd0545c commit 6f9e9cc

16 files changed

+207
-316
lines changed

phpunit.xml.dist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
<testsuite name="Unit">
1313
<directory suffix="Test.php">./tests/Unit</directory>
1414
</testsuite>
15+
<testsuite name="Feature">
16+
<directory suffix="Test.php">./tests/Feature</directory>
17+
</testsuite>
1518
</testsuites>
1619
<filter>
1720
<whitelist processUncoveredFilesFromWhitelist="true">

tests/Unit/Macros/Route/IsLocalizedMacroTest.php renamed to tests/Feature/Macros/Route/IsLocalizedMacroTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace CodeZero\LocalizedRoutes\Tests\Unit\Macros\Route;
3+
namespace CodeZero\LocalizedRoutes\Tests\Feature\Macros\Route;
44

55
use CodeZero\LocalizedRoutes\Tests\TestCase;
66
use Illuminate\Support\Facades\Route;

tests/Unit/Macros/Route/LocalizedMacroTest.php renamed to tests/Feature/Macros/Route/LocalizedMacroTest.php

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace CodeZero\LocalizedRoutes\Tests\Unit\Macros\Route;
3+
namespace CodeZero\LocalizedRoutes\Tests\Feature\Macros\Route;
44

55
use CodeZero\LocalizedRoutes\Tests\TestCase;
66
use Illuminate\Support\Facades\Config;
@@ -243,40 +243,4 @@ public function it_uses_scoped_config_options()
243243
$this->assertEquals('en.scoped', $route->action['as']);
244244
$this->assertEquals('with-scoped-config', $route->uri);
245245
}
246-
247-
/** @test */
248-
public function it_creates_localized_routes_within_route_groups()
249-
{
250-
$this->setSupportedLocales(['en', 'nl']);
251-
252-
Route::group([
253-
'as' => 'admin.',
254-
'prefix' => 'admin'
255-
], function () {
256-
Route::localized(function () {
257-
Route::get('route', function () {})
258-
->name('route.name');
259-
});
260-
});
261-
262-
$routes = $this->getRoutes();
263-
$domains = $routes->pluck('action.domain');
264-
$names = $routes->pluck('action.as');
265-
$uris = $routes->pluck('uri');
266-
267-
// Verify that no custom domains are registered.
268-
$this->assertTrue($domains->filter()->isEmpty());
269-
270-
$this->assertNotContains('admin.route.name', $names);
271-
$this->assertContains('admin.en.route.name', $names);
272-
$this->assertContains('admin.nl.route.name', $names);
273-
274-
$this->assertNotContains('admin/route', $uris);
275-
$this->assertContains('admin/en/route', $uris);
276-
$this->assertContains('admin/nl/route', $uris);
277-
278-
$this->call('GET', '/admin/route')->assertNotFound();
279-
$this->call('GET', '/admin/en/route')->assertOk();
280-
$this->call('GET', '/admin/nl/route')->assertOk();
281-
}
282246
}

tests/Unit/Macros/Route/LocalizedUrlMacroTest.php renamed to tests/Feature/Macros/Route/LocalizedUrlMacroTest.php

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
<?php
22

3-
namespace CodeZero\LocalizedRoutes\Tests\Unit\Macros\Route;
3+
namespace CodeZero\LocalizedRoutes\Tests\Feature\Macros\Route;
44

55
use CodeZero\LocalizedRoutes\Middleware\SetLocale;
6-
use CodeZero\LocalizedRoutes\Tests\Stubs\Model;
7-
use CodeZero\LocalizedRoutes\Tests\Stubs\ModelBar;
8-
use CodeZero\LocalizedRoutes\Tests\Stubs\ModelFoo;
9-
use CodeZero\LocalizedRoutes\Tests\Stubs\ModelWithCustomRouteParameters;
6+
use CodeZero\LocalizedRoutes\Tests\Stubs\Models\ModelOneWithRouteBinding;
7+
use CodeZero\LocalizedRoutes\Tests\Stubs\Models\ModelTwoWithRouteBinding;
8+
use CodeZero\LocalizedRoutes\Tests\Stubs\Models\ModelWithMultipleRouteParameters;
109
use CodeZero\LocalizedRoutes\Tests\TestCase;
1110
use Illuminate\Database\Eloquent\ModelNotFoundException;
1211
use Illuminate\Support\Facades\App;
@@ -24,17 +23,17 @@ public function it_generates_urls_with_default_localized_route_keys_for_the_curr
2423
$this->withoutExceptionHandling();
2524
$this->setSupportedLocales(['en', 'nl']);
2625

27-
$model = (new Model([
26+
$model = (new ModelOneWithRouteBinding([
2827
'slug' => [
2928
'en' => 'en-slug',
3029
'nl' => 'nl-slug',
3130
],
3231
]))->setKeyName('slug');
3332

34-
App::instance(Model::class, $model);
33+
App::instance(ModelOneWithRouteBinding::class, $model);
3534

3635
Route::localized(function () {
37-
Route::get('route/{first}/{second}', function (Model $first, Model $second) {
36+
Route::get('route/{first}/{second}', function (ModelOneWithRouteBinding $first, ModelOneWithRouteBinding $second) {
3837
return [
3938
'current' => Route::localizedUrl(),
4039
'en' => Route::localizedUrl('en'),
@@ -58,25 +57,25 @@ public function it_generates_urls_for_the_current_route_with_different_models_us
5857
$this->withoutExceptionHandling();
5958
$this->setSupportedLocales(['en', 'nl']);
6059

61-
$foo = (new ModelFoo([
60+
$foo = (new ModelOneWithRouteBinding([
6261
'slug' => [
6362
'en' => 'en-slug-foo',
6463
'nl' => 'nl-slug-foo',
6564
],
6665
]))->setKeyName('slug');
6766

68-
$bar = (new ModelBar([
67+
$bar = (new ModelTwoWithRouteBinding([
6968
'slug' => [
7069
'en' => 'en-slug-bar',
7170
'nl' => 'nl-slug-bar',
7271
],
7372
]))->setKeyName('slug');
7473

75-
App::instance(ModelFoo::class, $foo);
76-
App::instance(ModelBar::class, $bar);
74+
App::instance(ModelOneWithRouteBinding::class, $foo);
75+
App::instance(ModelTwoWithRouteBinding::class, $bar);
7776

7877
Route::localized(function () {
79-
Route::get('route/{foo}/{bar}', function (ModelFoo $foo, ModelBar $bar) {
78+
Route::get('route/{foo}/{bar}', function (ModelOneWithRouteBinding $foo, ModelTwoWithRouteBinding $bar) {
8079
return [
8180
'current' => Route::localizedUrl(),
8281
'en' => Route::localizedUrl('en'),
@@ -100,17 +99,17 @@ public function it_generates_urls_with_custom_localized_route_keys_for_the_curre
10099
$this->withoutExceptionHandling();
101100
$this->setSupportedLocales(['en', 'nl']);
102101

103-
$model = (new Model([
102+
$model = (new ModelOneWithRouteBinding([
104103
'slug' => [
105104
'en' => 'en-slug',
106105
'nl' => 'nl-slug',
107106
],
108107
]))->setKeyName('id');
109108

110-
App::instance(Model::class, $model);
109+
App::instance(ModelOneWithRouteBinding::class, $model);
111110

112111
Route::localized(function () {
113-
Route::get('route/{model:slug}', function (Model $model) {
112+
Route::get('route/{model:slug}', function (ModelOneWithRouteBinding $model) {
114113
return [
115114
'current' => Route::localizedUrl(),
116115
'en' => Route::localizedUrl('en'),
@@ -134,18 +133,18 @@ public function you_can_implement_an_interface_and_let_your_model_return_custom_
134133
$this->withoutExceptionHandling();
135134
$this->setSupportedLocales(['en', 'nl']);
136135

137-
$model = (new ModelWithCustomRouteParameters([
136+
$model = (new ModelWithMultipleRouteParameters([
138137
'id' => 1,
139138
'slug' => [
140139
'en' => 'en-slug',
141140
'nl' => 'nl-slug',
142141
],
143142
]))->setKeyName('id');
144143

145-
App::instance(ModelWithCustomRouteParameters::class, $model);
144+
App::instance(ModelWithMultipleRouteParameters::class, $model);
146145

147146
Route::localized(function () {
148-
Route::get('route/{model}/{slug}', function (ModelWithCustomRouteParameters $model, $slug) {
147+
Route::get('route/{model}/{slug}', function (ModelWithMultipleRouteParameters $model, $slug) {
149148
return [
150149
'current' => Route::localizedUrl(),
151150
'en' => Route::localizedUrl('en'),
@@ -169,14 +168,14 @@ public function it_cannot_guess_a_localized_route_key_without_route_model_bindin
169168
$this->withoutExceptionHandling();
170169
$this->setSupportedLocales(['en', 'nl']);
171170

172-
$model = (new Model([
171+
$model = (new ModelOneWithRouteBinding([
173172
'slug' => [
174173
'en' => 'en-slug',
175174
'nl' => 'nl-slug',
176175
],
177176
]))->setKeyName('slug');
178177

179-
App::instance(Model::class, $model);
178+
App::instance(ModelOneWithRouteBinding::class, $model);
180179

181180
Route::localized(function () {
182181
Route::get('route/{slug}', function ($slug) {
@@ -203,14 +202,14 @@ public function you_can_pass_it_a_model_with_a_localized_route_key_without_route
203202
$this->withoutExceptionHandling();
204203
$this->setSupportedLocales(['en', 'nl']);
205204

206-
$model = (new Model([
205+
$model = (new ModelOneWithRouteBinding([
207206
'slug' => [
208207
'en' => 'en-slug',
209208
'nl' => 'nl-slug',
210209
],
211210
]))->setKeyName('slug');
212211

213-
App::instance(Model::class, $model);
212+
App::instance(ModelOneWithRouteBinding::class, $model);
214213

215214
Route::localized(function () use ($model) {
216215
Route::get('route/{slug}', function ($slug) use ($model) {
@@ -237,15 +236,15 @@ public function you_can_pass_it_a_closure_that_returns_the_parameters_without_ro
237236
$this->withoutExceptionHandling();
238237
$this->setSupportedLocales(['en', 'nl']);
239238

240-
$model = (new Model([
239+
$model = (new ModelOneWithRouteBinding([
241240
'id' => 1,
242241
'slug' => [
243242
'en' => 'en-slug',
244243
'nl' => 'nl-slug',
245244
],
246245
]))->setKeyName('id');
247246

248-
App::instance(Model::class, $model);
247+
App::instance(ModelOneWithRouteBinding::class, $model);
249248

250249
Route::localized(function () use ($model) {
251250
Route::get('route/{id}/{slug}', function ($id, $slug) use ($model) {

tests/Unit/Middleware/SetLocaleTest.php renamed to tests/Feature/Middleware/SetLocaleTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace CodeZero\LocalizedRoutes\Tests\Unit\Middleware;
3+
namespace CodeZero\LocalizedRoutes\Tests\Feature\Middleware;
44

55
use CodeZero\LocalizedRoutes\Middleware\SetLocale;
66
use CodeZero\LocalizedRoutes\Tests\TestCase;

tests/Unit/RedirectToLocalizedTest.php renamed to tests/Feature/RedirectToLocalizedTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace CodeZero\LocalizedRoutes\Tests\Unit;
3+
namespace CodeZero\LocalizedRoutes\Tests\Feature;
44

55
use CodeZero\LocalizedRoutes\Tests\TestCase;
66
use Illuminate\Support\Facades\Route;

tests/Unit/RouteModelBindingTest.php renamed to tests/Feature/RouteModelBindingTest.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?php
22

3-
namespace CodeZero\LocalizedRoutes\Tests\Unit;
3+
namespace CodeZero\LocalizedRoutes\Tests\Feature;
44

55
use CodeZero\LocalizedRoutes\Middleware\SetLocale;
66
use Illuminate\Support\Facades\App;
77
use Illuminate\Support\Facades\Route;
88
use CodeZero\LocalizedRoutes\Tests\TestCase;
9-
use CodeZero\LocalizedRoutes\Tests\Stubs\Model;
9+
use CodeZero\LocalizedRoutes\Tests\Stubs\Models\ModelOneWithRouteBinding;
1010

1111
class RouteModelBindingTest extends TestCase
1212
{
@@ -15,20 +15,20 @@ public function it_loads_a_route_with_a_localized_route_key_based_on_the_active_
1515
{
1616
$this->setSupportedLocales(['en', 'nl']);
1717

18-
$model = (new Model([
18+
$model = (new ModelOneWithRouteBinding([
1919
'slug' => [
2020
'en' => 'en-slug',
2121
'nl' => 'nl-slug',
2222
],
2323
]))->setKeyName('slug');
2424

25-
App::instance(Model::class, $model);
25+
App::instance(ModelOneWithRouteBinding::class, $model);
2626

27-
Route::get('test/{model}', function (Model $model) {})
27+
Route::get('test/{model}', function (ModelOneWithRouteBinding $model) {})
2828
->middleware(['web']);
2929

3030
Route::localized(function () {
31-
Route::get('test/{model}', function (Model $model) {})
31+
Route::get('test/{model}', function (ModelOneWithRouteBinding $model) {})
3232
->middleware(['web', SetLocale::class]);
3333
});
3434

@@ -49,20 +49,20 @@ public function it_loads_a_route_with_a_custom_localized_route_key_based_on_the_
4949
{
5050
$this->setSupportedLocales(['en', 'nl']);
5151

52-
$model = (new Model([
52+
$model = (new ModelOneWithRouteBinding([
5353
'slug' => [
5454
'en' => 'en-slug',
5555
'nl' => 'nl-slug',
5656
],
5757
]))->setKeyName('id');
5858

59-
App::instance(Model::class, $model);
59+
App::instance(ModelOneWithRouteBinding::class, $model);
6060

61-
Route::get('test/{model:slug}', function (Model $model) {})
61+
Route::get('test/{model:slug}', function (ModelOneWithRouteBinding $model) {})
6262
->middleware(['web']);
6363

6464
Route::localized(function () {
65-
Route::get('test/{model:slug}', function (Model $model) {})
65+
Route::get('test/{model:slug}', function (ModelOneWithRouteBinding $model) {})
6666
->middleware(['web', SetLocale::class]);
6767
});
6868

@@ -86,20 +86,20 @@ public function it_loads_a_route_with_a_localized_route_key_with_custom_slugs()
8686
'nl' => 'dutch',
8787
]);
8888

89-
$model = (new Model([
89+
$model = (new ModelOneWithRouteBinding([
9090
'slug' => [
9191
'en' => 'en-slug',
9292
'nl' => 'nl-slug',
9393
],
9494
]))->setKeyName('slug');
9595

96-
App::instance(Model::class, $model);
96+
App::instance(ModelOneWithRouteBinding::class, $model);
9797

98-
Route::get('test/{model}', function (Model $model) {})
98+
Route::get('test/{model}', function (ModelOneWithRouteBinding $model) {})
9999
->middleware(['web']);
100100

101101
Route::localized(function () {
102-
Route::get('test/{model}', function (Model $model) {})
102+
Route::get('test/{model}', function (ModelOneWithRouteBinding $model) {})
103103
->middleware(['web', SetLocale::class]);
104104
});
105105

tests/Stubs/Kernel.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,6 @@
66

77
class Kernel extends HttpKernel
88
{
9-
/**
10-
* The application's global HTTP middleware stack.
11-
*
12-
* These middleware are run during every request to your application.
13-
*
14-
* @var array
15-
*/
16-
protected $middleware = [];
17-
189
/**
1910
* The application's route middleware groups.
2011
*
@@ -31,15 +22,6 @@ class Kernel extends HttpKernel
3122
],
3223
];
3324

34-
/**
35-
* The application's route middleware.
36-
*
37-
* These middleware may be assigned to groups or used individually.
38-
*
39-
* @var array
40-
*/
41-
protected $routeMiddleware = [];
42-
4325
/**
4426
* The priority-sorted list of middleware.
4527
*

0 commit comments

Comments
 (0)