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