mirror of
https://github.com/pacnpal/thrillwiki_laravel.git
synced 2025-12-20 06:11:09 -05:00
- Added rides index view with search and filter options. - Created rides show view to display ride details. - Implemented API routes for rides. - Developed authentication routes for user registration, login, and email verification. - Created tests for authentication, email verification, password reset, and user profile management. - Added feature tests for rides and operators, including creation, updating, deletion, and searching. - Implemented soft deletes and caching for rides and operators. - Enhanced manufacturer and operator model tests for various functionalities.
106 lines
2.9 KiB
PHP
106 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Models\Operator;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
class OperatorControllerTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
protected User $user;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
$this->user = User::factory()->create();
|
|
}
|
|
|
|
/** @test */
|
|
public function it_can_display_operators_index(): void
|
|
{
|
|
Operator::factory()->count(3)->create();
|
|
|
|
$response = $this->actingAs($this->user)->get(route('operators.index'));
|
|
|
|
$response->assertStatus(200)
|
|
->assertSee('Operators');
|
|
}
|
|
|
|
/** @test */
|
|
public function it_can_create_a_operator(): void
|
|
{
|
|
$operatorData = [
|
|
'name' => 'Test Operator',
|
|
'description' => 'Test description',
|
|
'is_active' => true,
|
|
];
|
|
|
|
$response = $this->actingAs($this->user)->post(route('operators.store'), $operatorData);
|
|
|
|
$response->assertRedirect();
|
|
$this->assertDatabaseHas('operators', $operatorData);
|
|
}
|
|
|
|
/** @test */
|
|
public function it_can_show_a_operator(): void
|
|
{
|
|
$operator = Operator::factory()->create();
|
|
|
|
$response = $this->actingAs($this->user)->get(route('operators.show', $operator));
|
|
|
|
$response->assertStatus(200)
|
|
->assertSee($operator->name);
|
|
}
|
|
|
|
/** @test */
|
|
public function it_can_update_a_operator(): void
|
|
{
|
|
$operator = Operator::factory()->create();
|
|
$updateData = [
|
|
'name' => 'Updated Operator',
|
|
'description' => 'Updated description',
|
|
'is_active' => false,
|
|
];
|
|
|
|
$response = $this->actingAs($this->user)->put(route('operators.update', $operator), $updateData);
|
|
|
|
$response->assertRedirect();
|
|
$this->assertDatabaseHas('operators', $updateData);
|
|
}
|
|
|
|
/** @test */
|
|
public function it_can_delete_a_operator(): void
|
|
{
|
|
$operator = Operator::factory()->create();
|
|
|
|
$response = $this->actingAs($this->user)->delete(route('operators.destroy', $operator));
|
|
|
|
$response->assertRedirect();
|
|
$this->assertSoftDeleted('operators', ['id' => $operator->id]);
|
|
}
|
|
|
|
/** @test */
|
|
public function it_validates_required_fields(): void
|
|
{
|
|
$response = $this->actingAs($this->user)->post(route('operators.store'), []);
|
|
|
|
$response->assertSessionHasErrors(['name']);
|
|
}
|
|
|
|
/** @test */
|
|
public function it_can_search_operators(): void
|
|
{
|
|
$operator1 = Operator::factory()->create(['name' => 'Searchable Operator']);
|
|
$operator2 = Operator::factory()->create(['name' => 'Other Operator']);
|
|
|
|
$response = $this->actingAs($this->user)->get(route('operators.index', ['search' => 'Searchable']));
|
|
|
|
$response->assertStatus(200)
|
|
->assertSee($operator1->name)
|
|
->assertDontSee($operator2->name);
|
|
}
|
|
} |