Skip to content
Permalink
Browse files

Adding tests for startupProcess and shutDownProcess in controller

Fixing variable reference
  • Loading branch information...
lorenzo committed Feb 28, 2010
1 parent 8dfadaf commit d5fa897681667d70e03bc25f2d318c6f85e071fa
@@ -542,7 +542,7 @@ function startupProcess() {
* @access public
*/
function shutdownProcess() {
$this->Component->triggerCallback('shutdown', $controller);
$this->Component->triggerCallback('shutdown', $this);
$this->afterFilter();
}
@@ -333,8 +333,6 @@ function testBakeActionsUsingSessions() {
$this->assertTrue(strpos($result, 'if ($this->Article->delete($id))') !== false);
$this->assertTrue(strpos($result, "\$this->Session->setFlash(sprintf(__('%s deleted', true), 'Article'));") !== false);
debug($result, true);
$result = $this->Task->bakeActions('Articles', 'admin_', true);
$this->assertTrue(strpos($result, 'function admin_index() {') !== false);
@@ -366,6 +366,31 @@ class TestComponent extends Object {
*/
function beforeRedirect() {
}
/**
* initialize method
*
* @access public
* @return void
*/
function initialize(&$controller) {
}
/**
* startup method
*
* @access public
* @return void
*/
function startup(&$controller) {
}
/**
* shutdown method
*
* @access public
* @return void
*/
function shutdown(&$controller) {
}
}
/**
@@ -382,7 +407,6 @@ class AnotherTestController extends AppController {
* @access public
*/
var $name = 'AnotherTest';
/**
* uses property
*
@@ -1307,5 +1331,43 @@ function testControllerHttpCodes() {
$expected = array(404 => 'Sorry Bro');
$this->assertEqual($result, $expected);
}
/**
* Tests that the startup process calls the correct functions
*
* @access public
* @return void
*/
function testStartupProcess() {
Mock::generatePartial('AnotherTestController','MockedController', array('beforeFilter'));
Mock::generate('TestComponent', 'MockTestComponent', array('startup', 'initialize'));
$MockedController =& new MockedController();
$MockedController->components = array('MockTest');
$MockedController->Component =& new Component();
$MockedController->Component->init($MockedController);
$MockedController->startupProcess();
$MockedController->expectCallCount('beforeFilter', 1);
$MockedController->MockTest->expectOnce('initialize', array($MockedController));
$MockedController->MockTest->expectOnce('startup', array($MockedController));
}
/**
* Tests that the shutdown process calls the correct functions
*
* @access public
* @return void
*/
function testShutdownProcess() {
Mock::generatePartial('AnotherTestController','MockedController2', array('afterFilter'));
Mock::generate('TestComponent', 'MockTestComponent', array('shutdown'));
$MockedController =& new MockedController2();
$MockedController->components = array('MockTest');
$MockedController->Component =& new Component();
$MockedController->Component->init($MockedController);
$MockedController->shutdownProcess();
$MockedController->expectCallCount('afterFilter', 1);
$MockedController->MockTest->expectOnce('shutdown', array($MockedController));
}
}
?>

0 comments on commit d5fa897

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