Skip to content

Commit

Permalink
Added test for nested methods sequence.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrbasso committed Apr 14, 2012
1 parent 2c1cf29 commit 30258ac
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php
Expand Up @@ -51,6 +51,10 @@ public function setConnection($conn) {
$this->_connection = $conn;
}

protected function _supportNestedTransaction() {
return true;
}

}

/**
Expand Down Expand Up @@ -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
*
Expand Down

0 comments on commit 30258ac

Please sign in to comment.