Updating RequestHandler::renderAs() to respect DS constant, fixing issues on PHP4 + Windows. Fixes #97

This commit is contained in:
mark_story 2009-10-12 23:55:40 -04:00
parent e04cc81613
commit e5a99b2685
2 changed files with 4 additions and 4 deletions

View file

@ -583,9 +583,9 @@ class RequestHandlerComponent extends Object {
$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 file

@ -267,13 +267,13 @@ class RequestHandlerComponentTest extends CakeTestCase {
**/
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));
}