Doctrine schema validation in a PHPUnit test

Doctrine offers a command line option to validate the schema (or mapping):

./doctrine orm:validate-schema

This is very useful, when I ran it against my code, which was working by the way, I got several errors/warnings.

However, I didn’t want to have to run this tool manually once in a while. I already have tests for that. So I thought: why not integrating the schema validation to the tests!

So here is my implementation of a PHPUnit test failing when Doctrine validation find errors: