Skip to content

Commit

Permalink
Adding tests for element callbacks.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Nov 7, 2010
1 parent 32587c1 commit 2e140a9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cake/libs/view/view.php
Expand Up @@ -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));
}
Expand Down
15 changes: 15 additions & 0 deletions cake/tests/cases/libs/view/view.test.php
Expand Up @@ -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
*
Expand Down

0 comments on commit 2e140a9

Please sign in to comment.