improve test coverage #54
3 changed files with 6 additions and 12 deletions
|
@ -67,15 +67,10 @@ class FoodOrder
|
|||
|
||||
public function isClosed(): bool
|
||||
{
|
||||
if ($this->closedAt === null) {
|
||||
if (! $this->closedAt instanceof DateTimeImmutable) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->closedAt < new DateTimeImmutable) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return $this->closedAt < new DateTimeImmutable;
|
||||
}
|
||||
|
||||
public function close(): static
|
||||
|
|
|
@ -192,7 +192,6 @@ final class FoodOrderControllerTest extends DbWebTest
|
|||
$this->manager->persist($order);
|
||||
$this->manager->flush();
|
||||
|
||||
|
||||
$this->client->request('GET', sprintf('%s%s/open', $this->path, $order->getId()));
|
||||
self::assertResponseRedirects("{$this->path}{$order->getId()}");
|
||||
$openOrder = $this->repository->find($order->getId());
|
||||
|
@ -209,7 +208,6 @@ final class FoodOrderControllerTest extends DbWebTest
|
|||
$this->manager->persist($order);
|
||||
$this->manager->flush();
|
||||
|
||||
|
||||
$this->client->request('GET', sprintf('%s%s/close', $this->path, $order->getId()));
|
||||
self::assertResponseRedirects("{$this->path}{$order->getId()}");
|
||||
$openOrder = $this->repository->find($order->getId());
|
||||
|
|
|
@ -8,6 +8,7 @@ use App\Entity\MenuItem;
|
|||
use App\Entity\OrderItem;
|
||||
use App\Repository\MenuItemRepository;
|
||||
use App\Tests\DbWebTest;
|
||||
use DateTimeImmutable;
|
||||
use Override;
|
||||
|
||||
use function sprintf;
|
||||
|
@ -66,7 +67,7 @@ final class OrderItemControllerTest extends DbWebTest
|
|||
public function testNewOrderClosed(): void
|
||||
{
|
||||
|
||||
$this->order->setClosedAt(new \DateTimeImmutable('-1 Hour'));
|
||||
$this->order->setClosedAt(new DateTimeImmutable('-1 Hour'));
|
||||
$this->manager->persist($this->order);
|
||||
$this->manager->flush();
|
||||
|
||||
|
@ -172,7 +173,6 @@ final class OrderItemControllerTest extends DbWebTest
|
|||
self::assertSame(1, $this->repository->count([]));
|
||||
self::assertSame(2, $this->menuItemRepository->count([]));
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function testEditOrderClosed(): void
|
||||
|
@ -182,13 +182,14 @@ final class OrderItemControllerTest extends DbWebTest
|
|||
$orderItem->setExtras('My Extra');
|
||||
$orderItem->setFoodOrder($this->order);
|
||||
$orderItem->setMenuItem($this->menuItem);
|
||||
|
||||
$this->order->close();
|
||||
|
||||
$this->manager->persist($orderItem);
|
||||
$this->manager->persist($this->order);
|
||||
$this->manager->flush();
|
||||
|
||||
$crawler = $this->client->request('GET', sprintf('%s%s/edit', $this->path, $orderItem->getId()));
|
||||
$this->client->request('GET', sprintf('%s%s/edit', $this->path, $orderItem->getId()));
|
||||
self::assertResponseRedirects(sprintf('/food/order/%s', $this->order->getId()));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue