mirror of
				https://github.com/elyby/accounts.git
				synced 2025-05-31 14:11:46 +05:30 
			
		
		
		
	Исправлен баг с ссылками в email с активацией
This commit is contained in:
		@@ -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 {
 | 
			
		||||
 
 | 
			
		||||
@@ -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 {
 | 
			
		||||
 
 | 
			
		||||
@@ -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() {
 | 
			
		||||
 
 | 
			
		||||
@@ -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') {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user