Compare commits
No commits in common. "2a28465626e414cc3cd8a285d076b3d92f2ea829" and "a4f62868fd21fecbf88f37c8f1d6c477c14b36e1" have entirely different histories.
2a28465626
...
a4f62868fd
3 changed files with 2 additions and 126 deletions
|
@ -58,7 +58,7 @@ class FoodOrder
|
||||||
return $this->closedAt;
|
return $this->closedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setClosedAt(DateTimeImmutable|null $closedAt = null): static
|
public function setClosedAt(DateTimeImmutable|null $closedAt): static
|
||||||
{
|
{
|
||||||
$this->closedAt = $closedAt;
|
$this->closedAt = $closedAt;
|
||||||
|
|
||||||
|
@ -67,10 +67,7 @@ class FoodOrder
|
||||||
|
|
||||||
public function isClosed(): bool
|
public function isClosed(): bool
|
||||||
{
|
{
|
||||||
if (! $this->closedAt instanceof DateTimeImmutable) {
|
return $this->closedAt instanceof DateTimeImmutable && $this->closedAt->getTimestamp() <= (new DateTimeImmutable)->getTimestamp();
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return $this->closedAt < new DateTimeImmutable;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function close(): static
|
public function close(): static
|
||||||
|
|
|
@ -182,38 +182,6 @@ final class FoodOrderControllerTest extends DbWebTest
|
||||||
self::assertSame(1, $this->repository->count([]));
|
self::assertSame(1, $this->repository->count([]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testOpen(): void
|
|
||||||
{
|
|
||||||
$order = new FoodOrder;
|
|
||||||
$order->setFoodVendor($this->vendor);
|
|
||||||
$order->close();
|
|
||||||
|
|
||||||
$this->assertTrue($order->isClosed());
|
|
||||||
$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());
|
|
||||||
$this->assertFalse($openOrder->isClosed());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testClose(): void
|
|
||||||
{
|
|
||||||
$order = new FoodOrder;
|
|
||||||
$order->setClosedAt();
|
|
||||||
$order->setFoodVendor($this->vendor);
|
|
||||||
|
|
||||||
$this->assertFalse($order->isClosed());
|
|
||||||
$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());
|
|
||||||
$this->assertTrue($openOrder->isClosed());
|
|
||||||
}
|
|
||||||
|
|
||||||
private function generatePaginatedOrders(): void
|
private function generatePaginatedOrders(): void
|
||||||
{
|
{
|
||||||
foreach (range(1, 35) as $i) {
|
foreach (range(1, 35) as $i) {
|
||||||
|
|
|
@ -8,7 +8,6 @@ use App\Entity\MenuItem;
|
||||||
use App\Entity\OrderItem;
|
use App\Entity\OrderItem;
|
||||||
use App\Repository\MenuItemRepository;
|
use App\Repository\MenuItemRepository;
|
||||||
use App\Tests\DbWebTest;
|
use App\Tests\DbWebTest;
|
||||||
use DateTimeImmutable;
|
|
||||||
use Override;
|
use Override;
|
||||||
|
|
||||||
use function sprintf;
|
use function sprintf;
|
||||||
|
@ -64,23 +63,6 @@ final class OrderItemControllerTest extends DbWebTest
|
||||||
self::assertSame(1, $this->menuItemRepository->count([]));
|
self::assertSame(1, $this->menuItemRepository->count([]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNewOrderClosed(): void
|
|
||||||
{
|
|
||||||
|
|
||||||
$this->order->setClosedAt(new DateTimeImmutable('-1 Hour'));
|
|
||||||
$this->manager->persist($this->order);
|
|
||||||
$this->manager->flush();
|
|
||||||
|
|
||||||
$this->client->request(
|
|
||||||
'GET',
|
|
||||||
sprintf('%snew/%s', $this->path, $this->order->getId())
|
|
||||||
);
|
|
||||||
|
|
||||||
self::assertResponseRedirects(sprintf('/food/order/%s', $this->order->getId()));
|
|
||||||
|
|
||||||
self::assertSame(0, $this->repository->count([]));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testNewCreateMenuItem(): void
|
public function testNewCreateMenuItem(): void
|
||||||
{
|
{
|
||||||
$this->client->request(
|
$this->client->request(
|
||||||
|
@ -119,26 +101,6 @@ final class OrderItemControllerTest extends DbWebTest
|
||||||
self::assertSame(0, $this->repository->count([]));
|
self::assertSame(0, $this->repository->count([]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testOrderClosed(): void
|
|
||||||
{
|
|
||||||
$fixture = new OrderItem;
|
|
||||||
$fixture->setName('Testing');
|
|
||||||
$fixture->setExtras('Value');
|
|
||||||
$fixture->setMenuItem($this->menuItem);
|
|
||||||
$fixture->setFoodOrder($this->order);
|
|
||||||
|
|
||||||
$this->order->close();
|
|
||||||
|
|
||||||
$this->manager->persist($this->order);
|
|
||||||
$this->manager->persist($fixture);
|
|
||||||
$this->manager->flush();
|
|
||||||
|
|
||||||
$this->client->request('GET', sprintf('%sdelete/%s', $this->path, $fixture->getId()));
|
|
||||||
|
|
||||||
self::assertResponseRedirects(sprintf('/food/order/%s', $this->order->getId()));
|
|
||||||
self::assertSame(1, $this->repository->count([]));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testEdit(): void
|
public function testEdit(): void
|
||||||
{
|
{
|
||||||
$orderItem = new OrderItem;
|
$orderItem = new OrderItem;
|
||||||
|
@ -162,35 +124,6 @@ final class OrderItemControllerTest extends DbWebTest
|
||||||
'My Extra',
|
'My Extra',
|
||||||
$extrasElem->attr('value')
|
$extrasElem->attr('value')
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->client->submitForm('Update', [
|
|
||||||
'order_item[name]' => 'Testing-1',
|
|
||||||
'order_item[extras]' => 'Testing-1',
|
|
||||||
]);
|
|
||||||
|
|
||||||
self::assertResponseRedirects(sprintf('/food/order/%s', $this->order->getId()));
|
|
||||||
|
|
||||||
self::assertSame(1, $this->repository->count([]));
|
|
||||||
self::assertSame(2, $this->menuItemRepository->count([]));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testEditOrderClosed(): void
|
|
||||||
{
|
|
||||||
$orderItem = new OrderItem;
|
|
||||||
$orderItem->setName('Testing');
|
|
||||||
$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();
|
|
||||||
|
|
||||||
$this->client->request('GET', sprintf('%s%s/edit', $this->path, $orderItem->getId()));
|
|
||||||
self::assertResponseRedirects(sprintf('/food/order/%s', $this->order->getId()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCopy(): void
|
public function testCopy(): void
|
||||||
|
@ -217,28 +150,6 @@ final class OrderItemControllerTest extends DbWebTest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCopyOrderClosed(): void
|
|
||||||
{
|
|
||||||
$orderItem = new OrderItem;
|
|
||||||
$orderItem->setName('My Title');
|
|
||||||
$orderItem->setExtras('My Title');
|
|
||||||
$orderItem->setFoodOrder($this->order);
|
|
||||||
$orderItem->setMenuItem($this->menuItem);
|
|
||||||
|
|
||||||
$this->order->close();
|
|
||||||
$this->manager->persist($this->order);
|
|
||||||
$this->manager->persist($orderItem);
|
|
||||||
$this->manager->flush();
|
|
||||||
|
|
||||||
$this->client->request('GET', sprintf('%s%s/copy', $this->path, $orderItem->getId()));
|
|
||||||
self::assertResponseRedirects(sprintf('/food/order/%s', $this->order->getId()));
|
|
||||||
|
|
||||||
$result = $this->repository->findBy([
|
|
||||||
'foodOrder' => $this->order->getId(),
|
|
||||||
]);
|
|
||||||
$this->assertCount(1, $result);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[Override]
|
#[Override]
|
||||||
public function getEntityClass(): string
|
public function getEntityClass(): string
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue