create(); Faculty::factory()->create(); Department::factory()->create(); $this->direction = Direction::factory()->create(); $this->data = Direction::factory()->make()->only([ 'position', 'name', 'description', 'slug', 'department_id', ]); $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 { $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()); } }