AMQPTest.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. use Codeception\Util\Stub as Stub;
  3. class AMQPTest extends \PHPUnit_Framework_TestCase
  4. {
  5. protected $config = array(
  6. 'host' => 'localhost',
  7. 'username' => 'guest',
  8. 'password' => 'guest',
  9. 'port' => '5672',
  10. 'vhost' => '/',
  11. 'cleanup' => false,
  12. 'queues' => array('queue1')
  13. );
  14. /**
  15. * @var \Codeception\Module\AMQP
  16. */
  17. protected $module = null;
  18. public function setUp()
  19. {
  20. $this->module = new \Codeception\Module\AMQP(make_container());
  21. $this->module->_setConfig($this->config);
  22. $res = @stream_socket_client('tcp://localhost:5672');
  23. if ($res === false) {
  24. $this->markTestSkipped('AMQP is not running');
  25. }
  26. $this->module->_initialize();
  27. $connection = $this->module->connection;
  28. $connection->channel()->queue_declare('queue1');
  29. }
  30. public function testQueueUsage()
  31. {
  32. $this->module->pushToQueue('queue1', 'hello');
  33. $this->module->seeMessageInQueueContainsText('queue1', 'hello');
  34. }
  35. }