Add basic unit tests for Queue class using Dummy driver

This commit is contained in:
Kijin Sung 2024-10-11 23:19:53 +09:00
parent b4e7d4aaad
commit 4b0b485a13
2 changed files with 36 additions and 1 deletions

View file

@ -9,6 +9,11 @@ use Rhymix\Framework\Drivers\QueueInterface;
*/
class Dummy implements QueueInterface
{
/**
* Dummy queue for testing.
*/
protected $_dummy_queue;
/**
* Create a new instance of the current Queue driver, using the given settings.
*
@ -80,6 +85,11 @@ class Dummy implements QueueInterface
*/
public function addTask(string $handler, ?object $args = null, ?object $options = null): int
{
$this->_dummy_queue = (object)[
'handler' => $handler,
'args' => $args,
'options' => $options,
];
return 0;
}
@ -91,6 +101,8 @@ class Dummy implements QueueInterface
*/
public function getTask(int $blocking = 0): ?object
{
return null;
$result = $this->_dummy_queue;
$this->_dummy_queue = null;
return $result;
}
}