Skip to content

Commit

Permalink
Updating ObjectCollection::trigger() so it doesn't call __get().
Browse files Browse the repository at this point in the history
Updating HelperCollection test which was passing by coincidence.
  • Loading branch information
markstory committed Aug 11, 2010
1 parent 6201988 commit 337ab19
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
3 changes: 1 addition & 2 deletions cake/libs/object_collection.php
Expand Up @@ -79,8 +79,7 @@ public function trigger($callback, $params = array(), $options = array()) {
$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)))
Expand Down
38 changes: 21 additions & 17 deletions cake/tests/cases/libs/view/helper_collection.test.php
Expand Up @@ -121,15 +121,17 @@ function testUnload() {
* @return void
*/
function testTrigger() {
$this->Helpers->load('Form');
$this->Helpers->load('Html');

$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')
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->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'));
Expand All @@ -141,17 +143,19 @@ function testTrigger() {
* @return void
*/
function testTriggerWithDisabledHelpers() {
$this->Helpers->load('Form');
$this->Helpers->load('Html');

$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')
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->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'));
}
Expand Down

0 comments on commit 337ab19

Please sign in to comment.