From 746afdacb39cc619a54a3e70d020a1ae9dad647c Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Thu, 12 Dec 2024 21:37:53 +0900 Subject: [PATCH] Fix queue config interfering with unit tests --- tests/unit/framework/MailTest.php | 13 +++++++++++++ tests/unit/framework/QueueTest.php | 22 ++++++++++++++-------- tests/unit/framework/SMSTest.php | 13 +++++++++++++ 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/tests/unit/framework/MailTest.php b/tests/unit/framework/MailTest.php index dc529cda6..4764620fb 100644 --- a/tests/unit/framework/MailTest.php +++ b/tests/unit/framework/MailTest.php @@ -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(); diff --git a/tests/unit/framework/QueueTest.php b/tests/unit/framework/QueueTest.php index 05ba3efc0..412c06e71 100644 --- a/tests/unit/framework/QueueTest.php +++ b/tests/unit/framework/QueueTest.php @@ -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']; diff --git a/tests/unit/framework/SMSTest.php b/tests/unit/framework/SMSTest.php index df947740a..a60610f63 100644 --- a/tests/unit/framework/SMSTest.php +++ b/tests/unit/framework/SMSTest.php @@ -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();