create(); Faculty::factory()->create(); Department::factory()->create(); EducationLevel::factory()->create(); EducationForm::factory()->create(); Direction::factory()->create(); $this->cost = Cost::factory()->create(); $this->data = Cost::factory()->make()->only([ 'position', 'description', 'cost', 'education_form_id', 'direction_id', ]); $this->user = User::factory()->create([ 'name' => 'admin', 'email' => 'test@example.com', 'password' => 123456 ]); } public function testIndexCostsPage(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->get(route('costs.index')); $response->assertOk(); } public function testCreateCostPage(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->get(route('costs.create')); $response->assertOk(); } public function testStoreCost(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->post(route('costs.store', $this->data)); $response->assertRedirect(route('costs.index')); $this->assertDatabaseHas('costs', $this->data); } public function testShowCost(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->get(route('costs.show', $this->cost)); $response->assertOk(); } public function testEditCostPage(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->get(route('costs.edit', $this->cost)); $response->assertOk(); } public function testUpdateCost(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->patch(route('costs.update', $this->cost), $this->data); $response->assertRedirect(route('costs.index')); $this->assertDatabaseHas('costs', $this->data); } public function testDestroyCost(): void { $response = $this->actingAs($this->user) ->withSession(['banned' => false]) ->delete(route('costs.destroy', $this->cost)); $response->assertRedirect(route('costs.index')); $this->assertDatabaseMissing('costs', $this->cost->toArray()); } }