Skip to content
Permalink
Browse files

Increase coverage by covering another failure case.

This path was untested before.
  • Loading branch information...
markstory committed Dec 19, 2015
1 parent 46847ac commit 15638b1a2aa3e8d6ea1fdebac60baef6b63fa20b
Showing with 22 additions and 0 deletions.
  1. +22 −0 tests/TestCase/ORM/Association/BelongsToManyTest.php
@@ -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.
*

0 comments on commit 15638b1

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