11<?php
22
3- namespace CodeZero \LocalizedRoutes \Tests \Unit \Macros \Route ;
3+ namespace CodeZero \LocalizedRoutes \Tests \Feature \Macros \Route ;
44
55use 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 ;
109use CodeZero \LocalizedRoutes \Tests \TestCase ;
1110use Illuminate \Database \Eloquent \ModelNotFoundException ;
1211use 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 ) {
0 commit comments