Add PHPUnit tests with coverage for all src classes
- 21 test files covering controllers, services, entities, enums, messages - CI: add test job with Xdebug coverage (clover + text) - SonarQube: configure coverage report path and test sources Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
37
tests/Enum/CacheKeyTest.php
Normal file
37
tests/Enum/CacheKeyTest.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tests\Enum;
|
||||
|
||||
use App\Enum\CacheKey;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CacheKeyTest extends TestCase
|
||||
{
|
||||
public function testResolveWithParameters(): void
|
||||
{
|
||||
self::assertSame('user_profile_42', CacheKey::USER_PROFILE->resolve(42));
|
||||
self::assertSame('event_detail_10', CacheKey::EVENT_DETAIL->resolve(10));
|
||||
self::assertSame('search_symfony', CacheKey::SEARCH_RESULTS->resolve('symfony'));
|
||||
}
|
||||
|
||||
public function testResolveWithoutParameters(): void
|
||||
{
|
||||
self::assertSame('event_list', CacheKey::EVENT_LIST->resolve());
|
||||
self::assertSame('home_page', CacheKey::HOME_PAGE->resolve());
|
||||
}
|
||||
|
||||
public function testTtlReturnsPositiveIntegers(): void
|
||||
{
|
||||
foreach (CacheKey::cases() as $case) {
|
||||
self::assertGreaterThan(0, $case->ttl(), "TTL for {$case->name} should be positive");
|
||||
}
|
||||
}
|
||||
|
||||
public function testSpecificTtlValues(): void
|
||||
{
|
||||
self::assertSame(1800, CacheKey::USER_PROFILE->ttl());
|
||||
self::assertSame(300, CacheKey::EVENT_LIST->ttl());
|
||||
self::assertSame(60, CacheKey::EVENT_TICKETS->ttl());
|
||||
self::assertSame(3600, CacheKey::SITEMAP_MAIN->ttl());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user