You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+60-15Lines changed: 60 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -589,32 +589,77 @@ To localize your post url see the example in [POST is not working](#post-is-not-
589
589
590
590
## Testing
591
591
592
-
During the test setup, the called route is not yet known. This means no language can be set.
593
-
When a request is made during a test, this results in a 404 - without the prefix set the localized route does not seem to exist.
592
+
In a typical request lifecycle, your application is bootstrapped automatically — allowing this package to detect the active route and set the appropriate locale.
593
+
However, when running tests, the application is bootstrapped before any request is made. As a result, the package can’t determine the current route, which often leads to a `404` error.
594
594
595
-
To fix this, you can use this function to manually set the language prefix:
595
+
To handle this, you can manually define the locale prefix in your tests by refreshing the application with a specific locale:
596
+
597
+
### PHPUnit
596
598
```php
597
-
// TestCase.php
598
-
protected function refreshApplicationWithLocale($locale)
599
+
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
600
+
use Mcamara\LaravelLocalization\LaravelLocalization;
0 commit comments