Skip to content
This repository
Browse code

Merge pull request #623 from dereuromark/2.2-bake-theme-order

Correct order of bake themes so app and plugin precede core ones

Fixes #2825
  • Loading branch information...
commit f150ebb9ccc080786a58faf5123748066bd2830a 2 parents 474eb89 + acd06d6
Mark Story authored April 26, 2012
17  lib/Cake/Console/Command/Task/TemplateTask.php
@@ -55,11 +55,18 @@ public function initialize() {
55 55
  * Find the paths to all the installed shell themes in the app.
56 56
  *
57 57
  * Bake themes are directories not named `skel` inside a `Console/Templates` path.
58  
- *
  58
+ * They are listed in this order: app -> plugin -> default
  59
+ * 
59 60
  * @return array Array of bake themes that are installed.
60 61
  */
61 62
 	protected function _findThemes() {
62  
-		$paths = array();
  63
+		$paths = App::path('Console');
  64
+		
  65
+		$plugins = App::objects('plugin');
  66
+		foreach ($plugins as $plugin) {
  67
+			$paths[] = $this->_pluginPath($plugin) . 'Console' . DS;
  68
+		}
  69
+
63 70
 		$core = current(App::core('Console'));
64 71
 		$separator = DS === '/' ? '/' : '\\\\';
65 72
 		$core = preg_replace('#shells' . $separator . '$#', '', $core);
@@ -69,13 +76,7 @@ protected function _findThemes() {
69 76
 		$contents = $Folder->read();
70 77
 		$themeFolders = $contents[0];
71 78
 
72  
-		$plugins = App::objects('plugin');
73 79
 		$paths[] = $core;
74  
-		foreach ($plugins as $plugin) {
75  
-			$paths[] = $this->_pluginPath($plugin) . 'Console' . DS;
76  
-		}
77  
-
78  
-		$paths = array_merge($paths, App::path('Console'));
79 80
 
80 81
 		// TEMPORARY TODO remove when all paths are DS terminated
81 82
 		foreach ($paths as $i => $path) {
8  lib/Cake/Test/Case/Console/Command/Task/TemplateTaskTest.php
@@ -107,15 +107,15 @@ public function testGetThemePath() {
107 107
 		$result = $this->Task->getThemePath();
108 108
 		$this->assertEquals($defaultTheme, $result);
109 109
 
110  
-		$this->Task->templatePaths = array('default' => $defaultTheme, 'other' => '/some/path');
  110
+		$this->Task->templatePaths = array('other' => '/some/path', 'default' => $defaultTheme);
111 111
 		$this->Task->params['theme'] = 'other';
112 112
 		$result = $this->Task->getThemePath();
113 113
 		$this->assertEquals('/some/path', $result);
114 114
 
115 115
 		$this->Task->params = array();
116 116
 		$result = $this->Task->getThemePath();
117  
-		$this->assertEquals($defaultTheme, $result);
118  
-		$this->assertEquals('default', $this->Task->params['theme']);
  117
+		$this->assertEquals('/some/path', $result);
  118
+		$this->assertEquals('other', $this->Task->params['theme']);
119 119
 	}
120 120
 
121 121
 /**
@@ -134,7 +134,7 @@ public function testGenerate() {
134 134
 
135 135
 		$result = $this->Task->generate('classes', 'test_object', array('test' => 'foo'));
136 136
 		$expected = "I got rendered\nfoo";
137  
-		$this->assertEquals($expected, $result);
  137
+		$this->assertTextEquals($expected, $result);
138 138
 	}
139 139
 
140 140
 /**

0 notes on commit f150ebb

Please sign in to comment.
Something went wrong with that request. Please try again.