-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"actingAs" helper is broken in unit tests #22808
Comments
I think we need two properties for the |
Yes, this commit should be reverted soon as it likely breaks many unit tests. |
Could someone create a failing tests for this (Laravel does have Integration tests) to mimick the issues. Would really benefit to see when and why it broken. I'm using |
@crynobone default guards are not using When sending an internal request from the tests, Laravel creates HttpKernel instance and send request to it: trait MakesHttpRequests
{
public function call($method, $uri, $parameters = [], $cookies = [], $files = [], $server = [], $content = null)
{
$kernel = $this->app->make(HttpKernel::class);
...
// This invoke rebind `request` in app container and RequestGuard set user to null
$response = $kernel->handle(
$request = Request::createFromBase($symfonyRequest)
);
...
return $this->createTestResponse($response);
} |
So wouldn't it make more sense to try to fix |
@crynobone in this case, we need to come up with a new way to authorize in tests. I need to write tests and have to come up with something to solve this problem. |
I already writen a testcase for Without proper tests that cover above scenarios anyone might redo the same mistake of sending similar PR and it still going to return green. To bad if you guys don't see the benefits of adding test to prevent regression bug. |
Description:
In unit tests, the user is reset to null even after using the
actingAs
method when performing a simulated request with theget
method.See: #22649
The text was updated successfully, but these errors were encountered: