create(); Faculty::factory()->create(); Department::factory()->create(); EducationLevel::factory()->create(); EducationForm::factory()->create(); $this->direction = Direction::factory()->create(); ExaminationType::factory()->create(); Subject::factory()->create(); SubjectType::factory()->create(); $this->entranceExamination = EntranceExamination::factory()->create(); $this->data = Direction::factory()->make()->only([ 'position', 'name', 'description', 'code', 'slug', 'education_level_id', 'education_form_id', 'department_id', 'budget_places', 'quota', 'paid_places', 'cost_paid_place', 'period' ]); $this->user = User::factory()->create([ 'name' => 'admin', 'email' => 'test@example.com', 'password' => 123456 ]); } public function testIndexDirectionsPage(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->get(route('directions.index')); $response->assertOk(); } public function testCreateDirectionPage(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->get(route('directions.create')); $response->assertOk(); } public function testStoreDirection(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->post(route('directions.store', $this->data)); $response->assertRedirect(route('directions.index')); $this->assertDatabaseHas('directions', $this->data); } public function testShowDirectionPage(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->get(route('directions.show', $this->direction)); $response->assertOk(); } public function testEditDirectionPage(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->get(route('directions.edit', $this->direction)); $response->assertOk(); } public function testUpdateDirection(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->patch(route('directions.update', $this->direction), $this->data); $response->assertRedirect(route('directions.index')); $this->assertDatabaseHas('directions', $this->data); } public function testDestroyDirection(): void { $this->entranceExamination->delete(); $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->delete(route('directions.destroy', $this->direction)); $response->assertRedirect(route('directions.index')); $this->assertDatabaseMissing('directions', $this->direction->toArray()); } public function testNotDestroyDirectionWithEntranceExamination(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->delete(route('directions.destroy', $this->direction)); $response->assertStatus(302); $this->assertDatabaseHas( 'directions', $this->direction->only([ 'position', 'name', 'description', 'code', 'slug', 'education_level_id', 'education_form_id', 'department_id', ]) ); } }