. */ namespace App\Tests\Services\LogSystem; use App\Services\LogSystem\LogLevelHelper; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Psr\Log\LogLevel; final class LogLevelHelperTest extends TestCase { private LogLevelHelper $service; protected function setUp(): void { $this->service = new LogLevelHelper(); } public static function iconClassProvider(): \Generator { yield [LogLevel::DEBUG, 'fa-bug']; yield [LogLevel::INFO, 'fa-info']; yield [LogLevel::NOTICE, 'fa-flag']; yield [LogLevel::WARNING, 'fa-exclamation-circle']; yield [LogLevel::ERROR, 'fa-exclamation-triangle']; yield [LogLevel::CRITICAL, 'fa-bolt']; yield [LogLevel::ALERT, 'fa-radiation']; yield [LogLevel::EMERGENCY, 'fa-skull-crossbones']; } #[DataProvider('iconClassProvider')] public function testLogLevelToIconClass(string $logLevel, string $expectedIcon): void { $this->assertSame($expectedIcon, $this->service->logLevelToIconClass($logLevel)); } public function testUnknownLogLevelReturnsDefaultIcon(): void { $this->assertSame('fa-question-circle', $this->service->logLevelToIconClass('unknown_level')); } public static function tableColorProvider(): \Generator { yield [LogLevel::EMERGENCY, 'table-danger']; yield [LogLevel::ALERT, 'table-danger']; yield [LogLevel::CRITICAL, 'table-danger']; yield [LogLevel::ERROR, 'table-danger']; yield [LogLevel::WARNING, 'table-warning']; yield [LogLevel::NOTICE, 'table-info']; yield [LogLevel::INFO, '']; yield [LogLevel::DEBUG, '']; } #[DataProvider('tableColorProvider')] public function testLogLevelToTableColorClass(string $logLevel, string $expectedClass): void { $this->assertSame($expectedClass, $this->service->logLevelToTableColorClass($logLevel)); } public function testUnknownLogLevelReturnsEmptyColor(): void { $this->assertSame('', $this->service->logLevelToTableColorClass('unknown_level')); } }