@@ -100,41 +100,64 @@ function initialize() {
100
100
foreach ($ plugins as $ p ) {
101
101
$ this ->plugins [] = Inflector::underscore ($ p );
102
102
}
103
+ $ this ->parseArgs ();
104
+ $ this ->getManager ();
103
105
}
104
106
105
107
/**
106
- * Main entry point to this shell
108
+ * Parse the arguments given into the Shell object properties.
107
109
*
108
110
* @return void
109
111
* @access public
110
112
*/
111
- function main () {
112
- $ this ->out ($ this ->headline );
113
- $ this ->hr ();
113
+ function parseArgs () {
114
+ $ this ->category = $ this ->args [0 ];
114
115
115
- if (count ($ this ->args ) > 0 ) {
116
- $ this ->category = $ this ->args [0 ];
116
+ if (!in_array ($ this ->category , array ('app ' , 'core ' ))) {
117
+ $ this ->isPluginTest = true ;
118
+ }
117
119
118
- if (! in_array ($ this ->category , array ( ' app ' , ' core ' ) )) {
119
- $ this ->isPluginTest = true ;
120
- }
120
+ if (isset ($ this ->args [ 1 ] )) {
121
+ $ this ->type = $ this -> args [ 1 ] ;
122
+ }
121
123
122
- if (isset ($ this ->args [1 ])) {
123
- $ this ->type = $ this ->args [1 ];
124
+ if (isset ($ this ->args [2 ])) {
125
+ if ($ this ->args [2 ] == 'cov ' ) {
126
+ $ this ->doCoverage = true ;
127
+ } else {
128
+ $ this ->file = Inflector::underscore ($ this ->args [2 ]);
124
129
}
130
+ }
125
131
126
- if (isset ($ this ->args [2 ])) {
127
- if ($ this ->args [2 ] == 'cov ' ) {
128
- $ this ->doCoverage = true ;
129
- } else {
130
- $ this ->file = Inflector::underscore ($ this ->args [2 ]);
131
- }
132
- }
132
+ if (isset ($ this ->args [3 ]) && $ this ->args [3 ] == 'cov ' ) {
133
+ $ this ->doCoverage = true ;
134
+ }
135
+ }
133
136
134
- if (isset ($ this ->args [3 ]) && $ this ->args [3 ] == 'cov ' ) {
135
- $ this ->doCoverage = true ;
136
- }
137
- } else {
137
+ /**
138
+ * Gets a manager instance, and set the app/plugin properties.
139
+ *
140
+ * @return void
141
+ */
142
+ function getManager () {
143
+ $ this ->Manager = new TestManager ();
144
+ $ this ->Manager ->appTest = ($ this ->category === 'app ' );
145
+ if ($ this ->isPluginTest ) {
146
+ $ this ->Manager ->pluginTest = $ this ->category ;
147
+ }
148
+ }
149
+
150
+ /**
151
+ * Main entry point to this shell
152
+ *
153
+ * @return void
154
+ * @access public
155
+ */
156
+ function main () {
157
+ $ this ->out ($ this ->headline );
158
+ $ this ->hr ();
159
+
160
+ if (count ($ this ->args ) == 0 ) {
138
161
$ this ->err ('Sorry, you did not pass any arguments! ' );
139
162
}
140
163
@@ -252,11 +275,10 @@ function __canRun() {
252
275
* @access private
253
276
*/
254
277
function __run () {
255
- $ reporter = new CLIReporter ();
256
- $ this ->__setGetVars ();
278
+ $ Reporter = new CakeCliReporter ();
257
279
258
280
if ($ this ->type == 'all ' ) {
259
- return TestManager:: runAllTests ($ reporter );
281
+ return $ this -> Manager -> runAllTests ($ Reporter );
260
282
}
261
283
262
284
if ($ this ->doCoverage ) {
@@ -278,9 +300,9 @@ function __run() {
278
300
279
301
if ($ this ->doCoverage ) {
280
302
require_once CAKE . 'tests ' . DS . 'lib ' . DS . 'code_coverage_manager.php ' ;
281
- CodeCoverageManager::start ($ ucFirstGroup , $ reporter );
303
+ CodeCoverageManager::start ($ ucFirstGroup , $ Reporter );
282
304
}
283
- $ result = TestManager:: runGroupTest ($ ucFirstGroup , $ reporter );
305
+ $ result = $ this -> Manager -> runGroupTest ($ ucFirstGroup , $ Reporter );
284
306
if ($ this ->doCoverage ) {
285
307
CodeCoverageManager::report ();
286
308
}
@@ -301,10 +323,10 @@ function __run() {
301
323
302
324
if ($ this ->doCoverage ) {
303
325
require_once CAKE . 'tests ' . DS . 'lib ' . DS . 'code_coverage_manager.php ' ;
304
- CodeCoverageManager::start ($ case , $ reporter );
326
+ CodeCoverageManager::start ($ case , $ Reporter );
305
327
}
306
328
307
- $ result = TestManager:: runTestCase ($ case , $ reporter );
329
+ $ result = $ this -> Manager -> runTestCase ($ case , $ Reporter );
308
330
if ($ this ->doCoverage ) {
309
331
CodeCoverageManager::report ();
310
332
}
@@ -328,14 +350,9 @@ function __findFolderByCategory($category) {
328
350
if (array_key_exists ($ category , $ paths )) {
329
351
$ folder = $ paths [$ category ] . 'tests ' ;
330
352
} else {
331
- $ scoredCategory = Inflector::underscore ($ category );
332
- $ folder = APP . 'plugins ' . DS . $ scoredCategory . DS ;
333
- $ pluginPaths = App::path ('plugins ' );
334
- foreach ($ pluginPaths as $ path ) {
335
- if (file_exists ($ path . $ scoredCategory . DS . 'tests ' )) {
336
- $ folder = $ path . $ scoredCategory . DS . 'tests ' ;
337
- break ;
338
- }
353
+ $ pluginPath = App::pluginPath ($ category );
354
+ if (is_dir ($ pluginPath . 'tests ' )) {
355
+ $ folder = $ pluginPath . 'tests ' . DS ;
339
356
}
340
357
}
341
358
return $ folder ;
0 commit comments