Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
13532 anikendra 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
 * get the option parser for the test suite.
36
 *
37
 * @return void
38
 */
39
	public function getOptionParser() {
40
		$parser = parent::getOptionParser();
41
		$parser->description(array(
42
			__d('cake_console', 'The CakePHP Testsuite allows you to run test cases from the command line'),
43
			__d('cake_console', "<warning>This shell is for backwards-compatibility only</warning>\nuse the test shell instead"),
44
		));
45
 
46
		return $parser;
47
	}
48
 
49
/**
50
 * Parse the CLI options into an array CakeTestDispatcher can use.
51
 *
52
 * @return array Array of params for CakeTestDispatcher
53
 */
54
	protected function _parseArgs() {
55
		if (empty($this->args)) {
56
			return;
57
		}
58
		$params = array(
59
			'core' => false,
60
			'app' => false,
61
			'plugin' => null,
62
			'output' => 'text',
63
		);
64
 
65
		$category = $this->args[0];
66
 
67
		if ($category === 'core') {
68
			$params['core'] = true;
69
		} elseif ($category === 'app') {
70
			$params['app'] = true;
71
		} elseif ($category !== 'core') {
72
			$params['plugin'] = $category;
73
		}
74
 
75
		if (isset($this->args[1])) {
76
			$params['case'] = $this->args[1];
77
		}
78
		return $params;
79
	}
80
 
81
/**
82
 * Main entry point to this shell
83
 *
84
 * @return void
85
 */
86
	public function main() {
87
		$this->out(__d('cake_console', 'CakePHP Test Shell'));
88
		$this->hr();
89
 
90
		$args = $this->_parseArgs();
91
 
92
		if (empty($args['case'])) {
93
			return $this->available();
94
		}
95
 
96
		$this->_run($args, $this->_runnerOptions());
97
	}
98
 
99
}