mirror of
https://github.com/pacnpal/thrillwiki_laravel.git
synced 2025-12-20 06:51:10 -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.
101 lines
2.3 KiB
PHP
101 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Models\Ride;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Foundation\Testing\WithFaker;
|
|
use Tests\TestCase;
|
|
|
|
/**
|
|
* Ride Model Feature Tests
|
|
*
|
|
* Tests for ThrillWiki Ride model functionality
|
|
*/
|
|
class RideTest extends TestCase
|
|
{
|
|
use RefreshDatabase, WithFaker;
|
|
|
|
/**
|
|
* Test model creation.
|
|
*/
|
|
public function test_can_create_ride(): void
|
|
{
|
|
$ride = Ride::factory()->create();
|
|
|
|
$this->assertDatabaseHas('rides', [
|
|
'id' => $ride->id,
|
|
'name' => $ride->name,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Test model factory.
|
|
*/
|
|
public function test_ride_factory_works(): void
|
|
{
|
|
$ride = Ride::factory()->create();
|
|
|
|
$this->assertInstanceOf(Ride::class, $ride);
|
|
$this->assertNotEmpty($ride->name);
|
|
$this->assertIsBool($ride->is_active);
|
|
}
|
|
|
|
/**
|
|
* Test active scope.
|
|
*/
|
|
public function test_active_scope_filters_correctly(): void
|
|
{
|
|
Ride::factory()->active()->create();
|
|
Ride::factory()->inactive()->create();
|
|
|
|
$activeCount = Ride::active()->count();
|
|
$totalCount = Ride::count();
|
|
|
|
$this->assertEquals(1, $activeCount);
|
|
$this->assertEquals(2, $totalCount);
|
|
}
|
|
|
|
/**
|
|
* Test cache key generation.
|
|
*/
|
|
public function test_cache_key_generation(): void
|
|
{
|
|
$ride = Ride::factory()->create();
|
|
|
|
$cacheKey = $ride->getCacheKey();
|
|
$expectedKey = strtolower('ride') . '.' . $ride->id;
|
|
|
|
$this->assertEquals($expectedKey, $cacheKey);
|
|
}
|
|
|
|
/**
|
|
* Test cache key with suffix.
|
|
*/
|
|
public function test_cache_key_with_suffix(): void
|
|
{
|
|
$ride = Ride::factory()->create();
|
|
|
|
$cacheKey = $ride->getCacheKey('details');
|
|
$expectedKey = strtolower('ride') . '.' . $ride->id . '.details';
|
|
|
|
$this->assertEquals($expectedKey, $cacheKey);
|
|
}
|
|
|
|
/**
|
|
* Test soft deletes.
|
|
*/
|
|
public function test_soft_deletes_work(): void
|
|
{
|
|
$ride = Ride::factory()->create();
|
|
$ride->delete();
|
|
|
|
$this->assertSoftDeleted($ride);
|
|
|
|
// Test that it's excluded from normal queries
|
|
$this->assertEquals(0, Ride::count());
|
|
|
|
// Test that it's included in withTrashed queries
|
|
$this->assertEquals(1, Ride::withTrashed()->count());
|
|
}
|
|
} |