The scrolls' API has become the tavern's main reservation channel. A regression there would be costly. And a leak of a guild's seal would be even costlier.
Your mission
In tests/Taverne/ApiTest.php, prepare a guild (with the seal self::SCEAU, sceau means seal), a dish and a review, then test:
GET /api/dishes: JSON, and only the menu fields (no reviews, no rating);POST /api/reservationswith the seal: 201, and the response names the guild;- that response never contains the seal;
- without a seal: 401;
- 13 adventurers: 422, with a violation on
personnes.
Testing an API
$this->client->jsonRequest('GET', '/api/dishes'); $this->client->jsonRequest('POST', '/api/reservations', ['nom' => 'Gimli', …], ['HTTP_AUTHORIZATION' => 'Bearer …']); $this->assertResponseStatusCodeSame(201); $json = json_decode($this->client->getResponse()->getContent(), true);
Be precise
For an API, “it responds” is not enough: the details make up the contract with the scrolls. The exact code (201 is not 200), the exact list of fields, and what must never show up.
Four mutants 🐛, one per detail.