Убраны разрознености в ошибках, скорреткированы тесты

This commit is contained in:
ErickSkrauch 2016-06-16 22:36:52 +03:00
parent 73d07f355a
commit 4614cf8fe7
8 changed files with 11 additions and 11 deletions

View File

@ -69,7 +69,7 @@ class AuthenticationController extends Controller {
'errors' => $this->normalizeModelErrors($model->getErrors()),
];
if (ArrayHelper::getValue($data['errors'], 'login') === 'error.email_frequency') {
if (ArrayHelper::getValue($data['errors'], 'login') === 'error.recently_sent_message') {
$emailActivation = $model->getEmailActivation();
$data['data'] = [
'canRepeatIn' => $emailActivation->canRepeatIn(),

View File

@ -46,7 +46,7 @@ class ForgotPasswordForm extends ApiForm {
if (!$this->hasErrors()) {
$emailConfirmation = $this->getEmailActivation();
if ($emailConfirmation !== null && !$emailConfirmation->canRepeat()) {
$this->addError($attribute, 'error.email_frequency');
$this->addError($attribute, 'error.recently_sent_message');
}
}
}

View File

@ -27,7 +27,7 @@ class RegistrationForm extends ApiForm {
public function rules() {
return [
[[], ReCaptchaValidator::class, 'message' => 'error.captcha_invalid', 'when' => !YII_ENV_TEST],
['rulesAgreement', 'required', 'message' => 'error.you_must_accept_rules'],
['rulesAgreement', 'required', 'message' => 'error.rulesAgreement_required'],
['username', 'validateUsername', 'skipOnEmpty' => false],
['email', 'validateEmail', 'skipOnEmpty' => false],

View File

@ -13,7 +13,7 @@ class KeyConfirmationForm extends ApiForm {
public function rules() {
return [
// TODO: нужно провалидировать количество попыток ввода кода для определённого IP адреса и в случае чего запросить капчу
['key', 'required', 'message' => 'error.key_is_required'],
['key', 'required', 'message' => 'error.key_required'],
['key', EmailActivationKeyValidator::class],
];
}

View File

@ -13,7 +13,7 @@ class EmailConfirmationCest {
$I->canSeeResponseContainsJson([
'success' => false,
'errors' => [
'key' => 'error.key_is_required',
'key' => 'error.key_required',
],
]);

View File

@ -39,7 +39,7 @@ class ForgotPasswordCest {
$I->canSeeResponseContainsJson([
'success' => false,
'errors' => [
'login' => 'error.email_frequency',
'login' => 'error.recently_sent_message',
],
]);
$I->canSeeResponseJsonMatchesJsonPath('$.data.canRepeatIn');

View File

@ -18,7 +18,7 @@ class RegisterCest {
public function testIncorrectRegistration(FunctionalTester $I) {
$route = new SignupRoute($I);
$I->wantTo('get error.you_must_accept_rules if we don\'t accept rules');
$I->wantTo('get error.rulesAgreement_required if we don\'t accept rules');
$route->register([
'username' => 'ErickSkrauch',
'email' => 'erickskrauch@ely.by',
@ -28,17 +28,17 @@ class RegisterCest {
$I->canSeeResponseContainsJson([
'success' => false,
'errors' => [
'rulesAgreement' => 'error.you_must_accept_rules',
'rulesAgreement' => 'error.rulesAgreement_required',
],
]);
$I->wantTo('don\'t see error.you_must_accept_rules if we accept rules');
$I->wantTo('don\'t see error.rulesAgreement_requireds if we accept rules');
$route->register([
'rulesAgreement' => true,
]);
$I->cantSeeResponseContainsJson([
'errors' => [
'rulesAgreement' => 'error.you_must_accept_rules',
'rulesAgreement' => 'error.rulesAgreement_required',
],
]);

View File

@ -79,7 +79,7 @@ class ForgotPasswordFormTest extends DbTestCase {
]);
$model->validateFrequency('login');
expect($model->getErrors('login'))->equals(['error.email_frequency']);
expect($model->getErrors('login'))->equals(['error.recently_sent_message']);
});
$this->specify('empty errors if email was sent a long time ago', function() {