actingAs($this->user); $this->post(route('projects.create'), [ 'name' => 'test', ])->assertSessionHasNoErrors(); $this->assertDatabaseHas('projects', [ 'name' => 'test', ]); } public function test_see_projects_list(): void { $this->actingAs($this->user); $project = Project::factory()->create([ 'user_id' => $this->user->id, ]); $this->get(route('projects')) ->assertSee($project->name); } /** * @throws JsonException */ public function test_delete_project(): void { $this->actingAs($this->user); $project = Project::factory()->create([ 'user_id' => $this->user->id, ]); $this->delete(route('projects.delete', $project)) ->assertSessionHasNoErrors(); $this->assertDatabaseMissing('projects', [ 'id' => $project->id, ]); } /** * @throws JsonException */ public function test_edit_project(): void { $this->actingAs($this->user); $project = Project::factory()->create([ 'user_id' => $this->user->id, ]); $this->post(route('projects.update', $project), [ 'name' => 'new-name', ])->assertSessionHasNoErrors(); $this->assertDatabaseHas('projects', [ 'id' => $project->id, 'name' => 'new-name', ]); } }