Navigation Menu

Skip to content

Commit

Permalink
Adding failing test for #917
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Jul 16, 2010
1 parent 21f359b commit 0e184c6
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion cake/tests/cases/libs/controller/controller.test.php
Expand Up @@ -391,6 +391,16 @@ function startup(&$controller) {
*/
function shutdown(&$controller) {
}
/**
* beforeRender callback
*
* @return void
*/
function beforeRender(&$controller) {
if ($this->viewclass) {
$controller->view = $this->viewclass;
}
}
}

/**
Expand Down Expand Up @@ -894,6 +904,27 @@ function testRender() {
App::build();
}

/**
* test that a component beforeRender can change the controller view class.
*
* @return void
*/
function testComponentBeforeRenderChangingViewClass() {
App::build(array(
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)
), true);
$Controller =& new Controller();
$Controller->uses = array();
$Controller->components = array('Test');
$Controller->constructClasses();
$Controller->Test->viewclass = 'Theme';
$Controller->viewPath = 'posts';
$Controller->theme = 'test_theme';
$result = $Controller->render('index');
$this->assertPattern('/posts index themed view/', $result);
App::build();
}

/**
* testToBeInheritedGuardmethods method
*
Expand Down Expand Up @@ -1411,4 +1442,4 @@ function testShutdownProcess() {
$MockedController->MockTest->expectCallCount('shutdown', 1);
$MockedController->shutdownProcess();
}
}
}

0 comments on commit 0e184c6

Please sign in to comment.