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
With a basic installation of laravel and passport, when I run a basic test of the default route, it fails with a different response status than the one expected.
$ ./vendor/bin/phpunit
PHPUnit 7.3.5 by Sebastian Bergmann and contributors.
.F 2 / 2 (100%)
Time: 703 ms, Memory: 22.00MB
There was 1 failure:
1) Tests\Feature\ExampleTest::testBasicTest
Expected status code 200 but received 201.
Failed asserting that false is true.
FAILURES!
Tests: 2, Assertions: 2, Failures: 1.
If I replace the $request->user() by something else, it works.
Route::middleware('auth:api')->get('/user', function (Request$request, User$user) {
return$user->find($request->user()->id);
// return $request->user();
});
$ ./vendor/bin/phpunit
PHPUnit 7.3.5 by Sebastian Bergmann and contributors.
.. 2 / 2 (100%)
Time: 328 ms, Memory: 22.00MB
OK (2 tests, 2 assertions)
It behaves that way in the test and correctly when call with a http client.
The text was updated successfully, but these errors were encountered:
A user was created, so laravel attaches a 201 created by default.
When you perform another query as in your second example, to retrieve the user from the database, it is no longer a newly created model.
Description:
With a basic installation of laravel and passport, when I run a basic test of the default route, it fails with a different response status than the one expected.
Steps To Reproduce:
If I replace the $request->user() by something else, it works.
It behaves that way in the test and correctly when call with a http client.
The text was updated successfully, but these errors were encountered: