Example #1
0
 public function actionIndex()
 {
     $form = new LoginForm();
     if (\Yii::$app->request->isPost and $form->load(\Yii::$app->request->post()) and $form->login()) {
         return $this->goHome();
     }
     return $this->render('index.tpl', array('model' => $form));
 }
Example #2
0
 /**
  * Тест методов валидации
  */
 public function testValidate()
 {
     $this->specifyConfig()->cloneOnly('db', 'components');
     $model = new LoginForm();
     $this->specify("validate latin word", function () use($model) {
         $model->password = "******";
         $model->validate();
         $this->assertContains('Поле должно содержать латинские буквы или цифры.', $model->getErrors('password'));
         $model->password = "******";
         $model->validate();
         $this->assertNotContains('Поле должно содержать латинские буквы или цифры.', $model->getErrors('password'));
     });
 }