Browse Source

Assuming that updateAll is always OK if no exceptions occurred in _unlink. Removing unnecessary test.

Luan Hospodarsky 10 years ago
parent
commit
1379da0a3d
2 changed files with 2 additions and 89 deletions
  1. 2 1
      src/ORM/Association/HasMany.php
  2. 0 88
      tests/TestCase/ORM/TableTest.php

+ 2 - 1
src/ORM/Association/HasMany.php

@@ -431,7 +431,8 @@ class HasMany extends Association
             }
         } else {
             $updateFields = array_fill_keys($foreignKey, null);
-            return $target->updateAll($updateFields, $conditions);
+            $target->updateAll($updateFields, $conditions);
+            return true;
 
         }
     }

+ 0 - 88
tests/TestCase/ORM/TableTest.php

@@ -4126,94 +4126,6 @@ class TableTest extends TestCase
         $this->assertFalse($author->dirty('articles'));
     }
 
-    /**
-     * Integration test for replacing entities with HasMany and failing transaction. False should be returned when
-     * unlinking fails while replacing
-     *
-     * @return void
-     */
-    public function testReplaceHasManyOnError()
-    {
-        $articles = $this->getMock(
-            'Cake\ORM\Table',
-            ['updateAll'],
-            [[
-                'connection' => $this->connection,
-                'alias' => 'Articles',
-                'table' => 'articles',
-            ]]
-        );
-
-        $articles->method('updateAll')->willReturn(false);
-
-        $associations = new AssociationCollection();
-
-        $hasManyArticles = $this->getMock(
-            'Cake\ORM\Association\HasMany',
-            ['target'],
-            [
-                'articles',
-                [
-                    'target' => $articles,
-                    'foreignKey' => 'author_id',
-                ]
-            ]
-        );
-        $hasManyArticles->method('target')->willReturn($articles);
-
-        $associations->add('articles', $hasManyArticles);
-
-        $authors = new Table([
-            'connection' => $this->connection,
-            'alias' => 'Authors',
-            'table' => 'authors',
-            'associations' => $associations
-        ]);
-        $authors->Articles->source($authors);
-
-        $author = $authors->newEntity(['name' => 'mylux']);
-        $author = $authors->save($author);
-
-        $newArticles = $articles->newEntities(
-            [
-                [
-                    'title' => 'New bakery next corner',
-                    'body' => 'They sell tastefull cakes'
-                ],
-                [
-                    'title' => 'Spicy cake recipe',
-                    'body' => 'chocolate and peppers'
-                ]
-            ]
-        );
-
-        $sizeArticles = count($newArticles);
-
-        $this->assertTrue($authors->Articles->link($author, $newArticles));
-        $this->assertEquals($authors->Articles->findAllByAuthorId($author->id)->count(), $sizeArticles);
-        $this->assertEquals(count($author->articles), $sizeArticles);
-
-        $newArticles = array_merge(
-            $author->articles,
-            $articles->newEntities(
-                [
-                    [
-                        'title' => 'Cheese cake recipe',
-                        'body' => 'The secrets of mixing salt and sugar'
-                    ],
-                    [
-                        'title' => 'Not another piece of cake',
-                        'body' => 'This is the best'
-                    ]
-                ]
-            )
-        );
-        unset($newArticles[0]);
-
-        $this->assertFalse($authors->Articles->replace($author, $newArticles));
-        $this->assertCount($sizeArticles, $authors->Articles->findAllByAuthorId($author->id));
-    }
-
 
     /**
      * Integration test for replacing entities which depend on their source entity with HasMany and failing transaction. False should be returned when