Fix queue config interfering with unit tests

This commit is contained in:
Kijin Sung 2024-12-12 21:37:53 +09:00
parent eebd9a0005
commit 746afdacb3
3 changed files with 40 additions and 8 deletions

View file

@ -2,6 +2,19 @@
class MailTest extends \Codeception\Test\Unit
{
protected $_prev_queue_config;
public function _before()
{
$this->_prev_queue_config = config('queue');
config('queue.enabled', false);
}
public function _after()
{
config('queue', $this->_prev_queue_config);
}
public function testGetSetDefaultDriver()
{
$driver = Rhymix\Framework\Mail::getDefaultDriver();

View file

@ -2,10 +2,22 @@
class QueueTest extends \Codeception\Test\Unit
{
protected $_prev_queue_config;
public function _before()
{
$this->_prev_queue_config = config('queue');
config('queue.enabled', true);
config('queue.driver', 'dummy');
}
public function _after()
{
config('queue', $this->_prev_queue_config);
}
public function testDummyQueue()
{
config('queue.driver', 'dummy');
$handler = 'myfunc';
$args = (object)['foo' => 'bar'];
$options = (object)['key' => 'val'];
@ -23,9 +35,6 @@ class QueueTest extends \Codeception\Test\Unit
public function testScheduledTaskAt()
{
config('queue.enabled', true);
config('queue.driver', 'dummy');
$timestamp = time() + 43200;
$handler = 'MyClass::myFunc';
$args = (object)['foo' => 'bar'];
@ -48,9 +57,6 @@ class QueueTest extends \Codeception\Test\Unit
public function testScheduledTaskAtInterval()
{
config('queue.enabled', true);
config('queue.driver', 'db');
$interval = '30 9 1-15 */2 *';
$handler = 'MyClass::getInstance()->myMethod';
$args = (object)['foo' => 'bar'];

View file

@ -2,6 +2,19 @@
class SMSTest extends \Codeception\Test\Unit
{
protected $_prev_queue_config;
public function _before()
{
$this->_prev_queue_config = config('queue');
config('queue.enabled', false);
}
public function _after()
{
config('queue', $this->_prev_queue_config);
}
public function testGetSetDefaultDriver()
{
$driver = Rhymix\Framework\SMS::getDefaultDriver();