Skip to content

Commit

Permalink
Automatic update
Browse files Browse the repository at this point in the history
  • Loading branch information
xosofox committed May 7, 2011
1 parent fd133a9 commit 9330b97
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
11 changes: 11 additions & 0 deletions generator/lib/builder/om/PHP5ObjectBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4619,6 +4619,17 @@ public function clearAllReferences(\$deep = false)
}
$vars[] = $varName;
}
foreach ($this->getTable()->getCrossFks() as $fkList) {
list($refFK, $crossFK) = $fkList;
$varName = $this->getCrossFKVarName($crossFK);
$script .= "
if (\$this->$varName) {
foreach (\$this->$varName as \$o) {
\$o->clearAllReferences(\$deep);
}
}";
$vars[] = $varName;
}

$script .= "
} // if (\$deep)
Expand Down
16 changes: 15 additions & 1 deletion test/testsuite/generator/builder/om/GeneratedObjectRelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public function testMultiFkImplication()

/**
* Test the clearing of related object collection.
* @link http://propel.phpdb.org/trac/ticket/529
* @link http://www.propelorm.org/ticket/529
*/
public function testClearRefFk()
{
Expand All @@ -290,6 +290,20 @@ public function testClearRefFk()
$book->clearReviews();
$this->assertEquals(0, count($book->getReviews()));
}

/**
* Test the clearing of related object collection via a many-to-many association.
* @link http://www.propelorm.org/ticket/1374
*/
public function testClearCrossFk()
{
$book = new Book();
$bookClub = new BookClubList();
$book->addBookClubList($bookClub);
$this->assertEquals(1, count($book->getBookClubLists()));
$book->clear();
$this->assertEquals(0, count($book->getBookClubLists()));
}

/**
* This tests to see whether modified objects are being silently overwritten by calls to fk accessor methods.
Expand Down

0 comments on commit 9330b97

Please sign in to comment.