educationalInstitution = EducationalInstitution::factory()->create(); $this->data = EducationalInstitution::factory()->make()->only([ 'position', 'name', 'description', 'slug', ]); $this->faculty = Faculty::factory()->create(); $this->user = User::factory()->create([ 'name' => 'admin', 'email' => 'test@example.com', 'password' => 123456 ]); } public function testIndexEducationalInstitutionsPage(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->get(route('educational_institutions.index')); $response->assertOk(); } public function testCreateEducationalInstitutionPage(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->get(route('educational_institutions.create')); $response->assertOk(); } public function testStoreEducationalInstitution(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->post(route('educational_institutions.store', $this->data)); $response->assertRedirect(route('educational_institutions.index')); $this->assertDatabaseHas('educational_institutions', $this->data); } public function testShowEducationalInstitutionPage(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->get(route('educational_institutions.show', $this->educationalInstitution)); $response->assertOk(); } public function testEditEducationalInstitutionPage(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->get(route('educational_institutions.edit', $this->educationalInstitution)); $response->assertOk(); } public function testUpdateEducationalInstitution(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->patch(route('educational_institutions.update', $this->educationalInstitution), $this->data); $response->assertRedirect(route('educational_institutions.index')); $this->assertDatabaseHas('educational_institutions', $this->data); } public function testDestroyFaculty(): void { $this->faculty->delete(); $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->delete(route('educational_institutions.destroy', $this->educationalInstitution)); $response->assertRedirect(route('educational_institutions.index')); $this->assertDatabaseMissing('educational_institutions', $this->educationalInstitution->toArray()); } }