Skip to content

Commit 01cfe32

Browse files
committed
Adding a test case list to the test suite cli runner
1 parent eed9d93 commit 01cfe32

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed

cake/console/libs/testsuite.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@ public function initialize() {
4242
} else {
4343
define('TEST_CAKE_CORE_INCLUDE_PATH', CAKE_CORE_INCLUDE_PATH);
4444
}
45+
4546
$this->_dispatcher = new CakeTestSuiteDispatcher();
4647
$this->_dispatcher->loadTestFramework();
48+
require_once CAKE . 'tests' . DS . 'lib' . DS . 'test_manager.php';
4749
}
4850

4951
/**
@@ -113,6 +115,65 @@ public function main() {
113115
$testCli->run($this->runnerOptions());
114116
}
115117

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+
116177
/**
117178
* Help screen
118179
*

cake/tests/lib/test_runner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121

2222
require 'PHPUnit/TextUI/Command.php';
23-
require 'test_manager.php';
23+
require_once 'test_manager.php';
2424

2525
PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'DEFAULT');
2626

0 commit comments

Comments
 (0)