Making Model::resetAssociations public and changing tests that use it

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6909 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mariano.iglesias 2008-05-17 16:23:46 +00:00
parent bc6a8e03b5
commit 05047a90b0
2 changed files with 6 additions and 6 deletions

View file

@ -398,7 +398,7 @@ class Model extends Overloadable {
$return = $db->query($method, $params, $this); $return = $db->query($method, $params, $this);
if (!PHP5) { if (!PHP5) {
$this->__resetAssociations(); $this->resetAssociations();
} }
return $return; return $return;
} }
@ -1763,7 +1763,7 @@ class Model extends Overloadable {
} }
$results = $db->read($this, $query); $results = $db->read($this, $query);
$this->__resetAssociations(); $this->resetAssociations();
$this->findQueryType = null; $this->findQueryType = null;
if ($type === 'all') { if ($type === 'all') {
@ -1897,9 +1897,9 @@ class Model extends Overloadable {
* to the original as set in the model. * to the original as set in the model.
* *
* @return boolean Success * @return boolean Success
* @access private * @access public
*/ */
function __resetAssociations() { function resetAssociations() {
if (!empty($this->__backAssociation)) { if (!empty($this->__backAssociation)) {
foreach ($this->__associations as $type) { foreach ($this->__associations as $type) {
if (isset($this->__backAssociation[$type])) { if (isset($this->__backAssociation[$type])) {
@ -1912,7 +1912,7 @@ class Model extends Overloadable {
foreach ($this->__associations as $type) { foreach ($this->__associations as $type) {
foreach ($this->{$type} as $key => $name) { foreach ($this->{$type} as $key => $name) {
if (!empty($this->{$key}->__backAssociation)) { if (!empty($this->{$key}->__backAssociation)) {
$this->{$key}->__resetAssociations(); $this->{$key}->resetAssociations();
} }
} }
} }

View file

@ -969,7 +969,7 @@ class ModelTest extends CakeTestCase {
array('id' => '2', 'article_id' => '1', 'user_id' => '4', 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31')))); array('id' => '2', 'article_id' => '1', 'user_id' => '4', 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31'))));
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$TestModel->__resetAssociations(); $TestModel->resetAssociations();
$result = $TestModel->hasMany; $result = $TestModel->hasMany;
$this->assertEqual($result, array()); $this->assertEqual($result, array());