Testing the orders

Exercise 5 of 6 in chapter 11 · 280 XP · 5 objectives checked by tests

Topics covered: CommandTester

The big clean-up works. But a command that deletes data, run every month without anyone watching it, is exactly the kind of code you want to be sure of. The day Pippin “simplifies” it, the tests will have to scream.

Testing a command

CommandTester runs a command as in a terminal, without a terminal:

$this->commande->execute(['--avant' => '2026-08-01', '--dry-run' => true]);
$this->commande->getStatusCode();  // the exit code
$this->commande->getDisplay();     // what it displayed

For a command that changes data, what matters most is not what it displays, it is what it does: look at what is left in the database.

Your mission

In tests/Taverne/PurgeTest.php, write the tests that protect the big clean-up. A first test is already there, with helpers to save reservations (reservation()) and read the ones that are left (restantes() = the remaining ones).

How you're graded

Same as for the aviary: your tests must pass on the big clean-up as it is, then fail on each of the four mutants 🐛. Each mutant is a plausible mistake, the kind you make while “simplifying”. A mutant that survives is a missing test.