tests/Entity/ServiceStatusHistoryTest.php (nouveau, 2 tests): - testConstructor: verifie id null, service, status, message et createdAt - testConstructorWithoutMessage: message nullable a null par defaut tests/Entity/UserExtendedTest.php (nouveau, 9 tests): - testKeycloakId: get/set keycloakId nullable - testTempPassword: get/set/has tempPassword nullable - testGoogleAuthenticator: isEnabled (false par defaut, true quand secret set + isGoogleAuthEnabled true), get/set secret, getUsername - testEmailAuth: isEnabled (false par defaut), getRecipient, get/set code - testBackupCodes: get/set codes, isBackupCode, invalidateBackupCode (supprime du tableau) - testAvatar: get/set avatar nullable - testFullName: retourne "FirstName LastName" - testRoles: contient toujours ROLE_USER, set/get custom roles - testUserIdentifier: retourne l'email tests/EventListener/AdminLogListenerTest.php (nouveau, 7 tests): - testLogsAdminRoute: appelle log() pour une route app_admin_* - testLogsAdminRouteWithUser: passe le User depuis le TokenStorage - testIgnoresNonAdminRoute: ne log pas les routes non admin - testIgnoresSubRequest: ne log pas les sous-requetes - testIgnoresAjaxSearch: ne log pas les recherches AJAX - testLogThrowsDoesNotBlock: exception dans log() ne bloque pas la requete (catch silencieux) - testNoTokenReturnsNullUser: token null passe null comme user Resultat global: 262 tests, 463 assertions, 0 failures Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
40 lines
1.1 KiB
PHP
40 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Tests\Entity;
|
|
|
|
use App\Entity\Service;
|
|
use App\Entity\ServiceCategory;
|
|
use App\Entity\ServiceStatusHistory;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class ServiceStatusHistoryTest extends TestCase
|
|
{
|
|
private function createService(): Service
|
|
{
|
|
$category = new ServiceCategory('Web', 'web');
|
|
|
|
return new Service('Test Service', 'test-service', $category);
|
|
}
|
|
|
|
public function testConstructor(): void
|
|
{
|
|
$service = $this->createService();
|
|
$history = new ServiceStatusHistory($service, 'up', 'All good');
|
|
|
|
$this->assertNull($history->getId());
|
|
$this->assertSame($service, $history->getService());
|
|
$this->assertSame('up', $history->getStatus());
|
|
$this->assertSame('All good', $history->getMessage());
|
|
$this->assertInstanceOf(\DateTimeImmutable::class, $history->getCreatedAt());
|
|
}
|
|
|
|
public function testConstructorWithoutMessage(): void
|
|
{
|
|
$service = $this->createService();
|
|
$history = new ServiceStatusHistory($service, 'down');
|
|
|
|
$this->assertSame('down', $history->getStatus());
|
|
$this->assertNull($history->getMessage());
|
|
}
|
|
}
|