mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Добавлен Helper для AMQP, который собирает все поступающие сообщения и предоставляет методы для проверки созданных сообщений
Исправлен баг в форме ChangeUsernameForm Исправлен баг с конфигурацией тестов, который не позволял правильно проводить проверки на существование\несуществование моделей Добавлена поддержка передачи хоста Redis через env переменные в тестах
This commit is contained in:
58
tests/codeception/common/_support/amqp/TestComponent.php
Normal file
58
tests/codeception/common/_support/amqp/TestComponent.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
namespace tests\codeception\common\_support\amqp;
|
||||
|
||||
use common\components\RabbitMQ\Component;
|
||||
use PhpAmqpLib\Connection\AbstractConnection;
|
||||
|
||||
class TestComponent extends Component {
|
||||
|
||||
private $sentMessages = [];
|
||||
|
||||
public function init() {
|
||||
\yii\base\Component::init();
|
||||
}
|
||||
|
||||
public function getConnection() {
|
||||
/** @noinspection MagicMethodsValidityInspection */
|
||||
/** @noinspection PhpMissingParentConstructorInspection */
|
||||
return new class extends AbstractConnection {
|
||||
public function __construct(
|
||||
$user,
|
||||
$password,
|
||||
$vhost,
|
||||
$insist,
|
||||
$login_method,
|
||||
$login_response,
|
||||
$locale,
|
||||
\PhpAmqpLib\Wire\IO\AbstractIO $io,
|
||||
$heartbeat
|
||||
) {
|
||||
// ничего не делаем
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public function sendToExchange($exchangeName, $routingKey, $message, $exchangeArgs = [], $publishArgs = []) {
|
||||
$this->sentMessages[$exchangeName][] = $this->prepareMessage($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $exchangeName
|
||||
* @return \PhpAmqpLib\Message\AMQPMessage[]
|
||||
*/
|
||||
public function getSentMessages(string $exchangeName = null) : array {
|
||||
if ($exchangeName !== null) {
|
||||
return $this->sentMessages[$exchangeName] ?? [];
|
||||
} else {
|
||||
$messages = [];
|
||||
foreach($this->sentMessages as $exchangeGroup) {
|
||||
foreach ($exchangeGroup as $message) {
|
||||
$messages[] = $message;
|
||||
}
|
||||
}
|
||||
|
||||
return $messages;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user