Skip to content
Permalink
Browse files

Consistently inflect theme names.

Themes should be consistently converted into CamelCase, this
makes the camelization consitent with the treatment in App::themePath().

Fixes #3508
  • Loading branch information...
markstory committed Jan 4, 2013
1 parent 75f654b commit 6d743971e976cee8eaf8eb577240d1eb17be1e67
Showing with 6 additions and 12 deletions.
  1. +3 −10 lib/Cake/Test/Case/View/ViewTest.php
  2. +3 −2 lib/Cake/View/View.php
@@ -300,7 +300,7 @@ public function testGetTemplate() {
$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 @@ public function testGetTemplate() {
$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 @@ public function testMissingView() {
$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 @@ public function testMissingLayout() {
$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);
}
/**
@@ -1111,13 +1111,14 @@ protected function _paths($plugin = null, $cached = true) {
$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);

0 comments on commit 6d74397

Please sign in to comment.
You can’t perform that action at this time.