Continuous Integration Fixes
All checks were successful
/ ls (push) Successful in 34s

This commit is contained in:
Continuous Integration 2024-08-14 17:41:59 +00:00
parent 83989916a3
commit 25b73e7da5
2 changed files with 15 additions and 5 deletions

View file

@ -11,6 +11,8 @@ use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Types\UlidType;
use Symfony\Component\Uid\Ulid;
use function iterator_to_array;
#[ORM\Entity(repositoryClass: FoodOrderRepository::class)]
class FoodOrder
{
@ -104,9 +106,10 @@ class FoodOrder
*/
public function getOrderItemsSortedByName(): Collection
{
$iterator = $this->getOrderItems()->getIterator();
$iterator = $this->getOrderItems()
->getIterator();
$iterator->uasort(
fn (OrderItem $a, OrderItem $b): int => $a->getName() <=> $b->getName()
static fn(OrderItem $a, OrderItem $b): int => $a->getName() <=> $b->getName()
);
return new ArrayCollection(
iterator_to_array(

View file

@ -58,36 +58,43 @@ final class FoodOrderControllerTest extends DbWebTest
{
$order = new FoodOrder;
$order->setFoodVendor($this->vendor);
$this->manager->persist($order);
$this->manager->persist($this->vendor);
$menuItemA = new MenuItem();
$menuItemA = new MenuItem;
$menuItemA->setName('A');
$menuItemA->setFoodVendor($this->vendor);
$this->manager->persist($menuItemA);
$itemA = new OrderItem;
$itemA->setMenuItem($menuItemA);
$itemA->setName($menuItemA->getName());
$order->addOrderItem($itemA);
$this->manager->persist($itemA);
$menuItemC = new MenuItem();
$menuItemC = new MenuItem;
$menuItemC->setName('C');
$menuItemC->setFoodVendor($this->vendor);
$this->manager->persist($menuItemC);
$itemC = new OrderItem;
$itemC->setMenuItem($menuItemC);
$itemC->setName($menuItemC->getName());
$order->addOrderItem($itemC);
$this->manager->persist($itemC);
$menuItemB = new MenuItem();
$menuItemB = new MenuItem;
$menuItemB->setName('B');
$menuItemB->setFoodVendor($this->vendor);
$this->manager->persist($menuItemB);
$itemB = new OrderItem;
$itemB->setMenuItem($menuItemB);
$itemB->setName($menuItemB->getName());
$order->addOrderItem($itemB);
$this->manager->persist($itemB);