protected function setUp()
 {
     $this->em = $this->getEntityManager();
     $schemaTool = new SchemaTool($this->em);
     $classes = $this->em->getMetaDataFactory()->getAllMetadata();
     $schemaTool->dropSchema($classes);
     $schemaTool->createSchema($classes);
 }
예제 #2
0
 private function setupTestSchema()
 {
     $this->entityManager->clear();
     $classes = $this->entityManager->getMetaDataFactory()->getAllMetaData();
     $tool = new Doctrine\ORM\Tools\SchemaTool($this->entityManager);
     // $tool->dropSchema($classes);
     $tool->createSchema($classes);
 }
예제 #3
0
 private function setupTestSchema()
 {
     if ($this->metaDataClassNames === null) {
         $classes = $this->entityManager->getMetaDataFactory()->getAllMetaData();
     } else {
         $classes = [];
         foreach ($this->metaDataClassNames as $className) {
             $classes[] = $this->entityManager->getMetaDataFactory()->getMetadataFor($className);
         }
     }
     $tool = new SchemaTool($this->entityManager);
     $tool->createSchema($classes);
 }
예제 #4
0
 private function setupTestSchema()
 {
     $this->entityManager->clear();
     if (empty($this->metaDataClassNames)) {
         $classes = $this->entityManager->getMetaDataFactory()->getAllMetaData();
     } else {
         $classes = [];
         foreach ($this->metaDataClassNames as $className) {
             $classes[] = $this->entityManager->getMetaDataFactory()->getMetadataFor($className);
         }
     }
     $tool = new Doctrine\ORM\Tools\SchemaTool($this->entityManager);
     // $tool->dropSchema($classes);
     $tool->createSchema($classes);
 }
 /**
  * Get database connection.
  *
  * @static
  *
  * @return DatabaseConnection
  */
 public static function create($mappingPath)
 {
     self::$_config = array('dbname' => $GLOBALS['db_name'], 'driver' => 'pdo_mysql', 'host' => $GLOBALS['db_host'], 'user' => $GLOBALS['db_user'], 'password' => $GLOBALS['db_password'], 'charset' => 'UTF8');
     self::createDatabase(self::$_config);
     /** @var \Doctrine\ORM\Configuration */
     $metadataConfiguration = Setup::createAnnotationMetadataConfiguration(array($mappingPath), true, null, null, false);
     self::$_em = EntityManager::create(self::$_config, $metadataConfiguration);
     $pdo = self::$_em->getConnection()->getWrappedConnection();
     self::$_em->clear();
     $tool = new SchemaTool(self::$_em);
     $classes = self::$_em->getMetaDataFactory()->getAllMetaData();
     $tool->dropSchema($classes);
     $tool->createSchema($classes);
     return new self();
 }
예제 #6
0
 public function getConnection()
 {
     $this->em = EntityManagerFactory::createEntityManager(__DIR__ . '/../../../../app/config/parameters_test.yml', __DIR__ . '/../../../../src', false);
     // Retrieve PDO instance
     $pdo = $this->em->getConnection()->getWrappedConnection();
     // Clear Doctrine to be safe
     $this->em->clear();
     // Schema Tool to process our entities
     $tool = new SchemaTool($this->em);
     $classes = $this->em->getMetaDataFactory()->getAllMetaData();
     // Drop all classes and re-build them for each test case
     $tool->dropSchema($classes);
     $tool->createSchema($classes);
     // Pass to PHPUnit
     return $this->createDefaultDBConnection($pdo, 'angular_cms_test');
 }
예제 #7
0
 /**
  *
  */
 public function __construct(EntityManager $entity_manager)
 {
     $metadata_factory = $entity_manager->getMetaDataFactory();
     foreach ($metadata_factory->getAllMetaData() as $class => $metadata) {
         if ($metadata->customRepositoryClassName == get_class($this)) {
             $this->model = $metadata->getName();
         }
     }
     parent::__construct($entity_manager, $entity_manager->getclassMetaData($this->model));
 }
예제 #8
0
 public static function createDatabase(EntityManager $em)
 {
     // Clear Doctrine to be safe
     $em->clear();
     // Schema Tool to process our entities
     $tool = new SchemaTool($em);
     $classes = $em->getMetaDataFactory()->getAllMetaData();
     // Drop all classes and re-build them for each test case
     $tool->dropSchema($classes);
     $tool->createSchema($classes);
 }
예제 #9
0
 protected function setUp()
 {
     if (!class_exists('\\Doctrine\\ORM\\Configuration')) {
         static::markTestSkipped('Doctrine is not available');
     }
     $config = new Configuration();
     $config->setMetadataCacheImpl(new ArrayCache());
     $config->setQueryCacheImpl(new ArrayCache());
     $config->setProxyDir(__DIR__ . '/Proxies');
     $config->setProxyNamespace('Boldtrn\\JsonbBundle\\Tests\\Proxies');
     $config->setAutoGenerateProxyClasses(true);
     $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver(__DIR__ . '/Entities'));
     $config->addEntityNamespace('E', 'Boldtrn\\JsonbBundle\\Tests\\Entities');
     $config->setCustomStringFunctions(array('JSONB_AG' => 'Boldtrn\\JsonbBundle\\Query\\JsonbAtGreater', 'JSONB_HGG' => 'Boldtrn\\JsonbBundle\\Query\\JsonbHashGreaterGreater', 'JSONB_EX' => 'Boldtrn\\JsonbBundle\\Query\\JsonbExistence'));
     $this->entityManager = EntityManager::create($this->dbParams, $config);
     $this->connection = $this->entityManager->getConnection();
     $this->setUpDBALTypes();
     $tool = new SchemaTool($this->entityManager);
     $classes = $this->entityManager->getMetaDataFactory()->getAllMetaData();
     // Drop all classes and re-build them for each test case
     $tool->dropSchema($classes);
     $tool->createSchema($classes);
 }
 /**
  * @return EntityManager|object
  * @throws \Doctrine\ORM\Tools\ToolsException
  */
 public function getEntityManager()
 {
     if (!self::$entityManager instanceof EntityManager) {
         $kernel = static::createKernel();
         $kernel->boot();
         self::$entityManager = $kernel->getContainer()->get('doctrine.orm.entity_manager');
         // Clear Doctrine to be safe
         self::$entityManager->clear();
         // Schema Tool to process our entities
         $tool = new SchemaTool(self::$entityManager);
         $classes = self::$entityManager->getMetaDataFactory()->getAllMetaData();
         // Drop all classes and re-build them for each test case
         $tool->dropSchema($classes);
         $tool->createSchema($classes);
         //create our api user on first run
         $this->getUser();
     }
     return self::$entityManager;
 }
예제 #11
0
 public function dropSchema()
 {
     $classes = $this->entityManager->getMetaDataFactory()->getAllMetaData();
     $this->schemaTool->dropSchema($classes);
 }