本文整理汇总了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();
}