test: couverture 100% ServiceLog (8/8 methods, 13/13 lines)
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>
This commit is contained in:
46
tests/Entity/ServiceLogTest.php
Normal file
46
tests/Entity/ServiceLogTest.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user