Testomatio - Test Management for Codeception
composer require --dev codeception/module-amqpThis module interacts with message broker software that implements the Advanced Message Queuing Protocol (AMQP) standard. For example, RabbitMQ (tested).
modules:
    enabled:
        - AMQP:
            host: 'localhost'
            port: '5672'
            username: 'guest'
            password: 'guest'
            vhost: '/'
            queues: [queue1, queue2]
            single_channel: false
param string $queueparam string $exchangeparam string $routing_keyparam bool $nowaitparam ?array $argumentsparam ?int $ticketreturn mixedBinds a queue to an exchange
This is an alias of method queue_bind of PhpAmqpLib\Channel\AMQPChannel.
<?php
$I->bindQueueToExchange(
    'nameOfMyQueueToBind', // name of the queue
    'transactionTracking.transaction', // exchange name to bind to
    'your.routing.key' // Optionally, provide a binding key
)param string $exchangeparam string $typeparam bool $passiveparam bool $durableparam bool $auto_deleteparam bool $internalparam bool $nowaitparam ?array $argumentsparam ?int $ticketreturn mixedDeclares an exchange
This is an alias of method exchange_declare of PhpAmqpLib\Channel\AMQPChannel.
<?php
$I->declareExchange(
    'nameOfMyExchange', // exchange name
    'topic' // exchange type
)param string $queueparam bool $passiveparam bool $durableparam bool $exclusiveparam bool $auto_deleteparam bool $nowaitparam ?array $argumentsparam ?int $ticketreturn mixedDeclares queue, creates if needed
This is an alias of method queue_declare of PhpAmqpLib\Channel\AMQPChannel.
<?php
$I->declareQueue(
    'nameOfMyQueue', // exchange name
)param string $queuereturn voidChecks if queue is not empty.
<?php
$I->pushToQueue('queue.emails', 'Hello, davert');
$I->dontSeeQueueIsEmpty('queue.emails');param string $queuereturn ?\PhpAmqpLib\Message\AMQPMessageTakes last message from queue.
<?php
$message = $I->grabMessageFromQueue('queue.emails');return voidPurge all queues defined in config.
<?php
$I->purgeAllQueues();param string $queueNamereturn voidPurge a specific queue defined in config.
<?php
$I->purgeQueue('queue.emails');param string $exchangeparam \PhpAmqpLib\Message\AMQPMessage|string $messageparam ?string $routing_keyreturn voidSends message to exchange by sending exchange name, message and (optionally) a routing key
<?php
$I->pushToExchange('exchange.emails', 'thanks');
$I->pushToExchange('exchange.emails', new AMQPMessage('Thanks!'));
$I->pushToExchange('exchange.emails', new AMQPMessage('Thanks!'), 'severity');param string $queueparam \PhpAmqpLib\Message\AMQPMessage|string $messagereturn voidSends message to queue
<?php
$I->pushToQueue('queue.jobs', 'create user');
$I->pushToQueue('queue.jobs', new AMQPMessage('create'));param string $queuereturn voidAdd a queue to purge list
param string $queueparam string $textreturn voidChecks if message containing text received.
This method drops message from queue This method will wait for message. If none is sent the script will stuck.
<?php
$I->pushToQueue('queue.emails', 'Hello, davert');
$I->seeMessageInQueueContainsText('queue.emails','davert');param string $queueparam int $expectedreturn voidChecks that queue have expected number of message
<?php
$I->pushToQueue('queue.emails', 'Hello, davert');
$I->seeNumberOfMessagesInQueue('queue.emails',1);param string $queuereturn voidChecks that queue is empty
<?php
$I->pushToQueue('queue.emails', 'Hello, davert');
$I->purgeQueue('queue.emails');
$I->seeQueueIsEmpty('queue.emails');