mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
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:
parent
3eb9f65e99
commit
943bb53dda
2 changed files with 23 additions and 1 deletions
|
@ -664,7 +664,9 @@ class View extends Object {
|
||||||
@include ($___viewFn);
|
@include ($___viewFn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($loadHelpers === true) {
|
||||||
$this->_triggerHelpers('afterRender');
|
$this->_triggerHelpers('afterRender');
|
||||||
|
}
|
||||||
|
|
||||||
$out = ob_get_clean();
|
$out = ob_get_clean();
|
||||||
$caching = (
|
$caching = (
|
||||||
|
|
|
@ -189,6 +189,9 @@ class TestAfterHelper extends Helper {
|
||||||
$View->output .= 'modified in the afterlife';
|
$View->output .= 'modified in the afterlife';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Mock::generate('Helper', 'CallbackMockHelper');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Short description for class.
|
* Short description for class.
|
||||||
*
|
*
|
||||||
|
@ -453,6 +456,23 @@ class ViewTest extends CakeTestCase {
|
||||||
$this->assertTrue(is_object($result['PluggedHelper']));
|
$this->assertTrue(is_object($result['PluggedHelper']));
|
||||||
$this->assertTrue(is_object($result['PluggedHelper']->OtherHelper));
|
$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
|
* testBeforeLayout method
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue