Skip to content

Commit

Permalink
Increase coverage by covering another failure case.
Browse files Browse the repository at this point in the history
This path was untested before.
  • Loading branch information
markstory committed Dec 19, 2015
1 parent 46847ac commit 15638b1
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/TestCase/ORM/Association/BelongsToManyTest.php
Expand Up @@ -671,6 +671,28 @@ public function emptyProvider()
];
}

/**
* Test that saveAssociated() fails on non-empty, non-iterable value
*
* @expectedException InvalidArgumentException
* @expectedExceptionMessage Could not save tags, it cannot be traversed
* @return void
*/
public function testSaveAssociatedNotEmptyNotIterable()
{
$articles = TableRegistry::get('Articles');
$assoc = $articles->belongsToMany('Tags', [
'saveStrategy' => BelongsToMany::SAVE_APPEND,
'joinTable' => 'articles_tags',
]);
$entity = new Entity([
'id' => 1,
'tags' => 'oh noes',
], ['markNew' => true]);

$assoc->saveAssociated($entity);
}

/**
* Test that saving an empty set on create works.
*
Expand Down

0 comments on commit 15638b1

Please sign in to comment.