diff --git a/cake/libs/view/view.php b/cake/libs/view/view.php index 1f272dcb173..33df1c0dfaa 100644 --- a/cake/libs/view/view.php +++ b/cake/libs/view/view.php @@ -360,7 +360,7 @@ public function element($name, $params = array(), $callbacks = false) { if ($callbacks) { $this->Helpers->trigger('beforeRender', array($file)); } - $element = $this->_render($file, array_merge($this->viewVars, $params), $loadHelpers); + $element = $this->_render($file, array_merge($this->viewVars, $params)); if ($callbacks) { $this->Helpers->trigger('afterRender', array($file, $element)); } diff --git a/cake/tests/cases/libs/view/view.test.php b/cake/tests/cases/libs/view/view.test.php index 5c303cf747f..7c723a366c1 100644 --- a/cake/tests/cases/libs/view/view.test.php +++ b/cake/tests/cases/libs/view/view.test.php @@ -475,6 +475,21 @@ function testElement() { $this->assertPattern('/non_existant_element/', $result); } +/** + * test that elements can have callbacks + * + */ + function testElementCallbacks() { + $this->getMock('HtmlHelper', array(), array($this->View), 'ElementCallbackMockHtmlHelper'); + $this->View->helpers = array('ElementCallbackMockHtml'); + $this->View->loadHelpers(); + + $this->View->ElementCallbackMockHtml->expects($this->at(0))->method('beforeRender'); + $this->View->ElementCallbackMockHtml->expects($this->at(1))->method('afterRender'); + + $this->View->element('test_element', array(), true); + $this->mockObjects[] = $this->View->ElementCallbackMockHtml; + } /** * testElementCacheHelperNoCache method *