Skip to content
Permalink
Browse files

Don't try to recover from inconsistent data.

If an association property contains a mix of arrays + entities stop as
soon as a non-entity value is found. This makes saving consistent with
validation.
  • Loading branch information...
markstory committed Dec 24, 2013
1 parent 353bd1a commit d8a6a4ca401cb224cc648d1a2334a884c6cc2e34
@@ -395,7 +395,7 @@ protected function _saveTarget(Entity $parentEntity, $entities, $options) {
foreach ($entities as $k => $entity) {
if (!($entity instanceof Entity)) {
continue;
break;
}
if (!empty($options['atomic'])) {
@@ -140,7 +140,7 @@ public function save(Entity $entity, $options = []) {
foreach ($targetEntities as $k => $targetEntity) {
if (!($targetEntity instanceof Entity)) {
continue;
break;
}
if (!empty($options['atomic'])) {
@@ -1148,9 +1148,8 @@ public function testSaveOnlyEntities() {
]
]);
$mock->expects($this->once())
->method('save')
->with($entity->tags[1]);
$mock->expects($this->never())
->method('save');
$association = new BelongsToMany('Tags', $config);
$association->save($entity);
@@ -552,9 +552,8 @@ public function testSaveOnlyEntities() {
]
]);
$mock->expects($this->once())
->method('save')
->with($entity->articles[1]);
$mock->expects($this->never())
->method('save');
$association = new HasMany('Articles', $config);
$association->save($entity);
@@ -2241,7 +2241,7 @@ public function testSaveOnlySaveAssociatedEntities() {
$this->assertSame($entity, $table->save($entity));
$this->assertFalse($entity->isNew());
$this->assertEmpty($entity->article);
$this->assertInternalType('array', $entity->article);
}

0 comments on commit d8a6a4c

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