Andy.PB
Testing - get created record
I don´t know how to retrieve the created record id, so I simply assume which record was created and load the model for further testing:
Livewire::actingAs($user)
->test(ArticleCreate::class)
->fill($data)
->call('create')
->assertHasNoFormErrors()
->assertStatus(200)
->assertSessionHas('success', 'Article created successfully.')
->assertRedirect('/article/1');
$this->assertDatabaseCount('articles', 1);
$article = Article::find(1);
3 replies