本文整理匯總了PHP中CDbTestCase::setUpBeforeClass方法的典型用法代碼示例。如果您正苦於以下問題:PHP CDbTestCase::setUpBeforeClass方法的具體用法?PHP CDbTestCase::setUpBeforeClass怎麽用?PHP CDbTestCase::setUpBeforeClass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CDbTestCase
的用法示例。
在下文中一共展示了CDbTestCase::setUpBeforeClass方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: setUpBeforeClass
/**
* Loads "reference fixtures" defined in {@link referenceFixtures()} and
* sets up some special environment variables before proceeding.
*/
public static function setUpBeforeClass()
{
if (!YII_UNIT_TESTING) {
throw new CException('YII_UNIT_TESTING must be set to true');
}
Yii::app()->cache->flush();
self::setUpAppEnvironment();
// Load "reference fixtures", needed for reference, which do not need
// to be reloaded after every single test method:
$testClass = get_called_class();
if (X2_TEST_DEBUG_LEVEL > 0) {
/**/
println($testClass);
}
$refFix = call_user_func("{$testClass}::referenceFixtures");
$fm = Yii::app()->getComponent('fixture');
self::$_referenceFixtureRows = array();
self::$_referenceFixtureRecords = array();
if (is_array($refFix)) {
Yii::import('application.components.X2Settings.*');
$fm->load($refFix);
if (self::$loadFixtures || self::$loadFixturesForClassOnly) {
foreach ($refFix as $alias => $table) {
$tableName = is_array($table) ? $table[0] : $table;
self::$_referenceFixtureRows[$alias] = $fm->getRows($alias);
if (strpos($tableName, ':') !== 0) {
foreach (self::$_referenceFixtureRows[$alias] as $rowAlias => $row) {
$model = CActiveRecord::model($tableName);
$key = $model->getTableSchema()->primaryKey;
if (is_string($key)) {
$pk = $row[$key];
} else {
foreach ($key as $k) {
$pk[$k] = $row[$k];
}
}
self::$_referenceFixtureRecords[$alias][$rowAlias] = $model->findByPk($pk);
}
}
}
}
}
self::setUpAppEnvironment2();
parent::setUpBeforeClass();
}
示例2: setUpBeforeClass
public static function setUpBeforeClass()
{
Yii::app()->db->createCommand()->createTable('split_element_test', array('id' => 'pk', 'title' => 'string NOT NULL', 'eye_id' => 'int(10) unsigned NOT NULL', ' CONSTRAINT `split_eye_id_fk` FOREIGN KEY (`eye_id`) REFERENCES `eye` (`id`)'));
parent::setUpBeforeClass();
}