Skip to content

Commit

Permalink
Applying patch from 'mulleto'. Fixes plugin view file location with C…
Browse files Browse the repository at this point in the history
…amelCase plugin names. Test cases added.

Fixes #6334

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8202 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information
markstory committed Jun 24, 2009
1 parent 16eb51e commit fd818bc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cake/libs/view/view.php
Expand Up @@ -800,7 +800,7 @@ function _getViewFileName($name = null) {
}
}

$paths = $this->_paths($this->plugin);
$paths = $this->_paths(Inflector::underscore($this->plugin));

foreach ($paths as $path) {
if (file_exists($path . $name . $this->ext)) {
Expand Down Expand Up @@ -840,7 +840,7 @@ function _getLayoutFileName($name = null) {
if (!is_null($this->layoutPath)) {
$subDir = $this->layoutPath . DS;
}
$paths = $this->_paths($this->plugin);
$paths = $this->_paths(Inflector::underscore($this->plugin));
$file = 'layouts' . DS . $subDir . $name;

$exts = array($this->ext, '.ctp', '.thtml');
Expand Down
23 changes: 23 additions & 0 deletions cake/tests/cases/libs/view/view.test.php
Expand Up @@ -248,6 +248,29 @@ function testPluginGetTemplate() {
$this->assertEqual($result, $expected);
}
/**
* test that CamelCase plugins still find their view files.
*
* @return void
**/
function testCamelCasePluginGetTemplate() {
$this->Controller->plugin = 'TestPlugin';
$this->Controller->name = 'TestPlugin';
$this->Controller->viewPath = 'tests';
$this->Controller->action = 'index';

$View = new TestView($this->Controller);
Configure::write('pluginPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS));
Configure::write('viewPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS));

$expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS .'test_plugin' . DS . 'views' . DS .'tests' . DS .'index.ctp';
$result = $View->getViewFileName('index');
$this->assertEqual($result, $expected);

$expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS .'test_plugin' . DS . 'views' . DS . 'layouts' . DS .'default.ctp';
$result = $View->getLayoutFileName();
$this->assertEqual($result, $expected);
}
/**
* testGetTemplate method
*
* @access public
Expand Down

0 comments on commit fd818bc

Please sign in to comment.