diff --git a/tests/Entity/LogSystem/AbstractLogEntryTest.php b/tests/Entity/LogSystem/AbstractLogEntryTest.php index fe4cdb58..0fde2daf 100644 --- a/tests/Entity/LogSystem/AbstractLogEntryTest.php +++ b/tests/Entity/LogSystem/AbstractLogEntryTest.php @@ -44,6 +44,7 @@ namespace App\Tests\Entity\LogSystem; use App\Entity\Attachments\Attachment; use App\Entity\Attachments\AttachmentType; use App\Entity\Attachments\PartAttachment; +use App\Entity\LogSystem\UserLoginLogEntry; use App\Entity\ProjectSystem\Project; use App\Entity\ProjectSystem\ProjectBOMEntry; use App\Entity\LogSystem\AbstractLogEntry; @@ -160,4 +161,25 @@ class AbstractLogEntryTest extends TestCase $this->assertNull($log->getTargetClass()); $this->assertNull($log->getTargetID()); } + + public function testCLIUsername(): void + { + $log = new UserLoginLogEntry('1.1.1.1'); + + //By default no no CLI username is set + $this->assertNull($log->getCLIUsername()); + $this->assertFalse($log->isCLIUser()); + + $user = new User(); + $user->setName('test'); + $log->setUser($user); + + //Set a CLI username + $log->setCLIUser('root'); + $this->assertSame('root', $log->getCLIUsername()); + $this->assertTrue($log->isCLIUser()); + + //Normal user must be null now + $this->assertNull($log->getUser()); + } }