|
@@ -16,20 +16,21 @@ class LoginFormTest extends TestCase
|
|
|
Yii::$app->user->logout();
|
|
|
parent::tearDown();
|
|
|
}
|
|
|
-//
|
|
|
-// public function testLoginNoUser()
|
|
|
-// {
|
|
|
-// $model = new LoginForm([
|
|
|
-// 'username' => 'not_existing_username',
|
|
|
-// 'password' => 'not_existing_password',
|
|
|
-// ]);
|
|
|
-//
|
|
|
-// $this->specify('user should not be able to login, when there is no identity', function () use ($model) {
|
|
|
-// expect('model should not login user', $model->login())->false();
|
|
|
-// expect('user should not be logged in', Yii::$app->user->isGuest)->true();
|
|
|
-// });
|
|
|
-// }
|
|
|
-//
|
|
|
+
|
|
|
+ public function testLoginNoUser()
|
|
|
+ {
|
|
|
+ $model = new LoginForm([
|
|
|
+ 'username' => 'not_existing_username',
|
|
|
+ 'password' => 'not_existing_password',
|
|
|
+ ]);
|
|
|
+
|
|
|
+
|
|
|
+ $this->specify('user should not be able to login, when there is no identity', function () use ($model) {
|
|
|
+ expect('model should not login user', $model->login())->false();
|
|
|
+ expect('user should not be logged in', Yii::$app->user->isGuest)->true();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
// public function testLoginWrongPassword()
|
|
|
// {
|
|
|
// $model = new LoginForm([
|
|
@@ -44,18 +45,18 @@ class LoginFormTest extends TestCase
|
|
|
// });
|
|
|
// }
|
|
|
|
|
|
-// public function testLoginCorrect()
|
|
|
-// {
|
|
|
-// $model = new LoginForm([
|
|
|
-// 'username' => 'demo',
|
|
|
-// 'password' => 'demo',
|
|
|
-// ]);
|
|
|
-//
|
|
|
-// $this->specify('user should be able to login with correct credentials', function () use ($model) {
|
|
|
-// 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();
|
|
|
-// });
|
|
|
-// }
|
|
|
+ public function testLoginCorrect()
|
|
|
+ {
|
|
|
+ $model = new LoginForm([
|
|
|
+ 'username' => 'demo',
|
|
|
+ 'password' => 'demo',
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $this->specify('user should be able to login with correct credentials', function () use ($model) {
|
|
|
+ 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();
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
}
|