I have created a Symfony Command to reset my Application to an initial state. To run that command from the cli I need to type:
php bin/console app:reset
I would like to run that command once before all unit tests. I could manage to do that before each test and surely before all classes. Therefore I used that code:
public function setUp()
{
$kernel = new \AppKernel('test', true);
$kernel->boot();
$app = new \Symfony\Bundle\FrameworkBundle\Console\Application($kernel);
$app->setAutoExit(false);
$app->run(new ArrayInput([
'command' => 'app:reset', ['-q']
]), new NullOutput());
}
As mentioned above, that is working nice before each test and with setUpBeforeClass() I could have that before each class, but once before all tests would be sufficient, since that command take some time to run.