From 0e184c66f4cf871fc7a7722f1e84aed50371f66a Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 15 Jul 2010 21:52:24 -0400 Subject: [PATCH] Adding failing test for #917 --- .../cases/libs/controller/controller.test.php | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/cake/tests/cases/libs/controller/controller.test.php b/cake/tests/cases/libs/controller/controller.test.php index a517092ea27..f588b82a14e 100644 --- a/cake/tests/cases/libs/controller/controller.test.php +++ b/cake/tests/cases/libs/controller/controller.test.php @@ -391,6 +391,16 @@ function startup(&$controller) { */ function shutdown(&$controller) { } +/** + * beforeRender callback + * + * @return void + */ + function beforeRender(&$controller) { + if ($this->viewclass) { + $controller->view = $this->viewclass; + } + } } /** @@ -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 * @@ -1411,4 +1442,4 @@ function testShutdownProcess() { $MockedController->MockTest->expectCallCount('shutdown', 1); $MockedController->shutdownProcess(); } -} +} \ No newline at end of file