pictcode / lib / Cake / Console / Command / TestsuiteShell.php @ 635eef61
履歴 | 表示 | アノテート | ダウンロード (2.502 KB)
| 1 |
<?php
|
|---|---|
| 2 |
/**
|
| 3 |
* Test Suite Shell
|
| 4 |
*
|
| 5 |
* This is a bc wrapper for the newer Test shell
|
| 6 |
*
|
| 7 |
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
|
| 8 |
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
| 9 |
*
|
| 10 |
* Licensed under The MIT License
|
| 11 |
* For full copyright and license information, please see the LICENSE.txt
|
| 12 |
* Redistributions of files must retain the above copyright notice
|
| 13 |
*
|
| 14 |
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
| 15 |
* @link http://book.cakephp.org/2.0/en/development/testing.html
|
| 16 |
* @since CakePHP(tm) v 1.2.0.4433
|
| 17 |
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
| 18 |
*/
|
| 19 |
|
| 20 |
App::uses('TestShell', 'Console/Command'); |
| 21 |
App::uses('AppShell', 'Console/Command'); |
| 22 |
App::uses('CakeTestSuiteDispatcher', 'TestSuite'); |
| 23 |
App::uses('CakeTestSuiteCommand', 'TestSuite'); |
| 24 |
App::uses('CakeTestLoader', 'TestSuite'); |
| 25 |
|
| 26 |
/**
|
| 27 |
* Provides a CakePHP wrapper around PHPUnit.
|
| 28 |
* Adds in CakePHP's fixtures and gives access to plugin, app and core test cases
|
| 29 |
*
|
| 30 |
* @package Cake.Console.Command
|
| 31 |
*/
|
| 32 |
class TestsuiteShell extends TestShell { |
| 33 |
|
| 34 |
/**
|
| 35 |
* Gets the option parser instance and configures it.
|
| 36 |
*
|
| 37 |
* @return ConsoleOptionParser
|
| 38 |
*/
|
| 39 |
public function getOptionParser() { |
| 40 |
$parser = parent::getOptionParser(); |
| 41 |
|
| 42 |
$parser->description(array( |
| 43 |
__d('cake_console', 'The CakePHP Testsuite allows you to run test cases from the command line'), |
| 44 |
__d('cake_console', "<warning>This shell is for backwards-compatibility only</warning>\nuse the test shell instead") |
| 45 |
)); |
| 46 |
|
| 47 |
return $parser; |
| 48 |
} |
| 49 |
|
| 50 |
/**
|
| 51 |
* Parse the CLI options into an array CakeTestDispatcher can use.
|
| 52 |
*
|
| 53 |
* @return array Array of params for CakeTestDispatcher
|
| 54 |
*/
|
| 55 |
protected function _parseArgs() { |
| 56 |
if (empty($this->args)) { |
| 57 |
return;
|
| 58 |
} |
| 59 |
$params = array( |
| 60 |
'core' => false, |
| 61 |
'app' => false, |
| 62 |
'plugin' => null, |
| 63 |
'output' => 'text', |
| 64 |
); |
| 65 |
|
| 66 |
$category = $this->args[0]; |
| 67 |
|
| 68 |
if ($category === 'core') { |
| 69 |
$params['core'] = true; |
| 70 |
} elseif ($category === 'app') { |
| 71 |
$params['app'] = true; |
| 72 |
} elseif ($category !== 'core') { |
| 73 |
$params['plugin'] = $category; |
| 74 |
} |
| 75 |
|
| 76 |
if (isset($this->args[1])) { |
| 77 |
$params['case'] = $this->args[1]; |
| 78 |
} |
| 79 |
return $params; |
| 80 |
} |
| 81 |
|
| 82 |
/**
|
| 83 |
* Main entry point to this shell
|
| 84 |
*
|
| 85 |
* @return void
|
| 86 |
*/
|
| 87 |
public function main() { |
| 88 |
$this->out(__d('cake_console', 'CakePHP Test Shell')); |
| 89 |
$this->hr();
|
| 90 |
|
| 91 |
$args = $this->_parseArgs(); |
| 92 |
|
| 93 |
if (empty($args['case'])) { |
| 94 |
return $this->available(); |
| 95 |
} |
| 96 |
|
| 97 |
$this->_run($args, $this->_runnerOptions()); |
| 98 |
} |
| 99 |
|
| 100 |
} |