From 72dab2bc4e6ebd191f6b754fed417cb1bfe5d950 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sat, 8 Apr 2023 01:07:59 +0200 Subject: [PATCH] Added tests for CLI user functions on AbstractLogEntry --- .../Entity/LogSystem/AbstractLogEntryTest.php | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) 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()); + } }