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
This commit is contained in:
mark_story 2008-12-21 22:14:48 +00:00
parent 3eb9f65e99
commit 943bb53dda
2 changed files with 23 additions and 1 deletions

View file

@ -664,7 +664,9 @@ class View extends Object {
@include ($___viewFn);
}
if ($loadHelpers === true) {
$this->_triggerHelpers('afterRender');
}
$out = ob_get_clean();
$caching = (

View file

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