The aviary works. Now you need to make sure it will still work in six months, when Pippin has “tidied up” the configuration.
Testing messages calls for a bit of method: the work no longer happens during the request. A test that only looks at the final result would not see the difference between “handled in the background” and “handled right away”.
Your mission
In tests/Taverne/CorbeauxTest.php, write the tests for the whole chain:
- a reservation puts a message in the queue, and does not send any raven right away;
- when the queue is handled, the raven leaves, with the right message;
- an impossible delivery (Sauron) is retried, then set aside in the failure queue;
- the evening summary only counts tomorrow's tables.
Your tools
The FileDeMessages trait (message queue), already provided:
$this->messagesEnFile(); // the messages waiting in the queue ("async" transport) $this->messagesEnFile('echoues'); // the ones that were set aside $this->consommerLaFile(); // handles the queue, and returns the number of messages handled $this->lancerLeWorker(); // a real worker: retries and failure queue included
consommerLaFile() (consume the queue) is enough for the normal case. To observe a failure, you need a real worker (lancerLeWorker(), start the worker): its retries are what end up setting the message aside.
How you're graded
Same as in the previous chapter: your tests must pass on the aviary as it is, then fail on each of the four mutants 🐛. A mutant that survives means a missing test.