From 2e140a9fd3c48c82bfeb377c98c438a83a28bdfc Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 4 Nov 2010 23:45:07 -0400 Subject: [PATCH] Adding tests for element callbacks. --- cake/libs/view/view.php | 2 +- cake/tests/cases/libs/view/view.test.php | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/cake/libs/view/view.php b/cake/libs/view/view.php index 1f272dcb1..33df1c0df 100644 --- a/cake/libs/view/view.php +++ b/cake/libs/view/view.php @@ -360,7 +360,7 @@ class View extends Object { 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 5c303cf74..7c723a366 100644 --- a/cake/tests/cases/libs/view/view.test.php +++ b/cake/tests/cases/libs/view/view.test.php @@ -475,6 +475,21 @@ class ViewTest extends CakeTestCase { $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 *