我想在Laravel测试我的注册表单。我这样做:Laravel测试:创建一个新用户
$this->visit('/auth/signup/free')
->type('First Name', 'first_name')
->type('[email protected]', 'email')
->type('mypassword', 'password')
->press('Get Started');
但我有一个错误500,因为我那么将用户重定向到其测试当前用户的某些属性欢迎页面,而这些的人不存在:
A request to [http://localhost/welcome] failed. Received status code [500].
Caused by
exception 'ErrorException' with message 'Undefined property: App\Models\User::$active' in D:\workspace\myproject\app\Models\User.php:48
Stack trace:
#0 D:\workspace\myproject\app\Models\User.php(48): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8, 'Undefined prope...', 'D:\\workspace\\my...', 48, Array)
#1 D:\workspace\myproject\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php(2670): App\Models\User->active()
[...]
用户出现在数据库中,但似乎Laravel无法访问其任何属性。
我该如何处理?
编辑:我正在使用Laravel 5.3。我有同样的错误比这个家伙:https://laracasts.com/discuss/channels/testing/51-phpunit-tests-fail-without-middleware/replies/89708
您使用的是什么版本的Laravel? – EddyTheDove
我正在使用Laravel 5.3。 – Kevin