|
|
@@ -488,6 +488,25 @@ class ConnectionTest extends TestCase
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Tests that the destructor of Connection does not crash
|
|
|
+ * when transaction is not closed
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testCloseConnectionWithUncommittedTransaction()
|
|
|
+ {
|
|
|
+ $driver = $this->getMockFormDriver();
|
|
|
+ $connection = $this->getMockBuilder('\Cake\Database\Connection')
|
|
|
+ ->setMethods(['connect'])
|
|
|
+ ->setConstructorArgs([['driver' => $driver]])
|
|
|
+ ->getMock();
|
|
|
+ $connection->begin();
|
|
|
+ $this->assertTrue($connection->inTransaction());
|
|
|
+
|
|
|
+ // a warning log will be generated by __destruct of Connection.
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* Tests that it is possible to use virtualized nested transaction
|
|
|
* with early rollback algorithm
|
|
|
*
|