Permalink
Browse files

Refactoring extensions in ScaffoldView to reflect removal of magic .t…

…html extension.

Adding test for interaction of Themed views and Scaffolded views.  Fixes #255
  • Loading branch information...
markstory committed Jan 28, 2010
1 parent 76d6864 commit 30cb38eb93b416f53abd946b5a48e2794cf61b70
Showing with 24 additions and 5 deletions.
  1. +7 −5 cake/libs/controller/scaffold.php
  2. +17 −0 cake/tests/cases/libs/controller/scaffold.test.php
@@ -584,11 +584,13 @@ function _getViewFileName($name = null) {
$names[] = 'scaffolds' . DS . $subDir . $name;
$paths = $this->_paths($this->plugin);
-
- $exts = array($this->ext, '.ctp', '.thtml');
- foreach ($paths as $path) {
- foreach ($names as $name) {
- foreach ($exts as $ext) {
+ $exts = array($this->ext);
+ if ($this->ext !== '.ctp') {
+ array_push($exts, '.ctp');
+ }
+ foreach ($exts as $ext) {
+ foreach ($paths as $path) {
+ foreach ($names as $name) {
if (file_exists($path . $name . $ext)) {
return $path . $name . $ext;
}
@@ -380,6 +380,23 @@ function testGetViewFilename() {
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
*

0 comments on commit 30cb38e

Please sign in to comment.