entityManager; } protected function setUp(): void { $this->entityManager = static::createClient()->getContainer() ->get('doctrine') ->getManager(); parent::setUp(); } protected static function runCommand($command) { $command = sprintf('%s --quiet', $command); return self::getApplication()->run(new StringInput($command)); } private static function getApplication(): Application { if (self::$application === null) { $client = static::createClient(); self::$application = new Application($client->getKernel()); self::$application->setAutoExit(false); self::$application->setCatchExceptions(false); } // Since Symfony 4.3.0, the `doRun` method no longer triggers `->boot()`, so we do it ourselves. // @see: https://github.com/symfony/framework-bundle/commit/2c0499210e365bdfe81ae2c56a5a81c5ec687532 self::$application->getKernel()->boot(); return self::$application; } protected function tearDown(): void { parent::tearDown(); $this->entityManager->close(); // avoid memory leaks $this->entityManager = null; } }