2012d67be7
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
47 lines
1.4 KiB
PHP
47 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace KTXT\Unit\Event;
|
|
|
|
use KTXC\Security\Event\SecurityEvent;
|
|
use PHPUnit\Framework\Attributes\Test;
|
|
use PHPUnit\Framework\Attributes\TestDox;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class SecurityEventTest extends TestCase
|
|
{
|
|
#[Test]
|
|
#[TestDox('Direct construction applies the event type default severity')]
|
|
public function appliesDefaultSeverityDuringConstruction(): void
|
|
{
|
|
self::assertSame(
|
|
SecurityEvent::SEVERITY_WARNING,
|
|
(new SecurityEvent(SecurityEvent::AUTH_FAILURE))->getSeverity(),
|
|
);
|
|
self::assertSame(
|
|
SecurityEvent::SEVERITY_ERROR,
|
|
(new SecurityEvent(SecurityEvent::RATE_LIMIT_EXCEEDED))->getSeverity(),
|
|
);
|
|
self::assertSame(
|
|
SecurityEvent::SEVERITY_CRITICAL,
|
|
(new SecurityEvent(SecurityEvent::DEVICE_BLOCKED))->getSeverity(),
|
|
);
|
|
self::assertSame(
|
|
SecurityEvent::SEVERITY_INFO,
|
|
(new SecurityEvent(SecurityEvent::FIREWALL_RULE_CREATED))->getSeverity(),
|
|
);
|
|
}
|
|
|
|
#[Test]
|
|
#[TestDox('Explicit severity can override the event type default')]
|
|
public function allowsSeverityOverride(): void
|
|
{
|
|
$event = new SecurityEvent(SecurityEvent::AUTH_FAILURE);
|
|
|
|
$event->setSeverity(SecurityEvent::SEVERITY_CRITICAL);
|
|
|
|
self::assertSame(SecurityEvent::SEVERITY_CRITICAL, $event->getSeverity());
|
|
}
|
|
}
|