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()); } }