public function __construct() { parent::__construct(); $matches = array(); assert(preg_match("/host=([^;]+);(?:port=([^;]+);)?dbname=([^;]+)/", Yii::app()->db->connectionString, $matches) == 1); // Not Coding Standard if ($matches[2] != '') { $this->databasePort = intval($matches[2]); } else { $databaseType = RedBeanDatabase::getDatabaseTypeFromDsnString(Yii::app()->db->connectionString); $this->databasePort = DatabaseCompatibilityUtil::getDatabaseDefaultPort($databaseType); } $this->hostname = $matches[1]; $this->rootUsername = Yii::app()->db->username; $this->rootPassword = Yii::app()->db->password; $this->existingDatabaseName = $matches[3]; $this->temporaryDatabaseName = "zurmo_wacky"; if ($this->rootUsername == 'zurmo') { $this->rootUsername = '******'; $this->rootPassword = '******'; $this->temporaryDatabaseName = 'zurmo_wacky'; } $this->superUserPassword = '******'; $this->databaseBackupTestFile = INSTANCE_ROOT . '/protected/runtime/databaseBackupTest.sql'; }
/** * @expectedException NotSupportedException */ public function testGetDatabaseTypeFromDsnString() { $dsn = 'mysql:host=localhost;port=3306;dbname=zurmo'; // Not Coding Standard $databaseType = RedBeanDatabase::getDatabaseTypeFromDsnString($dsn); $this->assertEquals('mysql', $databaseType); $dsn = 'oci:host=localhost;dbname=zurmo'; // Not Coding Standard $databaseType = RedBeanDatabase::getDatabaseTypeFromDsnString($dsn); $this->assertEquals('oci', $databaseType); // Invalid connection string, so NotSupportedException should be thrown. $dsn = 'host=localhost;dbname=zurmo'; // Not Coding Standard $databaseType = RedBeanDatabase::getDatabaseTypeFromDsnString($dsn); }