Исправлен баг с ссылками в email с активацией

This commit is contained in:
ErickSkrauch 2017-06-11 21:06:55 +03:00
parent 861c6810cb
commit 013d0eda60
4 changed files with 22 additions and 7 deletions

View File

@ -12,7 +12,7 @@ class ForgotPasswordParams {
public function __construct(string $username, string $code, string $link) {
$this->username = $username;
$this->code = $code;
$this->link = $code;
$this->link = $link;
}
public function getUsername(): string {

View File

@ -12,7 +12,7 @@ class RegistrationEmailParams {
public function __construct(string $username, string $code, string $link) {
$this->username = $username;
$this->code = $code;
$this->link = $code;
$this->link = $link;
}
public function getUsername(): string {

View File

@ -96,8 +96,14 @@ class ForgotPasswordFormTest extends TestCase {
public function testForgotPassword() {
$model = new ForgotPasswordForm(['login' => $this->tester->grabFixture('accounts', 'admin')['username']]);
$this->assertTrue($model->forgotPassword(), 'form should be successfully processed');
$this->assertInstanceOf(EmailActivation::class, $model->getEmailActivation(), 'getEmailActivation should return valid object instance');
$activation = $model->getEmailActivation();
$this->assertInstanceOf(EmailActivation::class, $activation, 'getEmailActivation should return valid object instance');
$this->tester->canSeeEmailIsSent(1);
/** @var \yii\swiftmailer\Message $email */
$email = $this->tester->grabSentEmails()[0];
$body = $email->getSwiftMessage()->getBody();
$this->assertContains($activation->key, $body);
$this->assertContains('/recover-password/' . $activation->key, $body);
}
public function testForgotPasswordResend() {

View File

@ -97,16 +97,25 @@ class RegistrationFormTest extends TestCase {
'username' => 'some_username',
'email' => 'some_email@example.com',
])->exists(), 'user model exists in database');
$this->assertTrue(EmailActivation::find()->andWhere([
'account_id' => $account->id,
'type' => EmailActivation::TYPE_REGISTRATION_EMAIL_CONFIRMATION,
])->exists(), 'email activation code exists in database');
/** @var EmailActivation $activation */
$activation = EmailActivation::find()
->andWhere([
'account_id' => $account->id,
'type' => EmailActivation::TYPE_REGISTRATION_EMAIL_CONFIRMATION,
])
->one();
$this->assertInstanceOf(EmailActivation::class, $activation, 'email activation code exists in database');
$this->assertTrue(UsernameHistory::find()->andWhere([
'username' => $account->username,
'account_id' => $account->id,
'applied_in' => $account->created_at,
])->exists(), 'username history record exists in database');
$this->tester->canSeeEmailIsSent(1);
/** @var \yii\swiftmailer\Message $email */
$email = $this->tester->grabSentEmails()[0];
$body = $email->getSwiftMessage()->getBody();
$this->assertContains($activation->key, $body);
$this->assertContains('/activation/' . $activation->key, $body);
}
private function mockRequest($ip = '88.225.20.236') {