Create login interface in yii2 framework

First, we create a user, then we try to login and see whether the indicator is reflecting the authentication, and then we try to logout and see whether the indicator is back to the state meant for guests.

The highlighted lines are the steps that are not defined yet. They are pretty straightforward.

Checking that we are in the Login Form UI:

    public function seeIAmInLoginFormUi()
    {
        $I = $this;
        $I->seeCurrentUrlEquals('/site/login');
    }

Filling the login form with the data generated previously:

    public function fillLoginForm($user)
    {
        $I = $this;
        $I->fillField('LoginForm[username]', $user['UserRecord[username]']);
        $I->fillField('LoginForm[password]', $user['UserRecord[password]']);
    }

Note that the function shown in the preceding code is the exact duplicate of the similar “fill form” method in AcceptanceTester\CRMUsersManagementSteps. We skipped the refactoring step again.

Submit the login form using the submitLoginForm() method:

    public function submitLoginForm()
    {
        $I = $this;
        $I->click('button[type=submit]');
        $I->wait(1);
    }

 

 

Pin It on Pinterest

Shares

Get the best in web dev

Join dunebook.com and recieve best in web dev , once a week FREE

An email has been Sent to your Inbox ! Please Confirm your Subscription :)