我创建了一个带有身份验证的新 laravel 5.4 项目。
然后我为登录过程创建了一个功能测试,如下所示
public function test_login()
{
$user = factory(\App\User::class)->make();
$user->save();
$this->visit('/login')
->type($user->email,'email')
->type($user->password,'password')
->press('login');;
$this->seePageIs('/dashboard');
}
但是当我运行测试时,我得到
错误:调用未定义的方法 Tests\Feature\UserTest::visit()
不确定我是否需要安装另一个组件。这就是我的 composer.json 的样子
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.6.4",
"laravel/dusk": "^1.0",
"laravel/framework": "5.4.*",
"laravel/tinker": "~1.0"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~5.7"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-root-package-install": [
"php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan optimize"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan optimize"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true
}
}