@@ -97,6 +97,122 @@ public function you_can_configure_which_segment_to_use_as_locale()
9797 $ this ->assertEquals ('nl ' , $ response ->original );
9898 }
9999
100+ /** @test */
101+ public function it_looks_for_custom_slugs ()
102+ {
103+ $ this ->setSupportedLocales ([
104+ 'en ' => 'english ' ,
105+ 'nl ' => 'dutch ' ,
106+ 'fr ' => 'french ' ,
107+ ]);
108+ $ this ->setAppLocale ('en ' );
109+
110+ Route::get ('dutch/some/route ' , function () {
111+ return App::getLocale ();
112+ })->middleware (['web ' , SetLocale::class]);
113+
114+ $ response = $ this ->get ('dutch/some/route ' );
115+
116+ $ response ->assertSessionHas ($ this ->sessionKey , 'nl ' );
117+ $ response ->assertCookie ($ this ->cookieName , 'nl ' );
118+ $ this ->assertEquals ('nl ' , $ response ->original );
119+ }
120+
121+ /** @test */
122+ public function you_can_use_multiple_slugs_for_a_locale ()
123+ {
124+ $ this ->setSupportedLocales ([
125+ 'en ' => 'english ' ,
126+ 'nl ' => ['dutch ' , 'nederlands ' ],
127+ 'fr ' => 'french ' ,
128+ ]);
129+ $ this ->setAppLocale ('en ' );
130+
131+ Route::get ('dutch/some/route ' , function () {
132+ return App::getLocale ();
133+ })->middleware (['web ' , SetLocale::class]);
134+
135+ Route::get ('nederlands/some/route ' , function () {
136+ return App::getLocale ();
137+ })->middleware (['web ' , SetLocale::class]);
138+
139+ $ response = $ this ->get ('dutch/some/route ' );
140+
141+ $ response ->assertSessionHas ($ this ->sessionKey , 'nl ' );
142+ $ response ->assertCookie ($ this ->cookieName , 'nl ' );
143+ $ this ->assertEquals ('nl ' , $ response ->original );
144+
145+ $ response = $ this ->get ('nederlands/some/route ' );
146+
147+ $ response ->assertSessionHas ($ this ->sessionKey , 'nl ' );
148+ $ response ->assertCookie ($ this ->cookieName , 'nl ' );
149+ $ this ->assertEquals ('nl ' , $ response ->original );
150+ }
151+
152+ /** @test */
153+ public function it_looks_for_custom_domains ()
154+ {
155+ $ this ->setSupportedLocales ([
156+ 'en ' => 'english.test ' ,
157+ 'nl ' => 'dutch.test ' ,
158+ 'fr ' => 'french.test ' ,
159+ ]);
160+ $ this ->setAppLocale ('en ' );
161+
162+ Route::group ([
163+ 'domain ' => 'dutch.test ' ,
164+ ], function () {
165+ Route::get ('some/route ' , function () {
166+ return App::getLocale ();
167+ })->middleware (['web ' , SetLocale::class]);
168+ });
169+
170+ $ response = $ this ->get ('http://dutch.test/some/route ' );
171+
172+ $ response ->assertSessionHas ($ this ->sessionKey , 'nl ' );
173+ $ response ->assertCookie ($ this ->cookieName , 'nl ' );
174+ $ this ->assertEquals ('nl ' , $ response ->original );
175+ }
176+
177+ /** @test */
178+ public function you_can_use_multiple_domains_for_a_locale ()
179+ {
180+ $ this ->setSupportedLocales ([
181+ 'en ' => 'english.test ' ,
182+ 'nl ' => ['dutch.test ' , 'nederlands.test ' ],
183+ 'fr ' => 'french.test ' ,
184+ ]);
185+ $ this ->setAppLocale ('en ' );
186+
187+ Route::group ([
188+ 'domain ' => 'dutch.test ' ,
189+ ], function () {
190+ Route::get ('some/route ' , function () {
191+ return App::getLocale ();
192+ })->middleware (['web ' , SetLocale::class]);
193+ });
194+
195+ Route::group ([
196+ 'domain ' => 'nederlands.test ' ,
197+ ], function () {
198+ Route::get ('some/route ' , function () {
199+ return App::getLocale ();
200+ })->middleware (['web ' , SetLocale::class]);
201+ });
202+
203+ $ response = $ this ->get ('http://dutch.test/some/route ' );
204+
205+ $ response ->assertSessionHas ($ this ->sessionKey , 'nl ' );
206+ $ response ->assertCookie ($ this ->cookieName , 'nl ' );
207+ $ this ->assertEquals ('nl ' , $ response ->original );
208+
209+ $ response = $ this ->get ('http://nederlands.test/some/route ' );
210+
211+ $ response ->assertSessionHas ($ this ->sessionKey , 'nl ' );
212+ $ response ->assertCookie ($ this ->cookieName , 'nl ' );
213+ $ this ->assertEquals ('nl ' , $ response ->original );
214+ }
215+
100216 /** @test */
101217 public function it_checks_for_a_configured_omitted_locale ()
102218 {
0 commit comments