mirror of
https://github.com/pacnpal/thrillwiki_laravel.git
synced 2025-12-22 11:31:11 -05:00
feat: Implement rides management with CRUD functionality
- 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.
This commit is contained in:
101
tests/Feature/RideTest.php
Normal file
101
tests/Feature/RideTest.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user