Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. <?php
  2.  
  3. use OldSound\RabbitMqBundle\RabbitMq\Consumer;
  4. use PhpAmqpLib\Message\AMQPMessage;
  5.  
  6. class AsyncEventsTest extends \AppBundle\Tests\IntegrationTest\AbstractIntegrationTest
  7. {
  8. use RabbitConsumerTest;
  9.  
  10. protected function setUp()
  11. {
  12. parent::setUp();
  13.  
  14. $this->mqRoutingKey = 'project.created';
  15. $this->mqExchangeOptions = ['name' => 'app-events', 'type' => 'direct'];
  16. $this->mqQueueOptions = ['name' => 'app-project-create'];
  17. }
  18.  
  19.  
  20. public function testItProducesAndConsumes()
  21. {
  22. $this->bootKernel();
  23.  
  24. $message = uniqid('some_body', true);
  25.  
  26. $this->getProducer()->publish($message, 'project.created');
  27.  
  28. static::assertSame($message, $this->consumeMessage()->getBody());
  29. }
  30.  
  31. protected function getProducer()
  32. {
  33. return static::$kernel->getContainer()->get('old_sound_rabbit_mq.app_events_producer');
  34. }
  35.  
  36. /**
  37. * @return object|\PhpAmqpLib\Connection\AMQPConnection
  38. */
  39. private function getConnection()
  40. {
  41. return static::$kernel->getContainer()->get('old_sound_rabbit_mq.connection.default');
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement