I am using the package Laravel Localization.
The package loads the prefix in the routes file
Route::group(['prefix' => LaravelLocalization::setLocale()], function(){
Route::get('/', 'HomeController@index');
// ..
});
If one accesses mydomain.net/de/article, through the browser then LaravelLocalization::setLocale() returns de and thus the route exists.
However, when I do a simple feature test like this:
$response = $this->get('/de/article');
$response->assertStatus(200);
Then the route is not found:
Expected status code 200 but received 404. Failed asserting that false is true.
I already noticed that the method LaravelLocalization::setLocale() determines the locale on this line
$locale = $this->request->segment(1);
And it seems that on the feature test $this->request->segment(1); is null. In fact, if I dump $this->request then it returns
"REQUEST_METHOD" => "GET"
"REQUEST_URI" => "/"
as parameters (when calling with phpunit).
The request is saved in the __construct method of the singleton LaravelLocalization like this:
$this->app = app();
$this->request = $this->app['request'];
Why is the request uri empty when I call it with phpunit? How may I get the correct request_uri?
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2Q0TPij
via IFTTT
Aucun commentaire:
Enregistrer un commentaire