1
1
<?php
2
2
3
- namespace CodeZero \LocalizedRoutes \Tests \Unit \Macros \Route ;
3
+ namespace CodeZero \LocalizedRoutes \Tests \Feature \Macros \Route ;
4
4
5
5
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 ;
10
9
use CodeZero \LocalizedRoutes \Tests \TestCase ;
11
10
use Illuminate \Database \Eloquent \ModelNotFoundException ;
12
11
use Illuminate \Support \Facades \App ;
@@ -24,17 +23,17 @@ public function it_generates_urls_with_default_localized_route_keys_for_the_curr
24
23
$ this ->withoutExceptionHandling ();
25
24
$ this ->setSupportedLocales (['en ' , 'nl ' ]);
26
25
27
- $ model = (new Model ([
26
+ $ model = (new ModelOneWithRouteBinding ([
28
27
'slug ' => [
29
28
'en ' => 'en-slug ' ,
30
29
'nl ' => 'nl-slug ' ,
31
30
],
32
31
]))->setKeyName ('slug ' );
33
32
34
- App::instance (Model ::class, $ model );
33
+ App::instance (ModelOneWithRouteBinding ::class, $ model );
35
34
36
35
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 ) {
38
37
return [
39
38
'current ' => Route::localizedUrl (),
40
39
'en ' => Route::localizedUrl ('en ' ),
@@ -58,25 +57,25 @@ public function it_generates_urls_for_the_current_route_with_different_models_us
58
57
$ this ->withoutExceptionHandling ();
59
58
$ this ->setSupportedLocales (['en ' , 'nl ' ]);
60
59
61
- $ foo = (new ModelFoo ([
60
+ $ foo = (new ModelOneWithRouteBinding ([
62
61
'slug ' => [
63
62
'en ' => 'en-slug-foo ' ,
64
63
'nl ' => 'nl-slug-foo ' ,
65
64
],
66
65
]))->setKeyName ('slug ' );
67
66
68
- $ bar = (new ModelBar ([
67
+ $ bar = (new ModelTwoWithRouteBinding ([
69
68
'slug ' => [
70
69
'en ' => 'en-slug-bar ' ,
71
70
'nl ' => 'nl-slug-bar ' ,
72
71
],
73
72
]))->setKeyName ('slug ' );
74
73
75
- App::instance (ModelFoo ::class, $ foo );
76
- App::instance (ModelBar ::class, $ bar );
74
+ App::instance (ModelOneWithRouteBinding ::class, $ foo );
75
+ App::instance (ModelTwoWithRouteBinding ::class, $ bar );
77
76
78
77
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 ) {
80
79
return [
81
80
'current ' => Route::localizedUrl (),
82
81
'en ' => Route::localizedUrl ('en ' ),
@@ -100,17 +99,17 @@ public function it_generates_urls_with_custom_localized_route_keys_for_the_curre
100
99
$ this ->withoutExceptionHandling ();
101
100
$ this ->setSupportedLocales (['en ' , 'nl ' ]);
102
101
103
- $ model = (new Model ([
102
+ $ model = (new ModelOneWithRouteBinding ([
104
103
'slug ' => [
105
104
'en ' => 'en-slug ' ,
106
105
'nl ' => 'nl-slug ' ,
107
106
],
108
107
]))->setKeyName ('id ' );
109
108
110
- App::instance (Model ::class, $ model );
109
+ App::instance (ModelOneWithRouteBinding ::class, $ model );
111
110
112
111
Route::localized (function () {
113
- Route::get ('route/{model:slug} ' , function (Model $ model ) {
112
+ Route::get ('route/{model:slug} ' , function (ModelOneWithRouteBinding $ model ) {
114
113
return [
115
114
'current ' => Route::localizedUrl (),
116
115
'en ' => Route::localizedUrl ('en ' ),
@@ -134,18 +133,18 @@ public function you_can_implement_an_interface_and_let_your_model_return_custom_
134
133
$ this ->withoutExceptionHandling ();
135
134
$ this ->setSupportedLocales (['en ' , 'nl ' ]);
136
135
137
- $ model = (new ModelWithCustomRouteParameters ([
136
+ $ model = (new ModelWithMultipleRouteParameters ([
138
137
'id ' => 1 ,
139
138
'slug ' => [
140
139
'en ' => 'en-slug ' ,
141
140
'nl ' => 'nl-slug ' ,
142
141
],
143
142
]))->setKeyName ('id ' );
144
143
145
- App::instance (ModelWithCustomRouteParameters ::class, $ model );
144
+ App::instance (ModelWithMultipleRouteParameters ::class, $ model );
146
145
147
146
Route::localized (function () {
148
- Route::get ('route/{model}/{slug} ' , function (ModelWithCustomRouteParameters $ model , $ slug ) {
147
+ Route::get ('route/{model}/{slug} ' , function (ModelWithMultipleRouteParameters $ model , $ slug ) {
149
148
return [
150
149
'current ' => Route::localizedUrl (),
151
150
'en ' => Route::localizedUrl ('en ' ),
@@ -169,14 +168,14 @@ public function it_cannot_guess_a_localized_route_key_without_route_model_bindin
169
168
$ this ->withoutExceptionHandling ();
170
169
$ this ->setSupportedLocales (['en ' , 'nl ' ]);
171
170
172
- $ model = (new Model ([
171
+ $ model = (new ModelOneWithRouteBinding ([
173
172
'slug ' => [
174
173
'en ' => 'en-slug ' ,
175
174
'nl ' => 'nl-slug ' ,
176
175
],
177
176
]))->setKeyName ('slug ' );
178
177
179
- App::instance (Model ::class, $ model );
178
+ App::instance (ModelOneWithRouteBinding ::class, $ model );
180
179
181
180
Route::localized (function () {
182
181
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
203
202
$ this ->withoutExceptionHandling ();
204
203
$ this ->setSupportedLocales (['en ' , 'nl ' ]);
205
204
206
- $ model = (new Model ([
205
+ $ model = (new ModelOneWithRouteBinding ([
207
206
'slug ' => [
208
207
'en ' => 'en-slug ' ,
209
208
'nl ' => 'nl-slug ' ,
210
209
],
211
210
]))->setKeyName ('slug ' );
212
211
213
- App::instance (Model ::class, $ model );
212
+ App::instance (ModelOneWithRouteBinding ::class, $ model );
214
213
215
214
Route::localized (function () use ($ model ) {
216
215
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
237
236
$ this ->withoutExceptionHandling ();
238
237
$ this ->setSupportedLocales (['en ' , 'nl ' ]);
239
238
240
- $ model = (new Model ([
239
+ $ model = (new ModelOneWithRouteBinding ([
241
240
'id ' => 1 ,
242
241
'slug ' => [
243
242
'en ' => 'en-slug ' ,
244
243
'nl ' => 'nl-slug ' ,
245
244
],
246
245
]))->setKeyName ('id ' );
247
246
248
- App::instance (Model ::class, $ model );
247
+ App::instance (ModelOneWithRouteBinding ::class, $ model );
249
248
250
249
Route::localized (function () use ($ model ) {
251
250
Route::get ('route/{id}/{slug} ' , function ($ id , $ slug ) use ($ model ) {
0 commit comments