Skip to content
Permalink
Browse files

Updating View::_paths to remove an always miss file_exists() check.

Test case added.
Refs #49
  • Loading branch information...
markstory committed Aug 24, 2009
1 parent a0feb84 commit 325446a8b33732182d3eeddf112ad711bff426f1
Showing with 42 additions and 13 deletions.
  1. +4 −1 cake/libs/view/view.php
  2. +38 −12 cake/tests/cases/libs/view/view.test.php
@@ -939,11 +939,14 @@ function _paths($plugin = null, $cached = true) {
}
$paths = array();
$viewPaths = App::path('views');
$corePaths = array_flip(App::core('views'));
if (!empty($plugin)) {
$count = count($viewPaths);
for ($i = 0; $i < $count; $i++) {
$paths[] = $viewPaths[$i] . 'plugins' . DS . $plugin . DS;
if (!isset($corePaths[$viewPaths[$i]])) {
$paths[] = $viewPaths[$i] . 'plugins' . DS . $plugin . DS;
}
}
$pluginPaths = App::path('plugins');
$count = count($pluginPaths);
@@ -110,18 +110,6 @@ function _stop() {
*/
class TestView extends View {
/**
* renderElement method
*
* @param mixed $name
* @param array $params
* @access public
* @return void
*/
function renderElement($name, $params = array()) {
return $name;
}
/**
* getViewFileName method
*
@@ -157,6 +145,18 @@ function loadHelpers(&$loaded, $helpers, $parent = null) {
return $this->_loadHelpers($loaded, $helpers, $parent);
}
/**
* paths method
*
* @param string $plugin
* @param boolean $cached
* @access public
* @return void
*/
function paths($plugin = null, $cached = true) {
return $this->_paths($plugin, $cached);
}
/**
* cakeError method
*
@@ -294,6 +294,32 @@ function testPluginGetTemplate() {
$this->assertEqual($result, $expected);
}
/**
* test that plugin/$plugin_name is only appended to the paths it should be.
*
* @return void
**/
function testPluginPathGeneration() {
$this->Controller->plugin = 'test_plugin';
$this->Controller->name = 'TestPlugin';
$this->Controller->viewPath = 'tests';
$this->Controller->action = 'index';
$View = new TestView($this->Controller);
$paths = $View->paths();
$this->assertEqual($paths, App::path('views'));
$paths = $View->paths('test_plugin');
$expected = array(
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'plugins' . DS . 'test_plugin' . DS,
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'views' . DS,
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS,
TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS
);
$this->assertEqual($paths, $expected);
}
/**
* test that CamelCase plugins still find their view files.
*

0 comments on commit 325446a

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