Добавлен Helper для AMQP, который собирает все поступающие сообщения и предоставляет методы для проверки созданных сообщений

Исправлен баг в форме ChangeUsernameForm
Исправлен баг с конфигурацией тестов, который не позволял правильно проводить проверки на существование\несуществование моделей
Добавлена поддержка передачи хоста Redis через env переменные в тестах
This commit is contained in:
ErickSkrauch
2016-12-04 19:56:49 +03:00
parent 363b25e6da
commit a8c7118e38
14 changed files with 188 additions and 20 deletions

View File

@@ -18,9 +18,8 @@ class ConfirmNewEmailFormTest extends TestCase {
}
public function testChangeEmail() {
$accountId = $this->tester->grabFixture('accounts', 'account-with-change-email-finish-state')['id'];
/** @var Account $account */
$account = Account::findOne($accountId);
$account = Account::findOne($this->getAccountId());
$newEmailConfirmationFixture = $this->tester->grabFixture('emailActivations', 'newEmailConfirmation');
$model = new ConfirmNewEmailForm($account, [
'key' => $newEmailConfirmationFixture['key'],
@@ -32,6 +31,23 @@ class ConfirmNewEmailFormTest extends TestCase {
]));
$data = unserialize($newEmailConfirmationFixture['_data']);
$this->assertEquals($data['newEmail'], $account->email);
$this->tester->canSeeAmqpMessageIsCreated('events');
}
public function testCreateTask() {
/** @var Account $account */
$account = Account::findOne($this->getAccountId());
$model = new ConfirmNewEmailForm($account);
$model->createTask(1, 'test1@ely.by', 'test@ely.by');
$message = $this->tester->grabLastSentAmqpMessage('events');
$body = json_decode($message->getBody(), true);
$this->assertEquals(1, $body['accountId']);
$this->assertEquals('test1@ely.by', $body['newEmail']);
$this->assertEquals('test@ely.by', $body['oldEmail']);
}
private function getAccountId() {
return $this->tester->grabFixture('accounts', 'account-with-change-email-finish-state')['id'];
}
}