@@ -42,8 +42,10 @@ public function initialize() {
42
42
} else {
43
43
define ('TEST_CAKE_CORE_INCLUDE_PATH ' , CAKE_CORE_INCLUDE_PATH );
44
44
}
45
+
45
46
$ this ->_dispatcher = new CakeTestSuiteDispatcher ();
46
47
$ this ->_dispatcher ->loadTestFramework ();
48
+ require_once CAKE . 'tests ' . DS . 'lib ' . DS . 'test_manager.php ' ;
47
49
}
48
50
49
51
/**
@@ -113,6 +115,65 @@ public function main() {
113
115
$ testCli ->run ($ this ->runnerOptions ());
114
116
}
115
117
118
+ /**
119
+ * Shows a list of available test cases and gives the option to run one of them
120
+ *
121
+ * @return void
122
+ */
123
+ public function available () {
124
+ $ params = $ this ->parseArgs ();
125
+ $ testCases = TestManager::getTestCaseList ($ params );
126
+ $ app = $ params ['app ' ];
127
+ $ plugin = $ params ['plugin ' ];
128
+
129
+ $ title = "Core Test Cases: " ;
130
+ $ category = 'core ' ;
131
+ if ($ app ) {
132
+ $ title = "App Test Cases: " ;
133
+ $ category = 'app ' ;
134
+ } elseif ($ plugin ) {
135
+ $ title = Inflector::humanize ($ plugin ) . " Test Cases: " ;
136
+ $ category = $ plugin ;
137
+ }
138
+
139
+ if (empty ($ testCases )) {
140
+ $ this ->out (__ ('No test cases available ' ));
141
+ return ;
142
+ }
143
+
144
+ $ this ->out ($ title );
145
+ $ i = 1 ;
146
+ $ cases = array ();
147
+ foreach ($ testCases as $ testCaseFile => $ testCase ) {
148
+ $ case = explode (DS , str_replace ('.test.php ' , '' , $ testCase ));
149
+ $ case [count ($ case ) - 1 ] = Inflector::camelize ($ case [count ($ case ) - 1 ]);
150
+ $ case = implode ('/ ' , $ case );
151
+ $ this ->out ("[ $ i] $ case " );
152
+ $ cases [$ i ] = $ case ;
153
+ $ i ++;
154
+ }
155
+
156
+ while ($ choice = $ this ->in (__ ('What test case would you like to run? ' ), null , 'q ' )) {
157
+ if (is_numeric ($ choice ) && isset ($ cases [$ choice ])) {
158
+ $ this ->args [0 ] = $ category ;
159
+ $ this ->args [1 ] = $ cases [$ choice ];
160
+ $ this ->main ();
161
+ break ;
162
+ }
163
+
164
+ if (is_string ($ choice ) && in_array ($ choice , $ cases )) {
165
+ $ this ->args [0 ] = $ category ;
166
+ $ this ->args [1 ] = $ choice ;
167
+ $ this ->main ();
168
+ break ;
169
+ }
170
+
171
+ if ($ choice == 'q ' ) {
172
+ break ;
173
+ }
174
+ }
175
+ }
176
+
116
177
/**
117
178
* Help screen
118
179
*
0 commit comments