Skip to content

Commit

Permalink
Updating RequestHandler::renderAs() to respect DS constant, fixing is…
Browse files Browse the repository at this point in the history
…sues on PHP4 + Windows. Fixes #97
  • Loading branch information
markstory committed Oct 13, 2009
1 parent e04cc81 commit e5a99b2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cake/libs/controller/components/request_handler.php
Expand Up @@ -583,9 +583,9 @@ function renderAs(&$controller, $type) {
$controller->ext = '.ctp'; $controller->ext = '.ctp';


if (empty($this->__renderType)) { if (empty($this->__renderType)) {
$controller->viewPath .= '/' . $type; $controller->viewPath .= DS . $type;
} else { } else {
$remove = preg_replace("/(?:\/{$this->__renderType})$/", '/' . $type, $controller->viewPath); $remove = preg_replace("/([\/\\\\]{$this->__renderType})$/", DS . $type, $controller->viewPath);
$controller->viewPath = $remove; $controller->viewPath = $remove;
} }
$this->__renderType = $type; $this->__renderType = $type;
Expand Down
Expand Up @@ -267,13 +267,13 @@ function testRenderAs() {
**/ **/
function testRenderAsCalledTwice() { function testRenderAsCalledTwice() {
$this->RequestHandler->renderAs($this->Controller, 'xml'); $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->assertEqual($this->Controller->layoutPath, 'xml');


$this->assertTrue(in_array('Xml', $this->Controller->helpers)); $this->assertTrue(in_array('Xml', $this->Controller->helpers));


$this->RequestHandler->renderAs($this->Controller, 'js'); $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->assertEqual($this->Controller->layoutPath, 'js');
$this->assertTrue(in_array('Js', $this->Controller->helpers)); $this->assertTrue(in_array('Js', $this->Controller->helpers));
} }
Expand Down

0 comments on commit e5a99b2

Please sign in to comment.