Over four years our test suite accumulated twelve helper traits providing assertions like assertArrayMatchesSchema(). Maintaining these across PHPUnit version upgrades was a steady tax of deprecated internal class references.
// Old custom helper trait (80 lines of reflection):
$this->assertMatchesJsonContract($expectedJson, $response->getContent());
// PHPUnit 12 modern native assertion:
$this->assertThat(
$response->getContent(),
$this->logicalAnd(
$this->isJson(),
$this->matchesRegularExpression('/"status":"success"/')
)
);
Deleting custom assertion traits eliminated four hundred lines of untested testing infrastructure. When a native constraint fails, the diff output from PHPUnit is significantly cleaner and accurately points to the line in the test file rather than inside the trait wrapper.