tengo este metodo del controlador de usuarios:
public function store(Request $request)
{
//
User::create($request->all());
//return response()->json(null,200);
}
La ruta es un resource
:
Route::resource('user', UserController::class);
Y el test
que le estoy implementando es el siguiente:
public function testUserCreate()
{
$faker = Factory::create();
$data = [
'name'=>$faker->name(),
'email'=>$faker->email(),
'password'=>$faker->password()
];
$reponse = $this->post('user',$data);
$reponse->assertStatus(200);
}
El resultado que obtengo es:
FAIL Tests\Feature\UserTest
⨯ user create
---
• Tests\Feature\UserTest > user create
Expected status code 200 but received 500.
Failed asserting that 200 is identical to 500.
at proyecto\tests\Feature\UserTest.php:28
24▕ 'email'=>$faker->email(),
25▕ 'password'=>$faker->password()
26▕ ];
27▕ $reponse = $this->post('user',$data);
➜ 28▕ $reponse->assertStatus(200);
29▕
30▕ }
31▕ }
32▕
1 proyecto\vendor\phpunit\phpunit\phpunit:61
PHPUnit\TextUI\Command::main()
Tests: 1 failed
Time: 0.52s
El tema es que no deberia fallar eso, pero no se porque me da error 500 en vez de 200