Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests in each datasource to test the nested transactions.
- Loading branch information
Showing
3 changed files
with
107 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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' | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
ceeram
Contributor
|
||
); | ||
|
||
/** | ||
|
@@ -3579,4 +3579,40 @@ public function testTruncateStatements() { | |
->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)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.address isnt available in my app
this causes to fail 2.2-mysql now on jenkins
can you add it to core
Also the $model = ClassRegistry::init('Address'); Address model isnt present in core