Attempt to fix MySQL transaction test

This commit is contained in:
Timothy Warren 2020-12-03 15:50:32 -05:00
parent 8678913cd0
commit d69655be02
2 changed files with 14 additions and 3 deletions

View File

@ -91,8 +91,6 @@ class ConnectionManagerTest extends TestCase {
}; };
$conn = self::$instance->connect($params); $conn = self::$instance->connect($params);
$this->assertInstanceOf(QueryBuilderInterface::class, $conn);
// Check that the connection just made is returned from the get_connection method // Check that the connection just made is returned from the get_connection method
$this->assertEqual($conn, self::$instance->getConnection()); $this->assertEqual($conn, self::$instance->getConnection());
@ -111,7 +109,6 @@ class ConnectionManagerTest extends TestCase {
]; ];
$conn = self::$instance->connect($params); $conn = self::$instance->connect($params);
$this->assertInstanceOf(QueryBuilderInterface::class, $conn);
$this->assertEqual($conn, self::$instance->getConnection('conn_manager')); $this->assertEqual($conn, self::$instance->getConnection('conn_manager'));
} }

View File

@ -154,6 +154,13 @@ SQL;
public function testCommitTransaction(): void 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()); $this->assertTrue(self::$db->beginTransaction());
$sql = 'INSERT INTO `create_test` (`id`, `key`, `val`) VALUES (10, 12, 14)'; $sql = 'INSERT INTO `create_test` (`id`, `key`, `val`) VALUES (10, 12, 14)';
@ -165,6 +172,13 @@ SQL;
public function testRollbackTransaction(): void 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()); $this->assertTrue(self::$db->beginTransaction());
$sql = 'INSERT INTO `create_test` (`id`, `key`, `val`) VALUES (182, 96, 43)'; $sql = 'INSERT INTO `create_test` (`id`, `key`, `val`) VALUES (182, 96, 43)';