test.php

Go to the documentation of this file.
00001 <?php
00002 /* SVN FILE: $Id: test.php 7805 2008-10-30 17:30:26Z AD7six $ */
00003 /**
00004  * Short description for file.
00005  *
00006  * Long description for file
00007  *
00008  * PHP versions 4 and 5
00009  *
00010  * CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
00011  * Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
00012  *
00013  *  Licensed under The Open Group Test Suite License
00014  *  Redistributions of files must retain the above copyright notice.
00015  *
00016  * @filesource
00017  * @copyright     Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
00018  * @link          https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
00019  * @package       cake
00020  * @subpackage    cake.cake.tests.libs
00021  * @since         CakePHP(tm) v 1.2.0.4433
00022  * @version       $Revision: 7805 $
00023  * @modifiedby    $LastChangedBy: AD7six $
00024  * @lastmodified  $Date: 2008-10-30 13:30:26 -0400 (Thu, 30 Oct 2008) $
00025  * @license       http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
00026  */
00027 error_reporting(E_ALL);
00028 set_time_limit(0);
00029 ini_set('memory_limit','128M');
00030 ini_set('display_errors', 1);
00031 /**
00032  * Use the DS to separate the directories in other defines
00033  */
00034     if (!defined('DS')) {
00035         define('DS', DIRECTORY_SEPARATOR);
00036     }
00037 /**
00038  * These defines should only be edited if you have cake installed in
00039  * a directory layout other than the way it is distributed.
00040  * When using custom settings be sure to use the DS and do not add a trailing DS.
00041  */
00042 
00043 /**
00044  * The full path to the directory which holds "app", WITHOUT a trailing DS.
00045  *
00046  */
00047     if (!defined('ROOT')) {
00048         define('ROOT', dirname(dirname(dirname(__FILE__))));
00049     }
00050 /**
00051  * The actual directory name for the "app".
00052  *
00053  */
00054     if (!defined('APP_DIR')) {
00055         define('APP_DIR', basename(dirname(dirname(__FILE__))));
00056     }
00057 /**
00058  * The absolute path to the "cake" directory, WITHOUT a trailing DS.
00059  *
00060  */
00061     if (!defined('CAKE_CORE_INCLUDE_PATH')) {
00062         define('CAKE_CORE_INCLUDE_PATH', ROOT);
00063     }
00064 
00065 /**
00066  * Editing below this line should not be necessary.
00067  * Change at your own risk.
00068  *
00069  */
00070 if (!defined('WEBROOT_DIR')) {
00071     define('WEBROOT_DIR', basename(dirname(__FILE__)));
00072 }
00073 if (!defined('WWW_ROOT')) {
00074     define('WWW_ROOT', dirname(__FILE__) . DS);
00075 }
00076 if (!defined('CORE_PATH')) {
00077     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'))) {
00078         define('APP_PATH', null);
00079         define('CORE_PATH', null);
00080     } else {
00081         define('APP_PATH', ROOT . DS . APP_DIR . DS);
00082         define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
00083     }
00084 }
00085 if (!include(CORE_PATH . 'cake' . DS . 'bootstrap.php')) {
00086     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);
00087 }
00088 
00089 $corePath = Configure::corePaths('cake');
00090 if (isset($corePath[0])) {
00091     define('TEST_CAKE_CORE_INCLUDE_PATH', rtrim($corePath[0], DS) . DS);
00092 } else {
00093     define('TEST_CAKE_CORE_INCLUDE_PATH', CAKE_CORE_INCLUDE_PATH);
00094 }
00095 
00096 require_once CAKE_TESTS_LIB . 'test_manager.php';
00097 
00098 if (Configure::read('debug') < 1) {
00099     die(__('Debug setting does not allow access to this url.', true));
00100 }
00101 
00102 if (!isset($_SERVER['SERVER_NAME'])) {
00103     $_SERVER['SERVER_NAME'] = '';
00104 }
00105 if (empty( $_GET['output'])) {
00106     $_GET['output'] = 'html';
00107 }
00108 /**
00109  *
00110  * Used to determine output to display
00111  */
00112 define('CAKE_TEST_OUTPUT_HTML', 1);
00113 define('CAKE_TEST_OUTPUT_TEXT', 2);
00114 
00115 if (isset($_GET['output']) && $_GET['output'] == 'html') {
00116     define('CAKE_TEST_OUTPUT', CAKE_TEST_OUTPUT_HTML);
00117 } else {
00118     Debugger::output('txt');
00119     define('CAKE_TEST_OUTPUT', CAKE_TEST_OUTPUT_TEXT);
00120 }
00121 
00122 if (!App::import('Vendor', 'simpletest' . DS . 'reporter')) {
00123     CakePHPTestHeader();
00124     include CAKE_TESTS_LIB . 'simpletest.php';
00125     CakePHPTestSuiteFooter();
00126     exit();
00127 }
00128 
00129 $analyzeCodeCoverage = false;
00130 if (isset($_GET['code_coverage'])) {
00131     $analyzeCodeCoverage = true;
00132     require_once CAKE_TESTS_LIB . 'code_coverage_manager.php';
00133     if (!extension_loaded('xdebug')) {
00134         CakePHPTestHeader();
00135         include CAKE_TESTS_LIB . 'xdebug.php';
00136         CakePHPTestSuiteFooter();
00137         exit();
00138     }
00139 }
00140 
00141 CakePHPTestHeader();
00142 CakePHPTestSuiteHeader();
00143 define('RUN_TEST_LINK', $_SERVER['PHP_SELF']);
00144 
00145 if (isset($_GET['group'])) {
00146     if ('all' == $_GET['group']) {
00147         TestManager::runAllTests(CakeTestsGetReporter());
00148     } else {
00149         if ($analyzeCodeCoverage) {
00150             CodeCoverageManager::start($_GET['group'], CakeTestsGetReporter());
00151         }
00152         TestManager::runGroupTest(ucfirst($_GET['group']), CakeTestsGetReporter());
00153         if ($analyzeCodeCoverage) {
00154             CodeCoverageManager::report();
00155         }
00156     }
00157 
00158     CakePHPTestRunMore();
00159     CakePHPTestAnalyzeCodeCoverage();
00160 } elseif (isset($_GET['case'])) {
00161     if ($analyzeCodeCoverage) {
00162         CodeCoverageManager::start($_GET['case'], CakeTestsGetReporter());
00163     }
00164 
00165     TestManager::runTestCase($_GET['case'], CakeTestsGetReporter());
00166 
00167     if ($analyzeCodeCoverage) {
00168         CodeCoverageManager::report();
00169     }
00170 
00171     CakePHPTestRunMore();
00172     CakePHPTestAnalyzeCodeCoverage();
00173 } elseif (isset($_GET['show']) && $_GET['show'] == 'cases') {
00174     CakePHPTestCaseList();
00175 } else {
00176     CakePHPTestGroupTestList();
00177 }
00178 CakePHPTestSuiteFooter();
00179 $output = ob_get_clean();
00180 echo $output;
00181 ?>

Generated on Sun Nov 22 00:30:52 2009 for CakePHP 1.2.x.x (v1.2.4.8284) by doxygen 1.4.7