2011-10-18 10:18:50 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Test Suite Shell
|
|
|
|
*
|
|
|
|
* This is a bc wrapper for the newer Test shell
|
|
|
|
*
|
|
|
|
* PHP 5
|
|
|
|
*
|
2012-04-27 02:49:18 +00:00
|
|
|
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
|
2013-02-08 11:59:49 +00:00
|
|
|
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
2011-10-18 10:18:50 +00:00
|
|
|
*
|
|
|
|
* Licensed under The MIT License
|
2013-02-08 12:22:51 +00:00
|
|
|
* For full copyright and license information, please see the LICENSE.txt
|
2011-10-18 10:18:50 +00:00
|
|
|
* Redistributions of files must retain the above copyright notice
|
|
|
|
*
|
2013-02-08 11:59:49 +00:00
|
|
|
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
2012-04-27 02:49:18 +00:00
|
|
|
* @link http://book.cakephp.org/2.0/en/development/testing.html
|
2011-10-18 10:18:50 +00:00
|
|
|
* @since CakePHP(tm) v 1.2.0.4433
|
2013-05-30 22:11:14 +00:00
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
2011-10-18 10:18:50 +00:00
|
|
|
*/
|
|
|
|
|
2011-10-18 10:28:52 +00:00
|
|
|
App::uses('TestShell', 'Console/Command');
|
2011-11-25 21:05:00 +00:00
|
|
|
App::uses('AppShell', 'Console/Command');
|
2010-12-08 06:19:36 +00:00
|
|
|
App::uses('CakeTestSuiteDispatcher', 'TestSuite');
|
2011-02-14 04:26:41 +00:00
|
|
|
App::uses('CakeTestSuiteCommand', 'TestSuite');
|
|
|
|
App::uses('CakeTestLoader', 'TestSuite');
|
2011-10-18 10:18:50 +00:00
|
|
|
|
2011-10-18 10:24:35 +00:00
|
|
|
/**
|
|
|
|
* Provides a CakePHP wrapper around PHPUnit.
|
|
|
|
* Adds in CakePHP's fixtures and gives access to plugin, app and core test cases
|
|
|
|
*
|
|
|
|
* @package Cake.Console.Command
|
|
|
|
*/
|
2011-10-18 10:28:52 +00:00
|
|
|
class TestsuiteShell extends TestShell {
|
2011-10-18 10:18:50 +00:00
|
|
|
|
2011-10-18 10:24:35 +00:00
|
|
|
/**
|
|
|
|
* get the option parser for the test suite.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2011-10-18 10:18:50 +00:00
|
|
|
public function getOptionParser() {
|
2012-03-19 01:57:15 +00:00
|
|
|
$parser = parent::getOptionParser();
|
2011-10-18 10:18:50 +00:00
|
|
|
$parser->description(array(
|
|
|
|
__d('cake_console', 'The CakePHP Testsuite allows you to run test cases from the command line'),
|
|
|
|
__d('cake_console', '<warning>This shell is for backwards-compatibility only</warning>'),
|
|
|
|
__d('cake_console', 'use the test shell instead')
|
|
|
|
));
|
|
|
|
|
|
|
|
return $parser;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parse the CLI options into an array CakeTestDispatcher can use.
|
|
|
|
*
|
|
|
|
* @return array Array of params for CakeTestDispatcher
|
|
|
|
*/
|
|
|
|
protected function _parseArgs() {
|
|
|
|
if (empty($this->args)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$params = array(
|
|
|
|
'core' => false,
|
|
|
|
'app' => false,
|
|
|
|
'plugin' => null,
|
|
|
|
'output' => 'text',
|
|
|
|
);
|
|
|
|
|
|
|
|
$category = $this->args[0];
|
|
|
|
|
2013-02-12 02:38:08 +00:00
|
|
|
if ($category === 'core') {
|
2011-10-18 10:18:50 +00:00
|
|
|
$params['core'] = true;
|
2013-02-12 02:38:08 +00:00
|
|
|
} elseif ($category === 'app') {
|
2011-10-18 10:18:50 +00:00
|
|
|
$params['app'] = true;
|
2013-02-12 02:38:08 +00:00
|
|
|
} elseif ($category !== 'core') {
|
2011-10-18 10:18:50 +00:00
|
|
|
$params['plugin'] = $category;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($this->args[1])) {
|
|
|
|
$params['case'] = $this->args[1];
|
|
|
|
}
|
|
|
|
return $params;
|
|
|
|
}
|
2011-10-18 10:24:35 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Main entry point to this shell
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function main() {
|
|
|
|
$this->out(__d('cake_console', 'CakePHP Test Shell'));
|
|
|
|
$this->hr();
|
|
|
|
|
|
|
|
$args = $this->_parseArgs();
|
|
|
|
|
|
|
|
if (empty($args['case'])) {
|
|
|
|
return $this->available();
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->_run($args, $this->_runnerOptions());
|
|
|
|
}
|
2012-03-03 23:55:07 +00:00
|
|
|
|
2011-10-18 10:18:50 +00:00
|
|
|
}
|