Пример #1
0
 public function testValidationRules()
 {
     $this->model = new RegistrationForm();
     verify('username is required', $this->model->validate(['username']))->false();
     $this->model->username = \Yii::$app->security->generateRandomKey();
     verify('username is too long', $this->model->validate(['username']))->false();
     $this->model->username = '******';
     verify('username contains invalid characters', $this->model->validate(['username']))->false();
     $this->model->username = '******';
     verify('username is already using', $this->model->validate(['username']))->false();
     $this->model->username = '******';
     verify('username is ok', $this->model->validate(['username']))->true();
     verify('email is required', $this->model->validate(['email']))->false();
     $this->model->email = 'not valid email';
     verify('email is not email', $this->model->validate(['email']))->false();
     $this->model->email = '*****@*****.**';
     verify('email is already using', $this->model->validate(['email']))->false();
     $this->model->email = '*****@*****.**';
     verify('email is ok', $this->model->validate(['email']))->true();
     verify('password is required', $this->model->validate(['password']))->false();
     $this->model->password = '******';
     verify('password is too short', $this->model->validate(['password']))->false();
     $this->model->password = '******';
     verify('password is ok', $this->model->validate(['password']))->true();
 }