feat: add the booking domain layer

This commit is contained in:
fromme committed 2026-09-13 14:54:42 +02:00
1 parent ef8a88ed2a
commit cb407477bf
13 files changed
+693 -6

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
<?php
declare(strict_types=1);
namespace App\Tests\Entity;
use App\Entity\Booking;
use App\Entity\Resource;
use App\Entity\ResourceType;
use App\Entity\User;
use PHPUnit\Framework\TestCase;
class BookingTest extends TestCase
{
public function testTheDateIsNormalisedToMidnightSoTheUniqueConstraintCannotBeSidestepped(): void
{
$booking = new Booking(
new User('[email protected]', 'A'),
new Resource(ResourceType::DESK, 'D1'),
new \DateTimeImmutable('2026-09-13 14:37:11'),
);
self::assertSame('2026-09-13 00:00:00', $booking->getDate()->format('Y-m-d H:i:s'));
}
}
+29
View File
@@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace App\Tests\Entity;
use App\Entity\User;
use PHPUnit\Framework\TestCase;
class UserTest extends TestCase
{
public function testEveryUserGetsRoleUserWithoutItBeingStored(): void
{
self::assertSame(['ROLE_USER'], (new User('[email protected]', 'A'))->getRoles());
}
public function testRoleUserIsNotDuplicatedWhenAlreadyGranted(): void
{
$user = new User('[email protected]', 'A');
$user->setRoles(['ROLE_USER', 'ROLE_EMPLOYEE']);
self::assertSame(['ROLE_USER', 'ROLE_EMPLOYEE'], $user->getRoles());
}
public function testTheEmailIsTheSecurityIdentifier(): void
{
self::assertSame('[email protected]', (new User('[email protected]', 'A'))->getUserIdentifier());
}
}