futtern/tests/Entity/FoodVendorTest.php
lubiana 34171d6c2b
All checks were successful
/ ls (pull_request) Successful in 37s
/ ls (push) Successful in 37s
/ ls (release) Successful in 24s
100% test coverage
2024-08-16 13:44:16 +02:00

43 lines
1.4 KiB
PHP

<?php declare(strict_types=1);
namespace App\Tests\Entity;
use App\Entity\FoodOrder;
use App\Entity\FoodVendor;
use App\Entity\MenuItem;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Uid\Ulid;
final class FoodVendorTest extends TestCase
{
public function testFoodVendor(): void
{
$vendor = new FoodVendor;
$vendor->setName('Test');
$this->assertEquals('Test', $vendor->getName());
$this->assertInstanceOf(Ulid::class, $vendor->getId());
$this->assertCount(0, $vendor->getFoodOrders());
$order1 = new FoodOrder;
$vendor->addFoodOrder($order1);
$vendor->addFoodOrder($order1);
$this->assertCount(1, $vendor->getFoodOrders());
$vendor->removeFoodOrder($order1);
$this->assertCount(0, $vendor->getFoodOrders());
$menuItem1 = new MenuItem;
$menuItem2 = new MenuItem;
$this->assertCount(0, $vendor->getMenuItems());
$vendor->addMenuItem($menuItem1);
$vendor->addMenuItem($menuItem1);
$this->assertCount(1, $vendor->getMenuItems());
$vendor->removeMenuItem($menuItem1);
$this->assertCount(0, $vendor->getMenuItems());
$vendor->addMenuItem($menuItem1);
$menuItem2->delete();
$vendor->addMenuItem($menuItem2);
$this->assertCount(1, $vendor->getMenuItems());
$this->assertCount(2, $vendor->getMenuItems(true));
}
}