[ 'class' => UserFixture::className(), 'dataFile' => codecept_data_dir() . 'user.php' ] ]; } public function testLoginNoUser() { $form = new \core\forms\auth\LoginForm(); $form->username = 'not_existing_username'; $form->password = 'not_existing_password'; $model = new User($form); //$as = new AuthService(new UserRepository(new SimpleEventDispatcher(null, null))); //$as->auth($form); expect('model should not login user', Yii::$app->user->login(new Identity($model)))->false(); expect('user should not be logged in', Yii::$app->user->isGuest)->true(); } public function testLoginWrongPassword() { $model = new LoginForm([ 'username' => 'bayer.hudson', 'password' => 'wrong_password', ]); expect('model should not login user', $model->login())->false(); expect('error message should be set', $model->errors)->hasKey('password'); expect('user should not be logged in', Yii::$app->user->isGuest)->true(); } public function testLoginCorrect() { $model = new LoginForm([ 'username' => 'bayer.hudson', 'password' => 'password_0', ]); expect('model should login user', $model->login())->true(); expect('error message should not be set', $model->errors)->hasntKey('password'); expect('user should be logged in', Yii::$app->user->isGuest)->false(); } }