Adding failing test for #917

This commit is contained in:
mark_story 2010-07-15 21:52:24 -04:00
parent 21f359bff9
commit 0e184c66f4

View file

@ -391,6 +391,16 @@ class TestComponent extends Object {
*/ */
function shutdown(&$controller) { function shutdown(&$controller) {
} }
/**
* beforeRender callback
*
* @return void
*/
function beforeRender(&$controller) {
if ($this->viewclass) {
$controller->view = $this->viewclass;
}
}
} }
/** /**
@ -894,6 +904,27 @@ class ControllerTest extends CakeTestCase {
App::build(); 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 * testToBeInheritedGuardmethods method
* *