/**
  * Retrieves a list of test cases from the active Manager class,
  * displaying it in the correct format for the reporter subclass
  *
  * @return mixed
  */
 public function testCaseList()
 {
     $testList = CakeTestLoader::generateTestList($this->params);
     return $testList;
 }
Beispiel #2
0
 /**
  * Shows a list of available test cases and gives the option to run one of them
  *
  * @return void
  */
 public function available()
 {
     $params = $this->_parseArgs();
     $testCases = CakeTestLoader::generateTestList($params);
     $app = $params['app'];
     $plugin = $params['plugin'];
     $title = "Core Test Cases:";
     $category = 'core';
     if ($app) {
         $title = "App Test Cases:";
         $category = 'app';
     } elseif ($plugin) {
         $title = Inflector::humanize($plugin) . " Test Cases:";
         $category = $plugin;
     }
     if (empty($testCases)) {
         $this->out(__d('cake_console', "No test cases available \n\n"));
         return $this->out($this->OptionParser->help());
     }
     $this->out($title);
     $i = 1;
     $cases = array();
     foreach ($testCases as $testCase) {
         $case = str_replace('Test.php', '', $testCase);
         $this->out("[{$i}] {$case}");
         $cases[$i] = $case;
         $i++;
     }
     while ($choice = $this->in(__d('cake_console', 'What test case would you like to run?'), null, 'q')) {
         if (is_numeric($choice) && isset($cases[$choice])) {
             $this->args[0] = $category;
             $this->args[1] = $cases[$choice];
             $this->_run($this->_parseArgs(), $this->_runnerOptions());
             break;
         }
         if (is_string($choice) && in_array($choice, $cases)) {
             $this->args[0] = $category;
             $this->args[1] = $choice;
             $this->_run($this->_parseArgs(), $this->_runnerOptions());
             break;
         }
         if ($choice === 'q') {
             break;
         }
     }
 }