mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Cleanup code, improve typings
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace common\tests\unit\tasks;
|
||||
|
||||
use common\models\Account;
|
||||
use common\models\AccountQuery;
|
||||
use common\models\confirmations\CurrentEmailConfirmation;
|
||||
use common\tasks\SendCurrentEmailConfirmation;
|
||||
use common\tests\unit\TestCase;
|
||||
@@ -15,13 +18,14 @@ class SendCurrentEmailConfirmationTest extends TestCase {
|
||||
$account->email = 'mock@ely.by';
|
||||
$account->lang = 'id';
|
||||
|
||||
/** @var \Mockery\Mock|CurrentEmailConfirmation $confirmation */
|
||||
$confirmation = mock(CurrentEmailConfirmation::class)->makePartial();
|
||||
$accountQuery = $this->createMock(AccountQuery::class);
|
||||
$accountQuery->method('findFor')->willReturn($account);
|
||||
|
||||
$confirmation = $this->createPartialMock(CurrentEmailConfirmation::class, ['getAccount']);
|
||||
$confirmation->method('getAccount')->willReturn($accountQuery);
|
||||
$confirmation->key = 'ABCDEFG';
|
||||
$confirmation->shouldReceive('getAccount')->andReturn($account);
|
||||
|
||||
$result = SendCurrentEmailConfirmation::createFromConfirmation($confirmation);
|
||||
$this->assertInstanceOf(SendCurrentEmailConfirmation::class, $result);
|
||||
$this->assertSame('mock-username', $result->username);
|
||||
$this->assertSame('mock@ely.by', $result->email);
|
||||
$this->assertSame('ABCDEFG', $result->code);
|
||||
@@ -33,7 +37,7 @@ class SendCurrentEmailConfirmationTest extends TestCase {
|
||||
$task->email = 'mock@ely.by';
|
||||
$task->code = 'GFEDCBA';
|
||||
|
||||
$task->execute(mock(Queue::class));
|
||||
$task->execute($this->createMock(Queue::class));
|
||||
|
||||
$this->tester->canSeeEmailIsSent(1);
|
||||
/** @var \yii\swiftmailer\Message $email */
|
||||
|
@@ -1,7 +1,10 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace common\tests\unit\tasks;
|
||||
|
||||
use common\models\Account;
|
||||
use common\models\AccountQuery;
|
||||
use common\models\confirmations\NewEmailConfirmation;
|
||||
use common\tasks\SendNewEmailConfirmation;
|
||||
use common\tests\unit\TestCase;
|
||||
@@ -14,14 +17,15 @@ class SendNewEmailConfirmationTest extends TestCase {
|
||||
$account->username = 'mock-username';
|
||||
$account->lang = 'id';
|
||||
|
||||
/** @var \Mockery\Mock|NewEmailConfirmation $confirmation */
|
||||
$confirmation = mock(NewEmailConfirmation::class)->makePartial();
|
||||
$accountQuery = $this->createMock(AccountQuery::class);
|
||||
$accountQuery->method('findFor')->willReturn($account);
|
||||
|
||||
$confirmation = $this->createPartialMock(NewEmailConfirmation::class, ['getAccount']);
|
||||
$confirmation->method('getAccount')->willReturn($accountQuery);
|
||||
$confirmation->setNewEmail('new-email@ely.by');
|
||||
$confirmation->key = 'ABCDEFG';
|
||||
$confirmation->shouldReceive('getAccount')->andReturn($account);
|
||||
$confirmation->shouldReceive('getNewEmail')->andReturn('new-email@ely.by');
|
||||
|
||||
$result = SendNewEmailConfirmation::createFromConfirmation($confirmation);
|
||||
$this->assertInstanceOf(SendNewEmailConfirmation::class, $result);
|
||||
$this->assertSame('mock-username', $result->username);
|
||||
$this->assertSame('new-email@ely.by', $result->email);
|
||||
$this->assertSame('ABCDEFG', $result->code);
|
||||
@@ -33,7 +37,7 @@ class SendNewEmailConfirmationTest extends TestCase {
|
||||
$task->email = 'mock@ely.by';
|
||||
$task->code = 'GFEDCBA';
|
||||
|
||||
$task->execute(mock(Queue::class));
|
||||
$task->execute($this->createMock(Queue::class));
|
||||
|
||||
$this->tester->canSeeEmailIsSent(1);
|
||||
/** @var \yii\swiftmailer\Message $email */
|
||||
|
@@ -5,6 +5,7 @@ namespace common\tests\unit\tasks;
|
||||
|
||||
use common\emails\RendererInterface;
|
||||
use common\models\Account;
|
||||
use common\models\AccountQuery;
|
||||
use common\models\confirmations\ForgotPassword;
|
||||
use common\tasks\SendPasswordRecoveryEmail;
|
||||
use common\tests\unit\TestCase;
|
||||
@@ -24,10 +25,12 @@ class SendPasswordRecoveryEmailTest extends TestCase {
|
||||
$account->email = 'mock@ely.by';
|
||||
$account->lang = 'id';
|
||||
|
||||
/** @var \Mockery\Mock|ForgotPassword $confirmation */
|
||||
$confirmation = mock(ForgotPassword::class)->makePartial();
|
||||
$accountQuery = $this->createMock(AccountQuery::class);
|
||||
$accountQuery->method('findFor')->willReturn($account);
|
||||
|
||||
$confirmation = $this->createPartialMock(ForgotPassword::class, ['getAccount']);
|
||||
$confirmation->method('getAccount')->willReturn($accountQuery);
|
||||
$confirmation->key = 'ABCDEFG';
|
||||
$confirmation->shouldReceive('getAccount')->andReturn($account);
|
||||
|
||||
$result = SendPasswordRecoveryEmail::createFromConfirmation($confirmation);
|
||||
$this->assertSame('mock-username', $result->username);
|
||||
@@ -51,7 +54,7 @@ class SendPasswordRecoveryEmailTest extends TestCase {
|
||||
'link' => 'https://account.ely.by/recover-password/ABCDEFG',
|
||||
])->willReturn('mock-template');
|
||||
|
||||
$task->execute(mock(Queue::class));
|
||||
$task->execute($this->createMock(Queue::class));
|
||||
|
||||
$this->tester->canSeeEmailIsSent(1);
|
||||
/** @var \yii\swiftmailer\Message $email */
|
||||
|
@@ -5,6 +5,7 @@ namespace common\tests\unit\tasks;
|
||||
|
||||
use common\emails\RendererInterface;
|
||||
use common\models\Account;
|
||||
use common\models\AccountQuery;
|
||||
use common\models\confirmations\RegistrationConfirmation;
|
||||
use common\tasks\SendRegistrationEmail;
|
||||
use common\tests\unit\TestCase;
|
||||
@@ -24,10 +25,12 @@ class SendRegistrationEmailTest extends TestCase {
|
||||
$account->email = 'mock@ely.by';
|
||||
$account->lang = 'ru';
|
||||
|
||||
/** @var \Mockery\Mock|RegistrationConfirmation $confirmation */
|
||||
$confirmation = mock(RegistrationConfirmation::class)->makePartial();
|
||||
$accountQuery = $this->createMock(AccountQuery::class);
|
||||
$accountQuery->method('findFor')->willReturn($account);
|
||||
|
||||
$confirmation = $this->createPartialMock(RegistrationConfirmation::class, ['getAccount']);
|
||||
$confirmation->method('getAccount')->willReturn($accountQuery);
|
||||
$confirmation->key = 'ABCDEFG';
|
||||
$confirmation->shouldReceive('getAccount')->andReturn($account);
|
||||
|
||||
$result = SendRegistrationEmail::createFromConfirmation($confirmation);
|
||||
$this->assertSame('mock-username', $result->username);
|
||||
|
Reference in New Issue
Block a user