From e5a99b26852fce13efb33c07db1ea67bae5bf801 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 12 Oct 2009 23:55:40 -0400 Subject: [PATCH] Updating RequestHandler::renderAs() to respect DS constant, fixing issues on PHP4 + Windows. Fixes #97 --- cake/libs/controller/components/request_handler.php | 4 ++-- .../cases/libs/controller/components/request_handler.test.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cake/libs/controller/components/request_handler.php b/cake/libs/controller/components/request_handler.php index efca6b2c5..2c61f82b2 100644 --- a/cake/libs/controller/components/request_handler.php +++ b/cake/libs/controller/components/request_handler.php @@ -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; diff --git a/cake/tests/cases/libs/controller/components/request_handler.test.php b/cake/tests/cases/libs/controller/components/request_handler.test.php index f0e638d4d..7285ba847 100644 --- a/cake/tests/cases/libs/controller/components/request_handler.test.php +++ b/cake/tests/cases/libs/controller/components/request_handler.test.php @@ -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)); }