Permalink
Browse files

Updating RequestHandler::renderAs() to respect DS constant, fixing is…

…sues on PHP4 + Windows. Fixes #97
  • Loading branch information...
1 parent e04cc81 commit e5a99b26852fce13efb33c07db1ea67bae5bf801 @markstory markstory committed Oct 13, 2009
View
4 cake/libs/controller/components/request_handler.php
@@ -583,9 +583,9 @@ function renderAs(&$controller, $type) {
$controller->ext = '.ctp';
if (empty($this->__renderType)) {
- $controller->viewPath .= '/' . $type;
+ $controller->viewPath .= DS . $type;
} else {
- $remove = preg_replace("/(?:\/{$this->__renderType})$/", '/' . $type, $controller->viewPath);
+ $remove = preg_replace("/([\/\\\\]{$this->__renderType})$/", DS . $type, $controller->viewPath);
$controller->viewPath = $remove;
}
$this->__renderType = $type;
View
4 cake/tests/cases/libs/controller/components/request_handler.test.php
@@ -267,13 +267,13 @@ function testRenderAs() {
**/
function testRenderAsCalledTwice() {
$this->RequestHandler->renderAs($this->Controller, 'xml');
- $this->assertEqual($this->Controller->viewPath, 'request_handler_test/xml');
+ $this->assertEqual($this->Controller->viewPath, 'request_handler_test' . DS . 'xml');
$this->assertEqual($this->Controller->layoutPath, 'xml');
$this->assertTrue(in_array('Xml', $this->Controller->helpers));
$this->RequestHandler->renderAs($this->Controller, 'js');
- $this->assertEqual($this->Controller->viewPath, 'request_handler_test/js');
+ $this->assertEqual($this->Controller->viewPath, 'request_handler_test' . DS . 'js');
$this->assertEqual($this->Controller->layoutPath, 'js');
$this->assertTrue(in_array('Js', $this->Controller->helpers));
}

0 comments on commit e5a99b2

Please sign in to comment.