mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Added tests in each datasource to test the nested transactions.
This commit is contained in:
parent
30258ac817
commit
22cd65b7d8
3 changed files with 107 additions and 1 deletions
|
@ -45,7 +45,7 @@ class MysqlTest extends CakeTestCase {
|
|||
public $fixtures = array(
|
||||
'core.apple', 'core.article', 'core.articles_tag', 'core.attachment', 'core.comment',
|
||||
'core.sample', 'core.tag', 'core.user', 'core.post', 'core.author', 'core.data_test',
|
||||
'core.binary_test'
|
||||
'core.binary_test', 'app.address'
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -3579,4 +3579,40 @@ class MysqlTest extends CakeTestCase {
|
|||
->with("TRUNCATE TABLE `$schema`.`tbl_articles`");
|
||||
$this->Dbo->truncate('articles');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test nested transaction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testNestedTransaction() {
|
||||
$obj = new ReflectionMethod($this->Dbo, '_supportNestedTransaction');
|
||||
$obj->setAccessible(true);
|
||||
$this->skipIf($obj->invoke($this->Dbo) === false, 'The MySQL server do not support nested transaction');
|
||||
|
||||
$this->loadFixtures('Address');
|
||||
$model = ClassRegistry::init('Address');
|
||||
$model->hasOne = $model->hasMany = $model->belongsTo = $model->hasAndBelongsToMany = array();
|
||||
$model->cacheQueries = false;
|
||||
$this->Dbo->cacheMethods = false;
|
||||
|
||||
$this->assertTrue($this->Dbo->begin());
|
||||
$this->assertNotEmpty($model->read(null, 1));
|
||||
|
||||
$this->assertTrue($this->Dbo->begin());
|
||||
$this->assertTrue($model->delete(1));
|
||||
$this->assertEmpty($model->read(null, 1));
|
||||
$this->assertTrue($this->Dbo->rollback());
|
||||
$this->assertNotEmpty($model->read(null, 1));
|
||||
|
||||
$this->assertTrue($this->Dbo->begin());
|
||||
$this->assertTrue($model->delete(1));
|
||||
$this->assertEmpty($model->read(null, 1));
|
||||
$this->assertTrue($this->Dbo->commit());
|
||||
$this->assertEmpty($model->read(null, 1));
|
||||
|
||||
$this->assertTrue($this->Dbo->rollback());
|
||||
$this->assertNotEmpty($model->read(null, 1));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -909,4 +909,39 @@ class PostgresTest extends CakeTestCase {
|
|||
$this->Dbo->truncate('articles');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test nested transaction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testNestedTransaction() {
|
||||
$obj = new ReflectionMethod($this->Dbo, '_supportNestedTransaction');
|
||||
$obj->setAccessible(true);
|
||||
$this->skipIf($obj->invoke($this->Dbo) === false, 'The Postgres server do not support nested transaction');
|
||||
|
||||
$this->loadFixtures('Article');
|
||||
$model = new Article();
|
||||
$model->hasOne = $model->hasMany = $model->belongsTo = $model->hasAndBelongsToMany = array();
|
||||
$model->cacheQueries = false;
|
||||
$this->Dbo->cacheMethods = false;
|
||||
|
||||
$this->assertTrue($this->Dbo->begin());
|
||||
$this->assertNotEmpty($model->read(null, 1));
|
||||
|
||||
$this->assertTrue($this->Dbo->begin());
|
||||
$this->assertTrue($model->delete(1));
|
||||
$this->assertEmpty($model->read(null, 1));
|
||||
$this->assertTrue($this->Dbo->rollback());
|
||||
$this->assertNotEmpty($model->read(null, 1));
|
||||
|
||||
$this->assertTrue($this->Dbo->begin());
|
||||
$this->assertTrue($model->delete(1));
|
||||
$this->assertEmpty($model->read(null, 1));
|
||||
$this->assertTrue($this->Dbo->commit());
|
||||
$this->assertEmpty($model->read(null, 1));
|
||||
|
||||
$this->assertTrue($this->Dbo->rollback());
|
||||
$this->assertNotEmpty($model->read(null, 1));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -383,4 +383,39 @@ class SqliteTest extends CakeTestCase {
|
|||
$this->assertTrue(Validation::uuid($result['Uuid']['id']), 'Not a uuid');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test nested transaction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testNestedTransaction() {
|
||||
$obj = new ReflectionMethod($this->Dbo, '_supportNestedTransaction');
|
||||
$obj->setAccessible(true);
|
||||
$this->skipIf($obj->invoke($this->Dbo) === false, 'The Sqlite version do not support nested transaction');
|
||||
|
||||
$this->loadFixtures('User');
|
||||
$model = new User();
|
||||
$model->hasOne = $model->hasMany = $model->belongsTo = $model->hasAndBelongsToMany = array();
|
||||
$model->cacheQueries = false;
|
||||
$this->Dbo->cacheMethods = false;
|
||||
|
||||
$this->assertTrue($this->Dbo->begin());
|
||||
$this->assertNotEmpty($model->read(null, 1));
|
||||
|
||||
$this->assertTrue($this->Dbo->begin());
|
||||
$this->assertTrue($model->delete(1));
|
||||
$this->assertEmpty($model->read(null, 1));
|
||||
$this->assertTrue($this->Dbo->rollback());
|
||||
$this->assertNotEmpty($model->read(null, 1));
|
||||
|
||||
$this->assertTrue($this->Dbo->begin());
|
||||
$this->assertTrue($model->delete(1));
|
||||
$this->assertEmpty($model->read(null, 1));
|
||||
$this->assertTrue($this->Dbo->commit());
|
||||
$this->assertEmpty($model->read(null, 1));
|
||||
|
||||
$this->assertTrue($this->Dbo->rollback());
|
||||
$this->assertNotEmpty($model->read(null, 1));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue