create(); Faculty::factory()->create(); Department::factory()->create(); $this->level = EducationLevel::factory()->create(); $this->direction = Direction::factory()->create(); $this->data = EducationLevel::factory()->make()->only([ 'name', 'description', 'slug', ]); $this->user = User::factory()->create([ 'name' => 'admin', 'email' => 'test@example.com', 'password' => 123456 ]); } public function testIndexEducationLevelsPage(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->get(route('education_levels.index')); $response->assertOk(); } public function testCreateEducationLevelPage(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->get(route('education_levels.create')); $response->assertOk(); } public function testStoreEducationLevel(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->post(route('education_levels.store', $this->data)); $response->assertRedirect(route('education_levels.index')); $this->assertDatabaseHas('education_levels', $this->data); } public function testShowEducationLevelPage(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->get(route('education_levels.show', $this->level)); $response->assertOk(); } public function testEditEducationLevelPage(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->get(route('education_levels.edit', $this->level)); $response->assertOk(); } public function testUpdateEducationLevel(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->patch(route('education_levels.update', $this->level), $this->data); $response->assertRedirect(route('education_levels.index')); $this->assertDatabaseHas('education_levels', $this->data); } public function testDestroyEducationLevel(): void { $this->direction->delete(); $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->delete(route('education_levels.destroy', $this->level)); $response->assertRedirect(route('education_levels.index')); $this->assertDatabaseMissing('education_levels', $this->level->toArray()); } public function testNotDestroyEducationLevel(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->delete(route('education_levels.destroy', $this->level)); $response->assertStatus(302); $this->assertDatabaseHas('education_levels', $this->level->only(['name', 'slug'])); } }