forked from aslan/applicant-site
117 lines
3.4 KiB
PHP
117 lines
3.4 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace Tests\Feature\admin\catalog\direction;
|
||
|
|
||
|
use App\Models\Department;
|
||
|
use App\Models\Direction;
|
||
|
use App\Models\DirectionProfile;
|
||
|
use App\Models\EducationalInstitution;
|
||
|
use App\Models\EducationForm;
|
||
|
use App\Models\EducationLevel;
|
||
|
use App\Models\Faculty;
|
||
|
use App\Models\Place;
|
||
|
use App\Models\PlaceType;
|
||
|
use App\Models\User;
|
||
|
use Tests\TestCase;
|
||
|
|
||
|
class DirectionProfileTest extends TestCase
|
||
|
{
|
||
|
private User $user;
|
||
|
private DirectionProfile $directionProfile;
|
||
|
private array $data;
|
||
|
protected function setUp(): void
|
||
|
{
|
||
|
parent::setUp();
|
||
|
EducationalInstitution::factory()->create();
|
||
|
Faculty::factory()->create();
|
||
|
Department::factory()->create();
|
||
|
EducationLevel::factory()->create();
|
||
|
EducationForm::factory()->create();
|
||
|
Direction::factory()->create();
|
||
|
|
||
|
$this->directionProfile = DirectionProfile::factory()->create();
|
||
|
|
||
|
$this->data = DirectionProfile::factory()->make()->only([
|
||
|
'name',
|
||
|
'position',
|
||
|
'description',
|
||
|
'slug',
|
||
|
]);
|
||
|
|
||
|
$this->user = User::factory()->create([
|
||
|
'name' => 'admin',
|
||
|
'email' => 'test@example.com',
|
||
|
'password' => 123456
|
||
|
]);
|
||
|
}
|
||
|
|
||
|
public function testIndexDirectionProfilesPage(): void
|
||
|
{
|
||
|
$response = $this->actingAs($this->user)
|
||
|
->withSession(['banned' => false])
|
||
|
->get(route('direction_profiles.index'));
|
||
|
|
||
|
$response->assertOk();
|
||
|
}
|
||
|
|
||
|
public function testCreateDirectionProfilePage(): void
|
||
|
{
|
||
|
$response = $this->actingAs($this->user)
|
||
|
->withSession(['banned' => false])
|
||
|
->get(route('direction_profiles.create'));
|
||
|
|
||
|
$response->assertOk();
|
||
|
}
|
||
|
|
||
|
public function testStoreDirectionProfile(): void
|
||
|
{
|
||
|
$response = $this->actingAs($this->user)
|
||
|
->withSession(['banned' => false])
|
||
|
->post(route('direction_profiles.store', $this->data));
|
||
|
|
||
|
$response->assertRedirect(route('direction_profiles.index'));
|
||
|
|
||
|
$this->assertDatabaseHas('direction_profiles', $this->data);
|
||
|
}
|
||
|
|
||
|
public function testShowDirectionProfilePage(): void
|
||
|
{
|
||
|
$response = $this->actingAs($this->user)
|
||
|
->withSession(['banned' => false])
|
||
|
->get(route('direction_profiles.show', $this->directionProfile));
|
||
|
|
||
|
$response->assertOk();
|
||
|
}
|
||
|
|
||
|
public function testEditDirectionProfilePage(): void
|
||
|
{
|
||
|
$response = $this->actingAs($this->user)
|
||
|
->withSession(['banned' => false])
|
||
|
->get(route('direction_profiles.edit', $this->directionProfile));
|
||
|
|
||
|
$response->assertOk();
|
||
|
}
|
||
|
|
||
|
public function testUpdateDirectionProfile(): void
|
||
|
{
|
||
|
$response = $this->actingAs($this->user)
|
||
|
->withSession(['banned' => false])
|
||
|
->patch(route('direction_profiles.update', $this->directionProfile), $this->data);
|
||
|
|
||
|
$response->assertRedirect(route('direction_profiles.index'));
|
||
|
|
||
|
$this->assertDatabaseHas('direction_profiles', $this->data);
|
||
|
}
|
||
|
|
||
|
public function testDestroyDirectionProfile(): void
|
||
|
{
|
||
|
$response = $this->actingAs($this->user)
|
||
|
->withSession(['banned' => false])
|
||
|
->delete(route('direction_profiles.destroy', $this->directionProfile));
|
||
|
|
||
|
$response->assertRedirect(route('direction_profiles.index'));
|
||
|
|
||
|
$this->assertDatabaseMissing('direction_profiles', $this->directionProfile->toArray());
|
||
|
}
|
||
|
}
|