mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 09:35:49 +02:00
Added tests for CLI user functions on AbstractLogEntry
This commit is contained in:
parent
b0d2a22f62
commit
72dab2bc4e
1 changed files with 22 additions and 0 deletions
|
@ -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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue