尝试加载依赖于另一个的灯具:
namespace app\tests\fixtures;
use yii\test\ActiveFixture;
class UserFixture extends ActiveFixture {
public $modelClass = 'app\models\User';
public $depends = [
'app\tests\fixtures\ProfileFixture',
];
}
这失败了:
Fixture data file does not exist:
/var/www/vhosts/somedomain.com/httpdocs/yii2/tests/fixtures/data/profile.php
灯具数据在../yii2/tests/_data
,因此它在错误的位置寻找数据文件。如何更改此路径?
答案 0 :(得分:1)
在灯具类ERROR: referenced relation "user" is not a table
中,将路径添加到数据文件
ProfileFixture
但是我认为最好将数据文件移动到此命名空间class ProfileFixture extends ActiveFixture {
public $modelClass = 'app\models\Prodile';
public $dataFile = '@yii2/tests/_data/profile.php';
}