Beispiel #1
0
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     global $freeze;
     RedBeanDatabase::setup(Yii::app()->db->connectionString, Yii::app()->db->username, Yii::app()->db->password);
     assert('RedBeanDatabase::isSetup()');
     // Not Coding Standard
     if ($freeze) {
         $schemaFile = sys_get_temp_dir() . '/autobuilt.sql';
         $success = preg_match("/;dbname=([^;]+)/", Yii::app()->db->connectionString, $matches);
         // Not Coding Standard
         assert('$success == 1');
         // Not Coding Standard
         $databaseName = $matches[1];
         if (is_readable($schemaFile) && filesize($schemaFile) > 0) {
             $systemOutput = system('mysql -u' . Yii::app()->db->username . ' -p' . Yii::app()->db->password . ' ' . $databaseName . " < {$schemaFile}");
             if ($systemOutput != null) {
                 echo 'Loading schema using system command. Output: ' . $systemOutput . "\n\n";
             }
         } else {
             echo "The schema file is not readable: {$schemaFile}. \n\n";
             exit;
         }
     }
     CustomFieldData::forgetAllPhpCache();
     GeneralCache::forgetAll();
     BeanModelCache::forgetAll();
     if ($freeze) {
         RedBeanDatabase::freeze();
         TestDatabaseUtil::deleteRowsFromAllTablesExceptLog();
     } else {
         TestDatabaseUtil::deleteAllTablesExceptLog();
     }
     Yii::app()->user->userModel = null;
     Yii::app()->user->clearStates();
     //reset session.
     Yii::app()->language = Yii::app()->getConfigLanguageValue();
     Yii::app()->timeZoneHelper->setTimeZone(Yii::app()->getConfigTimeZoneValue());
     Yii::app()->timeZoneHelper->load();
     //resets timezone
     Yii::app()->languageHelper->flushModuleLabelTranslationParameters();
     if (static::$activateDefaultLanguages) {
         Yii::app()->languageHelper->load();
         Yii::app()->languageHelper->activateLanguagesForTesting();
         Yii::app()->languageHelper->importMessagesForTesting();
     }
 }