mirror of
https://github.com/elyby/accounts.git
synced 2024-12-03 12:10:57 +05:30
Первичная реализация формы отправки нового письма с активацией аккаунта, чуть-чуть рефакторинга тестов
This commit is contained in:
parent
7e2247ccb5
commit
b9ee667829
@ -2,6 +2,7 @@
|
|||||||
namespace api\controllers;
|
namespace api\controllers;
|
||||||
|
|
||||||
use api\models\ConfirmEmailForm;
|
use api\models\ConfirmEmailForm;
|
||||||
|
use api\models\NewAccountActivationForm;
|
||||||
use api\models\RegistrationForm;
|
use api\models\RegistrationForm;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\filters\AccessControl;
|
use yii\filters\AccessControl;
|
||||||
@ -12,13 +13,13 @@ class SignupController extends Controller {
|
|||||||
public function behaviors() {
|
public function behaviors() {
|
||||||
return ArrayHelper::merge(parent::behaviors(), [
|
return ArrayHelper::merge(parent::behaviors(), [
|
||||||
'authenticator' => [
|
'authenticator' => [
|
||||||
'except' => ['index', 'confirm'],
|
'except' => ['index', 'new-message', 'confirm'],
|
||||||
],
|
],
|
||||||
'access' => [
|
'access' => [
|
||||||
'class' => AccessControl::class,
|
'class' => AccessControl::class,
|
||||||
'rules' => [
|
'rules' => [
|
||||||
[
|
[
|
||||||
'actions' => ['index', 'confirm'],
|
'actions' => ['index', 'new-message', 'confirm'],
|
||||||
'allow' => true,
|
'allow' => true,
|
||||||
'roles' => ['?'],
|
'roles' => ['?'],
|
||||||
],
|
],
|
||||||
@ -31,6 +32,7 @@ class SignupController extends Controller {
|
|||||||
return [
|
return [
|
||||||
'register' => ['POST'],
|
'register' => ['POST'],
|
||||||
'confirm' => ['POST'],
|
'confirm' => ['POST'],
|
||||||
|
'new-message' => ['POST'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,6 +51,31 @@ class SignupController extends Controller {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function actionNewMessage() {
|
||||||
|
$model = new NewAccountActivationForm();
|
||||||
|
$model->load(Yii::$app->request->post());
|
||||||
|
if (!$model->sendNewMessage()) {
|
||||||
|
$response = [
|
||||||
|
'success' => false,
|
||||||
|
'errors' => $this->normalizeModelErrors($model->getErrors()),
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($response['errors']['email'] === 'error.recently_sent_message') {
|
||||||
|
$activeActivation = $model->getActiveActivation();
|
||||||
|
$response['data'] = [
|
||||||
|
'can_repeat_in' => $activeActivation->created_at - time() + NewAccountActivationForm::REPEAT_FREQUENCY,
|
||||||
|
'repeat_frequency' => NewAccountActivationForm::REPEAT_FREQUENCY,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'success' => true,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
public function actionConfirm() {
|
public function actionConfirm() {
|
||||||
$model = new ConfirmEmailForm();
|
$model = new ConfirmEmailForm();
|
||||||
$model->load(Yii::$app->request->post());
|
$model->load(Yii::$app->request->post());
|
||||||
|
@ -11,6 +11,7 @@ class BaseKeyConfirmationForm extends BaseApiForm {
|
|||||||
|
|
||||||
public function rules() {
|
public function rules() {
|
||||||
return [
|
return [
|
||||||
|
// TODO: нужно провалидировать количество попыток ввода кода для определённого IP адреса и в случае чего запросить капчу
|
||||||
['key', 'required', 'message' => 'error.key_is_required'],
|
['key', 'required', 'message' => 'error.key_is_required'],
|
||||||
['key', 'validateKey'],
|
['key', 'validateKey'],
|
||||||
];
|
];
|
||||||
|
103
api/models/NewAccountActivationForm.php
Normal file
103
api/models/NewAccountActivationForm.php
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
<?php
|
||||||
|
namespace api\models;
|
||||||
|
|
||||||
|
use common\components\UserFriendlyRandomKey;
|
||||||
|
use common\models\Account;
|
||||||
|
use common\models\EmailActivation;
|
||||||
|
use Yii;
|
||||||
|
use yii\base\ErrorException;
|
||||||
|
|
||||||
|
class NewAccountActivationForm extends BaseApiForm {
|
||||||
|
|
||||||
|
// Частота повтора отправки нового письма
|
||||||
|
const REPEAT_FREQUENCY = 5 * 60;
|
||||||
|
|
||||||
|
public $email;
|
||||||
|
|
||||||
|
public function rules() {
|
||||||
|
return [
|
||||||
|
['email', 'filter', 'filter' => 'trim'],
|
||||||
|
['email', 'required', 'message' => 'error.email_required'],
|
||||||
|
['email', 'validateAccountForEmail'],
|
||||||
|
['email', 'validateExistsActivation'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function validateAccountForEmail($attribute) {
|
||||||
|
if (!$this->hasErrors($attribute)) {
|
||||||
|
$account = $this->getAccount();
|
||||||
|
if ($account && $account->status === Account::STATUS_ACTIVE) {
|
||||||
|
$this->addError($attribute, "error.account_already_activated");
|
||||||
|
} elseif (!$account) {
|
||||||
|
$this->addError($attribute, "error.{$attribute}_not_found");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function validateExistsActivation($attribute) {
|
||||||
|
if (!$this->hasErrors($attribute)) {
|
||||||
|
if ($this->getActiveActivation() !== null) {
|
||||||
|
$this->addError($attribute, 'error.recently_sent_message');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sendNewMessage() {
|
||||||
|
if (!$this->validate()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$account = $this->getAccount();
|
||||||
|
$transaction = Yii::$app->db->beginTransaction();
|
||||||
|
try {
|
||||||
|
// Удаляем все активации аккаунта для пользователя этого E-mail адреса
|
||||||
|
/** @var EmailActivation[] $activations */
|
||||||
|
$activations = $account->getEmailActivations()
|
||||||
|
->andWhere(['type' => EmailActivation::TYPE_REGISTRATION_EMAIL_CONFIRMATION])
|
||||||
|
->all();
|
||||||
|
|
||||||
|
foreach ($activations as $activation) {
|
||||||
|
$activation->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
$activation = new EmailActivation();
|
||||||
|
$activation->account_id = $account->id;
|
||||||
|
$activation->type = EmailActivation::TYPE_REGISTRATION_EMAIL_CONFIRMATION;
|
||||||
|
$activation->key = UserFriendlyRandomKey::make();
|
||||||
|
if (!$activation->save()) {
|
||||||
|
throw new ErrorException('Unable save email-activation model.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$regForm = new RegistrationForm();
|
||||||
|
$regForm->sendMail($activation, $account);
|
||||||
|
|
||||||
|
$transaction->commit();
|
||||||
|
} catch (ErrorException $e) {
|
||||||
|
$transaction->rollBack();
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Account|null
|
||||||
|
*/
|
||||||
|
public function getAccount() {
|
||||||
|
return Account::find()
|
||||||
|
->andWhere(['email' => $this->email])
|
||||||
|
->one();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return EmailActivation|null
|
||||||
|
*/
|
||||||
|
public function getActiveActivation() {
|
||||||
|
return $this->getAccount()
|
||||||
|
->getEmailActivations()
|
||||||
|
->andWhere(['type' => EmailActivation::TYPE_REGISTRATION_EMAIL_CONFIRMATION])
|
||||||
|
->andWhere(['>=', 'created_at', time() - self::REPEAT_FREQUENCY])
|
||||||
|
->one();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -82,25 +82,7 @@ class RegistrationForm extends BaseApiForm {
|
|||||||
throw new ErrorException('Unable save email-activation model.');
|
throw new ErrorException('Unable save email-activation model.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var \yii\swiftmailer\Mailer $mailer */
|
$this->sendMail($emailActivation, $account);
|
||||||
$mailer = Yii::$app->mailer;
|
|
||||||
/** @var \yii\swiftmailer\Message $message */
|
|
||||||
$message = $mailer->compose(
|
|
||||||
[
|
|
||||||
'html' => '@app/mails/registration-confirmation-html',
|
|
||||||
'text' => '@app/mails/registration-confirmation-text',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'key' => $emailActivation->key,
|
|
||||||
]
|
|
||||||
)
|
|
||||||
->setTo([$account->email => $account->username])
|
|
||||||
->setFrom([Yii::$app->params['fromEmail'] => 'Ely.by Accounts'])
|
|
||||||
->setSubject('Ely.by Account registration');
|
|
||||||
|
|
||||||
if (!$message->send()) {
|
|
||||||
throw new ErrorException('Unable send email with activation code.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$transaction->commit();
|
$transaction->commit();
|
||||||
} catch (ErrorException $e) {
|
} catch (ErrorException $e) {
|
||||||
@ -111,4 +93,24 @@ class RegistrationForm extends BaseApiForm {
|
|||||||
return $account;
|
return $account;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: подумать, чтобы вынести этот метод в какую-то отдельную конструкцию, т.к. используется и внутри NewAccountActivationForm
|
||||||
|
public function sendMail(EmailActivation $emailActivation, Account $account) {
|
||||||
|
/** @var \yii\swiftmailer\Mailer $mailer */
|
||||||
|
$mailer = Yii::$app->mailer;
|
||||||
|
/** @var \yii\swiftmailer\Message $message */
|
||||||
|
$message = $mailer->compose([
|
||||||
|
'html' => '@app/mails/registration-confirmation-html',
|
||||||
|
'text' => '@app/mails/registration-confirmation-text',
|
||||||
|
], [
|
||||||
|
'key' => $emailActivation->key,
|
||||||
|
])
|
||||||
|
->setTo([$account->email => $account->username])
|
||||||
|
->setFrom([Yii::$app->params['fromEmail'] => 'Ely.by Accounts'])
|
||||||
|
->setSubject('Ely.by Account registration');
|
||||||
|
|
||||||
|
if (!$message->send()) {
|
||||||
|
throw new ErrorException('Unable send email with activation code.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -189,7 +189,7 @@ class Account extends ActiveRecord implements IdentityInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getEmailActivations() {
|
public function getEmailActivations() {
|
||||||
return $this->hasMany(EmailActivation::class, ['id' => 'account_id']);
|
return $this->hasMany(EmailActivation::class, ['account_id' => 'id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSessions() {
|
public function getSessions() {
|
||||||
@ -206,9 +206,9 @@ class Account extends ActiveRecord implements IdentityInterface {
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function canAutoApprove(OauthClient $client, array $scopes = []) {
|
public function canAutoApprove(OauthClient $client, array $scopes = []) {
|
||||||
//if ($client->is_trusted) {
|
if ($client->is_trusted) {
|
||||||
// return true;
|
return true;
|
||||||
//}
|
}
|
||||||
|
|
||||||
/** @var OauthSession|null $session */
|
/** @var OauthSession|null $session */
|
||||||
$session = $this->getSessions()->andWhere(['client_id' => $client->id])->one();
|
$session = $this->getSessions()->andWhere(['client_id' => $client->id])->one();
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace tests\codeception\api\_pages;
|
|
||||||
|
|
||||||
use yii\codeception\BasePage;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @property \tests\codeception\api\FunctionalTester $actor
|
|
||||||
*/
|
|
||||||
class EmailConfirmRoute extends BasePage {
|
|
||||||
|
|
||||||
public $route = ['signup/confirm'];
|
|
||||||
|
|
||||||
public function confirm($key = '') {
|
|
||||||
$this->actor->sendPOST($this->getUrl(), [
|
|
||||||
'key' => $key,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace tests\codeception\api\_pages;
|
|
||||||
|
|
||||||
use yii\codeception\BasePage;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @property \tests\codeception\api\FunctionalTester $actor
|
|
||||||
*/
|
|
||||||
class RegisterRoute extends BasePage {
|
|
||||||
|
|
||||||
public $route = ['signup/index'];
|
|
||||||
|
|
||||||
public function send(array $registrationData) {
|
|
||||||
$this->actor->sendPOST($this->getUrl(), $registrationData);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
28
tests/codeception/api/_pages/SignupRoute.php
Normal file
28
tests/codeception/api/_pages/SignupRoute.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
namespace tests\codeception\api\_pages;
|
||||||
|
|
||||||
|
use yii\codeception\BasePage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property \tests\codeception\api\FunctionalTester $actor
|
||||||
|
*/
|
||||||
|
class SignupRoute extends BasePage {
|
||||||
|
|
||||||
|
public function register(array $registrationData) {
|
||||||
|
$this->route = ['signup/index'];
|
||||||
|
$this->actor->sendPOST($this->getUrl(), $registrationData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sendNewMessage($email = '') {
|
||||||
|
$this->route = ['signup/new-message'];
|
||||||
|
$this->actor->sendPOST($this->getUrl(), ['email' => $email]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function confirm($key = '') {
|
||||||
|
$this->route = ['signup/confirm'];
|
||||||
|
$this->actor->sendPOST($this->getUrl(), [
|
||||||
|
'key' => $key,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,12 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace tests\codeception\api;
|
namespace tests\codeception\api;
|
||||||
|
|
||||||
use tests\codeception\api\_pages\EmailConfirmRoute;
|
use tests\codeception\api\_pages\SignupRoute;
|
||||||
|
|
||||||
class EmailConfirmationCest {
|
class EmailConfirmationCest {
|
||||||
|
|
||||||
public function testLoginEmailOrUsername(FunctionalTester $I) {
|
public function testLoginEmailOrUsername(FunctionalTester $I) {
|
||||||
$route = new EmailConfirmRoute($I);
|
$route = new SignupRoute($I);
|
||||||
|
|
||||||
$I->wantTo('see error.key_is_required expected if key is not set');
|
$I->wantTo('see error.key_is_required expected if key is not set');
|
||||||
$route->confirm();
|
$route->confirm();
|
||||||
@ -28,7 +28,7 @@ class EmailConfirmationCest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testLoginByEmailCorrect(FunctionalTester $I) {
|
public function testLoginByEmailCorrect(FunctionalTester $I) {
|
||||||
$route = new EmailConfirmRoute($I);
|
$route = new SignupRoute($I);
|
||||||
|
|
||||||
$I->wantTo('confirm my email using correct activation key');
|
$I->wantTo('confirm my email using correct activation key');
|
||||||
$route->confirm('HABGCABHJ1234HBHVD');
|
$route->confirm('HABGCABHJ1234HBHVD');
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
namespace tests\codeception\api\functional;
|
||||||
|
|
||||||
|
use Codeception\Specify;
|
||||||
|
use tests\codeception\api\_pages\SignupRoute;
|
||||||
|
use tests\codeception\api\FunctionalTester;
|
||||||
|
|
||||||
|
class NewAccountActivationCest {
|
||||||
|
|
||||||
|
public function testSuccess(FunctionalTester $I) {
|
||||||
|
$route = new SignupRoute($I);
|
||||||
|
|
||||||
|
$I->wantTo('ensure that signup works');
|
||||||
|
$route->sendNewMessage('achristiansen@gmail.com');
|
||||||
|
$I->canSeeResponseCodeIs(200);
|
||||||
|
$I->canSeeResponseIsJson();
|
||||||
|
$I->canSeeResponseContainsJson(['success' => true]);
|
||||||
|
$I->cantSeeResponseJsonMatchesJsonPath('$.errors');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -3,7 +3,7 @@ namespace tests\codeception\api\functional;
|
|||||||
|
|
||||||
use Codeception\Specify;
|
use Codeception\Specify;
|
||||||
use common\models\Account;
|
use common\models\Account;
|
||||||
use tests\codeception\api\_pages\RegisterRoute;
|
use tests\codeception\api\_pages\SignupRoute;
|
||||||
use tests\codeception\api\FunctionalTester;
|
use tests\codeception\api\FunctionalTester;
|
||||||
|
|
||||||
class RegisterCest {
|
class RegisterCest {
|
||||||
@ -16,10 +16,10 @@ class RegisterCest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testIncorrectRegistration(FunctionalTester $I) {
|
public function testIncorrectRegistration(FunctionalTester $I) {
|
||||||
$route = new RegisterRoute($I);
|
$route = new SignupRoute($I);
|
||||||
|
|
||||||
$I->wantTo('get error.you_must_accept_rules if we don\'t accept rules');
|
$I->wantTo('get error.you_must_accept_rules if we don\'t accept rules');
|
||||||
$route->send([
|
$route->register([
|
||||||
'username' => 'ErickSkrauch',
|
'username' => 'ErickSkrauch',
|
||||||
'email' => 'erickskrauch@ely.by',
|
'email' => 'erickskrauch@ely.by',
|
||||||
'password' => 'some_password',
|
'password' => 'some_password',
|
||||||
@ -33,7 +33,7 @@ class RegisterCest {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$I->wantTo('don\'t see error.you_must_accept_rules if we accept rules');
|
$I->wantTo('don\'t see error.you_must_accept_rules if we accept rules');
|
||||||
$route->send([
|
$route->register([
|
||||||
'rulesAgreement' => true,
|
'rulesAgreement' => true,
|
||||||
]);
|
]);
|
||||||
$I->cantSeeResponseContainsJson([
|
$I->cantSeeResponseContainsJson([
|
||||||
@ -43,7 +43,7 @@ class RegisterCest {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$I->wantTo('see error.username_required if username is not set');
|
$I->wantTo('see error.username_required if username is not set');
|
||||||
$route->send([
|
$route->register([
|
||||||
'username' => '',
|
'username' => '',
|
||||||
'email' => '',
|
'email' => '',
|
||||||
'password' => '',
|
'password' => '',
|
||||||
@ -58,7 +58,7 @@ class RegisterCest {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$I->wantTo('don\'t see error.username_required if username is not set');
|
$I->wantTo('don\'t see error.username_required if username is not set');
|
||||||
$route->send([
|
$route->register([
|
||||||
'username' => 'valid_nickname',
|
'username' => 'valid_nickname',
|
||||||
'email' => '',
|
'email' => '',
|
||||||
'password' => '',
|
'password' => '',
|
||||||
@ -72,7 +72,7 @@ class RegisterCest {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$I->wantTo('see error.email_required if email is not set');
|
$I->wantTo('see error.email_required if email is not set');
|
||||||
$route->send([
|
$route->register([
|
||||||
'username' => 'valid_nickname',
|
'username' => 'valid_nickname',
|
||||||
'email' => '',
|
'email' => '',
|
||||||
'password' => '',
|
'password' => '',
|
||||||
@ -87,7 +87,7 @@ class RegisterCest {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$I->wantTo('see error.email_invalid if email is set, but invalid');
|
$I->wantTo('see error.email_invalid if email is set, but invalid');
|
||||||
$route->send([
|
$route->register([
|
||||||
'username' => 'valid_nickname',
|
'username' => 'valid_nickname',
|
||||||
'email' => 'invalid@email',
|
'email' => 'invalid@email',
|
||||||
'password' => '',
|
'password' => '',
|
||||||
@ -102,7 +102,7 @@ class RegisterCest {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$I->wantTo('see error.email_invalid if email is set, valid, but domain doesn\'t exist or don\'t have mx record');
|
$I->wantTo('see error.email_invalid if email is set, valid, but domain doesn\'t exist or don\'t have mx record');
|
||||||
$route->send([
|
$route->register([
|
||||||
'username' => 'valid_nickname',
|
'username' => 'valid_nickname',
|
||||||
'email' => 'invalid@govnomail.com',
|
'email' => 'invalid@govnomail.com',
|
||||||
'password' => '',
|
'password' => '',
|
||||||
@ -117,7 +117,7 @@ class RegisterCest {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$I->wantTo('see error.email_not_available if email is set, fully valid, but not available for registration');
|
$I->wantTo('see error.email_not_available if email is set, fully valid, but not available for registration');
|
||||||
$route->send([
|
$route->register([
|
||||||
'username' => 'valid_nickname',
|
'username' => 'valid_nickname',
|
||||||
'email' => 'admin@ely.by',
|
'email' => 'admin@ely.by',
|
||||||
'password' => '',
|
'password' => '',
|
||||||
@ -132,7 +132,7 @@ class RegisterCest {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$I->wantTo('don\'t see errors on email if all valid');
|
$I->wantTo('don\'t see errors on email if all valid');
|
||||||
$route->send([
|
$route->register([
|
||||||
'username' => 'valid_nickname',
|
'username' => 'valid_nickname',
|
||||||
'email' => 'erickskrauch@ely.by',
|
'email' => 'erickskrauch@ely.by',
|
||||||
'password' => '',
|
'password' => '',
|
||||||
@ -142,7 +142,7 @@ class RegisterCest {
|
|||||||
$I->cantSeeResponseJsonMatchesJsonPath('$.errors.email');
|
$I->cantSeeResponseJsonMatchesJsonPath('$.errors.email');
|
||||||
|
|
||||||
$I->wantTo('see error.password_required if password is not set');
|
$I->wantTo('see error.password_required if password is not set');
|
||||||
$route->send([
|
$route->register([
|
||||||
'username' => 'valid_nickname',
|
'username' => 'valid_nickname',
|
||||||
'email' => 'erickskrauch@ely.by',
|
'email' => 'erickskrauch@ely.by',
|
||||||
'password' => '',
|
'password' => '',
|
||||||
@ -157,7 +157,7 @@ class RegisterCest {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$I->wantTo('see error.password_too_short before it will be compared with rePassword');
|
$I->wantTo('see error.password_too_short before it will be compared with rePassword');
|
||||||
$route->send([
|
$route->register([
|
||||||
'username' => 'valid_nickname',
|
'username' => 'valid_nickname',
|
||||||
'email' => 'correct-email@ely.by',
|
'email' => 'correct-email@ely.by',
|
||||||
'password' => 'short',
|
'password' => 'short',
|
||||||
@ -173,7 +173,7 @@ class RegisterCest {
|
|||||||
$I->cantSeeResponseJsonMatchesJsonPath('$.errors.rePassword');
|
$I->cantSeeResponseJsonMatchesJsonPath('$.errors.rePassword');
|
||||||
|
|
||||||
$I->wantTo('see error.rePassword_required if password valid and rePassword not set');
|
$I->wantTo('see error.rePassword_required if password valid and rePassword not set');
|
||||||
$route->send([
|
$route->register([
|
||||||
'username' => 'valid_nickname',
|
'username' => 'valid_nickname',
|
||||||
'email' => 'correct-email@ely.by',
|
'email' => 'correct-email@ely.by',
|
||||||
'password' => 'valid-password',
|
'password' => 'valid-password',
|
||||||
@ -188,7 +188,7 @@ class RegisterCest {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$I->wantTo('see error.rePassword_does_not_match if password valid and rePassword donen\'t match it');
|
$I->wantTo('see error.rePassword_does_not_match if password valid and rePassword donen\'t match it');
|
||||||
$route->send([
|
$route->register([
|
||||||
'username' => 'valid_nickname',
|
'username' => 'valid_nickname',
|
||||||
'email' => 'correct-email@ely.by',
|
'email' => 'correct-email@ely.by',
|
||||||
'password' => 'valid-password',
|
'password' => 'valid-password',
|
||||||
@ -205,10 +205,10 @@ class RegisterCest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testUserCorrectRegistration(FunctionalTester $I) {
|
public function testUserCorrectRegistration(FunctionalTester $I) {
|
||||||
$route = new RegisterRoute($I);
|
$route = new SignupRoute($I);
|
||||||
|
|
||||||
$I->wantTo('ensure that signup works');
|
$I->wantTo('ensure that signup works');
|
||||||
$route->send([
|
$route->register([
|
||||||
'username' => 'some_username',
|
'username' => 'some_username',
|
||||||
'email' => 'some_email@example.com',
|
'email' => 'some_email@example.com',
|
||||||
'password' => 'some_password',
|
'password' => 'some_password',
|
||||||
|
Loading…
Reference in New Issue
Block a user