我正在学习 Laravel 测试,但由于以下错误,我无法继续测试 Eloquent:
错误:对空值调用成员函数connection()
这是我的代码:
public function test_users_can_follow_each_other()
{
$this->userOne = User::find(1);
$this->userTwo = User::find(2);
$this->userOne->followedBy($this->userTwo->id);
$this->assertTrue($this->userTwo->isFollowedBy($this->userOne->id));
}
Run Code Online (Sandbox Code Playgroud)
我也在使用这个特质use DatabaseTransactions;
数据库已创建,用户表上有 2 条记录。还需要配置什么吗,谢谢!