Updating ObjectCollection::trigger() so it doesn't call __get().

Updating HelperCollection test which was passing by coincidence.
This commit is contained in:
mark_story 2010-07-04 14:00:05 -04:00
parent 62019888ba
commit 337ab19145
2 changed files with 20 additions and 17 deletions

View file

@ -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)))

View file

@ -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->Html = $this->getMock('HtmlHelper', array(), array($this->View));
$this->Helpers->Form = $this->getMock('FormHelper', array(), array($this->View));
$this->Helpers->load('TriggerMockHtml');
$this->Helpers->load('TriggerMockForm');
$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->load('TriggerMockHtml');
$this->Helpers->load('TriggerMockForm');
$this->Helpers->Html->expects($this->once())->method('beforeRender')
$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'));
}