diff --git a/cake/libs/object_collection.php b/cake/libs/object_collection.php index 97b121f22..e4983b8cd 100644 --- a/cake/libs/object_collection.php +++ b/cake/libs/object_collection.php @@ -79,8 +79,7 @@ abstract class ObjectCollection { $options ); foreach ($this->_enabled as $name) { - $result = call_user_func_array(array($this->{$name}, $callback), $params); - + $result = call_user_func_array(array(&$this->_loaded[$name], $callback), $params); if ( $options['break'] && ($result === $options['breakOn'] || (is_array($options['breakOn']) && in_array($result, $options['breakOn'], true))) diff --git a/cake/tests/cases/libs/view/helper_collection.test.php b/cake/tests/cases/libs/view/helper_collection.test.php index e771702f3..67307d940 100644 --- a/cake/tests/cases/libs/view/helper_collection.test.php +++ b/cake/tests/cases/libs/view/helper_collection.test.php @@ -121,15 +121,17 @@ class HelperCollectionTest extends CakeTestCase { * @return void */ function testTrigger() { - $this->Helpers->load('Form'); - $this->Helpers->load('Html'); + if (!class_exists('TriggerMockHtmlHelper')) { + $this->getMock('HtmlHelper', array(), array($this->View), 'TriggerMockHtmlHelper'); + $this->getMock('FormHelper', array(), array($this->View), 'TriggerMockFormHelper'); + } + + $this->Helpers->load('TriggerMockHtml'); + $this->Helpers->load('TriggerMockForm'); - $this->Helpers->Html = $this->getMock('HtmlHelper', array(), array($this->View)); - $this->Helpers->Form = $this->getMock('FormHelper', array(), array($this->View)); - - $this->Helpers->Html->expects($this->once())->method('beforeRender') + $this->Helpers->TriggerMockForm->expects($this->once())->method('beforeRender') ->with('one', 'two'); - $this->Helpers->Form->expects($this->once())->method('beforeRender') + $this->Helpers->TriggerMockForm->expects($this->once())->method('beforeRender') ->with('one', 'two'); $this->Helpers->trigger('beforeRender', array('one', 'two')); @@ -141,17 +143,19 @@ class HelperCollectionTest extends CakeTestCase { * @return void */ function testTriggerWithDisabledHelpers() { - $this->Helpers->load('Form'); - $this->Helpers->load('Html'); + if (!class_exists('TriggerMockHtmlHelper')) { + $this->getMock('HtmlHelper', array(), array($this->View), 'TriggerMockHtmlHelper'); + $this->getMock('FormHelper', array(), array($this->View), 'TriggerMockFormHelper'); + } - $this->Helpers->Html = $this->getMock('HtmlHelper', array(), array($this->View)); - $this->Helpers->Form = $this->getMock('FormHelper', array(), array($this->View)); - - $this->Helpers->Html->expects($this->once())->method('beforeRender') + $this->Helpers->load('TriggerMockHtml'); + $this->Helpers->load('TriggerMockForm'); + + $this->Helpers->TriggerMockHtml->expects($this->once())->method('beforeRender') ->with('one', 'two'); - $this->Helpers->Form->expects($this->never())->method('beforeRender'); + $this->Helpers->TriggerMockForm->expects($this->never())->method('beforeRender'); - $this->Helpers->disable('Form'); + $this->Helpers->disable('TriggerMockForm'); $this->Helpers->trigger('beforeRender', array('one', 'two')); }