add ExaminationTypeTest.php

This commit is contained in:
aslan 2024-02-17 10:24:21 +03:00
parent f5d69e9c7f
commit 5f3c4449c0
1 changed files with 107 additions and 0 deletions

View File

@ -0,0 +1,107 @@
<?php
namespace Tests\Feature\admin\catalog\direction;
use App\Models\Department;
use App\Models\Direction;
use App\Models\EducationalInstitution;
use App\Models\EducationForm;
use App\Models\EducationLevel;
use App\Models\ExaminationType;
use App\Models\Faculty;
use App\Models\User;
use Tests\TestCase;
class ExaminationTypeTest extends TestCase
{
private User $user;
private ExaminationType $type;
private array $data;
protected function setUp(): void
{
parent::setUp();
$this->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());
}
}