create(); Faculty::factory()->create(); Department::factory()->create(); EducationLevel::factory()->create(); $this->form = EducationForm::factory()->create(); $this->direction = Direction::factory()->create(); $this->data = EducationForm::factory()->make()->only([ 'name', 'description', 'slug', ]); $this->user = User::factory()->create([ 'name' => 'admin', 'email' => 'test@example.com', 'password' => 123456 ]); } public function testIndexEducationFormsPage(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->get(route('education_forms.index')); $response->assertOk(); } public function testCreateEducationFormPage(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->get(route('education_forms.create')); $response->assertOk(); } public function testStoreEducationForm(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->post(route('education_forms.store', $this->data)); $response->assertRedirect(route('education_forms.index')); $this->assertDatabaseHas('education_forms', $this->data); } public function testShowEducationFormPage(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->get(route('education_forms.show', $this->form)); $response->assertOk(); } public function testEditEducationFormPage(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->get(route('education_forms.edit', $this->form)); $response->assertOk(); } public function testUpdateEducationForm(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->patch(route('education_forms.update', $this->form), $this->data); $response->assertRedirect(route('education_forms.index')); $this->assertDatabaseHas('education_forms', $this->data); } public function testDestroyEducationForm(): void { $this->direction->delete(); $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->delete(route('education_forms.destroy', $this->form)); $response->assertRedirect(route('education_forms.index')); $this->assertDatabaseMissing('education_forms', $this->form->toArray()); } public function testNotDestroyEducationForm(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->delete(route('education_forms.destroy', $this->form)); $response->assertStatus(302); $this->assertDatabaseHas('education_forms', $this->form->only(['name', 'slug'])); } }