Refactoring extensions in ScaffoldView to reflect removal of magic .thtml extension.

Adding test for interaction of Themed views and Scaffolded views.  Fixes #255
This commit is contained in:
Mark Story 2010-01-28 11:11:19 -05:00
parent 76d6864d90
commit 30cb38eb93
2 changed files with 24 additions and 5 deletions

View file

@ -584,11 +584,13 @@ class ScaffoldView extends ThemeView {
$names[] = 'scaffolds' . DS . $subDir . $name;
$paths = $this->_paths($this->plugin);
$exts = array($this->ext, '.ctp', '.thtml');
$exts = array($this->ext);
if ($this->ext !== '.ctp') {
array_push($exts, '.ctp');
}
foreach ($exts as $ext) {
foreach ($paths as $path) {
foreach ($names as $name) {
foreach ($exts as $ext) {
if (file_exists($path . $name . $ext)) {
return $path . $name . $ext;
}

View file

@ -380,6 +380,23 @@ class ScaffoldViewTest extends CakeTestCase {
Configure::write('Routing.prefixes', $_admin);
}
/**
* test getting the view file name for themed scaffolds.
*
* @return void
*/
function testGetViewFileNameWithTheme() {
$this->Controller->action = 'index';
$this->Controller->viewPath = 'posts';
$this->Controller->theme = 'test_theme';
$ScaffoldView =& new TestScaffoldView($this->Controller);
$result = $ScaffoldView->testGetFilename('index');
$expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS
. 'themed' . DS . 'test_theme' . DS . 'posts' . DS . 'scaffold.index.ctp';
$this->assertEqual($result, $expected);
}
/**
* test default index scaffold generation
*