【发布时间】:2019-03-27 04:48:15
【问题描述】:
我必须将我的单元测试转换为代码接收。我需要使用本文中的 loginWithFakeUser() 函数 - How to mock authentication user on unit test in Laravel?
public function loginWithFakeUser() {
$user = new User([
'id' => 1,
'name' => 'yish'
]);
$this->be($user);
}
当我的课程已经在扩展\Codeception\Test\Unit 时,我如何使用$this->be()?我不知道我应该use .. 或如何正确使用。将函数 loginWithFakeUser() 放在这个里面:
use Illuminate\Foundation\Testing\Concerns\InteractsWithAuthentication;
use Illuminate\Foundation\Testing\Concerns\InteractsWithSession;
class AdminTest extends \Codeception\Test\Unit {
use InteractsWithAuthentication;
use InteractsWithSession;
}
给我一个错误:
[ErrorException] 未定义属性:AdminTest::$app
我不确定如何设置 $app 变量。请帮我。非常感谢!
【问题讨论】:
标签: laravel unit-testing codeception laravel-authentication