I have such test:
public function testUpdate()
{
$user = factory(User::class)->create([
'id' => 1,
'role_id' => 1,
]);
factory(User::class)->create([
'id' => 2,
'username' => 'Test_username',
]);
$this->patch('/api/users/2', [
'username' => 'Test',
'profile' => [
[
'bio' => 'Test_bio',
],
],
], ['authorization' => "Bearer {$user->api_token}"])->assertJson([
'username' => 'Test',
]);
$this->get('/api/users/2?fields=*,profiles.*', [
'accept' => 'application/json',
])->assertJson([
'username' => 'Test',
'profile' => [
[
'bio' => 'Test_bio',
],
],
]);
}
It's test update for user and relatinhipmodel profile. But I have error:
1) Tests\Feature\Controllers\UserTest::testUpdate
Symfony\Component\Debug\Exception\FatalThrowableError: Method name must be a string
Method update work, I test it manually on Postman and frontend. Problem in test code.
Aucun commentaire:
Enregistrer un commentaire