Created
November 22, 2011 08:04
-
-
Save cakper/1385149 to your computer and use it in GitHub Desktop.
Prepare entity Manager
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Symfony\Component\Validator\ValidatorFactory; | |
use Doctrine\ORM\Mapping\Driver\AnnotationDriver; | |
use Doctrine\Common\Annotations\AnnotationReader; | |
use Doctrine\Common\Annotations\IndexedReader; | |
/** | |
* Prepare entity manager for testing LifeCycleCallbacks | |
*/ | |
protected function prepareEntityManager() | |
{ | |
$conn = \Doctrine\DBAL\DriverManager::getConnection(array( | |
'driver' => 'pdo_sqlite', | |
'memory' => true | |
)); | |
$config = new \Doctrine\ORM\Configuration(); | |
$config->setAutoGenerateProxyClasses(true); | |
$config->setProxyDir(\sys_get_temp_dir()); | |
$config->setProxyNamespace('JazzyTransactionTests\Entities'); | |
$config->setMetadataDriverImpl(new AnnotationDriver(new IndexedReader(new AnnotationReader()))); | |
$config->setQueryCacheImpl(new \Doctrine\Common\Cache\ArrayCache()); | |
$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache()); | |
$params = array( | |
'driver' => 'pdo_sqlite', | |
'memory' => true, | |
); | |
$this->entityManager = \Doctrine\ORM\EntityManager::create($params, $config); | |
$schemaTool = new \Doctrine\ORM\Tools\SchemaTool($this->entityManager); | |
$classes = array( | |
$this->entityManager->getClassMetadata("\Jazzy\TransactionBundle\Entity\MoneyTransaction"), | |
$this->entityManager->getClassMetadata("\Jazzy\UserBundle\Entity\User"), | |
); | |
$schemaTool->dropSchema($classes); | |
$schemaTool->createSchema($classes); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment