You say the Update is NOT done and the result is false how do you expect it to be true when the update is NOT done?
Jan 13, 2022
9
Level 63
Livewire test for an update do not work ?
Hello,
I'm trying Livewire tests, but I'm lost.
The update is not done and the result is false.
What is wrong in my code ?
/** @test */
public function admin_can_update()
{
$user = User::where('admin', true)->first();
$this->actingAs($user);
$author = Author::
where('firstname', 'Nom')
->where('lastname', 'Prénom')
->where('website', 'https://www.nom-prenom.fr/')
->first();
Livewire::test(AdminAuthorForm::class, ['author' => $author])
->set('updateMode', true)
->set('author.firstname', 'Mon nom')
->set('author.lastname', 'Mon prénom')
->set('author.website', 'https://www.nomprenom.fr/')
->call('save');
$result = Author::
where('firstname', 'Mon nom')
->where('lastname', 'Mon prénom')
->where('website', 'https://www.nomprenom.fr/')
->exists();
$this->assertTrue($result);
}
Thanks for your help ;).
Level 73
@vincent15000 try instead of ->first() use ->firstOrFail() and tell me if it blows up or it works ?
You tried dd() in the test or in the browser?
Do you have $author in the mount() method as a param, or just as a property? Try setting it:
Livewire::test(AdminAuthorForm::class, ['author' => $author])
->set('author', $author)..
Seeing just your test is hard to say what could be wrong, but there are tons of ways to debug this.
1 like
Please or to participate in this conversation.