/** * Creates a Client. * * @param array $options An array of options to pass to the createKernel class * @param array $server An array of server parameters * * @return Client A Client instance */ protected static function createClient(array $options = array(), array $server = array()) { if (!self::$internalClient) { self::$internalClient = parent::createClient($options, $server); if (self::$db_isolation) { /** @var Client $client */ $client = self::$internalClient; //workaround MyISAM search tables are not on transaction if (self::$db_reindex) { $kernel = $client->getKernel(); $application = new \Symfony\Bundle\FrameworkBundle\Console\Application($kernel); $application->setAutoExit(false); $options = array('command' => 'oro:search:reindex'); $options['--env'] = "test"; $options['--quiet'] = null; $application->run(new \Symfony\Component\Console\Input\ArrayInput($options)); } $client->startTransaction(); $pdoConnection = Client::getPdoConnection(); if ($pdoConnection) { //set transaction level to 1 for entityManager $connection = $client->createConnection($pdoConnection); $client->getContainer()->set('doctrine.dbal.default_connection', $connection); /** @var EntityManager $entityManager */ $entityManager = $client->getContainer()->get('doctrine.orm.entity_manager'); if (spl_object_hash($entityManager->getConnection()) != spl_object_hash($connection)) { $reflection = new \ReflectionProperty('Doctrine\\ORM\\EntityManager', 'conn'); $reflection->setAccessible(true); $reflection->setValue($entityManager, $connection); } } } } return self::$internalClient; }