After upgrade from Lumen 5.5 to Lumen 5.6, all tets that uses traits with "this->artisan" call are broken.
In this line Request is saved with Request namespace string (Request::class):
/lumen-framework/src/Concerns/RoutesRequests.php:182
And here is retrieved with literal string 'request':
/lumen-framework/src/Concerns/RoutesRequests.php:182
I'm using the trait "DatabaseMigrations". I put a "breakpoint" in $this->artisan() call on DatabaseMigrations code:
public function runDatabaseMigrations()
{
**$this->artisan('migrate:fresh');**
$this->app[Kernel::class]->setArtisan(null);
$this->beforeApplicationDestroyed(function () {
$this->artisan('migrate:rollback');
RefreshDatabaseState::$migrated = false;
});
}
Before the call , app('request') returns valid Request with all headers, after this call, app('request') is creating a new Request because can't resolve 'request' as an alias from Request:class.
Break point in the same line on LUmen 5.5 seems works well (app('request') always returns valid Request object).
I can confirm this issue.
I wanted to upgrade to Lumen 5.6 and I'm experiencing the same issues in test.
Still haven't found a solution
I experienced the same issue. I think the problem is the newly added setRequestForConsole function in Kernel, which registers the request class in the container again.
In my case HTTP_Authorization doesn't properly translate into the request. Works in version 5.5, in fact I reversed to 5.5 due to this error.
$response = $this->call('GET', API_V1 . '/client/workout/routine', $data, [], [], [
'HTTP_Authorization' => "Bearer {$this->user->token}"
]);
This occurs on version 5.6.2 and reverting to 5.6.1.
Problem is that setRequestForConsole strips down request made from tests and places request object thats later used in MakesHttpRequest.php file.
Temporary solution: revert to 5.6.1 version
As far as I could see, there is already a merged pull request regarding this issue.
Most helpful comment
This occurs on version 5.6.2 and reverting to 5.6.1.
Problem is that setRequestForConsole strips down request made from tests and places request object thats later used in MakesHttpRequest.php file.
Temporary solution: revert to 5.6.1 version