From 5f3c4449c00a2d0657c18ca5b64ff627e65e04ab Mon Sep 17 00:00:00 2001 From: aslan Date: Sat, 17 Feb 2024 10:24:21 +0300 Subject: [PATCH] add ExaminationTypeTest.php --- .../catalog/direction/ExaminationTypeTest.php | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 tests/Feature/admin/catalog/direction/ExaminationTypeTest.php diff --git a/tests/Feature/admin/catalog/direction/ExaminationTypeTest.php b/tests/Feature/admin/catalog/direction/ExaminationTypeTest.php new file mode 100644 index 0000000..ba0d620 --- /dev/null +++ b/tests/Feature/admin/catalog/direction/ExaminationTypeTest.php @@ -0,0 +1,107 @@ +type = ExaminationType::factory()->create(); + + $this->data = ExaminationType::factory()->make()->only([ + 'name', + 'description', + 'position', + 'slug', + ]); + + $this->user = User::factory()->create([ + 'name' => 'admin', + 'email' => 'test@example.com', + 'password' => 123456 + ]); + } + + public function testIndexExaminationTypesPage(): void + { + $response = $this->actingAs($this->user) + ->withSession(['banned' => false]) + ->get(route('examination_types.index')); + + $response->assertOk(); + } + + public function testCreateExaminationTypePage(): void + { + $response = $this->actingAs($this->user) + ->withSession(['banned' => false]) + ->get(route('examination_types.create')); + + $response->assertOk(); + } + + public function testStoreExaminationType(): void + { + $response = $this->actingAs($this->user) + ->withSession(['banned' => false]) + ->post(route('examination_types.store', $this->data)); + + $response->assertRedirect(route('examination_types.index')); + + $this->assertDatabaseHas('examination_types', $this->data); + } + + public function testShowExaminationTypePage(): void + { + $response = $this->actingAs($this->user) + ->withSession(['banned' => false]) + ->get(route('examination_types.show', $this->type)); + + $response->assertOk(); + } + + public function testEditExaminationTypePage(): void + { + $response = $this->actingAs($this->user) + ->withSession(['banned' => false]) + ->get(route('examination_types.edit', $this->type)); + + $response->assertOk(); + } + + public function testUpdateExaminationType(): void + { + $response = $this->actingAs($this->user) + ->withSession(['banned' => false]) + ->patch(route('examination_types.update', $this->type), $this->data); + + $response->assertRedirect(route('examination_types.index')); + + $this->assertDatabaseHas('examination_types', $this->data); + } + + public function testDestroyExaminationType(): void + { + $response = $this->actingAs($this->user) + ->withSession(['banned' => false]) + ->delete(route('examination_types.destroy', $this->type)); + + $response->assertRedirect(route('examination_types.index')); + + $this->assertDatabaseMissing('examination_types', $this->type->toArray()); + } +}