Check if the server support nested transactions
public nestedTransactionSupported ( ) : boolean | ||
return | boolean |
/** * Test nested transaction * * @return void */ public function testNestedTransaction() { $nested = $this->Dbo->useNestedTransactions; $this->Dbo->useNestedTransactions = true; if ($this->Dbo->nestedTransactionSupported() === false) { $this->Dbo->useNestedTransactions = $nested; $this->skipIf(true, 'The MySQL server do not support nested transaction'); } $this->loadFixtures('Inno'); $model = ClassRegistry::init('Inno'); $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)); $this->Dbo->useNestedTransactions = $nested; }
/** * Test nested transaction * * @return void */ public function testNestedTransaction() { $this->skipIf($this->Dbo->nestedTransactionSupported() === 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)); }
/** * Test nested transaction * * @return void */ public function testNestedTransaction() { $this->Dbo->useNestedTransactions = TRUE; $this->skipIf($this->Dbo->nestedTransactionSupported() === 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)); }