Пример #1
0
 public static function suite()
 {
     $suite = new \Doctrine\Tests\DbalFunctionalTestSuite('Doctrine Dbal Functional');
     $conn = TestUtil::getConnection();
     $sm = $conn->getSchemaManager();
     if ($sm instanceof \Doctrine\DBAL\Schema\SqliteSchemaManager) {
         $suite->addTestSuite('Doctrine\\Tests\\DBAL\\Functional\\Schema\\SqliteSchemaManagerTest');
     } else {
         if ($sm instanceof \Doctrine\DBAL\Schema\MySqlSchemaManager) {
             $suite->addTestSuite('Doctrine\\Tests\\DBAL\\Functional\\Schema\\MySqlSchemaManagerTest');
         } else {
             if ($sm instanceof \Doctrine\DBAL\Schema\PostgreSqlSchemaManager) {
                 $suite->addTestSuite('Doctrine\\Tests\\DBAL\\Functional\\Schema\\PostgreSqlSchemaManagerTest');
             } else {
                 if ($sm instanceof \Doctrine\DBAL\Schema\OracleSchemaManager) {
                     $suite->addTestSuite('Doctrine\\Tests\\DBAL\\Functional\\Schema\\OracleSchemaManagerTest');
                 } else {
                     if ($sm instanceof \Doctrine\DBAL\Schema\DB2SchemaManager) {
                         $suite->addTestSuite('Doctrine\\Tests\\DBAL\\Functional\\Schema\\Db2SchemaManagerTest');
                     }
                 }
             }
         }
     }
     $suite->addTestSuite('Doctrine\\Tests\\DBAL\\Functional\\ConnectionTest');
     $suite->addTestSuite('Doctrine\\Tests\\DBAL\\Functional\\DataAccessTest');
     $suite->addTestSuite('Doctrine\\Tests\\DBAL\\Functional\\WriteTest');
     $suite->addTestSuite('Doctrine\\Tests\\DBAL\\Functional\\LoggingTest');
     $suite->addTestSuite('Doctrine\\Tests\\DBAL\\Functional\\TypeConversionTest');
     return $suite;
 }
 public function testListDatabases()
 {
     // We need the temp connection that has privileges to create a database.
     $sm = TestUtil::getTempConnection()->getSchemaManager();
     $sm->dropAndCreateDatabase('c##test_create_database');
     $databases = $this->_sm->listDatabases();
     $databases = array_map('strtolower', $databases);
     $this->assertContains('c##test_create_database', $databases);
 }
 public function setUp()
 {
     parent::setUp();
     if (!isset($GLOBALS['db_username'])) {
         $this->markTestSkipped('Foo');
     }
     $username = $GLOBALS['db_username'];
     $query = "GRANT ALL PRIVILEGES TO " . $username;
     $conn = \Doctrine\Tests\TestUtil::getTempConnection();
     $conn->executeUpdate($query);
 }
Пример #4
0
 /**
  * Creates a connection to the test database, if there is none yet, and
  * creates the necessary tables.
  *
  * @return void
  */
 protected function setUp()
 {
     $this->setUpDBALTypes();
     $forceCreateTables = false;
     if (!isset(static::$_sharedConn)) {
         static::$_sharedConn = TestUtil::getConnection();
         if (static::$_sharedConn->getDriver() instanceof \Doctrine\DBAL\Driver\PDOSqlite\Driver) {
             $forceCreateTables = true;
         }
     }
     if (isset($GLOBALS['DOCTRINE_MARK_SQL_LOGS'])) {
         if (in_array(static::$_sharedConn->getDatabasePlatform()->getName(), array("mysql", "postgresql"))) {
             static::$_sharedConn->executeQuery('SELECT 1 /*' . get_class($this) . '*/');
         } else {
             if (static::$_sharedConn->getDatabasePlatform()->getName() == "oracle") {
                 static::$_sharedConn->executeQuery('SELECT 1 /*' . get_class($this) . '*/ FROM dual');
             }
         }
     }
     if (!$this->_em) {
         $this->_em = $this->_getEntityManager();
         $this->_schemaTool = new \Doctrine\ORM\Tools\SchemaTool($this->_em);
     }
     $classes = array();
     foreach ($this->_usedModelSets as $setName => $bool) {
         if (!isset(static::$_tablesCreated[$setName])) {
             foreach (static::$_modelSets[$setName] as $className) {
                 $classes[] = $this->_em->getClassMetadata($className);
             }
             static::$_tablesCreated[$setName] = true;
         }
     }
     if ($classes) {
         $this->_schemaTool->createSchema($classes);
     }
     $this->_sqlLoggerStack->enabled = true;
 }