diff --git a/cake/libs/view/view.php b/cake/libs/view/view.php index 9717afdf1..d0ad82bdf 100644 --- a/cake/libs/view/view.php +++ b/cake/libs/view/view.php @@ -664,7 +664,9 @@ class View extends Object { @include ($___viewFn); } - $this->_triggerHelpers('afterRender'); + if ($loadHelpers === true) { + $this->_triggerHelpers('afterRender'); + } $out = ob_get_clean(); $caching = ( diff --git a/cake/tests/cases/libs/view/view.test.php b/cake/tests/cases/libs/view/view.test.php index 99d9660b6..1a9bf0c70 100644 --- a/cake/tests/cases/libs/view/view.test.php +++ b/cake/tests/cases/libs/view/view.test.php @@ -189,6 +189,9 @@ class TestAfterHelper extends Helper { $View->output .= 'modified in the afterlife'; } } + +Mock::generate('Helper', 'CallbackMockHelper'); + /** * Short description for class. * @@ -453,6 +456,23 @@ class ViewTest extends CakeTestCase { $this->assertTrue(is_object($result['PluggedHelper'])); $this->assertTrue(is_object($result['PluggedHelper']->OtherHelper)); } +/** + * test the correct triggering of helper callbacks + * + * @return void + **/ + function testHelperCallbackTriggering() { + $this->PostsController->helpers = array('Html', 'CallbackMock'); + $View =& new TestView($this->PostsController); + $Critic =& new CallbackMockHelper(); + $loaded = array(); + $View->loaded = $View->loadHelpers($loaded, $this->PostsController->helpers); + $View->loaded['CallbackMock']->expectOnce('beforeRender'); + $View->loaded['CallbackMock']->expectOnce('afterRender'); + $View->loaded['CallbackMock']->expectOnce('beforeLayout'); + $View->loaded['CallbackMock']->expectOnce('afterLayout'); + $View->render('index'); + } /** * testBeforeLayout method *