我想测试一个代码:
public static function getFirstRole($userID) {
$role = array_values(Yii::$app->getAuthManager()->getRolesByUser($userID));
if (isset($role[0])) {
$role = $role[0];
} else {
$role = Yii::$app->getAuthManager()->getRole('client');
}
return $role;
}我的测试是:
expect('First role should be client',
AuthManager::getFirstRole(1)->name)->equals('client');当我运行这个测试,然后我得到
yii\base\InvalidConfigException:应用程序的"id“配置是必需的。
怎么修呢?
发布于 2015-02-04 10:10:44
我使用的是use yii\codeception\DbTestCase;而不是use tests\codeception\backend\unit\DbTestCase;。因为它不使用id为$app上传配置
https://stackoverflow.com/questions/28292293
复制相似问题