From e238947c9a8faa37558f8a8cf9f4a25abd698f29 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 19 Jun 2023 15:38:24 +0900 Subject: [PATCH] Add unit tests for DB->connect() and disconnect() --- tests/unit/framework/DBTest.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/unit/framework/DBTest.php b/tests/unit/framework/DBTest.php index 688d6dd45..ed9eb8ef3 100644 --- a/tests/unit/framework/DBTest.php +++ b/tests/unit/framework/DBTest.php @@ -14,10 +14,26 @@ class DBTest extends \Codeception\TestCase\Test $this->assertTrue($oDB instanceof Rhymix\Framework\DB); $this->assertEquals($oDB, \DB::getInstance()); $this->assertTrue(\DB::getInstance() instanceof Rhymix\Framework\DB); - $this->assertTrue($oDB->isConnected()); $this->assertTrue($oDB->getHandle() instanceof Rhymix\Framework\Helpers\DBHelper); } + public function testConnectDisconnect() + { + $oDB = Rhymix\Framework\DB::getInstance('master'); + $this->assertTrue(is_object($oDB->getHandle())); + + $oDB->disconnect(); + $this->assertTrue(is_null($oDB->getHandle())); + $this->assertFalse($oDB->isConnected()); + + $oDB->connect(config('db.master')); + $this->assertTrue(is_object($oDB->getHandle())); + $this->assertTrue($oDB->isConnected()); + + $oDB = Rhymix\Framework\DB::getInstance('master'); + $this->assertTrue(is_object($oDB->getHandle())); + } + public function testCompatProperties() { $oDB = Rhymix\Framework\DB::getInstance();