Compare commits
2 commits
bbc56a9af7
...
8ebf229d62
Author | SHA1 | Date | |
---|---|---|---|
8ebf229d62 | |||
1f9562d36b |
15 changed files with 2013 additions and 1349 deletions
|
@ -15,7 +15,6 @@
|
|||
"doctrine/orm": "^3.4.0",
|
||||
"nelmio/cors-bundle": "^2.5",
|
||||
"phpdocumentor/reflection-docblock": "^5.6.2",
|
||||
"phpstan/phpdoc-parser": "^1.33",
|
||||
"psr/clock": "^1.0",
|
||||
"symfony/asset": "7.3.*",
|
||||
"symfony/asset-mapper": "7.3.*",
|
||||
|
@ -42,7 +41,7 @@
|
|||
"require-dev": {
|
||||
"doctrine/doctrine-fixtures-bundle": "^4.1",
|
||||
"liip/test-fixtures-bundle": "^3.4",
|
||||
"lubiana/code-quality": "^1.7.2",
|
||||
"lubiana/code-quality": "1.7.3",
|
||||
"pestphp/pest": "^3.8.2",
|
||||
"symfony/browser-kit": "7.3.*",
|
||||
"symfony/css-selector": "7.3.*",
|
||||
|
|
2471
composer.lock
generated
2471
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -48,13 +48,13 @@ return [
|
|||
'dev' => true,
|
||||
'test' => true,
|
||||
],
|
||||
ApiPlatformBundle::class => [
|
||||
'all' => true,
|
||||
],
|
||||
TwigExtraBundle::class => [
|
||||
'all' => true,
|
||||
],
|
||||
MonologBundle::class => [
|
||||
'all' => true,
|
||||
],
|
||||
ApiPlatformBundle::class => [
|
||||
'all' => true,
|
||||
],
|
||||
];
|
||||
|
|
|
@ -14,22 +14,6 @@ use Symfony\Component\Routing\Attribute\Route;
|
|||
#[Route('/food/order')]
|
||||
final class FoodOrderController extends AbstractController
|
||||
{
|
||||
#[Route(
|
||||
path: '/list',
|
||||
name: 'app_food_order_index',
|
||||
methods: ['GET']
|
||||
)]
|
||||
public function index(FoodOrderRepository $foodOrderRepository): Response
|
||||
{
|
||||
|
||||
return $this->render('food_order/index.html.twig', [
|
||||
'food_orders' => $foodOrderRepository->findLatestEntries(days: 3),
|
||||
'current_page' => 0,
|
||||
'next_page' => 0,
|
||||
'prev_page' => 0,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route(
|
||||
path: '/list/archive/{page}',
|
||||
name: 'app_food_order_archive',
|
||||
|
@ -60,6 +44,32 @@ final class FoodOrderController extends AbstractController
|
|||
]);
|
||||
}
|
||||
|
||||
#[Route('/{id}/close', name: 'app_food_order_close', methods: ['GET'])]
|
||||
public function close(FoodOrder $foodOrder, FoodOrderRepository $repository): Response
|
||||
{
|
||||
$foodOrder->close();
|
||||
$repository->save();
|
||||
return $this->redirectToRoute('app_food_order_show', [
|
||||
'id' => $foodOrder->getId(),
|
||||
], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
|
||||
#[Route(
|
||||
path: '/list',
|
||||
name: 'app_food_order_index',
|
||||
methods: ['GET']
|
||||
)]
|
||||
public function index(FoodOrderRepository $foodOrderRepository): Response
|
||||
{
|
||||
|
||||
return $this->render('food_order/index.html.twig', [
|
||||
'food_orders' => $foodOrderRepository->findLatestEntries(days: 3),
|
||||
'current_page' => 0,
|
||||
'next_page' => 0,
|
||||
'prev_page' => 0,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/new', name: 'app_food_order_new', methods: ['GET', 'POST'])]
|
||||
public function new(Request $request, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
|
@ -84,24 +94,6 @@ final class FoodOrderController extends AbstractController
|
|||
]);
|
||||
}
|
||||
|
||||
#[Route('/{id}', name: 'app_food_order_show', methods: ['GET'])]
|
||||
public function show(FoodOrder $foodOrder): Response
|
||||
{
|
||||
return $this->render('food_order/show.html.twig', [
|
||||
'food_order' => $foodOrder,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/{id}/close', name: 'app_food_order_close', methods: ['GET'])]
|
||||
public function close(FoodOrder $foodOrder, FoodOrderRepository $repository): Response
|
||||
{
|
||||
$foodOrder->close();
|
||||
$repository->save();
|
||||
return $this->redirectToRoute('app_food_order_show', [
|
||||
'id' => $foodOrder->getId(),
|
||||
], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
|
||||
#[Route('/{id}/open', name: 'app_food_order_open', methods: ['GET'])]
|
||||
public function open(FoodOrder $foodOrder, FoodOrderRepository $repository): Response
|
||||
{
|
||||
|
@ -111,4 +103,12 @@ final class FoodOrderController extends AbstractController
|
|||
'id' => $foodOrder->getId(),
|
||||
], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
|
||||
#[Route('/{id}', name: 'app_food_order_show', methods: ['GET'])]
|
||||
public function show(FoodOrder $foodOrder): Response
|
||||
{
|
||||
return $this->render('food_order/show.html.twig', [
|
||||
'food_order' => $foodOrder,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,23 @@ use Symfony\Component\Routing\Attribute\Route;
|
|||
#[Route('/food/vendor')]
|
||||
final class FoodVendorController extends AbstractController
|
||||
{
|
||||
#[Route('/{id}/edit', name: 'app_food_vendor_edit', methods: ['GET', 'POST'])]
|
||||
public function edit(Request $request, FoodVendor $foodVendor, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$form = $this->createForm(FoodVendorType::class, $foodVendor);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('app_food_vendor_index', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
|
||||
return $this->render('food_vendor/edit.html.twig', [
|
||||
'form' => $form,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/', name: 'app_food_vendor_index', methods: ['GET'])]
|
||||
public function index(FoodVendorRepository $foodVendorRepository): Response
|
||||
{
|
||||
|
@ -51,21 +68,4 @@ final class FoodVendorController extends AbstractController
|
|||
'food_vendor' => $foodVendor,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/{id}/edit', name: 'app_food_vendor_edit', methods: ['GET', 'POST'])]
|
||||
public function edit(Request $request, FoodVendor $foodVendor, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$form = $this->createForm(FoodVendorType::class, $foodVendor);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('app_food_vendor_index', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
|
||||
return $this->render('food_vendor/edit.html.twig', [
|
||||
'form' => $form,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,12 +13,18 @@ use Symfony\Component\Routing\Attribute\Route;
|
|||
#[Route('/menu/item')]
|
||||
final class MenuItemController extends AbstractController
|
||||
{
|
||||
#[Route('/{id}', name: 'app_menu_item_show', methods: ['GET'])]
|
||||
public function show(MenuItem $menuItem): Response
|
||||
#[Route('/{id}', name: 'app_menu_item_delete', methods: ['POST'])]
|
||||
public function delete(Request $request, MenuItem $menuItem, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
return $this->render('menu_item/show.html.twig', [
|
||||
'menu_item' => $menuItem,
|
||||
]);
|
||||
if ($this->isCsrfTokenValid('delete' . $menuItem->getId(), $request->getPayload()->getString('_token'))) {
|
||||
$menuItem->delete();
|
||||
$entityManager->flush();
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('app_food_vendor_show', [
|
||||
'id' => $menuItem->getFoodVendor()
|
||||
->getId(),
|
||||
], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
|
||||
#[Route('/{id}/edit', name: 'app_menu_item_edit', methods: ['GET', 'POST'])]
|
||||
|
@ -52,17 +58,11 @@ final class MenuItemController extends AbstractController
|
|||
]);
|
||||
}
|
||||
|
||||
#[Route('/{id}', name: 'app_menu_item_delete', methods: ['POST'])]
|
||||
public function delete(Request $request, MenuItem $menuItem, EntityManagerInterface $entityManager): Response
|
||||
#[Route('/{id}', name: 'app_menu_item_show', methods: ['GET'])]
|
||||
public function show(MenuItem $menuItem): Response
|
||||
{
|
||||
if ($this->isCsrfTokenValid('delete' . $menuItem->getId(), $request->getPayload()->getString('_token'))) {
|
||||
$menuItem->delete();
|
||||
$entityManager->flush();
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('app_food_vendor_show', [
|
||||
'id' => $menuItem->getFoodVendor()
|
||||
->getId(),
|
||||
], Response::HTTP_SEE_OTHER);
|
||||
return $this->render('menu_item/show.html.twig', [
|
||||
'menu_item' => $menuItem,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,62 +16,6 @@ use Symfony\Component\Routing\Attribute\Route;
|
|||
#[Route('/order/item')]
|
||||
final class OrderItemController extends AbstractController
|
||||
{
|
||||
#[Route('/new/{foodOrder}', name: 'app_order_item_new', methods: ['GET', 'POST'])]
|
||||
public function new(Request $request, FoodOrder $foodOrder, EntityManagerInterface $entityManager, MenuItemRepository $menuItemRepository): Response
|
||||
{
|
||||
if ($foodOrder->isClosed()) {
|
||||
return $this->redirectToRoute('app_food_order_show', [
|
||||
'id' => $foodOrder->getId(),
|
||||
], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
|
||||
$orderItem = new OrderItem;
|
||||
$username = $request->cookies->get('username', 'nobody');
|
||||
$orderItem->setCreatedBy($username);
|
||||
|
||||
$form = $this->createForm(OrderItemType::class, $orderItem);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$menuItem = $menuItemRepository->findOneBy([
|
||||
'name' => $orderItem->getName(),
|
||||
'foodVendor' => $foodOrder->getFoodVendor(),
|
||||
]);
|
||||
|
||||
if ($menuItem === null) {
|
||||
$menuItem = new MenuItem;
|
||||
$menuItem->setName($orderItem->getName());
|
||||
$menuItem->setFoodVendor($foodOrder->getFoodVendor());
|
||||
$entityManager->persist($menuItem);
|
||||
}
|
||||
|
||||
if ($menuItem->getAliasOf() !== null) {
|
||||
$menuItem = $menuItem->getAliasOf();
|
||||
$orderItem->setName($menuItem->getName());
|
||||
}
|
||||
|
||||
$orderItem->setMenuItem($menuItem);
|
||||
$orderItem->setFoodOrder($foodOrder);
|
||||
$entityManager->persist($orderItem);
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('app_food_order_show', [
|
||||
'id' => $foodOrder->getId(),
|
||||
], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
$menuItems = $menuItemRepository->findBy([
|
||||
'foodVendor' => $foodOrder->getFoodVendor(),
|
||||
'deletedAt' => null,
|
||||
]);
|
||||
|
||||
return $this->render('order_item/new.html.twig', [
|
||||
'order_item' => $orderItem,
|
||||
'food_order' => $foodOrder,
|
||||
'form' => $form,
|
||||
'menuItems' => $menuItems,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/{id}/copy', name: 'app_order_item_copy', methods: ['GET'])]
|
||||
public function copy(OrderItem $orderItem, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
|
@ -95,6 +39,23 @@ final class OrderItemController extends AbstractController
|
|||
], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
|
||||
#[Route('/delete/{id}', name: 'app_order_item_delete')]
|
||||
public function delete(OrderItem $orderItem, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$foodOrder = $orderItem->getFoodOrder();
|
||||
if ($foodOrder->isClosed()) {
|
||||
return $this->redirectToRoute('app_food_order_show', [
|
||||
'id' => $foodOrder->getId(),
|
||||
], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
$entityManager->remove($orderItem);
|
||||
$entityManager->flush();
|
||||
return $this->redirectToRoute('app_food_order_show', [
|
||||
'id' => $orderItem->getFoodOrder()
|
||||
->getId(),
|
||||
], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
|
||||
#[Route('/{id}/edit', name: 'app_order_item_edit', methods: ['GET', 'POST'])]
|
||||
public function edit(
|
||||
Request $request,
|
||||
|
@ -143,20 +104,59 @@ final class OrderItemController extends AbstractController
|
|||
]);
|
||||
}
|
||||
|
||||
#[Route('/delete/{id}', name: 'app_order_item_delete')]
|
||||
public function delete(OrderItem $orderItem, EntityManagerInterface $entityManager): Response
|
||||
#[Route('/new/{foodOrder}', name: 'app_order_item_new', methods: ['GET', 'POST'])]
|
||||
public function new(Request $request, FoodOrder $foodOrder, EntityManagerInterface $entityManager, MenuItemRepository $menuItemRepository): Response
|
||||
{
|
||||
$foodOrder = $orderItem->getFoodOrder();
|
||||
if ($foodOrder->isClosed()) {
|
||||
return $this->redirectToRoute('app_food_order_show', [
|
||||
'id' => $foodOrder->getId(),
|
||||
], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
$entityManager->remove($orderItem);
|
||||
|
||||
$orderItem = new OrderItem;
|
||||
$username = $request->cookies->get('username', 'nobody');
|
||||
$orderItem->setCreatedBy($username);
|
||||
|
||||
$form = $this->createForm(OrderItemType::class, $orderItem);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$menuItem = $menuItemRepository->findOneBy([
|
||||
'name' => $orderItem->getName(),
|
||||
'foodVendor' => $foodOrder->getFoodVendor(),
|
||||
]);
|
||||
|
||||
if ($menuItem === null) {
|
||||
$menuItem = new MenuItem;
|
||||
$menuItem->setName($orderItem->getName());
|
||||
$menuItem->setFoodVendor($foodOrder->getFoodVendor());
|
||||
$entityManager->persist($menuItem);
|
||||
}
|
||||
|
||||
if ($menuItem->getAliasOf() !== null) {
|
||||
$menuItem = $menuItem->getAliasOf();
|
||||
$orderItem->setName($menuItem->getName());
|
||||
}
|
||||
|
||||
$orderItem->setMenuItem($menuItem);
|
||||
$orderItem->setFoodOrder($foodOrder);
|
||||
$entityManager->persist($orderItem);
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('app_food_order_show', [
|
||||
'id' => $orderItem->getFoodOrder()
|
||||
->getId(),
|
||||
'id' => $foodOrder->getId(),
|
||||
], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
$menuItems = $menuItemRepository->findBy([
|
||||
'foodVendor' => $foodOrder->getFoodVendor(),
|
||||
'deletedAt' => null,
|
||||
]);
|
||||
|
||||
return $this->render('order_item/new.html.twig', [
|
||||
'order_item' => $orderItem,
|
||||
'food_order' => $foodOrder,
|
||||
'form' => $form,
|
||||
'menuItems' => $menuItems,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,29 +16,6 @@ final class AppFixtures extends Fixture
|
|||
{
|
||||
private ObjectManager $manager;
|
||||
|
||||
#[Override]
|
||||
public function load(ObjectManager $manager): void
|
||||
{
|
||||
$this->manager = $manager;
|
||||
$vendorA = $this->createVendor('Vendor A');
|
||||
$this->addMenuItemsToVendor($vendorA);
|
||||
|
||||
$vendorB = $this->createVendor('Vendor B');
|
||||
$this->addMenuItemsToVendor($vendorB);
|
||||
}
|
||||
|
||||
public function createVendor(string $name): FoodVendor
|
||||
{
|
||||
$vendorA = new FoodVendor;
|
||||
$vendorA->setName($name);
|
||||
$vendorA->setMenuLink('https://vendora.com');
|
||||
$vendorA->setPhone('1234567890');
|
||||
|
||||
$this->manager->persist($vendorA);
|
||||
$this->manager->flush();
|
||||
return $vendorA;
|
||||
}
|
||||
|
||||
public function addMenuItemsToVendor(FoodVendor $vendor): void
|
||||
{
|
||||
$menuItems = [];
|
||||
|
@ -63,4 +40,27 @@ final class AppFixtures extends Fixture
|
|||
$this->manager->persist($orderItem);
|
||||
}
|
||||
}
|
||||
|
||||
public function createVendor(string $name): FoodVendor
|
||||
{
|
||||
$vendorA = new FoodVendor;
|
||||
$vendorA->setName($name);
|
||||
$vendorA->setMenuLink('https://vendora.com');
|
||||
$vendorA->setPhone('1234567890');
|
||||
|
||||
$this->manager->persist($vendorA);
|
||||
$this->manager->flush();
|
||||
return $vendorA;
|
||||
}
|
||||
|
||||
#[Override]
|
||||
public function load(ObjectManager $manager): void
|
||||
{
|
||||
$this->manager = $manager;
|
||||
$vendorA = $this->createVendor('Vendor A');
|
||||
$this->addMenuItemsToVendor($vendorA);
|
||||
|
||||
$vendorB = $this->createVendor('Vendor B');
|
||||
$this->addMenuItemsToVendor($vendorB);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,32 +47,32 @@ use function iterator_to_array;
|
|||
#[ORM\Entity(repositoryClass: FoodOrderRepository::class)]
|
||||
class FoodOrder
|
||||
{
|
||||
#[ORM\Column(nullable: true)]
|
||||
#[Groups(['food_order:read'])]
|
||||
#[ORM\Column(nullable: true)]
|
||||
private DateTimeImmutable|null $closedAt = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'foodOrders')]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
#[Groups(['food_order:read'])]
|
||||
#[ORM\Column(length: 255, options: [
|
||||
'default' => 'nobody',
|
||||
])]
|
||||
private string|null $createdBy = 'nobody';
|
||||
|
||||
#[Groups(['food_order:read', 'food_order:latest'])]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
#[ORM\ManyToOne(inversedBy: 'foodOrders')]
|
||||
private FoodVendor|null $foodVendor = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, OrderItem>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: OrderItem::class, mappedBy: 'foodOrder', orphanRemoval: true)]
|
||||
#[Groups(['food_order:read', 'food_order:latest'])]
|
||||
#[ORM\OneToMany(targetEntity: OrderItem::class, mappedBy: 'foodOrder', orphanRemoval: true)]
|
||||
private Collection $orderItems;
|
||||
|
||||
#[ORM\Column(length: 255, options: [
|
||||
'default' => 'nobody',
|
||||
])]
|
||||
#[Groups(['food_order:read'])]
|
||||
private string|null $createdBy = 'nobody';
|
||||
|
||||
public function __construct(
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(type: UlidType::NAME, unique: true)]
|
||||
#[Groups(['food_order:read'])]
|
||||
#[ORM\Column(type: UlidType::NAME, unique: true)]
|
||||
#[ORM\Id]
|
||||
private Ulid|null $id = new Ulid
|
||||
) {
|
||||
$this->id ??= new Ulid;
|
||||
|
@ -80,9 +80,24 @@ class FoodOrder
|
|||
$this->open();
|
||||
}
|
||||
|
||||
public function getId(): Ulid|null
|
||||
public function addOrderItem(OrderItem $orderItem): static
|
||||
{
|
||||
return $this->id;
|
||||
if (! $this->orderItems->contains($orderItem)) {
|
||||
$this->orderItems->add($orderItem);
|
||||
$orderItem->setFoodOrder($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function close(): static
|
||||
{
|
||||
return $this->setClosedAt(new DateTimeImmutable);
|
||||
}
|
||||
|
||||
public function getClosedAt(): DateTimeImmutable|null
|
||||
{
|
||||
return $this->closedAt;
|
||||
}
|
||||
|
||||
#[Groups(['food_order:read'])]
|
||||
|
@ -91,35 +106,9 @@ class FoodOrder
|
|||
return $this->id->getDateTime();
|
||||
}
|
||||
|
||||
public function getClosedAt(): DateTimeImmutable|null
|
||||
public function getCreatedBy(): string|null
|
||||
{
|
||||
return $this->closedAt;
|
||||
}
|
||||
|
||||
public function setClosedAt(DateTimeImmutable|null $closedAt = null): static
|
||||
{
|
||||
$this->closedAt = $closedAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isClosed(): bool
|
||||
{
|
||||
if (! $this->closedAt instanceof DateTimeImmutable) {
|
||||
return false;
|
||||
}
|
||||
return $this->closedAt < new DateTimeImmutable;
|
||||
}
|
||||
|
||||
public function close(): static
|
||||
{
|
||||
return $this->setClosedAt(new DateTimeImmutable);
|
||||
}
|
||||
|
||||
public function open(): static
|
||||
{
|
||||
$this->closedAt = (new DateTimeImmutable)->add(new DateInterval('PT1H'));
|
||||
return $this;
|
||||
return $this->createdBy;
|
||||
}
|
||||
|
||||
public function getFoodVendor(): FoodVendor|null
|
||||
|
@ -127,11 +116,9 @@ class FoodOrder
|
|||
return $this->foodVendor;
|
||||
}
|
||||
|
||||
public function setFoodVendor(FoodVendor|null $foodVendor): static
|
||||
public function getId(): Ulid|null
|
||||
{
|
||||
$this->foodVendor = $foodVendor;
|
||||
|
||||
return $this;
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -159,13 +146,17 @@ class FoodOrder
|
|||
);
|
||||
}
|
||||
|
||||
public function addOrderItem(OrderItem $orderItem): static
|
||||
public function isClosed(): bool
|
||||
{
|
||||
if (! $this->orderItems->contains($orderItem)) {
|
||||
$this->orderItems->add($orderItem);
|
||||
$orderItem->setFoodOrder($this);
|
||||
if (! $this->closedAt instanceof DateTimeImmutable) {
|
||||
return false;
|
||||
}
|
||||
return $this->closedAt < new DateTimeImmutable;
|
||||
}
|
||||
|
||||
public function open(): static
|
||||
{
|
||||
$this->closedAt = (new DateTimeImmutable)->add(new DateInterval('PT1H'));
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -179,9 +170,11 @@ class FoodOrder
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getCreatedBy(): string|null
|
||||
public function setClosedAt(DateTimeImmutable|null $closedAt = null): static
|
||||
{
|
||||
return $this->createdBy;
|
||||
$this->closedAt = $closedAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setCreatedBy(string $createdBy): static
|
||||
|
@ -190,4 +183,11 @@ class FoodOrder
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setFoodVendor(FoodVendor|null $foodVendor): static
|
||||
{
|
||||
$this->foodVendor = $foodVendor;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,19 +16,17 @@ use Symfony\Component\Validator\Constraints\Length;
|
|||
|
||||
use function mb_strlen;
|
||||
|
||||
#[ORM\Entity(repositoryClass: FoodVendorRepository::class)]
|
||||
#[ApiResource]
|
||||
#[ORM\Entity(repositoryClass: FoodVendorRepository::class)]
|
||||
class FoodVendor
|
||||
{
|
||||
#[ORM\Column(length: 50)]
|
||||
/**
|
||||
* String of emojis (max 30 characters)
|
||||
*/
|
||||
#[Groups(['food_order:latest', 'food_vendor:read'])]
|
||||
private string|null $name = null;
|
||||
|
||||
#[ORM\Column(length: 50, nullable: true, options: [
|
||||
'default' => '',
|
||||
])]
|
||||
#[Groups(['food_order:latest', 'food_vendor:read'])]
|
||||
private string|null $phone = null;
|
||||
#[Length(max: 10)]
|
||||
#[ORM\Column(length: 30, nullable: true)]
|
||||
private string|null $emojis = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, FoodOrder>
|
||||
|
@ -42,24 +40,26 @@ class FoodVendor
|
|||
#[ORM\OneToMany(targetEntity: MenuItem::class, mappedBy: 'foodVendor', orphanRemoval: true)]
|
||||
private Collection $menuItems;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
#[Groups(['food_order:latest'])]
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private string|null $menuLink = null;
|
||||
|
||||
/**
|
||||
* String of emojis (max 30 characters)
|
||||
*/
|
||||
#[ORM\Column(length: 30, nullable: true)]
|
||||
#[Groups(['food_order:latest', 'food_vendor:read'])]
|
||||
#[Length(max: 10)]
|
||||
private string|null $emojis = null;
|
||||
#[ORM\Column(length: 50)]
|
||||
private string|null $name = null;
|
||||
|
||||
#[Groups(['food_order:latest', 'food_vendor:read'])]
|
||||
#[ORM\Column(length: 50, nullable: true, options: [
|
||||
'default' => '',
|
||||
])]
|
||||
private string|null $phone = null;
|
||||
|
||||
public function __construct(
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
#[Groups(['food_order:latest'])]
|
||||
#[ORM\Column(type: UlidType::NAME, unique: true)]
|
||||
#[ORM\CustomIdGenerator(class: UlidGenerator::class)]
|
||||
#[Groups(['food_order:latest'])]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
#[ORM\Id]
|
||||
private Ulid|null $id = new Ulid
|
||||
) {
|
||||
$this->id ??= new Ulid;
|
||||
|
@ -67,31 +67,6 @@ class FoodVendor
|
|||
$this->menuItems = new ArrayCollection;
|
||||
}
|
||||
|
||||
public function getId(): Ulid|null
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): string|null
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): static
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, FoodOrder>
|
||||
*/
|
||||
public function getFoodOrders(): Collection
|
||||
{
|
||||
return $this->foodOrders;
|
||||
}
|
||||
|
||||
public function addFoodOrder(FoodOrder $foodOrder): static
|
||||
{
|
||||
if (! $this->foodOrders->contains($foodOrder)) {
|
||||
|
@ -102,16 +77,34 @@ class FoodVendor
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function removeFoodOrder(FoodOrder $foodOrder): static
|
||||
public function addMenuItem(MenuItem $menuItem): static
|
||||
{
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($this->foodOrders->removeElement($foodOrder)) {
|
||||
$foodOrder->setFoodVendor(null);
|
||||
if (! $this->menuItems->contains($menuItem)) {
|
||||
$this->menuItems->add($menuItem);
|
||||
$menuItem->setFoodVendor($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEmojis(): string|null
|
||||
{
|
||||
return $this->emojis;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, FoodOrder>
|
||||
*/
|
||||
public function getFoodOrders(): Collection
|
||||
{
|
||||
return $this->foodOrders;
|
||||
}
|
||||
|
||||
public function getId(): Ulid|null
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, MenuItem>
|
||||
*/
|
||||
|
@ -125,11 +118,26 @@ class FoodVendor
|
|||
);
|
||||
}
|
||||
|
||||
public function addMenuItem(MenuItem $menuItem): static
|
||||
public function getMenuLink(): string|null
|
||||
{
|
||||
if (! $this->menuItems->contains($menuItem)) {
|
||||
$this->menuItems->add($menuItem);
|
||||
$menuItem->setFoodVendor($this);
|
||||
return $this->menuLink;
|
||||
}
|
||||
|
||||
public function getName(): string|null
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getPhone(): string|null
|
||||
{
|
||||
return $this->phone;
|
||||
}
|
||||
|
||||
public function removeFoodOrder(FoodOrder $foodOrder): static
|
||||
{
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($this->foodOrders->removeElement($foodOrder)) {
|
||||
$foodOrder->setFoodVendor(null);
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
@ -145,34 +153,6 @@ class FoodVendor
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getMenuLink(): string|null
|
||||
{
|
||||
return $this->menuLink;
|
||||
}
|
||||
|
||||
public function setMenuLink(string|null $menuLink): static
|
||||
{
|
||||
$this->menuLink = $menuLink;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPhone(): string|null
|
||||
{
|
||||
return $this->phone;
|
||||
}
|
||||
|
||||
public function setPhone(string|null $phone): static
|
||||
{
|
||||
$this->phone = $phone;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEmojis(): string|null
|
||||
{
|
||||
return $this->emojis;
|
||||
}
|
||||
|
||||
public function setEmojis(string|null $emojis): static
|
||||
{
|
||||
if ($emojis !== null && mb_strlen($emojis) > 30) {
|
||||
|
@ -182,4 +162,24 @@ class FoodVendor
|
|||
$this->emojis = $emojis;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setMenuLink(string|null $menuLink): static
|
||||
{
|
||||
$this->menuLink = $menuLink;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setName(string $name): static
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setPhone(string|null $phone): static
|
||||
{
|
||||
$this->phone = $phone;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,108 +16,36 @@ use Symfony\Component\Uid\Ulid;
|
|||
#[ORM\Entity(repositoryClass: MenuItemRepository::class)]
|
||||
class MenuItem
|
||||
{
|
||||
#[ORM\Column(length: 255)]
|
||||
private string|null $name = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'menuItems')]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private FoodVendor|null $foodVendor = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private DateTimeImmutable|null $deletedAt = null;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'aliases')]
|
||||
private self|null $aliasOf = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, self>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: self::class, mappedBy: 'aliasOf')]
|
||||
private Collection $aliases;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'aliases')]
|
||||
private self|null $aliasOf = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private DateTimeImmutable|null $deletedAt = null;
|
||||
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
#[ORM\ManyToOne(inversedBy: 'menuItems')]
|
||||
private FoodVendor|null $foodVendor = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private string|null $name = null;
|
||||
|
||||
public function __construct(
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
#[ORM\Column(type: UlidType::NAME, unique: true)]
|
||||
#[ORM\CustomIdGenerator(class: UlidGenerator::class)]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
#[ORM\Id]
|
||||
private Ulid|null $id = new Ulid
|
||||
) {
|
||||
$this->id ??= new Ulid;
|
||||
$this->aliases = new ArrayCollection;
|
||||
}
|
||||
|
||||
public function getId(): Ulid|null
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): string|null
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): static
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFoodVendor(): FoodVendor|null
|
||||
{
|
||||
return $this->foodVendor;
|
||||
}
|
||||
|
||||
public function setFoodVendor(FoodVendor|null $foodVendor): static
|
||||
{
|
||||
$this->foodVendor = $foodVendor;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isDeleted(): bool
|
||||
{
|
||||
return $this->getDeletedAt() instanceof DateTimeImmutable;
|
||||
}
|
||||
|
||||
public function delete(): static
|
||||
{
|
||||
$this->setDeletedAt(new DateTimeImmutable);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDeletedAt(): DateTimeImmutable|null
|
||||
{
|
||||
return $this->deletedAt;
|
||||
}
|
||||
|
||||
public function setDeletedAt(DateTimeImmutable|null $deletedAt = new DateTimeImmutable): static
|
||||
{
|
||||
$this->deletedAt = $deletedAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAliasOf(): self|null
|
||||
{
|
||||
return $this->aliasOf;
|
||||
}
|
||||
|
||||
public function setAliasOf(self|null $aliasOf): static
|
||||
{
|
||||
$this->aliasOf = $aliasOf;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, self>
|
||||
*/
|
||||
public function getAliases(): Collection
|
||||
{
|
||||
return $this->aliases;
|
||||
}
|
||||
|
||||
public function addAlias(self $alias): static
|
||||
{
|
||||
if (! $this->aliases->contains($alias)) {
|
||||
|
@ -128,6 +56,50 @@ class MenuItem
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function delete(): static
|
||||
{
|
||||
$this->setDeletedAt(new DateTimeImmutable);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, self>
|
||||
*/
|
||||
public function getAliases(): Collection
|
||||
{
|
||||
return $this->aliases;
|
||||
}
|
||||
|
||||
public function getAliasOf(): self|null
|
||||
{
|
||||
return $this->aliasOf;
|
||||
}
|
||||
|
||||
public function getDeletedAt(): DateTimeImmutable|null
|
||||
{
|
||||
return $this->deletedAt;
|
||||
}
|
||||
|
||||
public function getFoodVendor(): FoodVendor|null
|
||||
{
|
||||
return $this->foodVendor;
|
||||
}
|
||||
|
||||
public function getId(): Ulid|null
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): string|null
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function isDeleted(): bool
|
||||
{
|
||||
return $this->getDeletedAt() instanceof DateTimeImmutable;
|
||||
}
|
||||
|
||||
public function removeAlias(self $alias): static
|
||||
{
|
||||
// set the owning side to null (unless already changed)
|
||||
|
@ -137,4 +109,32 @@ class MenuItem
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setAliasOf(self|null $aliasOf): static
|
||||
{
|
||||
$this->aliasOf = $aliasOf;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setDeletedAt(DateTimeImmutable|null $deletedAt = new DateTimeImmutable): static
|
||||
{
|
||||
$this->deletedAt = $deletedAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setFoodVendor(FoodVendor|null $foodVendor): static
|
||||
{
|
||||
$this->foodVendor = $foodVendor;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setName(string $name): static
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,62 +14,77 @@ use Symfony\Component\Uid\Ulid;
|
|||
#[ORM\Entity(repositoryClass: OrderItemRepository::class)]
|
||||
class OrderItem
|
||||
{
|
||||
#[ORM\Column(length: 255)]
|
||||
#[Groups(['food_order:latest'])]
|
||||
private string|null $name = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
#[Groups(['food_order:latest'])]
|
||||
private string|null $extras = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'orderItems')]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
private FoodOrder|null $foodOrder = null;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
#[Groups(['food_order:latest'])]
|
||||
private MenuItem|null $menuItem = null;
|
||||
|
||||
#[ORM\Column(length: 255, options: [
|
||||
'default' => 'nobody',
|
||||
])]
|
||||
#[Groups(['food_order:latest'])]
|
||||
private string|null $createdBy = 'nobody';
|
||||
|
||||
#[Groups(['food_order:latest'])]
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private string|null $extras = null;
|
||||
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
#[ORM\ManyToOne(inversedBy: 'orderItems')]
|
||||
private FoodOrder|null $foodOrder = null;
|
||||
|
||||
#[Groups(['food_order:latest'])]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
#[ORM\ManyToOne]
|
||||
private MenuItem|null $menuItem = null;
|
||||
|
||||
#[Groups(['food_order:latest'])]
|
||||
#[ORM\Column(length: 255)]
|
||||
private string|null $name = null;
|
||||
|
||||
public function __construct(
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
#[Groups(['food_order:latest'])]
|
||||
#[ORM\Column(type: UlidType::NAME, unique: true)]
|
||||
#[ORM\CustomIdGenerator(class: UlidGenerator::class)]
|
||||
#[Groups(['food_order:latest'])]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
#[ORM\Id]
|
||||
private Ulid|null $id = new Ulid
|
||||
) {
|
||||
$this->id ??= new Ulid;
|
||||
}
|
||||
|
||||
public function getCreatedBy(): string|null
|
||||
{
|
||||
return $this->createdBy;
|
||||
}
|
||||
|
||||
public function getExtras(): string|null
|
||||
{
|
||||
return $this->extras;
|
||||
}
|
||||
|
||||
public function getFoodOrder(): FoodOrder|null
|
||||
{
|
||||
return $this->foodOrder;
|
||||
}
|
||||
|
||||
public function getId(): Ulid|null
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getMenuItem(): MenuItem|null
|
||||
{
|
||||
return $this->menuItem;
|
||||
}
|
||||
|
||||
public function getName(): string|null
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): static
|
||||
public function setCreatedBy(string $createdBy): static
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->createdBy = $createdBy;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getExtras(): string|null
|
||||
{
|
||||
return $this->extras;
|
||||
}
|
||||
|
||||
public function setExtras(string|null $extras): static
|
||||
{
|
||||
$this->extras = $extras;
|
||||
|
@ -77,11 +92,6 @@ class OrderItem
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getFoodOrder(): FoodOrder|null
|
||||
{
|
||||
return $this->foodOrder;
|
||||
}
|
||||
|
||||
public function setFoodOrder(FoodOrder|null $foodOrder): static
|
||||
{
|
||||
$this->foodOrder = $foodOrder;
|
||||
|
@ -89,11 +99,6 @@ class OrderItem
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getMenuItem(): MenuItem|null
|
||||
{
|
||||
return $this->menuItem;
|
||||
}
|
||||
|
||||
public function setMenuItem(MenuItem|null $menuItem): static
|
||||
{
|
||||
$this->menuItem = $menuItem;
|
||||
|
@ -102,14 +107,9 @@ class OrderItem
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getCreatedBy(): string|null
|
||||
public function setName(string $name): static
|
||||
{
|
||||
return $this->createdBy;
|
||||
}
|
||||
|
||||
public function setCreatedBy(string $createdBy): static
|
||||
{
|
||||
$this->createdBy = $createdBy;
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
|
@ -19,12 +19,6 @@ final class FoodOrderRepository extends ServiceEntityRepository
|
|||
parent::__construct($registry, FoodOrder::class);
|
||||
}
|
||||
|
||||
public function save(): void
|
||||
{
|
||||
$this->getEntityManager()
|
||||
->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return FoodOrder[]
|
||||
*/
|
||||
|
@ -48,6 +42,15 @@ final class FoodOrderRepository extends ServiceEntityRepository
|
|||
->getValues();
|
||||
}
|
||||
|
||||
public function findLatestOrder(): FoodOrder|null
|
||||
{
|
||||
return $this->createQueryBuilder('alias')
|
||||
->orderBy('alias.id', 'DESC')
|
||||
->setMaxResults(1)
|
||||
->getQuery()
|
||||
->getOneOrNullResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return FoodOrder[]
|
||||
*/
|
||||
|
@ -63,12 +66,9 @@ final class FoodOrderRepository extends ServiceEntityRepository
|
|||
->getResult();
|
||||
}
|
||||
|
||||
public function findLatestOrder(): FoodOrder|null
|
||||
public function save(): void
|
||||
{
|
||||
return $this->createQueryBuilder('alias')
|
||||
->orderBy('alias.id', 'DESC')
|
||||
->setMaxResults(1)
|
||||
->getQuery()
|
||||
->getOneOrNullResult();
|
||||
$this->getEntityManager()
|
||||
->flush();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
{
|
||||
"api-platform/core": {
|
||||
"api-platform/symfony": {
|
||||
"version": "4.1",
|
||||
"recipe": {
|
||||
"repo": "github.com/symfony/recipes",
|
||||
"branch": "main",
|
||||
"version": "4.0",
|
||||
"ref": "cb9e6b8ceb9b62f32d41fc8ad72a25d5bd674c6d"
|
||||
"ref": "e9952e9f393c2d048f10a78f272cd35e807d972b"
|
||||
},
|
||||
"files": [
|
||||
"config/packages/api_platform.yaml",
|
||||
|
|
|
@ -18,10 +18,10 @@ use function str_contains;
|
|||
abstract class DbWebTest extends WebTestCase
|
||||
{
|
||||
protected KernelBrowser $client;
|
||||
protected EntityManagerInterface $manager;
|
||||
protected EntityRepository $repository;
|
||||
protected string $entityClass = '';
|
||||
protected EntityManagerInterface $manager;
|
||||
protected string $path = '';
|
||||
protected EntityRepository $repository;
|
||||
|
||||
#[Override]
|
||||
protected function setUp(): void
|
||||
|
@ -35,13 +35,6 @@ abstract class DbWebTest extends WebTestCase
|
|||
$schemaTool->updateSchema($metadata);
|
||||
}
|
||||
|
||||
protected function generateOldUlid(int $daysToSubtract = 10): Ulid
|
||||
{
|
||||
$date = (new DateTimeImmutable)->sub(new DateInterval('P' . $daysToSubtract . 'D'));
|
||||
$ulidString = Ulid::generate($date);
|
||||
return Ulid::fromString($ulidString);
|
||||
}
|
||||
|
||||
protected function assertElementContainsCount(Crawler $crawler, string $element, int $count, string $text): void
|
||||
{
|
||||
$this->assertCount(
|
||||
|
@ -53,6 +46,13 @@ abstract class DbWebTest extends WebTestCase
|
|||
);
|
||||
}
|
||||
|
||||
protected function generateOldUlid(int $daysToSubtract = 10): Ulid
|
||||
{
|
||||
$date = (new DateTimeImmutable)->sub(new DateInterval('P' . $daysToSubtract . 'D'));
|
||||
$ulidString = Ulid::generate($date);
|
||||
return Ulid::fromString($ulidString);
|
||||
}
|
||||
|
||||
protected function setEntityClass(string $entityClass): void
|
||||
{
|
||||
$this->entityClass = $entityClass;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue