create(); $this->faculty = Faculty::factory()->create(); $this->data = Faculty::factory()->make()->only([ 'position', 'name', 'description', 'slug', 'educational_institution_id', ]); $this->department = Department::factory()->create(); $this->user = User::factory()->create([ 'name' => 'admin', 'email' => 'test@example.com', 'password' => 123456 ]); } public function testIndexFacultiesPage(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->get(route('faculties.index')); $response->assertOk(); } public function testCreateFacultyPage(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->get(route('faculties.create')); $response->assertOk(); } public function testStoreFaculty(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->post(route('faculties.store', $this->data)); $response->assertRedirect(route('faculties.index')); $this->assertDatabaseHas('faculties', $this->data); } public function testShowFacultyPage(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->get(route('faculties.show', $this->faculty)); $response->assertOk(); } public function testEditFacultyPage(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->get(route('faculties.edit', $this->faculty)); $response->assertOk(); } public function testUpdateFaculty(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->patch(route('faculties.update', $this->faculty), $this->data); $response->assertRedirect(route('faculties.index')); $this->assertDatabaseHas('faculties', $this->data); } public function testDestroyFaculty(): void { $this->department->delete(); $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->delete(route('faculties.destroy', $this->faculty)); $response->assertRedirect(route('faculties.index')); $this->assertDatabaseMissing('faculties', $this->faculty->toArray()); } }