Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Correcting callback firing of helpers in view. Tests added fixes #5906

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7948 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information...
commit 943bb53dda24f176b12ff2c729717d6794424e13 1 parent 3eb9f65
@markstory markstory authored
View
4 cake/libs/view/view.php
@@ -664,7 +664,9 @@ function _render($___viewFn, $___dataForView, $loadHelpers = true, $cached = fal
@include ($___viewFn);
}
- $this->_triggerHelpers('afterRender');
+ if ($loadHelpers === true) {
+ $this->_triggerHelpers('afterRender');
+ }
$out = ob_get_clean();
$caching = (
View
20 cake/tests/cases/libs/view/view.test.php
@@ -189,6 +189,9 @@ function afterLayout() {
$View->output .= 'modified in the afterlife';
}
}
+
+Mock::generate('Helper', 'CallbackMockHelper');
+
/**
* Short description for class.
*
@@ -454,6 +457,23 @@ function testLoadHelpers() {
$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
*
* @access public
Please sign in to comment.
Something went wrong with that request. Please try again.