forked from lubiana/futtern
added a /api/food_orders/latest/ endpoint to recieve the latest food order
This commit is contained in:
parent
ee32852789
commit
300c8cafc9
4 changed files with 64 additions and 0 deletions
|
@ -231,6 +231,30 @@ describe(FoodOrderController::class, function (): void {
|
|||
$this->assertTrue($openOrder->isClosed());
|
||||
});
|
||||
|
||||
test('api_latest_order', function (): void {
|
||||
// Create an older order
|
||||
$olderOrder = new FoodOrder($this->generateOldUlid());
|
||||
$olderOrder->setFoodVendor($this->vendor);
|
||||
$this->manager->persist($olderOrder);
|
||||
|
||||
// Create the latest order
|
||||
$latestOrder = new FoodOrder;
|
||||
$latestOrder->setFoodVendor($this->vendor);
|
||||
$this->manager->persist($latestOrder);
|
||||
|
||||
$this->manager->flush();
|
||||
|
||||
// Test the API endpoint
|
||||
$this->client->request('GET', '/api/food_orders/latest');
|
||||
$this->assertResponseIsSuccessful();
|
||||
$this->assertResponseHeaderSame('Content-Type', 'application/ld+json; charset=utf-8');
|
||||
|
||||
$response = json_decode($this->client->getResponse()->getContent(), true);
|
||||
$this->assertIsArray($response);
|
||||
$this->assertArrayHasKey('@id', $response);
|
||||
$this->assertStringContainsString($latestOrder->getId()->__toString(), $response['@id']);
|
||||
});
|
||||
|
||||
})
|
||||
->covers(
|
||||
FoodOrderController::class,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue