ServiceLogTest (2 tests) : - testConstructorDefaults : id null, service, fromStatus, toStatus, source=manual, changedBy null, createdAt - testConstructorWithSourceAndUser : source=cron, changedBy=User Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
47 lines
1.4 KiB
PHP
47 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Tests\Entity;
|
|
|
|
use App\Entity\Service;
|
|
use App\Entity\ServiceCategory;
|
|
use App\Entity\ServiceLog;
|
|
use App\Entity\User;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class ServiceLogTest extends TestCase
|
|
{
|
|
private function createService(): Service
|
|
{
|
|
return new Service('Esy-Web', 'esy-web', new ServiceCategory('Web', 'web'));
|
|
}
|
|
|
|
public function testConstructorDefaults(): void
|
|
{
|
|
$service = $this->createService();
|
|
$log = new ServiceLog($service, 'up', 'down');
|
|
|
|
$this->assertNull($log->getId());
|
|
$this->assertSame($service, $log->getService());
|
|
$this->assertSame('up', $log->getFromStatus());
|
|
$this->assertSame('down', $log->getToStatus());
|
|
$this->assertSame('manual', $log->getSource());
|
|
$this->assertNull($log->getChangedBy());
|
|
$this->assertInstanceOf(\DateTimeImmutable::class, $log->getCreatedAt());
|
|
}
|
|
|
|
public function testConstructorWithSourceAndUser(): void
|
|
{
|
|
$service = $this->createService();
|
|
$user = new User();
|
|
$user->setEmail('admin@test.com');
|
|
$user->setFirstName('A');
|
|
$user->setLastName('B');
|
|
$user->setPassword('h');
|
|
|
|
$log = new ServiceLog($service, 'down', 'up', 'cron', $user);
|
|
|
|
$this->assertSame('cron', $log->getSource());
|
|
$this->assertSame($user, $log->getChangedBy());
|
|
}
|
|
}
|