| 1 |
lars |
1 |
<?php
|
|
|
2 |
/* SVN FILE: $Id: test.php 7945 2008-12-19 02:16:01Z gwoo $ */
|
|
|
3 |
/**
|
|
|
4 |
* Short description for file.
|
|
|
5 |
*
|
|
|
6 |
* Long description for file
|
|
|
7 |
*
|
|
|
8 |
* PHP versions 4 and 5
|
|
|
9 |
*
|
|
|
10 |
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
|
|
11 |
* Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
|
|
12 |
*
|
|
|
13 |
* Licensed under The Open Group Test Suite License
|
|
|
14 |
* Redistributions of files must retain the above copyright notice.
|
|
|
15 |
*
|
|
|
16 |
* @filesource
|
|
|
17 |
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
|
|
18 |
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
|
|
19 |
* @package cake
|
|
|
20 |
* @subpackage cake.cake.tests.libs
|
|
|
21 |
* @since CakePHP(tm) v 1.2.0.4433
|
|
|
22 |
* @version $Revision: 7945 $
|
|
|
23 |
* @modifiedby $LastChangedBy: gwoo $
|
|
|
24 |
* @lastmodified $Date: 2008-12-18 18:16:01 -0800 (Thu, 18 Dec 2008) $
|
|
|
25 |
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
|
|
26 |
*/
|
|
|
27 |
error_reporting(E_ALL);
|
|
|
28 |
set_time_limit(0);
|
|
|
29 |
ini_set('memory_limit','128M');
|
|
|
30 |
ini_set('display_errors', 1);
|
|
|
31 |
/**
|
|
|
32 |
* Use the DS to separate the directories in other defines
|
|
|
33 |
*/
|
|
|
34 |
if (!defined('DS')) {
|
|
|
35 |
define('DS', DIRECTORY_SEPARATOR);
|
|
|
36 |
}
|
|
|
37 |
/**
|
|
|
38 |
* These defines should only be edited if you have cake installed in
|
|
|
39 |
* a directory layout other than the way it is distributed.
|
|
|
40 |
* When using custom settings be sure to use the DS and do not add a trailing DS.
|
|
|
41 |
*/
|
|
|
42 |
|
|
|
43 |
/**
|
|
|
44 |
* The full path to the directory which holds "app", WITHOUT a trailing DS.
|
|
|
45 |
*
|
|
|
46 |
*/
|
|
|
47 |
if (!defined('ROOT')) {
|
|
|
48 |
define('ROOT', dirname(dirname(dirname(__FILE__))));
|
|
|
49 |
}
|
|
|
50 |
/**
|
|
|
51 |
* The actual directory name for the "app".
|
|
|
52 |
*
|
|
|
53 |
*/
|
|
|
54 |
if (!defined('APP_DIR')) {
|
|
|
55 |
define('APP_DIR', basename(dirname(dirname(__FILE__))));
|
|
|
56 |
}
|
|
|
57 |
/**
|
|
|
58 |
* The absolute path to the "cake" directory, WITHOUT a trailing DS.
|
|
|
59 |
*
|
|
|
60 |
*/
|
|
|
61 |
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
|
|
|
62 |
define('CAKE_CORE_INCLUDE_PATH', ROOT);
|
|
|
63 |
}
|
|
|
64 |
|
|
|
65 |
/**
|
|
|
66 |
* Editing below this line should not be necessary.
|
|
|
67 |
* Change at your own risk.
|
|
|
68 |
*
|
|
|
69 |
*/
|
|
|
70 |
if (!defined('WEBROOT_DIR')) {
|
|
|
71 |
define('WEBROOT_DIR', basename(dirname(__FILE__)));
|
|
|
72 |
}
|
|
|
73 |
if (!defined('WWW_ROOT')) {
|
|
|
74 |
define('WWW_ROOT', dirname(__FILE__) . DS);
|
|
|
75 |
}
|
|
|
76 |
if (!defined('CORE_PATH')) {
|
|
|
77 |
if (function_exists('ini_set') && ini_set('include_path', CAKE_CORE_INCLUDE_PATH . PATH_SEPARATOR . ROOT . DS . APP_DIR . DS . PATH_SEPARATOR . ini_get('include_path'))) {
|
|
|
78 |
define('APP_PATH', null);
|
|
|
79 |
define('CORE_PATH', null);
|
|
|
80 |
} else {
|
|
|
81 |
define('APP_PATH', ROOT . DS . APP_DIR . DS);
|
|
|
82 |
define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
|
|
|
83 |
}
|
|
|
84 |
}
|
|
|
85 |
if (!include(CORE_PATH . 'cake' . DS . 'bootstrap.php')) {
|
|
|
86 |
trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR);
|
|
|
87 |
}
|
|
|
88 |
|
|
|
89 |
$corePath = Configure::corePaths('cake');
|
|
|
90 |
if (isset($corePath[0])) {
|
|
|
91 |
define('TEST_CAKE_CORE_INCLUDE_PATH', rtrim($corePath[0], DS) . DS);
|
|
|
92 |
} else {
|
|
|
93 |
define('TEST_CAKE_CORE_INCLUDE_PATH', CAKE_CORE_INCLUDE_PATH);
|
|
|
94 |
}
|
|
|
95 |
|
|
|
96 |
require_once CAKE_TESTS_LIB . 'test_manager.php';
|
|
|
97 |
|
|
|
98 |
if (Configure::read('debug') < 1) {
|
|
|
99 |
die(__('Debug setting does not allow access to this url.', true));
|
|
|
100 |
}
|
|
|
101 |
|
|
|
102 |
if (!isset($_SERVER['SERVER_NAME'])) {
|
|
|
103 |
$_SERVER['SERVER_NAME'] = '';
|
|
|
104 |
}
|
|
|
105 |
if (empty( $_GET['output'])) {
|
|
|
106 |
$_GET['output'] = 'html';
|
|
|
107 |
}
|
|
|
108 |
/**
|
|
|
109 |
*
|
|
|
110 |
* Used to determine output to display
|
|
|
111 |
*/
|
|
|
112 |
define('CAKE_TEST_OUTPUT_HTML', 1);
|
|
|
113 |
define('CAKE_TEST_OUTPUT_TEXT', 2);
|
|
|
114 |
|
|
|
115 |
if (isset($_GET['output']) && $_GET['output'] == 'html') {
|
|
|
116 |
define('CAKE_TEST_OUTPUT', CAKE_TEST_OUTPUT_HTML);
|
|
|
117 |
} else {
|
|
|
118 |
Debugger::output('txt');
|
|
|
119 |
define('CAKE_TEST_OUTPUT', CAKE_TEST_OUTPUT_TEXT);
|
|
|
120 |
}
|
|
|
121 |
|
|
|
122 |
if (!App::import('Vendor', 'simpletest' . DS . 'reporter')) {
|
|
|
123 |
CakePHPTestHeader();
|
|
|
124 |
include CAKE_TESTS_LIB . 'simpletest.php';
|
|
|
125 |
CakePHPTestSuiteFooter();
|
|
|
126 |
exit();
|
|
|
127 |
}
|
|
|
128 |
|
|
|
129 |
$analyzeCodeCoverage = false;
|
|
|
130 |
if (isset($_GET['code_coverage'])) {
|
|
|
131 |
$analyzeCodeCoverage = true;
|
|
|
132 |
require_once CAKE_TESTS_LIB . 'code_coverage_manager.php';
|
|
|
133 |
if (!extension_loaded('xdebug')) {
|
|
|
134 |
CakePHPTestHeader();
|
|
|
135 |
include CAKE_TESTS_LIB . 'xdebug.php';
|
|
|
136 |
CakePHPTestSuiteFooter();
|
|
|
137 |
exit();
|
|
|
138 |
}
|
|
|
139 |
}
|
|
|
140 |
|
|
|
141 |
CakePHPTestHeader();
|
|
|
142 |
CakePHPTestSuiteHeader();
|
|
|
143 |
define('RUN_TEST_LINK', $_SERVER['PHP_SELF']);
|
|
|
144 |
|
|
|
145 |
if (isset($_GET['group'])) {
|
|
|
146 |
if ('all' == $_GET['group']) {
|
|
|
147 |
TestManager::runAllTests(CakeTestsGetReporter());
|
|
|
148 |
} else {
|
|
|
149 |
if ($analyzeCodeCoverage) {
|
|
|
150 |
CodeCoverageManager::start($_GET['group'], CakeTestsGetReporter());
|
|
|
151 |
}
|
|
|
152 |
TestManager::runGroupTest(ucfirst($_GET['group']), CakeTestsGetReporter());
|
|
|
153 |
if ($analyzeCodeCoverage) {
|
|
|
154 |
CodeCoverageManager::report();
|
|
|
155 |
}
|
|
|
156 |
}
|
|
|
157 |
|
|
|
158 |
CakePHPTestRunMore();
|
|
|
159 |
CakePHPTestAnalyzeCodeCoverage();
|
|
|
160 |
} elseif (isset($_GET['case'])) {
|
|
|
161 |
if ($analyzeCodeCoverage) {
|
|
|
162 |
CodeCoverageManager::start($_GET['case'], CakeTestsGetReporter());
|
|
|
163 |
}
|
|
|
164 |
|
|
|
165 |
TestManager::runTestCase($_GET['case'], CakeTestsGetReporter());
|
|
|
166 |
|
|
|
167 |
if ($analyzeCodeCoverage) {
|
|
|
168 |
CodeCoverageManager::report();
|
|
|
169 |
}
|
|
|
170 |
|
|
|
171 |
CakePHPTestRunMore();
|
|
|
172 |
CakePHPTestAnalyzeCodeCoverage();
|
|
|
173 |
} elseif (isset($_GET['show']) && $_GET['show'] == 'cases') {
|
|
|
174 |
CakePHPTestCaseList();
|
|
|
175 |
} else {
|
|
|
176 |
CakePHPTestGroupTestList();
|
|
|
177 |
}
|
|
|
178 |
CakePHPTestSuiteFooter();
|
|
|
179 |
$output = ob_get_clean();
|
|
|
180 |
echo $output;
|
|
|
181 |
?>
|