From d69655be023dfe848af3fe8b94a0bc71d22ca7d1 Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Thu, 3 Dec 2020 15:50:32 -0500 Subject: [PATCH] Attempt to fix MySQL transaction test --- tests/ConnectionManagerTest.php | 3 --- tests/Drivers/MySQL/MySQLDriverTest.php | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/tests/ConnectionManagerTest.php b/tests/ConnectionManagerTest.php index 35b450a..04f1b08 100644 --- a/tests/ConnectionManagerTest.php +++ b/tests/ConnectionManagerTest.php @@ -91,8 +91,6 @@ class ConnectionManagerTest extends TestCase { }; $conn = self::$instance->connect($params); - $this->assertInstanceOf(QueryBuilderInterface::class, $conn); - // Check that the connection just made is returned from the get_connection method $this->assertEqual($conn, self::$instance->getConnection()); @@ -111,7 +109,6 @@ class ConnectionManagerTest extends TestCase { ]; $conn = self::$instance->connect($params); - $this->assertInstanceOf(QueryBuilderInterface::class, $conn); $this->assertEqual($conn, self::$instance->getConnection('conn_manager')); } diff --git a/tests/Drivers/MySQL/MySQLDriverTest.php b/tests/Drivers/MySQL/MySQLDriverTest.php index 14edd87..4c8ed90 100644 --- a/tests/Drivers/MySQL/MySQLDriverTest.php +++ b/tests/Drivers/MySQL/MySQLDriverTest.php @@ -154,6 +154,13 @@ SQL; public function testCommitTransaction(): void { + // Make sure we aren't already in a transaction + if (self::$db->inTransaction()) + { + self::$db->commit(); + } + + $this->assertFalse(self::$db->inTransaction()); $this->assertTrue(self::$db->beginTransaction()); $sql = 'INSERT INTO `create_test` (`id`, `key`, `val`) VALUES (10, 12, 14)'; @@ -165,6 +172,13 @@ SQL; public function testRollbackTransaction(): void { + // Make sure we aren't already in a transaction + if (self::$db->inTransaction()) + { + self::$db->commit(); + } + + $this->assertFalse(self::$db->inTransaction()); $this->assertTrue(self::$db->beginTransaction()); $sql = 'INSERT INTO `create_test` (`id`, `key`, `val`) VALUES (182, 96, 43)';