【发布时间】:2015-02-17 02:48:27
【问题描述】:
有没有办法在 Yii2/Codeception ActiveFixture 的夹具数据文件中指定另一个夹具的相关行?考虑这个用户/个人资料关系的例子:
user.php:
return [
'user1' => [
'email' => 'user1@example.net',
]
];
profile.php:
use common\models\User;
return [
'profile1' => [
'user_id' => User::findOne(['email' => 'user1@example.net'])->id;
'name' => 'My Name',
]
];
文档声明“您可以为一行指定别名,以便稍后在您的测试中,您可以通过别名引用该行。”有没有办法引用另一个夹具内的行?例如,在 profile.php 中使用类似 $this->user('user1')->id 的东西?我找不到任何关于如何做到这一点的提及。你如何创建这种相关的灯具?
【问题讨论】:
标签: php yii2 fixtures codeception