mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Added test to check when driver do not support nested support.
This commit is contained in:
parent
79f7ca7d33
commit
b0a3a1a5aa
1 changed files with 27 additions and 1 deletions
|
@ -35,6 +35,8 @@ class MockDataSource extends DataSource {
|
|||
|
||||
class DboTestSource extends DboSource {
|
||||
|
||||
public static $nested = true;
|
||||
|
||||
public function connect($config = array()) {
|
||||
$this->connected = true;
|
||||
}
|
||||
|
@ -52,7 +54,7 @@ class DboTestSource extends DboSource {
|
|||
}
|
||||
|
||||
public function supportNestedTransaction() {
|
||||
return true;
|
||||
return self::$nested;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -854,6 +856,7 @@ class DboSourceTest extends CakeTestCase {
|
|||
$conn = $this->getMock('MockPDO');
|
||||
$db = new DboTestSource();
|
||||
$db->setConnection($conn);
|
||||
DboTestSource::$nested = true;
|
||||
|
||||
$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));
|
||||
|
@ -870,6 +873,29 @@ class DboSourceTest extends CakeTestCase {
|
|||
$db->commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test nested transaction calls without support
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testTransactionNestedWithoutSupport() {
|
||||
$conn = $this->getMock('MockPDO');
|
||||
$db = new DboTestSource();
|
||||
$db->setConnection($conn);
|
||||
DboTestSource::$nested = false;
|
||||
|
||||
$conn->expects($this->once())->method('beginTransaction')->will($this->returnValue(true));
|
||||
$conn->expects($this->never())->method('exec');
|
||||
$conn->expects($this->once())->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
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue