Level 47
you can use ->assertDatabaseHas to check if it is created or not check the docs for more info
i want to write a test for my comment model but for making that the user must be logged in i want to know how people write create tests in laravel because when i make it with the below method :
$file = UploadedFile::fake()->create('image.jpg');
$data = [
'title' => $this->faker->word,
'link' => $this->faker->url,
'image' => $file,
];
$employee = factory(User::class)->create();
$this
->actingAs($employee, 'admin')
->post(route('admin.carousel.store'), $data)
->assertStatus(302)
->assertRedirect(route('admin.carousel.index'))
->assertSessionHas('message', 'Create carousel successful!');
and when i make it with the below command i cant understand really if its created or not :
$this->actingAs($user);
$this->createMock(Comment::class);
so i really want to know how to check the creation of the model in laravel .
Please or to participate in this conversation.