Skip to content
Permalink
Browse files

Adding tests for Component::triggerCallback(). Deprecating other Comp…

…onent methods, as they are just wrappers for triggerCallback().
  • Loading branch information...
markstory committed Feb 28, 2010
1 parent 70c4c05 commit 37cf55470f6abbb9b88847ac6e03bcef1009c801
Showing with 23 additions and 0 deletions.
  1. +3 −0 cake/libs/controller/component.php
  2. +20 −0 cake/tests/cases/libs/controller/component.test.php
@@ -107,6 +107,7 @@ function initialize(&$controller) {
* @return void
* @access public
* @link http://book.cakephp.org/view/65/MVC-Class-Access-Within-Components
* @deprecated See Component::triggerCallback()
*/
function startup(&$controller) {
$this->triggerCallback('startup', $controller);
@@ -119,6 +120,7 @@ function startup(&$controller) {
* @param object $controller Controller with components to beforeRender
* @return void
* @access public
* @deprecated See Component::triggerCallback()
*/
function beforeRender(&$controller) {
$this->triggerCallback('beforeRender', $controller);
@@ -154,6 +156,7 @@ function beforeRedirect(&$controller, $url, $status = null, $exit = true) {
* @param object $controller Controller with components to shutdown
* @return void
* @access public
* @deprecated See Component::triggerCallback()
*/
function shutdown(&$controller) {
$this->triggerCallback('shutdown', $controller);
@@ -290,6 +290,8 @@ class SomethingWithEmailComponent extends Object {
var $components = array('Email');
}
Mock::generate('Object', 'ComponentMockComponent', array('startup', 'beforeFilter', 'beforeRender', 'other'));
/**
* ComponentTest class
*
@@ -416,6 +418,24 @@ function testComponentStartup() {
$this->assertFalse(isset($Controller->bar));
}
/**
* test that triggerCallbacks fires methods on all the components, and can trigger any method.
*
* @return void
*/
function testTriggerCallback() {
$Controller =& new ComponentTestController();
$Controller->components = array('ComponentMock');
$Controller->constructClasses();
$Controller->ComponentMock->expectOnce('beforeRender');
$Controller->Component->triggerCallback('beforeRender', $Controller);
$Controller->ComponentMock->expectNever('beforeFilter');
$Controller->ComponentMock->enabled = false;
$Controller->Component->triggerCallback('beforeFilter', $Controller);
}
/**
* test a component being used more than once.
*

0 comments on commit 37cf554

Please sign in to comment.
You can’t perform that action at this time.