create(); EducationalInstitution::factory()->create(); Faculty::factory()->create(); Department::factory()->create(); EducationLevel::factory()->create(); EducationForm::factory()->create(); Direction::factory()->create(); $this->place = Place::factory()->create(); $this->data = Place::factory()->make()->only([ 'position', 'description', 'amount', 'education_form_id', 'place_type_id', 'direction_id', ]); $this->user = User::factory()->create([ 'name' => 'admin', 'email' => 'test@example.com', 'password' => 123456 ]); } public function testIndexPlacesPage(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->get(route('places.index')); $response->assertOk(); } public function testCreatePlacePage(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->get(route('places.create')); $response->assertOk(); } public function testStorePlace(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->post(route('places.store', $this->data)); $response->assertRedirect(route('places.index')); $this->assertDatabaseHas('places', $this->data); } public function testShowPlacePage(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->get(route('places.show', $this->place)); $response->assertOk(); } public function testEditPlacePage(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->get(route('places.edit', $this->place)); $response->assertOk(); } public function testUpdatePlace(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->patch(route('places.update', $this->place), $this->data); $response->assertRedirect(route('places.index')); $this->assertDatabaseHas('places', $this->data); } public function testDestroyPlace(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->delete(route('places.destroy', $this->place)); $response->assertRedirect(route('places.index')); $this->assertDatabaseMissing('places', $this->place->toArray()); } }