- test methods, January to March
- 295 → 1,014
- test files
- 48 → 214
By the end of 2024 SupplyMars had a catalogue, pricing, orders, purchasing, a simulation and sales reports. It had 295 tests. Before building anything else, I spent the first quarter of 2025 going back over what was there.
One CRUD handler
The admin screens ran on a generic CRUD layer, in use since February 2024. By January it had six options classes, one per kind of operation plus shared bases. The rewrite collapsed the options into one CrudOptions and gave the handlers a single base class with a fixed shape: process() checks the entity exists, setup() builds that operation's options, and build() renders or acts on them. Create, read, update and delete each fill in those steps; search kept its own class.
The same change moved work out of controllers into services, such as ProductImageCreator, ProductImageOrderer and the supplier product mapping actions.
A test for every class, twice
The project has had three test tiers since March 2024: unit tests with no kernel, integration tests against a real database through Foundry factories, and application tests that drive the controllers. In the winter I filled them in.
The first step, in late January, was entity tests: 262 test methods in a day, written against the entities through their factories. In mid-February the order and purchase order entities moved to named constructors, and their tests and factories moved with them. Then came the big one. Every entity, DTO and event listener, and 42 services outside the CRUD layer, got a unit test, with its collaborators mocked, and an integration test, with the real thing:
| Kind | Unit | Integration |
|---|---|---|
| Entities | 24 | 24 |
| Services | 42 | 42 |
| DTOs | 18 | 18 |
| Event listeners | 13 | 13 |
Application tests went from 10 files to 17. That change ran from late February to late March, touched 494 files, and took the suite from 597 test methods to 1,014. The same commit moved Rector's configuration to withComposerBased(), which picks the Symfony, Doctrine, Twig and PHPUnit rule sets to match the versions installed.
The pairs test different things. CreateOrderTest mocks the entity manager, the validator and the event dispatcher, and checks what the service does with them. CreateOrderIntegrationTest creates a customer, an address and a VAT rate, runs the service, and finds the order in the database. A unit test says the logic is right; the integration test says it still works once Doctrine, validation and the real entities are involved.
Smaller fixes
assert()became real checks. The custom validation constraints usedassert()to check what they'd been given. PHP skipsassert()when assertions are turned off, as production configurations do, so those checks became explicitInvalidArgumentExceptions.- Tailwind v4.
tailwind.config.jswas deleted and the configuration moved into the CSS, with an@themeblock for the colours. Two custom variants,turbo-frame:andmodal:, let a template style itself differently inside a Turbo Frame or a dialog; 29 templates changed with the upgrade.
Update, January 2026: the CRUD layer, base class and all, was replaced by FormFlow in the rebuild by bounded context. The test suite was rebuilt with it, per context.
References