mirror of
https://github.com/pacnpal/thrillwiki_laravel.git
synced 2025-12-20 06:51:10 -05:00
- Added Ride CRUD system documentation detailing implementation summary, generated components, and performance metrics. - Created Ride CRUD system prompt for future development with core requirements and implementation strategy. - Established relationships between rides and parks, ensuring Django parity and optimized performance. - Implemented waiting for user command execution documentation for Park CRUD generation. - Developed Livewire components for RideForm and RideList with basic structure. - Created feature tests for Park and Ride components, ensuring proper rendering and functionality. - Added comprehensive tests for ParkController, ReviewImage, and ReviewReport models, validating CRUD operations and relationships.
101 lines
2.6 KiB
PHP
101 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Models\ReviewImage;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Foundation\Testing\WithFaker;
|
|
use Tests\TestCase;
|
|
|
|
/**
|
|
* ReviewImage Model Feature Tests
|
|
*
|
|
* Tests for ThrillWiki ReviewImage model functionality
|
|
*/
|
|
class ReviewImageTest extends TestCase
|
|
{
|
|
use RefreshDatabase, WithFaker;
|
|
|
|
/**
|
|
* Test model creation.
|
|
*/
|
|
public function test_can_create_reviewimage(): void
|
|
{
|
|
$reviewimage = ReviewImage::factory()->create();
|
|
|
|
$this->assertDatabaseHas('review_images', [
|
|
'id' => $reviewimage->id,
|
|
'name' => $reviewimage->name,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Test model factory.
|
|
*/
|
|
public function test_reviewimage_factory_works(): void
|
|
{
|
|
$reviewimage = ReviewImage::factory()->create();
|
|
|
|
$this->assertInstanceOf(ReviewImage::class, $reviewimage);
|
|
$this->assertNotEmpty($reviewimage->name);
|
|
$this->assertIsBool($reviewimage->is_active);
|
|
}
|
|
|
|
/**
|
|
* Test active scope.
|
|
*/
|
|
public function test_active_scope_filters_correctly(): void
|
|
{
|
|
ReviewImage::factory()->active()->create();
|
|
ReviewImage::factory()->inactive()->create();
|
|
|
|
$activeCount = ReviewImage::active()->count();
|
|
$totalCount = ReviewImage::count();
|
|
|
|
$this->assertEquals(1, $activeCount);
|
|
$this->assertEquals(2, $totalCount);
|
|
}
|
|
|
|
/**
|
|
* Test cache key generation.
|
|
*/
|
|
public function test_cache_key_generation(): void
|
|
{
|
|
$reviewimage = ReviewImage::factory()->create();
|
|
|
|
$cacheKey = $reviewimage->getCacheKey();
|
|
$expectedKey = strtolower('reviewimage') . '.' . $reviewimage->id;
|
|
|
|
$this->assertEquals($expectedKey, $cacheKey);
|
|
}
|
|
|
|
/**
|
|
* Test cache key with suffix.
|
|
*/
|
|
public function test_cache_key_with_suffix(): void
|
|
{
|
|
$reviewimage = ReviewImage::factory()->create();
|
|
|
|
$cacheKey = $reviewimage->getCacheKey('details');
|
|
$expectedKey = strtolower('reviewimage') . '.' . $reviewimage->id . '.details';
|
|
|
|
$this->assertEquals($expectedKey, $cacheKey);
|
|
}
|
|
|
|
/**
|
|
* Test soft deletes.
|
|
*/
|
|
public function test_soft_deletes_work(): void
|
|
{
|
|
$reviewimage = ReviewImage::factory()->create();
|
|
$reviewimage->delete();
|
|
|
|
$this->assertSoftDeleted($reviewimage);
|
|
|
|
// Test that it's excluded from normal queries
|
|
$this->assertEquals(0, ReviewImage::count());
|
|
|
|
// Test that it's included in withTrashed queries
|
|
$this->assertEquals(1, ReviewImage::withTrashed()->count());
|
|
}
|
|
} |