From 6d743971e976cee8eaf8eb577240d1eb17be1e67 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 3 Jan 2013 21:06:46 -0500 Subject: [PATCH] Consistently inflect theme names. Themes should be consistently converted into CamelCase, this makes the camelization consitent with the treatment in App::themePath(). Fixes #3508 --- lib/Cake/Test/Case/View/ViewTest.php | 13 +++---------- lib/Cake/View/View.php | 5 +++-- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/lib/Cake/Test/Case/View/ViewTest.php b/lib/Cake/Test/Case/View/ViewTest.php index ffcbb3ef9..f7048ffe4 100644 --- a/lib/Cake/Test/Case/View/ViewTest.php +++ b/lib/Cake/Test/Case/View/ViewTest.php @@ -300,7 +300,7 @@ class ViewTest extends CakeTestCase { $this->Controller->params['pass'] = array('home'); $ThemeView = new TestThemeView($this->Controller); - $ThemeView->theme = 'TestTheme'; + $ThemeView->theme = 'test_theme'; $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Pages' . DS . 'home.ctp'; $result = $ThemeView->getViewFileName('home'); $this->assertEquals($expected, $result); @@ -309,6 +309,7 @@ class ViewTest extends CakeTestCase { $result = $ThemeView->getViewFileName('/Posts/index'); $this->assertEquals($expected, $result); + $ThemeView->theme = 'TestTheme'; $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Layouts' . DS . 'default.ctp'; $result = $ThemeView->getLayoutFileName(); $this->assertEquals($expected, $result); @@ -546,11 +547,7 @@ class ViewTest extends CakeTestCase { $this->ThemeController->params['pass'] = array('home'); $View = new TestThemeView($this->ThemeController); - ob_start(); - $result = $View->getViewFileName('does_not_exist'); - $expected = ob_get_clean(); - $this->assertRegExp("/PagesController::/", $expected); - $this->assertRegExp("/views(\/|\\\)themed(\/|\\\)my_theme(\/|\\\)pages(\/|\\\)does_not_exist.ctp/", $expected); + $View->getViewFileName('does_not_exist'); } /** @@ -577,11 +574,7 @@ class ViewTest extends CakeTestCase { $this->ThemeController->theme = 'my_theme'; $View = new TestThemeView($this->ThemeController); - ob_start(); $result = $View->getLayoutFileName(); - $expected = ob_get_clean(); - $this->assertRegExp("/Missing Layout/", $expected); - $this->assertRegExp("/views(\/|\\\)themed(\/|\\\)my_theme(\/|\\\)layouts(\/|\\\)whatever.ctp/", $expected); } /** diff --git a/lib/Cake/View/View.php b/lib/Cake/View/View.php index 475f02bb3..6c08cd067 100644 --- a/lib/Cake/View/View.php +++ b/lib/Cake/View/View.php @@ -1111,13 +1111,14 @@ class View extends Object { $paths = array_unique(array_merge($paths, $viewPaths)); if (!empty($this->theme)) { + $theme = Inflector::camelize($this->theme); $themePaths = array(); foreach ($paths as $path) { if (strpos($path, DS . 'Plugin' . DS) === false) { if ($plugin) { - $themePaths[] = $path . 'Themed' . DS . $this->theme . DS . 'Plugin' . DS . $plugin . DS; + $themePaths[] = $path . 'Themed' . DS . $theme . DS . 'Plugin' . DS . $plugin . DS; } - $themePaths[] = $path . 'Themed' . DS . $this->theme . DS; + $themePaths[] = $path . 'Themed' . DS . $theme . DS; } } $paths = array_merge($themePaths, $paths);