Tutorials , code & Inspiration

Create login interface in yii2 framework

0

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

 

 

prevChapter 1 of 5

Leave A Reply

Your email address will not be published.

Pin It on Pinterest

Shares