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()); + } +}