public function tearDown() { RedBeanDatabase::close(); RedBeanDatabase::setup(Yii::app()->db->connectionString, Yii::app()->db->username, Yii::app()->db->password, true); if (is_file($this->databaseBackupTestFile)) { unlink($this->databaseBackupTestFile); } }
public static function tearDownAfterClass() { if (RedBeanDatabase::isFrozen()) { TestDatabaseUtil::deleteRowsFromAllTablesExceptLog(); } else { TestDatabaseUtil::deleteAllTablesExceptLog(); } RedBeanModel::forgetAll(); RedBeanDatabase::close(); assert('!RedBeanDatabase::isSetup()'); // Not Coding Standard GeneralCache::forgetAll(); }
protected static function closeDatabaseConnection() { if (RedBeanDatabase::isSetup()) { RedBeanDatabase::close(); assert('!RedBeanDatabase::isSetup()'); } }
public function handleEndRequest($event) { RedBeanDatabase::close(); exit; }
public function testRun() { chdir(COMMON_ROOT . DIRECTORY_SEPARATOR . 'protected' . DIRECTORY_SEPARATOR . 'commands'); $command = "php zurmocTest.php install {$this->temporaryDatabaseHostname} {$this->temporaryDatabaseName} "; $command .= "{$this->temporaryDatabaseUsername} {$this->temporaryDatabasePassword} {$this->temporaryDatabasePort} "; $command .= "{$this->superUserPassword} 'http://sampleHost' 'app/index.php' demodata 1"; if (!IS_WINNT) { $command .= ' 2>&1'; } exec($command, $output); $instanceRoot = INSTANCE_ROOT; $perInstanceConfigFile = "{$instanceRoot}/protected/config/perInstanceTest.php"; $debugConfigFile = "{$instanceRoot}/protected/config/debugTest.php"; $perInstanceConfiguration = file_get_contents($perInstanceConfigFile); $debugConfiguration = file_get_contents($debugConfigFile); //Check if config files is updated. $this->assertRegExp('/\\$connectionString = \'mysql:host=' . $this->temporaryDatabaseHostname . ';port=' . $this->temporaryDatabasePort . ';dbname=' . $this->temporaryDatabaseName . '\';/', $perInstanceConfiguration); $this->assertRegExp('/\\$username = \'' . $this->temporaryDatabaseUsername . '\';/', $perInstanceConfiguration); $this->assertRegExp('/\\$password = \'' . $this->temporaryDatabasePassword . '\';/', $perInstanceConfiguration); RedBeanDatabase::close(); RedBeanDatabase::setup(Yii::app()->tempDb->connectionString, Yii::app()->tempDb->username, Yii::app()->tempDb->password, true); $count = R::getRow('select count(*) count from _user'); $this->assertEquals(9, $count['count']); }
protected static function reconnectToDatabase() { RedBeanDatabase::close(); RedBeanDatabase::setup(Yii::app()->db->connectionString, Yii::app()->db->username, Yii::app()->db->password); }
/** * Closes the database. */ public static function close() { RedBeanDatabase::close(); }
public static function tearDownAfterClass() { if (static::$activateDefaultLanguages) { Yii::app()->languageHelper->deactivateLanguagesForTesting(); } TestDatabaseUtil::deleteRowsFromAllTablesExceptLog(); PermissionsCache::forgetAll(); AllPermissionsOptimizationCache::forgetAll(); RedBeanModel::forgetAll(); RedBeanDatabase::close(); assert('!RedBeanDatabase::isSetup()'); // Not Coding Standard GeneralCache::forgetAll(); BeanModelCache::forgetAll(); }
public function tearDown() { RedBeanDatabase::close(); RedBeanDatabase::setup(Yii::app()->db->connectionString, Yii::app()->db->username, Yii::app()->db->password, true); }
public function testAllActions() { //Ensure that installed = false Yii::app()->setApplicationInstalled(false); //Check index action. $this->runControllerWithNoExceptionsAndGetContent('install/default'); $this->runControllerWithNoExceptionsAndGetContent('install/default/index'); //Check welcome action. $this->runControllerWithNoExceptionsAndGetContent('install/default/welcome'); //Check checkSystem action. if (isset($_SERVER['SERVER_SOFTWARE'])) { $serverSoftware = $_SERVER['SERVER_SOFTWARE']; } $_SERVER['SERVER_SOFTWARE'] = 'Apache'; $this->runControllerWithNoExceptionsAndGetContent('install/default/checkSystem'); //Check settings action. $this->runControllerWithNoExceptionsAndGetContent('install/default/settings'); //Check validateSettings action. //First validation will fail, and there should be at least validation errors. $this->setPostArray(array('ajax' => 'install-form', 'InstallSettingsForm' => array('databaseHostname' => '', 'databaseAdminUsername' => '', 'databaseAdminPassword' => '', 'databaseName' => '', 'databaseUsername' => '', 'databasePassword' => '', 'databasePort' => '', 'superUserPassword' => '', 'memcacheHostname' => '', 'memcachePortNumber' => '', 'memcacheAvailable' => '', 'databaseType' => 'mysql', 'removeExistingData' => '', 'installDemoData' => ''))); $content = $this->runControllerWithExitExceptionAndGetContent('install/default/settings'); $errors = CJSON::decode($content); $this->assertGreaterThanOrEqual(5, count($errors)); $postData = array('ajax' => 'install-form', 'InstallSettingsForm' => array('databaseHostname' => $this->databaseHostname, 'databaseAdminUsername' => '', 'databaseAdminPassword' => '', 'databaseName' => $this->databaseName, 'databaseUsername' => $this->databaseUsername, 'databasePassword' => $this->databasePassword, 'databasePort' => $this->databasePort, 'superUserPassword' => $this->superUserPassword, 'databaseType' => 'mysql', 'removeExistingData' => '1', 'installDemoData' => '')); if (MEMCACHE_ON) { $memcacheSettings = array('memcacheHostname' => 'localhost', 'memcachePortNumber' => '11211', 'memcacheAvailable' => '1'); } else { $memcacheSettings = array('memcacheHostname' => '', 'memcachePortNumber' => '', 'memcacheAvailable' => '0'); } $postData['InstallSettingsForm'] = array_merge($postData['InstallSettingsForm'], $memcacheSettings); $this->setPostArray($postData); $content = $this->runControllerWithExitExceptionAndGetContent('install/default/settings'); $errors = CJSON::decode($content); $this->assertEquals(1, count($errors)); $postData['InstallSettingsForm']['hostInfo'] = 'http://www.example.com'; $this->setPostArray($postData); $content = $this->runControllerWithExitExceptionAndGetContent('install/default/settings'); $errors = CJSON::decode($content); $this->assertEquals(0, count($errors)); //Run installation. $this->setPostArray(array('InstallSettingsForm' => array('databaseHostname' => $this->databaseHostname, 'databaseAdminUsername' => '', 'databaseAdminPassword' => '', 'databaseName' => $this->databaseName, 'databaseUsername' => $this->databaseUsername, 'databasePassword' => $this->databasePassword, 'databasePort' => $this->databasePort, 'superUserPassword' => $this->superUserPassword, 'memcacheHostname' => 'localhost', 'memcachePortNumber' => '11211', 'memcacheAvailable' => '1', 'databaseType' => 'mysql', 'removeExistingData' => '1', 'installDemoData' => '', 'hostInfo' => 'http://www.example.com'))); //Close db connection(new will be created during installation process). RedBeanDatabase::close(); $this->runControllerWithExitExceptionAndGetContent('install/default/settings'); $industryFieldData = CustomFieldData::getByName('Industries'); $this->assertGreaterThan('0', count(unserialize($industryFieldData->serializedData))); //Check installDemoData action. RedBeanDatabase::close(); DemoDataUtil::unsetLoadedModules(); $this->runControllerWithNoExceptionsAndGetContent('install/default/installDemoData'); $this->assertGreaterThan('0', Account::getAll()); $this->assertGreaterThan('0', Contact::getAll()); //Restore $_SERVER['SERVER_SOFTWARE'] if (isset($serverSoftware)) { $_SERVER['SERVER_SOFTWARE'] = $serverSoftware; } else { unset($_SERVER['SERVER_SOFTWARE']); } }