Tuesday, March 7, 2017

acceptance test method visit undefinied

I have created a new laravel 5.4 project with authentication.

I have then created a feature test for the login process which is as follows

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');
    }

but when i run the test I get

Error: Call to undefined method Tests\Feature\UserTest::visit()

not sure if I need to install another component. this is what my composer.json looks like

{
    "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
    }
}



via JaChNo

Advertisement