Added tests for CLI user functions on AbstractLogEntry

This commit is contained in:
Jan Böhmer 2023-04-08 01:07:59 +02:00
parent b0d2a22f62
commit 72dab2bc4e

View file

@ -44,6 +44,7 @@ namespace App\Tests\Entity\LogSystem;
use App\Entity\Attachments\Attachment; use App\Entity\Attachments\Attachment;
use App\Entity\Attachments\AttachmentType; use App\Entity\Attachments\AttachmentType;
use App\Entity\Attachments\PartAttachment; use App\Entity\Attachments\PartAttachment;
use App\Entity\LogSystem\UserLoginLogEntry;
use App\Entity\ProjectSystem\Project; use App\Entity\ProjectSystem\Project;
use App\Entity\ProjectSystem\ProjectBOMEntry; use App\Entity\ProjectSystem\ProjectBOMEntry;
use App\Entity\LogSystem\AbstractLogEntry; use App\Entity\LogSystem\AbstractLogEntry;
@ -160,4 +161,25 @@ class AbstractLogEntryTest extends TestCase
$this->assertNull($log->getTargetClass()); $this->assertNull($log->getTargetClass());
$this->assertNull($log->getTargetID()); $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());
}
} }