mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6527 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
3404ccc668
commit
10bdc235ee
6 changed files with 322 additions and 375 deletions
|
@ -69,7 +69,7 @@ if (isset($corePath[0])) {
|
|||
} else {
|
||||
define('TEST_CAKE_CORE_INCLUDE_PATH', CAKE_CORE_INCLUDE_PATH);
|
||||
}
|
||||
require_once CAKE . 'tests' . DS . 'lib' . DS . 'test_manager.php';
|
||||
require_once CAKE_TESTS_LIB . 'test_manager.php';
|
||||
|
||||
if (Configure::read('debug') < 1) {
|
||||
die(__('Debug setting does not allow access to this url.', true));
|
||||
|
@ -81,172 +81,45 @@ if (!isset($_SERVER['SERVER_NAME'])) {
|
|||
if (empty( $_GET['output'])) {
|
||||
$_GET['output'] = 'html';
|
||||
}
|
||||
|
||||
$dispatch =& new Dispatcher();
|
||||
$dispatch->baseUrl();
|
||||
define('BASE', $dispatch->webroot);
|
||||
|
||||
/**
|
||||
*
|
||||
* Used to determine output to display
|
||||
*/
|
||||
define('CAKE_TEST_OUTPUT_HTML',1);
|
||||
define('CAKE_TEST_OUTPUT_TEXT',2);
|
||||
define('CAKE_TEST_OUTPUT_HTML', 1);
|
||||
define('CAKE_TEST_OUTPUT_TEXT', 2);
|
||||
|
||||
if (isset($_GET['output']) && $_GET['output'] == 'html') {
|
||||
define('CAKE_TEST_OUTPUT', CAKE_TEST_OUTPUT_HTML);
|
||||
} else {
|
||||
Debugger::output('txt');
|
||||
define('CAKE_TEST_OUTPUT', CAKE_TEST_OUTPUT_TEXT);
|
||||
}
|
||||
|
||||
if (!App::import('Vendor', 'simpletest' . DS . 'reporter')) {
|
||||
CakePHPTestHeader();
|
||||
include CAKE . 'tests' . DS . 'lib' . DS . 'simpletest.php';
|
||||
include CAKE_TESTS_LIB . 'simpletest.php';
|
||||
CakePHPTestSuiteFooter();
|
||||
exit();
|
||||
}
|
||||
|
||||
function &CakeTestsGetReporter() {
|
||||
static $Reporter = NULL;
|
||||
if (!$Reporter) {
|
||||
switch (CAKE_TEST_OUTPUT) {
|
||||
case CAKE_TEST_OUTPUT_HTML:
|
||||
require_once LIB_TESTS . 'cake_reporter.php';
|
||||
$Reporter = new CakeHtmlReporter();
|
||||
break;
|
||||
default:
|
||||
$Reporter = new TextReporter();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $Reporter;
|
||||
}
|
||||
CakePHPTestHeader();
|
||||
CakePHPTestSuiteHeader();
|
||||
define('RUN_TEST_LINK', $_SERVER['PHP_SELF']);
|
||||
|
||||
function CakePHPTestRunMore() {
|
||||
switch (CAKE_TEST_OUTPUT) {
|
||||
case CAKE_TEST_OUTPUT_HTML:
|
||||
if (isset($_GET['group'])) {
|
||||
if (isset($_GET['app'])) {
|
||||
$show = '?show=groups&app=true';
|
||||
} else {
|
||||
$show = '?show=groups';
|
||||
}
|
||||
}
|
||||
if (isset($_GET['case'])) {
|
||||
if (isset($_GET['app'])) {
|
||||
$show = '?show=cases&app=true';
|
||||
} else {
|
||||
$show = '?show=cases';
|
||||
}
|
||||
}
|
||||
echo "<p><a href='" . RUN_TEST_LINK . $show . "'>Run more tests</a></p>\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function CakePHPTestCaseList() {
|
||||
switch (CAKE_TEST_OUTPUT) {
|
||||
case CAKE_TEST_OUTPUT_HTML:
|
||||
if (isset($_GET['app'])) {
|
||||
echo HtmlTestManager::getTestCaseList(APP_TEST_CASES);
|
||||
} else {
|
||||
echo HtmlTestManager::getTestCaseList(CORE_TEST_CASES);
|
||||
}
|
||||
break;
|
||||
case CAKE_TEST_OUTPUT_TEXT:
|
||||
default:
|
||||
if (isset($_GET['app'])) {
|
||||
echo TextTestManager::getTestCaseList(APP_TEST_CASES);
|
||||
} else {
|
||||
echo TextTestManager::getTestCaseList(CORE_TEST_CASES);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function CakePHPTestGroupTestList() {
|
||||
switch (CAKE_TEST_OUTPUT) {
|
||||
case CAKE_TEST_OUTPUT_HTML:
|
||||
if (isset($_GET['app'])) {
|
||||
echo HtmlTestManager::getGroupTestList(APP_TEST_GROUPS);
|
||||
} else {
|
||||
echo HtmlTestManager::getGroupTestList(CORE_TEST_GROUPS);
|
||||
}
|
||||
break;
|
||||
case CAKE_TEST_OUTPUT_TEXT:
|
||||
default:
|
||||
if (isset($_GET['app'])) {
|
||||
echo TextTestManager::getGroupTestList(APP_TEST_GROUPS);
|
||||
} else {
|
||||
echo TextTestManager::getGroupTestList(CORE_TEST_GROUPS);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function CakePHPTestHeader() {
|
||||
switch (CAKE_TEST_OUTPUT) {
|
||||
case CAKE_TEST_OUTPUT_HTML:
|
||||
$baseUrl = BASE;
|
||||
$characterSet = 'charset=utf-8';
|
||||
include CAKE . 'tests' . DS . 'lib' . DS . 'header.php';
|
||||
break;
|
||||
case CAKE_TEST_OUTPUT_TEXT:
|
||||
default:
|
||||
header(' content-type: text/plain');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function CakePHPTestSuiteHeader() {
|
||||
switch (CAKE_TEST_OUTPUT) {
|
||||
case CAKE_TEST_OUTPUT_HTML:
|
||||
$groups = $_SERVER['PHP_SELF'].'?show=groups';
|
||||
$cases = $_SERVER['PHP_SELF'].'?show=cases';
|
||||
include CAKE . 'tests' . DS . 'lib' . DS . 'content.php';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function CakePHPTestSuiteFooter() {
|
||||
switch ( CAKE_TEST_OUTPUT) {
|
||||
case CAKE_TEST_OUTPUT_HTML:
|
||||
$baseUrl = BASE;
|
||||
include CAKE . 'tests' . DS . 'lib' . DS . 'footer.php';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CakePHPTestHeader();
|
||||
CakePHPTestSuiteHeader();
|
||||
define('RUN_TEST_LINK', $_SERVER['PHP_SELF']);
|
||||
|
||||
if (isset($_GET['group'])) {
|
||||
if ('all' == $_GET['group']) {
|
||||
TestManager::runAllTests(CakeTestsGetReporter());
|
||||
} else {
|
||||
if (isset($_GET['app'])) {
|
||||
TestManager::runGroupTest(ucfirst($_GET['group']), APP_TEST_GROUPS, CakeTestsGetReporter());
|
||||
} else {
|
||||
TestManager::runGroupTest(ucfirst($_GET['group']), CORE_TEST_GROUPS, CakeTestsGetReporter());
|
||||
}
|
||||
}
|
||||
CakePHPTestRunMore();
|
||||
CakePHPTestSuiteFooter();
|
||||
exit();
|
||||
}
|
||||
|
||||
if (isset($_GET['case'])) {
|
||||
TestManager::runTestCase($_GET['case'], CakeTestsGetReporter());
|
||||
CakePHPTestRunMore();
|
||||
CakePHPTestSuiteFooter();
|
||||
exit();
|
||||
}
|
||||
|
||||
if (isset($_GET['show']) && $_GET['show'] == 'cases') {
|
||||
CakePHPTestCaseList();
|
||||
if (isset($_GET['group'])) {
|
||||
if ('all' == $_GET['group']) {
|
||||
TestManager::runAllTests(CakeTestsGetReporter());
|
||||
} else {
|
||||
CakePHPTestGroupTestList();
|
||||
TestManager::runGroupTest(ucfirst($_GET['group']), CakeTestsGetReporter());
|
||||
}
|
||||
CakePHPTestSuiteFooter();
|
||||
CakePHPTestRunMore();
|
||||
} elseif (isset($_GET['case'])) {
|
||||
TestManager::runTestCase($_GET['case'], CakeTestsGetReporter());
|
||||
CakePHPTestRunMore();
|
||||
}elseif (isset($_GET['show']) && $_GET['show'] == 'cases') {
|
||||
CakePHPTestCaseList();
|
||||
} else {
|
||||
CakePHPTestGroupTestList();
|
||||
}
|
||||
CakePHPTestSuiteFooter();
|
||||
?>
|
|
@ -114,6 +114,17 @@
|
|||
if (!defined('TESTS')) {
|
||||
define ('TESTS', APP.'tests'.DS);
|
||||
}
|
||||
/**
|
||||
* Path to the core tests directory.
|
||||
*/
|
||||
if (!defined('CAKE_TESTS')) {
|
||||
define ('CAKE_TESTS', CAKE.'tests'.DS);
|
||||
}
|
||||
/**
|
||||
* Path to the test suite.
|
||||
*/
|
||||
define ('CAKE_TESTS_LIB', CAKE_TESTS.'lib'.DS);
|
||||
|
||||
/**
|
||||
* Path to the controller test directory.
|
||||
*/
|
||||
|
@ -133,7 +144,7 @@ if (!defined('TESTS')) {
|
|||
/**
|
||||
* Path to the lib test directory.
|
||||
*/
|
||||
define ('LIB_TESTS', CAKE.'tests'.DS.'lib'.DS);
|
||||
define ('LIB_TESTS', CAKE_TESTS.'cases'.DS.'lib'.DS);
|
||||
/**
|
||||
* Path to the temporary files directory.
|
||||
*/
|
||||
|
|
|
@ -69,7 +69,7 @@ if (isset($corePath[0])) {
|
|||
} else {
|
||||
define('TEST_CAKE_CORE_INCLUDE_PATH', CAKE_CORE_INCLUDE_PATH);
|
||||
}
|
||||
require_once CAKE . 'tests' . DS . 'lib' . DS . 'test_manager.php';
|
||||
require_once CAKE_TESTS_LIB . 'test_manager.php';
|
||||
|
||||
if (Configure::read('debug') < 1) {
|
||||
die(__('Debug setting does not allow access to this url.', true));
|
||||
|
@ -81,172 +81,45 @@ if (!isset($_SERVER['SERVER_NAME'])) {
|
|||
if (empty( $_GET['output'])) {
|
||||
$_GET['output'] = 'html';
|
||||
}
|
||||
|
||||
$dispatch =& new Dispatcher();
|
||||
$dispatch->baseUrl();
|
||||
define('BASE', $dispatch->webroot);
|
||||
|
||||
/**
|
||||
*
|
||||
* Used to determine output to display
|
||||
*/
|
||||
define('CAKE_TEST_OUTPUT_HTML',1);
|
||||
define('CAKE_TEST_OUTPUT_TEXT',2);
|
||||
define('CAKE_TEST_OUTPUT_HTML', 1);
|
||||
define('CAKE_TEST_OUTPUT_TEXT', 2);
|
||||
|
||||
if (isset($_GET['output']) && $_GET['output'] == 'html') {
|
||||
define('CAKE_TEST_OUTPUT', CAKE_TEST_OUTPUT_HTML);
|
||||
} else {
|
||||
Debugger::output('txt');
|
||||
define('CAKE_TEST_OUTPUT', CAKE_TEST_OUTPUT_TEXT);
|
||||
}
|
||||
|
||||
if (!App::import('Vendor', 'simpletest' . DS . 'reporter')) {
|
||||
CakePHPTestHeader();
|
||||
include CAKE . 'tests' . DS . 'lib' . DS . 'simpletest.php';
|
||||
include CAKE_TESTS_LIB . 'simpletest.php';
|
||||
CakePHPTestSuiteFooter();
|
||||
exit();
|
||||
}
|
||||
|
||||
function &CakeTestsGetReporter() {
|
||||
static $Reporter = NULL;
|
||||
if (!$Reporter) {
|
||||
switch (CAKE_TEST_OUTPUT) {
|
||||
case CAKE_TEST_OUTPUT_HTML:
|
||||
require_once LIB_TESTS . 'cake_reporter.php';
|
||||
$Reporter = new CakeHtmlReporter();
|
||||
break;
|
||||
default:
|
||||
$Reporter = new TextReporter();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $Reporter;
|
||||
}
|
||||
CakePHPTestHeader();
|
||||
CakePHPTestSuiteHeader();
|
||||
define('RUN_TEST_LINK', $_SERVER['PHP_SELF']);
|
||||
|
||||
function CakePHPTestRunMore() {
|
||||
switch (CAKE_TEST_OUTPUT) {
|
||||
case CAKE_TEST_OUTPUT_HTML:
|
||||
if (isset($_GET['group'])) {
|
||||
if (isset($_GET['app'])) {
|
||||
$show = '?show=groups&app=true';
|
||||
} else {
|
||||
$show = '?show=groups';
|
||||
}
|
||||
}
|
||||
if (isset($_GET['case'])) {
|
||||
if (isset($_GET['app'])) {
|
||||
$show = '??show=cases&app=truee';
|
||||
} else {
|
||||
$show = '?show=cases';
|
||||
}
|
||||
}
|
||||
echo "<p><a href='" . RUN_TEST_LINK . $show . "'>Run more tests</a></p>\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function CakePHPTestCaseList() {
|
||||
switch (CAKE_TEST_OUTPUT) {
|
||||
case CAKE_TEST_OUTPUT_HTML:
|
||||
if (isset($_GET['app'])) {
|
||||
echo HtmlTestManager::getTestCaseList(APP_TEST_CASES);
|
||||
} else {
|
||||
echo HtmlTestManager::getTestCaseList(CORE_TEST_CASES);
|
||||
}
|
||||
break;
|
||||
case CAKE_TEST_OUTPUT_TEXT:
|
||||
default:
|
||||
if (isset($_GET['app'])) {
|
||||
echo TextTestManager::getTestCaseList(APP_TEST_CASES);
|
||||
} else {
|
||||
echo TextTestManager::getTestCaseList(CORE_TEST_CASES);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function CakePHPTestGroupTestList() {
|
||||
switch (CAKE_TEST_OUTPUT) {
|
||||
case CAKE_TEST_OUTPUT_HTML:
|
||||
if (isset($_GET['app'])) {
|
||||
echo HtmlTestManager::getGroupTestList(APP_TEST_GROUPS);
|
||||
} else {
|
||||
echo HtmlTestManager::getGroupTestList(CORE_TEST_GROUPS);
|
||||
}
|
||||
break;
|
||||
case CAKE_TEST_OUTPUT_TEXT:
|
||||
default:
|
||||
if (isset($_GET['app'])) {
|
||||
echo TextTestManager::getGroupTestList(APP_TEST_GROUPS);
|
||||
} else {
|
||||
echo TextTestManager::getGroupTestList(CORE_TEST_GROUPS);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function CakePHPTestHeader() {
|
||||
switch (CAKE_TEST_OUTPUT) {
|
||||
case CAKE_TEST_OUTPUT_HTML:
|
||||
$baseUrl = BASE;
|
||||
$characterSet = 'charset=utf-8';
|
||||
include CAKE . 'tests' . DS . 'lib' . DS . 'header.php';
|
||||
break;
|
||||
case CAKE_TEST_OUTPUT_TEXT:
|
||||
default:
|
||||
header(' content-type: text/plain');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function CakePHPTestSuiteHeader() {
|
||||
switch (CAKE_TEST_OUTPUT) {
|
||||
case CAKE_TEST_OUTPUT_HTML:
|
||||
$groups = $_SERVER['PHP_SELF'].'?show=groups';
|
||||
$cases = $_SERVER['PHP_SELF'].'?show=cases';
|
||||
include CAKE . 'tests' . DS . 'lib' . DS . 'content.php';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function CakePHPTestSuiteFooter() {
|
||||
switch ( CAKE_TEST_OUTPUT) {
|
||||
case CAKE_TEST_OUTPUT_HTML:
|
||||
$baseUrl = BASE;
|
||||
include CAKE . 'tests' . DS . 'lib' . DS . 'footer.php';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CakePHPTestHeader();
|
||||
CakePHPTestSuiteHeader();
|
||||
define('RUN_TEST_LINK', $_SERVER['PHP_SELF']);
|
||||
|
||||
if (isset($_GET['group'])) {
|
||||
if ('all' == $_GET['group']) {
|
||||
TestManager::runAllTests(CakeTestsGetReporter());
|
||||
} else {
|
||||
if (isset($_GET['app'])) {
|
||||
TestManager::runGroupTest(ucfirst($_GET['group']), APP_TEST_GROUPS, CakeTestsGetReporter());
|
||||
} else {
|
||||
TestManager::runGroupTest(ucfirst($_GET['group']), CORE_TEST_GROUPS, CakeTestsGetReporter());
|
||||
}
|
||||
}
|
||||
CakePHPTestRunMore();
|
||||
CakePHPTestSuiteFooter();
|
||||
exit();
|
||||
}
|
||||
|
||||
if (isset($_GET['case'])) {
|
||||
TestManager::runTestCase($_GET['case'], CakeTestsGetReporter());
|
||||
CakePHPTestRunMore();
|
||||
CakePHPTestSuiteFooter();
|
||||
exit();
|
||||
}
|
||||
|
||||
if (isset($_GET['show']) && $_GET['show'] == 'cases') {
|
||||
CakePHPTestCaseList();
|
||||
if (isset($_GET['group'])) {
|
||||
if ('all' == $_GET['group']) {
|
||||
TestManager::runAllTests(CakeTestsGetReporter());
|
||||
} else {
|
||||
CakePHPTestGroupTestList();
|
||||
TestManager::runGroupTest(ucfirst($_GET['group']), CakeTestsGetReporter());
|
||||
}
|
||||
CakePHPTestSuiteFooter();
|
||||
CakePHPTestRunMore();
|
||||
} elseif (isset($_GET['case'])) {
|
||||
TestManager::runTestCase($_GET['case'], CakeTestsGetReporter());
|
||||
CakePHPTestRunMore();
|
||||
}elseif (isset($_GET['show']) && $_GET['show'] == 'cases') {
|
||||
CakePHPTestCaseList();
|
||||
} else {
|
||||
CakePHPTestGroupTestList();
|
||||
}
|
||||
CakePHPTestSuiteFooter();
|
||||
?>
|
|
@ -26,8 +26,8 @@
|
|||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||
*/
|
||||
require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_test_model.php';
|
||||
require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_test_fixture.php';
|
||||
require_once CAKE_TESTS_LIB . 'cake_test_model.php';
|
||||
require_once CAKE_TESTS_LIB . 'cake_test_fixture.php';
|
||||
!App::import('Vendor', 'simpletest' . DS . 'unit_tester');
|
||||
/**
|
||||
* Short description for class.
|
||||
|
@ -473,7 +473,16 @@ class CakeTestCase extends UnitTestCase {
|
|||
} elseif (strpos($fixture, 'app.') === 0) {
|
||||
$fixture = substr($fixture, strlen('app.'));
|
||||
$fixturePaths = array(
|
||||
TESTS . DS . 'fixtures',
|
||||
TESTS . 'fixtures',
|
||||
VENDORS . 'tests' . DS . 'fixtures'
|
||||
);
|
||||
} elseif (strpos($fixture, 'plugin.') === 0) {
|
||||
$parts = explode('.', $fixture, 3);
|
||||
$pluginName = $parts[1];
|
||||
$fixture = $parts[2];
|
||||
$fixturePaths = array(
|
||||
APP . 'plugins' . DS . $pluginName . DS . 'tests' . DS . 'fixtures',
|
||||
TESTS . 'fixtures',
|
||||
VENDORS . 'tests' . DS . 'fixtures'
|
||||
);
|
||||
} else {
|
||||
|
|
|
@ -27,12 +27,39 @@
|
|||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||
*/
|
||||
?>
|
||||
<ul>
|
||||
<li>
|
||||
<span style="font-size: 18px">Core</span>
|
||||
<ul>
|
||||
<li><a href='<?php echo $groups;?>'>Test Groups</a></li>
|
||||
<li><a href='<?php echo $cases;?>'>Test Cases</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li style="padding-top: 10px">
|
||||
<span style="font-size: 18px">App</span>
|
||||
<ul>
|
||||
<li><a href='<?php echo $groups;?>&app=true'>Test Groups</a></li>
|
||||
<li><a href='<?php echo $cases;?>&app=true'>Test Cases</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php
|
||||
if (!empty($plugins)):
|
||||
?>
|
||||
<li style="padding-top: 10px">
|
||||
<span style="font-size: 18px">Plugins</span>
|
||||
<?php foreach($plugins as $plugin):
|
||||
$pluginPath = Inflector::underscore($plugin);
|
||||
?>
|
||||
<ul>
|
||||
<li><a href='<?php echo $groups;?>'>Core Test Groups</a></li>
|
||||
<li><a href='<?php echo $cases;?>'>Core Test Cases</a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href='<?php echo $groups;?>&app=true'>App Test Groups</a></li>
|
||||
<li><a href='<?php echo $cases;?>&app=true'>App Test Cases</a></li>
|
||||
<li style="padding-top: 10px">
|
||||
<span style="font-size: 18px"><?php echo $plugin;?></span>
|
||||
<ul>
|
||||
<li><a href='<?php echo $groups;?>&plugin=<?php echo $pluginPath; ?>'>Test Groups</a></li>
|
||||
<li><a href='<?php echo $cases;?>&plugin=<?php echo $pluginPath; ?>'>Test Cases</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<?php endforeach; ?>
|
||||
<?php endif;?>
|
||||
</ul>
|
||||
|
||||
|
|
|
@ -39,34 +39,34 @@ define ('APP_TEST_GROUPS', APP . 'tests' .DS. 'groups');
|
|||
class TestManager {
|
||||
var $_testExtension = '.test.php';
|
||||
var $_groupExtension = '.group.php';
|
||||
var $usersAppTest = false;
|
||||
var $appTest = false;
|
||||
var $pluginTest = false;
|
||||
|
||||
function TestManager() {
|
||||
$this->_installSimpleTest();
|
||||
if (isset($_GET['app'])) {
|
||||
$this->usersAppTest = true;
|
||||
$this->appTest = true;
|
||||
}
|
||||
if (isset($_GET['plugin'])) {
|
||||
$this->pluginTest = $_GET['plugin'];
|
||||
}
|
||||
}
|
||||
|
||||
function _installSimpleTest() {
|
||||
App::import('Vendor', array('simpletest'.DS.'unit_tester', 'simpletest'.DS.'mock_objects', 'simpletest'.DS.'web_tester'));
|
||||
require_once(LIB_TESTS . 'cake_web_test_case.php');
|
||||
require_once(LIB_TESTS . 'cake_test_case.php');
|
||||
require_once(CAKE_TESTS_LIB . 'cake_web_test_case.php');
|
||||
require_once(CAKE_TESTS_LIB . 'cake_test_case.php');
|
||||
}
|
||||
|
||||
function runAllTests(&$reporter) {
|
||||
$manager =& new TestManager();
|
||||
|
||||
if (!empty($manager->usersAppTest)) {
|
||||
$testCasePath = APP_TEST_CASES;
|
||||
} else {
|
||||
$testCasePath = CORE_TEST_CASES;
|
||||
}
|
||||
$testCases =& $manager->_getTestFileList($testCasePath);
|
||||
$test =& new GroupTest('All Core Tests');
|
||||
$testCases =& $manager->_getTestFileList($manager->_getTestsPath());
|
||||
|
||||
if (isset($_GET['app'])) {
|
||||
if ($manager->appTest) {
|
||||
$test =& new GroupTest('All App Tests');
|
||||
} else if ($manager->pluginTest) {
|
||||
$test =& new GroupTest('All ' . Inflector::humanize($manager->pluginTest) . ' Plugin Tests');
|
||||
} else {
|
||||
$test =& new GroupTest('All Core Tests');
|
||||
}
|
||||
|
@ -80,11 +80,7 @@ class TestManager {
|
|||
function runTestCase($testCaseFile, &$reporter) {
|
||||
$manager =& new TestManager();
|
||||
|
||||
if (!empty($manager->usersAppTest)) {
|
||||
$testCaseFileWithPath = APP_TEST_CASES . DIRECTORY_SEPARATOR . $testCaseFile;
|
||||
} else {
|
||||
$testCaseFileWithPath = CORE_TEST_CASES . DIRECTORY_SEPARATOR . $testCaseFile;
|
||||
}
|
||||
$testCaseFileWithPath = $manager->_getTestsPath() . DS . $testCaseFile;
|
||||
if (! file_exists($testCaseFileWithPath)) {
|
||||
trigger_error("Test case {$testCaseFile} cannot be found", E_USER_ERROR);
|
||||
}
|
||||
|
@ -93,10 +89,9 @@ class TestManager {
|
|||
return $test->run($reporter);
|
||||
}
|
||||
|
||||
function runGroupTest($groupTestName, $groupTestDirectory, &$reporter) {
|
||||
function runGroupTest($groupTestName, &$reporter) {
|
||||
$manager =& new TestManager();
|
||||
$filePath = $groupTestDirectory . DIRECTORY_SEPARATOR .
|
||||
strtolower($groupTestName) . $manager->_groupExtension;
|
||||
$filePath = $manager->_getTestsPath('groups') . DS . strtolower($groupTestName) . $manager->_groupExtension;
|
||||
|
||||
if (! file_exists($filePath)) {
|
||||
trigger_error("Group test {$groupTestName} cannot be found at {$filePath}", E_USER_ERROR);
|
||||
|
@ -127,9 +122,9 @@ class TestManager {
|
|||
$groupTest->addTestFile($file.'.test.php');
|
||||
}
|
||||
|
||||
function &getTestCaseList($directory = '.') {
|
||||
function &getTestCaseList() {
|
||||
$manager =& new TestManager();
|
||||
$return = $manager->_getTestCaseList($directory);
|
||||
$return = $manager->_getTestCaseList($manager->_getTestsPath());
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
@ -147,9 +142,9 @@ class TestManager {
|
|||
return $return;
|
||||
}
|
||||
|
||||
function &getGroupTestList($directory = '.') {
|
||||
function &getGroupTestList() {
|
||||
$manager =& new TestManager();
|
||||
$return = $manager->_getTestGroupList($directory);
|
||||
$return = $manager->_getTestGroupList($manager->_getTestsPath('groups'));
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
@ -181,12 +176,15 @@ class TestManager {
|
|||
}
|
||||
|
||||
function &_getRecursiveFileList($directory = '.', $fileTestFunction) {
|
||||
$fileList = array();
|
||||
if (!is_dir($directory)) {
|
||||
return $fileList;
|
||||
}
|
||||
$dh = opendir($directory);
|
||||
if (! is_resource($dh)) {
|
||||
trigger_error("Couldn't open {$directory}", E_USER_ERROR);
|
||||
}
|
||||
|
||||
$fileList = array();
|
||||
while ($file = readdir($dh)) {
|
||||
$filePath = $directory . DIRECTORY_SEPARATOR . $file;
|
||||
if (0 === strpos($file, '.')) {
|
||||
|
@ -215,6 +213,26 @@ class TestManager {
|
|||
function _hasExpectedExtension($file, $extension) {
|
||||
return $extension == strtolower(substr($file, (0 - strlen($extension))));
|
||||
}
|
||||
|
||||
function _getTestsPath($type = 'cases') {
|
||||
if (!empty($this->appTest)) {
|
||||
if ($type == 'cases') {
|
||||
$result = APP_TEST_CASES;
|
||||
} else if ($type == 'groups') {
|
||||
$result = APP_TEST_GROUPS;
|
||||
}
|
||||
} else if (!empty($this->pluginTest)) {
|
||||
$_pluginBasePath = APP . 'plugins' . DS . $this->pluginTest . DS . 'tests';
|
||||
$result = $_pluginBasePath . DS . $type;
|
||||
} else {
|
||||
if ($type == 'cases') {
|
||||
$result = CORE_TEST_CASES;
|
||||
} else if ($type == 'groups') {
|
||||
$result = CORE_TEST_GROUPS;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Short description for class.
|
||||
|
@ -224,9 +242,9 @@ class TestManager {
|
|||
*/
|
||||
class CliTestManager extends TestManager {
|
||||
|
||||
function &getGroupTestList($directory = '.') {
|
||||
function &getGroupTestList() {
|
||||
$manager =& new CliTestManager();
|
||||
$groupTests =& $manager->_getTestGroupList($directory);
|
||||
$groupTests =& $manager->_getTestGroupList($manager->_getTestsPath('groups'));
|
||||
$buffer = "Available Group Test:\n";
|
||||
|
||||
foreach ($groupTests as $groupTest) {
|
||||
|
@ -235,9 +253,9 @@ class CliTestManager extends TestManager {
|
|||
return $buffer . "\n";
|
||||
}
|
||||
|
||||
function &getTestCaseList($directory = '.') {
|
||||
function &getTestCaseList() {
|
||||
$manager =& new CliTestManager();
|
||||
$testCases =& $manager->_getTestCaseList($directory);
|
||||
$testCases =& $manager->_getTestCaseList($manager->_getTestsPath());
|
||||
$buffer = "Available Test Cases:\n";
|
||||
|
||||
foreach ($testCases as $testCaseFile => $testCase) {
|
||||
|
@ -256,6 +274,7 @@ class TextTestManager extends TestManager {
|
|||
var $_url;
|
||||
|
||||
function TextTestManager() {
|
||||
parent::TestManager();
|
||||
$this->_url = $_SERVER['PHP_SELF'];
|
||||
}
|
||||
|
||||
|
@ -263,33 +282,54 @@ class TextTestManager extends TestManager {
|
|||
return $this->_url;
|
||||
}
|
||||
|
||||
function &getGroupTestList($directory = '.') {
|
||||
function &getGroupTestList() {
|
||||
$manager =& new TextTestManager();
|
||||
$groupTests =& $manager->_getTestGroupList($directory);
|
||||
$groupTests =& $manager->_getTestGroupList($manager->_getTestsPath('groups'));
|
||||
|
||||
$buffer = "Available test groups:\n";
|
||||
$buffer .= $manager->getBaseURL() . "?group=all All tests<\n";
|
||||
$buffer = "Core Test Groups:\n";
|
||||
$urlExtra = null;
|
||||
if ($manager->appTest) {
|
||||
$buffer = "App Test Groups:\n";
|
||||
$urlExtra = '&app=true';
|
||||
} else if ($manager->pluginTest) {
|
||||
$buffer = Inflector::humanize($manager->pluginTest) . " Test Groups:\n";
|
||||
$urlExtra = '&plugin=' . $manager->pluginTest;
|
||||
}
|
||||
|
||||
$buffer .= "All tests\n" . $_SERVER['SERVER_NAME'] . $manager->getBaseURL() . "?group=all&output=txt{$urlExtra}\n";
|
||||
|
||||
foreach ((array)$groupTests as $groupTest) {
|
||||
$buffer .= "<li><a href='" . $manager->getBaseURL() . "?group={$groupTest}'>" . $groupTest . "&output=txt"."</a></li>\n";
|
||||
$buffer .= $_SERVER['SERVER_NAME']. $manager->getBaseURL()."?group=" . $groupTest . "&output=txt{$urlExtra}"."\n";
|
||||
}
|
||||
return $buffer . "</ul>\n";
|
||||
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
function &getTestCaseList($directory = '.') {
|
||||
function &getTestCaseList() {
|
||||
$manager =& new TextTestManager();
|
||||
$testCases =& $manager->_getTestCaseList($directory);
|
||||
$testCases =& $manager->_getTestCaseList($manager->_getTestsPath());
|
||||
|
||||
$buffer = "Core Test Cases:\n";
|
||||
$urlExtra = null;
|
||||
if ($manager->appTest) {
|
||||
$buffer = "App Test Cases:\n";
|
||||
$urlExtra = '&app=true';
|
||||
} else if ($manager->pluginTest) {
|
||||
$buffer = Inflector::humanize($manager->pluginTest) . " Test Cases:\n";
|
||||
$urlExtra = '&plugin=' . $manager->pluginTest;
|
||||
}
|
||||
|
||||
if (1 > count($testCases)) {
|
||||
$noTestCases = "No test cases set up!";
|
||||
return $noTestCases;
|
||||
$buffer .= "EMPTY";
|
||||
return $buffer;
|
||||
}
|
||||
$buffer = "Available test cases:\n";
|
||||
|
||||
foreach ($testCases as $testCaseFile => $testCase) {
|
||||
$buffer .= $_SERVER['SERVER_NAME']. $manager->getBaseURL()."?case=" . $testCase . "&output=txt"."\n";
|
||||
}
|
||||
return $buffer . "\n";
|
||||
|
||||
$buffer .= "\n";
|
||||
return $buffer;
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
@ -302,6 +342,7 @@ class HtmlTestManager extends TestManager {
|
|||
var $_url;
|
||||
|
||||
function HtmlTestManager() {
|
||||
parent::TestManager();
|
||||
$this->_url = $_SERVER['PHP_SELF'];
|
||||
}
|
||||
|
||||
|
@ -309,50 +350,163 @@ class HtmlTestManager extends TestManager {
|
|||
return $this->_url;
|
||||
}
|
||||
|
||||
function &getGroupTestList($directory = '.') {
|
||||
$userApp = '';
|
||||
if (isset($_GET['app'])) {
|
||||
$userApp = '&app=true';
|
||||
}
|
||||
function &getGroupTestList() {
|
||||
$urlExtra = '';
|
||||
$manager =& new HtmlTestManager();
|
||||
$groupTests =& $manager->_getTestGroupList($directory);
|
||||
$groupTests =& $manager->_getTestGroupList($manager->_getTestsPath('groups'));
|
||||
|
||||
if (isset($_GET['app'])) {
|
||||
$buffer = "<h3>Available App Test Groups:</h3>\n<ul>";
|
||||
} else {
|
||||
$buffer = "<h3>Available Core Test Groups:</h3>\n<ul>";
|
||||
$buffer = "<h3>Core Test Groups:</h3>\n<ul>";
|
||||
$urlExtra = null;
|
||||
if ($manager->appTest) {
|
||||
$buffer = "<h3>App Test Groups:</h3>\n<ul>";
|
||||
$urlExtra = '&app=true';
|
||||
} else if ($manager->pluginTest) {
|
||||
$buffer = "<h3>" . Inflector::humanize($manager->pluginTest) . " Test Groups:</h3>\n<ul>";
|
||||
$urlExtra = '&plugin=' . $manager->pluginTest;
|
||||
}
|
||||
$buffer .= "<li><a href='" . $manager->getBaseURL() . "?group=all$userApp'>All tests</a></li>\n";
|
||||
|
||||
$buffer .= "<li><a href='" . $manager->getBaseURL() . "?group=all$urlExtra'>All tests</a></li>\n";
|
||||
|
||||
foreach ((array)$groupTests as $groupTest) {
|
||||
$buffer .= "<li><a href='" . $manager->getBaseURL() . "?group={$groupTest}" . "{$userApp}'>" . $groupTest . "</a></li>\n";
|
||||
$buffer .= "<li><a href='" . $manager->getBaseURL() . "?group={$groupTest}" . "{$urlExtra}'>" . $groupTest . "</a></li>\n";
|
||||
}
|
||||
$buffer .= "</ul>\n";
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
function &getTestCaseList($directory = '.') {
|
||||
$userApp = '';
|
||||
if (isset($_GET['app'])) {
|
||||
$userApp = '&app=true';
|
||||
}
|
||||
function &getTestCaseList() {
|
||||
$urlExtra = '';
|
||||
$manager =& new HtmlTestManager();
|
||||
$testCases =& $manager->_getTestCaseList($directory);
|
||||
$testCases =& $manager->_getTestCaseList($manager->_getTestsPath());
|
||||
|
||||
$buffer = "<h3>Core Test Cases:</h3>\n<ul>";
|
||||
$urlExtra = null;
|
||||
if ($manager->appTest) {
|
||||
$buffer = "<h3>App Test Cases:</h3>\n<ul>";
|
||||
$urlExtra = '&app=true';
|
||||
} else if ($manager->pluginTest) {
|
||||
$buffer = "<h3>" . Inflector::humanize($manager->pluginTest) . " Test Cases:</h3>\n<ul>";
|
||||
$urlExtra = '&plugin=' . $manager->pluginTest;
|
||||
}
|
||||
|
||||
if (1 > count($testCases)) {
|
||||
$noTestCases = "<h3>No test cases set up!</h3>";
|
||||
return $noTestCases;
|
||||
}
|
||||
if (isset($_GET['app'])) {
|
||||
$buffer = "<h3>Available App Test Cases:</h3>\n<ul>";
|
||||
} else {
|
||||
$buffer = "<h3>Available Core Test Cases:</h3>\n<ul>";
|
||||
$buffer .= "<strong>EMPTY</strong>";
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
foreach ($testCases as $testCaseFile => $testCase) {
|
||||
$buffer .= "<li><a href='" . $manager->getBaseURL() . "?case=" . urlencode($testCase) . $userApp ."'>" . $testCase . "</a></li>\n";
|
||||
$buffer .= "<li><a href='" . $manager->getBaseURL() . "?case=" . urlencode($testCase) . $urlExtra ."'>" . $testCase . "</a></li>\n";
|
||||
}
|
||||
$buffer .= "</ul>\n";
|
||||
return $buffer;
|
||||
}
|
||||
}
|
||||
if (function_exists('caketestsgetreporter')) {
|
||||
echo "You need a new test.php. \n";
|
||||
echo "Try this one: " . CONSOLE_LIBS . "templates" . DS . "skel" . DS . "webroot" . DS . "test.php";
|
||||
exit();
|
||||
} else {
|
||||
function &CakeTestsGetReporter() {
|
||||
static $Reporter = NULL;
|
||||
if (!$Reporter) {
|
||||
switch (CAKE_TEST_OUTPUT) {
|
||||
case CAKE_TEST_OUTPUT_HTML:
|
||||
require_once CAKE_TESTS_LIB . 'cake_reporter.php';
|
||||
$Reporter = new CakeHtmlReporter();
|
||||
break;
|
||||
default:
|
||||
$Reporter = new TextReporter();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $Reporter;
|
||||
}
|
||||
|
||||
function CakePHPTestRunMore() {
|
||||
switch (CAKE_TEST_OUTPUT) {
|
||||
case CAKE_TEST_OUTPUT_HTML:
|
||||
if (isset($_GET['group'])) {
|
||||
if (isset($_GET['app'])) {
|
||||
$show = '?show=groups&app=true';
|
||||
} else if (isset($_GET['plugin'])) {
|
||||
$show = '?show=groups&plugin=' . $_GET['plugin'];
|
||||
} else {
|
||||
$show = '?show=groups';
|
||||
}
|
||||
}
|
||||
if (isset($_GET['case'])) {
|
||||
if (isset($_GET['app'])) {
|
||||
$show = '?show=cases&app=true';
|
||||
} else if (isset($_GET['plugin'])) {
|
||||
$show = '?show=cases&plugin=' . $_GET['plugin'];
|
||||
} else {
|
||||
$show = '?show=cases';
|
||||
}
|
||||
}
|
||||
echo "<p><a href='" . RUN_TEST_LINK . $show . "'>Run more tests</a></p>\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function CakePHPTestCaseList() {
|
||||
switch (CAKE_TEST_OUTPUT) {
|
||||
case CAKE_TEST_OUTPUT_HTML:
|
||||
echo HtmlTestManager::getTestCaseList();
|
||||
break;
|
||||
case CAKE_TEST_OUTPUT_TEXT:
|
||||
default:
|
||||
echo TextTestManager::getTestCaseList();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function CakePHPTestGroupTestList() {
|
||||
switch (CAKE_TEST_OUTPUT) {
|
||||
case CAKE_TEST_OUTPUT_HTML:
|
||||
echo HtmlTestManager::getGroupTestList();
|
||||
break;
|
||||
case CAKE_TEST_OUTPUT_TEXT:
|
||||
default:
|
||||
echo TextTestManager::getGroupTestList();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function CakePHPTestHeader() {
|
||||
switch (CAKE_TEST_OUTPUT) {
|
||||
case CAKE_TEST_OUTPUT_HTML:
|
||||
$dispatch =& new Dispatcher();
|
||||
$dispatch->baseUrl();
|
||||
define('BASE', $dispatch->webroot);
|
||||
$baseUrl = BASE;
|
||||
$characterSet = 'charset=utf-8';
|
||||
include CAKE_TESTS_LIB . 'header.php';
|
||||
break;
|
||||
case CAKE_TEST_OUTPUT_TEXT:
|
||||
default:
|
||||
header('content-type: text/plain');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function CakePHPTestSuiteHeader() {
|
||||
switch (CAKE_TEST_OUTPUT) {
|
||||
case CAKE_TEST_OUTPUT_HTML:
|
||||
$groups = $_SERVER['PHP_SELF'].'?show=groups';
|
||||
$cases = $_SERVER['PHP_SELF'].'?show=cases';
|
||||
$plugins = Configure::listObjects('plugin');
|
||||
include CAKE_TESTS_LIB . 'content.php';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function CakePHPTestSuiteFooter() {
|
||||
switch ( CAKE_TEST_OUTPUT) {
|
||||
case CAKE_TEST_OUTPUT_HTML:
|
||||
$baseUrl = BASE;
|
||||
include CAKE_TESTS_LIB . 'footer.php';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Add table
Reference in a new issue