add price feature
All checks were successful
/ ls (pull_request) Successful in 1m37s

This commit is contained in:
lubiana 2025-06-29 23:18:23 +02:00
parent 15f8db46a0
commit 64f5341371
Signed by: lubiana
SSH key fingerprint: SHA256:vW1EA0fRR3Fw+dD/sM0K+x3Il2gSry6YRYHqOeQwrfk
18 changed files with 484 additions and 157 deletions

View file

@ -0,0 +1,45 @@
<?php declare(strict_types=1);
use App\Entity\FoodOrder;
use App\Entity\FoodVendor;
use App\Entity\OrderItem;
pest()
->beforeEach(function (): void {
$this->setEntityClass(FoodOrder::class);
$this->setPath('/food/order/');
$this->repository = $this->manager->getRepository($this->entityClass);
$this->vendor = new FoodVendor;
$this->vendor->setName('Food Vendor');
$this->manager->persist($this->vendor);
$this->order = new FoodOrder;
$this->order->setFoodVendor($this->vendor);
$this->manager->persist($this->order);
$this->manager->flush();
});
it('updates the menu item price', function (): void {
$orderItem = new OrderItem;
$orderItem->setFoodOrder($this->order);
$orderItem->setName('Item');
$orderItem->setPriceCents(100);
$this->manager->persist($orderItem);
$this->manager->flush();
expect($orderItem->getMenuItem()->getPriceCents())
->toBe(100);
$orderItem->setPriceCents(200);
$this->manager->persist($orderItem);
$this->manager->flush();
$id = $orderItem->getId();
$orderItem = $this->manager->find(OrderItem::class, $id);
expect($orderItem->getMenuItem()->getPriceCents())
->toBe(200);
});