@@ -25,6 +25,11 @@ protected function getPackageAliases($app)
25
25
];
26
26
}
27
27
28
+ public function setUp (): void
29
+ {
30
+ parent ::setUp ();
31
+ }
32
+
28
33
/**
29
34
* Set routes for testing.
30
35
*
@@ -109,10 +114,10 @@ protected function createRequest(
109
114
return $ request ->createFromBase (
110
115
\Symfony \Component \HttpFoundation \Request::create (
111
116
$ uri ,
112
- $ method ,
113
- $ parameters ,
114
- $ cookies ,
115
- $ files ,
117
+ ' GET ' ,
118
+ [] ,
119
+ [] ,
120
+ [] ,
116
121
$ server ,
117
122
$ content
118
123
)
@@ -168,22 +173,6 @@ public function testSetLocale()
168
173
$ this ->assertEquals ('en ' , app ('laravellocalization ' )->getCurrentLocale ());
169
174
}
170
175
171
- // LaravelLocalization setLocale method should return the locale of
172
- // the request uri (if any). This behavior should be independet
173
- // of the `hideDefaultLocaleInURL` setting
174
- public function testHideDefaultLocaleInUrlShouldNotChangeSetLocaleBehaviour ()
175
- {
176
- app ('config ' )->set ('laravellocalization.hideDefaultLocaleInURL ' , true );
177
-
178
- app ()['request ' ] = $ this ->createRequest (
179
- $ uri = '/en/test '
180
- );
181
-
182
- $ laravelLocalization = new \Mcamara \LaravelLocalization \LaravelLocalization ();
183
-
184
- $ this ->assertEquals ('en ' , $ laravelLocalization ->setLocale ());
185
- }
186
-
187
176
public function testLocalizeURL ()
188
177
{
189
178
$ this ->assertEquals (
@@ -336,6 +325,22 @@ public function testGetLocalizedURL()
336
325
);
337
326
}
338
327
328
+ public function testGetLocalizedURLWithQueryStringAndhideDefaultLocaleInURL ()
329
+ {
330
+ app ('config ' )->set ('laravellocalization.hideDefaultLocaleInURL ' , true );
331
+ app ()['request ' ] = $ this ->createRequest (
332
+ $ uri = 'en/about?q=2 '
333
+ );
334
+ $ laravelLocalization = new \Mcamara \LaravelLocalization \LaravelLocalization ();
335
+ $ laravelLocalization ->transRoute ('LaravelLocalization::routes.about ' );
336
+
337
+ $ this ->assertEquals (
338
+ $ this ->test_url . 'about?q=2 ' ,
339
+ $ laravelLocalization ->getLocalizedURL ()
340
+ );
341
+ }
342
+
343
+
339
344
/**
340
345
* @param string $path
341
346
* @param string|bool $expectedRouteName
0 commit comments