* Copyright (c) 2005, CakePHP Test Suite Authors/Developers * Author(s): Larry E. Masters aka PhpNut * * Portions modified from WACT Test Suite * Author(s): Harry Fuecks * Jon Ramsey * Jason E. Sweat * Franco Ponticelli * Lorenzo Alberton * * Licensed under The Open Group Test Suite License * Redistributions of files must retain the above copyright notice. * * @filesource * @author CakePHP Test Suite Authors/Developers * @copyright Copyright (c) 2005, CakePHP Test Suite Authors/Developers * @link https://trac.cakephp.org/wiki/Cake/Manual/TestSuite/Authors Authors/Developers * @package tests * @since CakePHP Test Suite v 1.0.0.0 * @version $Revision$ * @modifiedby $LastChangedBy$ * @lastmodified $Date$ * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License */ error_reporting(E_ALL); set_time_limit(600); ini_set('memory_limit','128M'); /** * Get root directory */ if (!defined('DS')) { define('DS', DIRECTORY_SEPARATOR); } if (!defined('ROOT')) { define('ROOT', dirname(dirname(dirname(__FILE__))).DS); } require_once ROOT . 'config'.DS.'paths.php'; require_once TESTS . 'test_paths.php'; require_once TESTS . 'lib'.DS.'test_manager.php'; require_once SIMPLE_TEST . 'reporter.php'; if (!isset( $_SERVER['SERVER_NAME'] )) { $_SERVER['SERVER_NAME'] = ''; } if (empty( $_GET['output'])) { TestManager::setOutputFromIni(TESTS . 'config.ini.php'); $_GET['output'] = TEST_OUTPUT; } /** * * Used to determine output to display */ define('CAKE_TEST_OUTPUT_HTML',1); define('CAKE_TEST_OUTPUT_XML',2); define('CAKE_TEST_OUTPUT_TEXT',3); if ( isset($_GET['output']) && $_GET['output'] == 'xml' ) { define('CAKE_TEST_OUTPUT', CAKE_TEST_OUTPUT_XML); } elseif ( isset($_GET['output']) && $_GET['output'] == 'html' ) { define('CAKE_TEST_OUTPUT', CAKE_TEST_OUTPUT_HTML); } else { define('CAKE_TEST_OUTPUT', CAKE_TEST_OUTPUT_TEXT); } function & CakeTestsGetReporter() { static $Reporter = NULL; if ( !$Reporter ) { switch ( CAKE_TEST_OUTPUT ) { case CAKE_TEST_OUTPUT_XML: require_once SIMPLE_TEST . 'xml.php'; $Reporter = new XmlReporter(); break; case CAKE_TEST_OUTPUT_HTML: require_once TESTS . 'lib'.DS.'cake_reporter.php'; $Reporter = new CakeHtmlReporter(); break; default: $Reporter = new TextReporter(); break; } } return $Reporter; } function CakePHPTestRunMore() { switch ( CAKE_TEST_OUTPUT ) { case CAKE_TEST_OUTPUT_XML: break; case CAKE_TEST_OUTPUT_HTML: $link = class_exists('Object') ? "

Run more tests

\n" : "

Run more tests

\n"; echo $link; break; case CAKE_TEST_OUTPUT_TEXT: default: break; } } function CakePHPTestCaseList() { switch ( CAKE_TEST_OUTPUT ) { case CAKE_TEST_OUTPUT_XML: if (isset($_GET['app'])) { echo XmlTestManager::getTestCaseList(APP_TEST_CASES); } else { echo XmlTestManager::getTestCaseList(CORE_TEST_CASES); } break; 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_XML: if (isset($_GET['app'])) { echo XmlTestManager::getGroupTestList(APP_TEST_GROUPS); } else { echo XmlTestManager::getGroupTestList(CORE_TEST_GROUPS); } break; 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_XML: header('Content-Type: text/xml; charset="utf-8"'); break; case CAKE_TEST_OUTPUT_HTML: $header = << CakePHP Test Suite v 1.0.0.0 EOF; echo $header; break; case CAKE_TEST_OUTPUT_TEXT: default: header('Content-type: text/plain'); break; } } function CakePHPTestSuiteHeader() { switch ( CAKE_TEST_OUTPUT ) { case CAKE_TEST_OUTPUT_XML: break; case CAKE_TEST_OUTPUT_HTML: $groups = class_exists('Object') ? 'groups' : $_SERVER['PHP_SELF'].'?show=groups'; $cases = class_exists('Object') ? 'cases' : $_SERVER['PHP_SELF'].'?show=cases'; $suiteHeader = <<

Core Test Groups || Core Test Cases

App Test Groups || App Test Cases

EOD; echo $suiteHeader; break; case CAKE_TEST_OUTPUT_TEXT: default: break; } } function CakePHPTestSuiteFooter() { switch ( CAKE_TEST_OUTPUT ) { case CAKE_TEST_OUTPUT_XML: break; case CAKE_TEST_OUTPUT_HTML: $footer = << EOD; echo $footer; break; case CAKE_TEST_OUTPUT_TEXT: default: break; } } 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(); exit(); } if (isset($_GET['case'])) { TestManager::runTestCase($_GET['case'], CakeTestsGetReporter()); CakePHPTestRunMore(); exit(); } CakePHPTestHeader(); CakePHPTestSuiteHeader(); if (isset($_GET['show']) && $_GET['show'] == 'cases') { CakePHPTestCaseList(); } else { CakePHPTestGroupTestList(); } CakePHPTestSuiteFooter(); ?>