120 lines
3.2 KiB
PHP
120 lines
3.2 KiB
PHP
<?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\EntranceExamination;
|
|
use App\Models\Faculty;
|
|
use App\Models\Place;
|
|
use App\Models\PlaceType;
|
|
use App\Models\User;
|
|
use Tests\TestCase;
|
|
|
|
class PlaceTest extends TestCase
|
|
{
|
|
private User $user;
|
|
private Place $place;
|
|
private array $data;
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
PlaceType::factory()->create();
|
|
EducationalInstitution::factory()->create();
|
|
Faculty::factory()->create();
|
|
Department::factory()->create();
|
|
EducationLevel::factory()->create();
|
|
EducationForm::factory()->create();
|
|
Direction::factory()->create();
|
|
|
|
$this->place = Place::factory()->create();
|
|
|
|
$this->data = Place::factory()->make()->only([
|
|
'position',
|
|
'description',
|
|
'amount',
|
|
'education_form_id',
|
|
'place_type_id',
|
|
'direction_id',
|
|
]);
|
|
|
|
$this->user = User::factory()->create([
|
|
'name' => 'admin',
|
|
'email' => 'test@example.com',
|
|
'password' => 123456
|
|
]);
|
|
}
|
|
|
|
public function testIndexPlacesPage(): void
|
|
{
|
|
$response = $this->actingAs($this->user)
|
|
->withSession(['banned' => false])
|
|
->get(route('places.index'));
|
|
|
|
$response->assertOk();
|
|
}
|
|
|
|
public function testCreatePlaceTypePage(): void
|
|
{
|
|
$response = $this->actingAs($this->user)
|
|
->withSession(['banned' => false])
|
|
->get(route('places.create'));
|
|
|
|
$response->assertOk();
|
|
}
|
|
|
|
public function testStorePlaceType(): void
|
|
{
|
|
$response = $this->actingAs($this->user)
|
|
->withSession(['banned' => false])
|
|
->post(route('places.store', $this->data));
|
|
|
|
$response->assertRedirect(route('places.index'));
|
|
|
|
$this->assertDatabaseHas('places', $this->data);
|
|
}
|
|
|
|
public function testShowPlaceTypePage(): void
|
|
{
|
|
$response = $this->actingAs($this->user)
|
|
->withSession(['banned' => false])
|
|
->get(route('places.show', $this->place));
|
|
|
|
$response->assertOk();
|
|
}
|
|
|
|
public function testEditPlaceTypePage(): void
|
|
{
|
|
$response = $this->actingAs($this->user)
|
|
->withSession(['banned' => false])
|
|
->get(route('places.edit', $this->place));
|
|
|
|
$response->assertOk();
|
|
}
|
|
|
|
public function testUpdatePlaceType(): void
|
|
{
|
|
$response = $this->actingAs($this->user)
|
|
->withSession(['banned' => false])
|
|
->patch(route('places.update', $this->place), $this->data);
|
|
|
|
$response->assertRedirect(route('places.index'));
|
|
|
|
$this->assertDatabaseHas('places', $this->data);
|
|
}
|
|
|
|
public function testDestroyPlaceType(): void
|
|
{
|
|
$response = $this->actingAs($this->user)
|
|
->withSession(['banned' => false])
|
|
->delete(route('places.destroy', $this->place));
|
|
|
|
$response->assertRedirect(route('places.index'));
|
|
|
|
$this->assertDatabaseMissing('places', $this->place->toArray());
|
|
}
|
|
}
|