Permalink
Browse files

Added test for nested methods sequence.

  • Loading branch information...
jrbasso committed Apr 1, 2012
1 parent 2c1cf29 commit 30258ac817e6494f3a75adc56710ec87b7bfa6dc
Showing with 29 additions and 0 deletions.
  1. +29 −0 lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php
@@ -51,6 +51,10 @@ public function setConnection($conn) {
$this->_connection = $conn;
}
+ protected function _supportNestedTransaction() {
+ return true;
+ }
+
}
/**
@@ -841,6 +845,31 @@ public function testTransactionLogging() {
$this->assertEquals($expected, $log['log'][0]);
}
+/**
+ * Test nested transaction calls
+ *
+ * @return void
+ */
+ public function testTransactionNested() {
+ $conn = $this->getMock('MockPDO');
+ $db = new DboTestSource();
+ $db->setConnection($conn);
+
+ $conn->expects($this->at(0))->method('beginTransaction')->will($this->returnValue(true));
+ $conn->expects($this->at(1))->method('exec')->with($this->equalTo('SAVEPOINT LEVEL1'))->will($this->returnValue(true));
+ $conn->expects($this->at(2))->method('exec')->with($this->equalTo('RELEASE SAVEPOINT LEVEL1'))->will($this->returnValue(true));
+ $conn->expects($this->at(3))->method('exec')->with($this->equalTo('SAVEPOINT LEVEL1'))->will($this->returnValue(true));
+ $conn->expects($this->at(4))->method('exec')->with($this->equalTo('ROLLBACK TO SAVEPOINT LEVEL1'))->will($this->returnValue(true));
+ $conn->expects($this->at(5))->method('commit')->will($this->returnValue(true));
+
+ $db->begin();
+ $db->begin();
+ $db->commit();
+ $db->begin();
+ $db->rollback();
+ $db->commit();
+ }
+
/**
* Test build statement with some fields missing
*

0 comments on commit 30258ac

Please sign in to comment.