Skip to content

Commit

Permalink
Add specific test case for dependent delete with aliased associations
Browse files Browse the repository at this point in the history
  • Loading branch information
PGBI committed Apr 16, 2015
1 parent 5070fc6 commit 8e11b33
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions tests/TestCase/ORM/TableTest.php
Expand Up @@ -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,
Expand Down Expand Up @@ -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
*
Expand Down

0 comments on commit 8e11b33

Please sign in to comment.