/** * @return \Doctrine\ORM\EntityManager */ protected function createEntityManager() { // event manager used to create schema before tests $eventManager = new EventManager(); $eventManager->addEventListener(array("preTestSetUp"), new SchemaSetupListener()); // doctrine xml configs and namespaces $configPathList = array(); if (is_dir(__DIR__ . '/../Resources/config/doctrine')) { $dir = __DIR__ . '/../Resources/config/doctrine'; $configPathList[] = $dir; $prefixList[$dir] = 'Kitpages\\DataGridBundle\\Entities'; } if (is_dir(__DIR__ . '/_doctrine/config')) { $dir = __DIR__ . '/_doctrine/config'; $configPathList[] = $dir; $prefixList[$dir] = 'Kitpages\\DataGridBundle\\Tests\\TestEntities'; } // create drivers (that reads xml configs) $driver = new \Symfony\Bridge\Doctrine\Mapping\Driver\XmlDriver($configPathList); $driver->setNamespacePrefixes($prefixList); // create config object $config = new Configuration(); $config->setMetadataCacheImpl(new ArrayCache()); $config->setMetadataDriverImpl($driver); $config->setProxyDir(__DIR__ . '/TestProxies'); $config->setProxyNamespace('Kitpages\\DataGridBundle\\Tests\\TestProxies'); $config->setAutoGenerateProxyClasses(true); //$config->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger()); // create entity manager $em = EntityManager::create(array('driver' => 'pdo_sqlite', 'path' => "/tmp/sqlite-test.db"), $config, $eventManager); return $em; }
protected function getDoctrine_Orm_DefaultEntityManagerService() { $a = $this->get('annotation_reader'); $b = new \Doctrine\Common\Cache\ArrayCache(); $b->setNamespace('sf2orm_default_d8f647542b9a185e9dc0cb3e9844293e'); $c = new \Doctrine\Common\Cache\ArrayCache(); $c->setNamespace('sf2orm_default_d8f647542b9a185e9dc0cb3e9844293e'); $d = new \Doctrine\Common\Cache\ArrayCache(); $d->setNamespace('sf2orm_default_d8f647542b9a185e9dc0cb3e9844293e'); $e = new \Symfony\Bridge\Doctrine\Annotations\IndexedReader($a); $f = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($e, array(0 => '/Applications/MAMP/htdocs/s3/src/SerieZone/SerieBundle/Entity', 1 => '/Applications/MAMP/htdocs/s3/src/SerieZone/UserBundle/Entity')); $g = new \Symfony\Bridge\Doctrine\Mapping\Driver\XmlDriver(array(0 => '/Applications/MAMP/htdocs/s3/vendor/bundles/FOS/UserBundle/Resources/config/doctrine')); $g->setNamespacePrefixes(array('/Applications/MAMP/htdocs/s3/vendor/bundles/FOS/UserBundle/Resources/config/doctrine' => 'FOS\\UserBundle\\Entity')); $g->setGlobalBasename('mapping'); $h = new \Doctrine\ORM\Mapping\Driver\DriverChain(); $h->addDriver($f, 'SerieZone\\SerieBundle\\Entity'); $h->addDriver($f, 'SerieZone\\UserBundle\\Entity'); $h->addDriver($g, 'FOS\\UserBundle\\Entity'); $i = new \Doctrine\ORM\Configuration(); $i->setEntityNamespaces(array('SerieZoneSerieBundle' => 'SerieZone\\SerieBundle\\Entity', 'SerieZoneUserBundle' => 'SerieZone\\UserBundle\\Entity', 'FOSUserBundle' => 'FOS\\UserBundle\\Entity')); $i->setMetadataCacheImpl($b); $i->setQueryCacheImpl($c); $i->setResultCacheImpl($d); $i->setMetadataDriverImpl($h); $i->setProxyDir('/Applications/MAMP/htdocs/s3/app/cache/prod/doctrine/orm/Proxies'); $i->setProxyNamespace('Proxies'); $i->setAutoGenerateProxyClasses(false); $i->setClassMetadataFactoryName('Doctrine\\ORM\\Mapping\\ClassMetadataFactory'); return $this->services['doctrine.orm.default_entity_manager'] = call_user_func(array('Doctrine\\ORM\\EntityManager', 'create'), $this->get('doctrine.dbal.default_connection'), $i); }
/** * EntityManager mock object together with annotation mapping driver and * pdo_sqlite database in memory * * @return EntityManager */ protected function getMockSqliteEntityManager() { $cache = new \Doctrine\Common\Cache\ArrayCache(); // xml driver $prefixes = array('FreeAgent\\WorkflowBundle\\Entity' => __DIR__ . '/../Resources/config/doctrine'); $xmlDriver = new \Symfony\Bridge\Doctrine\Mapping\Driver\XmlDriver(array_values($prefixes)); $xmlDriver->setNamespacePrefixes(array_flip($prefixes)); // configuration mock $config = $this->getMock('Doctrine\\ORM\\Configuration'); $config->expects($this->any())->method('getMetadataCacheImpl')->will($this->returnValue($cache)); $config->expects($this->any())->method('getQueryCacheImpl')->will($this->returnValue($cache)); $config->expects($this->once())->method('getProxyDir')->will($this->returnValue(sys_get_temp_dir())); $config->expects($this->once())->method('getProxyNamespace')->will($this->returnValue('Proxy')); $config->expects($this->once())->method('getAutoGenerateProxyClasses')->will($this->returnValue(true)); $config->expects($this->any())->method('getMetadataDriverImpl')->will($this->returnValue($xmlDriver)); $config->expects($this->any())->method('getClassMetadataFactoryName')->will($this->returnValue('Doctrine\\ORM\\Mapping\\ClassMetadataFactory')); $conn = array('driver' => 'pdo_sqlite', 'memory' => true); $em = EntityManager::create($conn, $config); return $em; }
/** * Gets the 'doctrine.orm.default_entity_manager' service. * * This service is shared. * This method always returns the same instance of the service. * * @return Doctrine\ORM\EntityManager A Doctrine\ORM\EntityManager instance. */ protected function getDoctrine_Orm_DefaultEntityManagerService() { $a = new \Doctrine\Common\Cache\ArrayCache(); $a->setNamespace('sf2orm_default_88e1867761ebe23502c81f256c44583e'); $b = new \Doctrine\Common\Cache\ArrayCache(); $b->setNamespace('sf2orm_default_88e1867761ebe23502c81f256c44583e'); $c = new \Doctrine\Common\Cache\ArrayCache(); $c->setNamespace('sf2orm_default_88e1867761ebe23502c81f256c44583e'); $d = new \Symfony\Bridge\Doctrine\Mapping\Driver\XmlDriver(array(0 => 'D:\\MyWork\\MeetingApp\\src\\MeetingApp\\CoreBundle\\Resources\\config\\doctrine')); $d->setNamespacePrefixes(array('D:\\MyWork\\MeetingApp\\src\\MeetingApp\\CoreBundle\\Resources\\config\\doctrine' => 'MeetingApp\\CoreBundle\\Entity')); $d->setGlobalBasename('mapping'); $e = new \Doctrine\ORM\Mapping\Driver\DriverChain(); $e->addDriver($d, 'MeetingApp\\CoreBundle\\Entity'); $f = new \Doctrine\ORM\Configuration(); $f->setEntityNamespaces(array('MeetingAppCoreBundle' => 'MeetingApp\\CoreBundle\\Entity')); $f->setMetadataCacheImpl($a); $f->setQueryCacheImpl($b); $f->setResultCacheImpl($c); $f->setMetadataDriverImpl($e); $f->setProxyDir('D:\\MyWork\\MeetingApp\\app/cache/dev/doctrine/orm/Proxies'); $f->setProxyNamespace('Proxies'); $f->setAutoGenerateProxyClasses(true); $f->setClassMetadataFactoryName('Doctrine\\ORM\\Mapping\\ClassMetadataFactory'); return $this->services['doctrine.orm.default_entity_manager'] = call_user_func(array('Doctrine\\ORM\\EntityManager', 'create'), $this->get('doctrine.dbal.default_connection'), $f); }
/** * Gets the 'doctrine.orm.default_entity_manager' service. * * This service is shared. * This method always returns the same instance of the service. * * @return Doctrine\ORM\EntityManager A Doctrine\ORM\EntityManager instance. */ protected function getDoctrine_Orm_DefaultEntityManagerService() { $a = new \Doctrine\Common\Cache\ArrayCache(); $a->setNamespace('sf2orm_default_27b5a52739c92d79cb05d57a363831b2'); $b = new \Doctrine\Common\Cache\ArrayCache(); $b->setNamespace('sf2orm_default_27b5a52739c92d79cb05d57a363831b2'); $c = new \Doctrine\Common\Cache\ArrayCache(); $c->setNamespace('sf2orm_default_27b5a52739c92d79cb05d57a363831b2'); $d = new \Symfony\Bridge\Doctrine\Mapping\Driver\XmlDriver(array(0 => '/Users/rfanjul/Public/api.quorra.com/vendor/bundles/FOS/UserBundle/Resources/config/doctrine')); $d->setNamespacePrefixes(array('/Users/rfanjul/Public/api.quorra.com/vendor/bundles/FOS/UserBundle/Resources/config/doctrine' => 'FOS\\UserBundle\\Entity')); $d->setGlobalBasename('mapping'); $e = new \Doctrine\ORM\Mapping\Driver\DriverChain(); $e->addDriver($d, 'FOS\\UserBundle\\Entity'); $f = new \Doctrine\ORM\Configuration(); $f->setEntityNamespaces(array('FOSUserBundle' => 'FOS\\UserBundle\\Entity')); $f->setMetadataCacheImpl($a); $f->setQueryCacheImpl($b); $f->setResultCacheImpl($c); $f->setMetadataDriverImpl($e); $f->setProxyDir('/Users/rfanjul/Public/api.quorra.com/app/cache/dev/doctrine/orm/Proxies'); $f->setProxyNamespace('Proxies'); $f->setAutoGenerateProxyClasses(true); $f->setClassMetadataFactoryName('Doctrine\\ORM\\Mapping\\ClassMetadataFactory'); return $this->services['doctrine.orm.default_entity_manager'] = call_user_func(array('Doctrine\\ORM\\EntityManager', 'create'), $this->get('doctrine.dbal.default_connection'), $f); }