/** * @param string $username * @param string $password */ public function login($username, $password) { $loginForm = new LoginForm(); $this->actor->fillField('input[name="' . $loginForm->formName() . '[username]"]', $username); $this->actor->fillField('input[name="' . $loginForm->formName() . '[password]"]', $password); $this->actor->click('login-button'); }
/** * Logs in a user. * @return mixed response */ public function actionLogin() { if (!Yii::$app->user->isGuest) { return $this->goHome(); } $model = new LoginForm(); if ($model->load(Yii::$app->request->post()) && $model->login()) { return $this->goBack(); } else { return $this->render('login', ['model' => $model]); } }