oms-HumanResourceTimeRecording/tests/Models/SessionElementMapperTest.php
Dennis Eichhorn 75c26d6e62
Some checks failed
Image optimization / general_image_workflow (push) Has been cancelled
CI / general_module_workflow_php (push) Has been cancelled
CI / general_module_workflow_js (push) Has been cancelled
fix permissions
2025-04-02 14:15:05 +00:00

43 lines
1.4 KiB
PHP

<?php
/**
* Jingga
*
* PHP Version 8.2
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 2.2
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\HumanResourceTimeRecording\tests\Models;
use Modules\Admin\Models\NullAccount;
use Modules\HumanResourceTimeRecording\Models\Session;
use Modules\HumanResourceTimeRecording\Models\SessionElement;
use Modules\HumanResourceTimeRecording\Models\SessionElementMapper;
/**
* @internal
*/
#[\PHPUnit\Framework\Attributes\CoversClass(\Modules\HumanResourceTimeRecording\Models\SessionElementMapper::class)]
final class SessionElementMapperTest extends \PHPUnit\Framework\TestCase
{
#[\PHPUnit\Framework\Attributes\Group('module')]
public function testCRUD() : void
{
$element = new SessionElement(new Session(new NullAccount(1)), new \DateTime('now'));
$id = SessionElementMapper::create()->execute($element);
self::assertGreaterThan(0, $element->id);
self::assertEquals($id, $element->id);
$elementR = SessionElementMapper::get()->with('session')->with('employee')->where('id', $element->id)->execute();
self::assertEquals($element->datetime->format('Y-m-d'), $elementR->datetime->format('Y-m-d'));
self::assertEquals($element->status, $elementR->status);
self::assertEquals($element->session->employee->id, $elementR->session->employee->id);
}
}