BeanstalkdTest.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. use Codeception\Util\Stub;
  3. use Pheanstalk\Exception\ConnectionException;
  4. class BeanstalkdTest extends \PHPUnit\Framework\TestCase
  5. {
  6. protected $config = array(
  7. 'type' => 'beanstalkq',
  8. 'host' => 'localhost'
  9. );
  10. /**
  11. * @var \Codeception\Module\Queue
  12. */
  13. protected $module = null;
  14. public function setUp()
  15. {
  16. $this->module = new \Codeception\Module\Queue(make_container());
  17. $this->module->_setConfig($this->config);
  18. $this->module->_before(Stub::makeEmpty('\Codeception\TestInterface'));
  19. try {
  20. $this->module->clearQueue('default');
  21. } catch (ConnectionException $e) {
  22. $this->markTestSkipped("Beanstalk is not running");
  23. }
  24. }
  25. /** @test */
  26. public function flow()
  27. {
  28. $this->module->addMessageToQueue('hello world - ' . date('d-m-y'), 'default');
  29. $this->module->clearQueue('default');
  30. $this->module->seeQueueExists('default');
  31. $this->module->dontSeeQueueExists('fake_queue');
  32. $this->module->seeEmptyQueue('default');
  33. $this->module->addMessageToQueue('hello world - ' . date('d-m-y'), 'default');
  34. $this->module->dontSeeEmptyQueue('default');
  35. $this->module->seeQueueHasTotalCount('default', 2);
  36. $this->module->seeQueueHasCurrentCount('default', 1);
  37. $this->module->dontSeeQueueHasCurrentCount('default', 9999);
  38. $this->module->grabQueues();
  39. }
  40. }