Files
thrillwiki_laravel/tests/Feature/ReviewReportTest.php
pacnpal bd08111971 feat: Complete implementation of Ride CRUD system with full functionality and testing
- 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.
2025-06-23 08:10:04 -04:00

101 lines
2.6 KiB
PHP

<?php
namespace Tests\Feature;
use App\Models\ReviewReport;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
/**
* ReviewReport Model Feature Tests
*
* Tests for ThrillWiki ReviewReport model functionality
*/
class ReviewReportTest extends TestCase
{
use RefreshDatabase, WithFaker;
/**
* Test model creation.
*/
public function test_can_create_reviewreport(): void
{
$reviewreport = ReviewReport::factory()->create();
$this->assertDatabaseHas('review_reports', [
'id' => $reviewreport->id,
'name' => $reviewreport->name,
]);
}
/**
* Test model factory.
*/
public function test_reviewreport_factory_works(): void
{
$reviewreport = ReviewReport::factory()->create();
$this->assertInstanceOf(ReviewReport::class, $reviewreport);
$this->assertNotEmpty($reviewreport->name);
$this->assertIsBool($reviewreport->is_active);
}
/**
* Test active scope.
*/
public function test_active_scope_filters_correctly(): void
{
ReviewReport::factory()->active()->create();
ReviewReport::factory()->inactive()->create();
$activeCount = ReviewReport::active()->count();
$totalCount = ReviewReport::count();
$this->assertEquals(1, $activeCount);
$this->assertEquals(2, $totalCount);
}
/**
* Test cache key generation.
*/
public function test_cache_key_generation(): void
{
$reviewreport = ReviewReport::factory()->create();
$cacheKey = $reviewreport->getCacheKey();
$expectedKey = strtolower('reviewreport') . '.' . $reviewreport->id;
$this->assertEquals($expectedKey, $cacheKey);
}
/**
* Test cache key with suffix.
*/
public function test_cache_key_with_suffix(): void
{
$reviewreport = ReviewReport::factory()->create();
$cacheKey = $reviewreport->getCacheKey('details');
$expectedKey = strtolower('reviewreport') . '.' . $reviewreport->id . '.details';
$this->assertEquals($expectedKey, $cacheKey);
}
/**
* Test soft deletes.
*/
public function test_soft_deletes_work(): void
{
$reviewreport = ReviewReport::factory()->create();
$reviewreport->delete();
$this->assertSoftDeleted($reviewreport);
// Test that it's excluded from normal queries
$this->assertEquals(0, ReviewReport::count());
// Test that it's included in withTrashed queries
$this->assertEquals(1, ReviewReport::withTrashed()->count());
}
}