Skip to content
Permalink
Browse files

Add specific test case for dependent delete with aliased associations

  • Loading branch information...
PGBI committed Apr 16, 2015
1 parent 5070fc6 commit 8e11b330555edf2d9524e7933f3e04fde2105ad1
Showing with 21 additions and 2 deletions.
  1. +21 −2 tests/TestCase/ORM/TableTest.php
@@ -2411,8 +2411,7 @@ public function testDeleteDependent()
public function testDeleteDependentHasMany()
{
$table = TableRegistry::get('authors');
$table->associations()->remove('articles');
$table->hasMany('aliased_articles', [
$table->hasMany('articles', [
'className' => 'articles',
'foreignKey' => 'author_id',
'dependent' => true,
@@ -2467,6 +2466,26 @@ public function testDeleteBelongsToMany()
$this->assertNull($query->all()->first(), 'Should not find any rows.');
}
public function testDeleteDependentAliased()
{
$Authors = TableRegistry::get('authors');
$Authors->associations()->removeAll();
$Articles = TableRegistry::get('articles');
$Articles->associations()->removeAll();
$Authors->hasMany('AliasedArticles', [
'className' => 'articles',
'dependent' => true,
'cascadeCallbacks' => true
]);
$Articles->belongsToMany('Tags');
$author = $Authors->get(1);
$result = $Authors->delete($author);
$this->assertTrue($result);
}
/**
* Test delete callbacks
*

0 comments on commit 8e11b33

Please sign in to comment.
You can’t perform that action at this time.