PageRenderTime 79ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/cake/console/libs/templates/skel/webroot/test.php

https://github.com/Sigiwara/candeo
PHP | 183 lines | 112 code | 15 blank | 56 comment | 34 complexity | 26f0aec01149808fe6aac681bc433819 MD5 | raw file
  1. <?php
  2. /* SVN FILE: $Id: test.php 7296 2008-06-27 09:09:03Z 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.
  12. * 1785 E. Sahara Avenue, Suite 490-204
  13. * Las Vegas, Nevada 89104
  14. *
  15. * Licensed under The Open Group Test Suite License
  16. * Redistributions of files must retain the above copyright notice.
  17. *
  18. * @filesource
  19. * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
  20. * @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
  21. * @package cake
  22. * @subpackage cake.cake.tests.libs
  23. * @since CakePHP(tm) v 1.2.0.4433
  24. * @version $Revision: 7296 $
  25. * @modifiedby $LastChangedBy: gwoo $
  26. * @lastmodified $Date: 2008-06-27 05:09:03 -0400 (Fri, 27 Jun 2008) $
  27. * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
  28. */
  29. error_reporting(E_ALL);
  30. set_time_limit(0);
  31. ini_set('memory_limit','128M');
  32. ini_set('display_errors', 1);
  33. /**
  34. * Use the DS to separate the directories in other defines
  35. */
  36. if (!defined('DS')) {
  37. define('DS', DIRECTORY_SEPARATOR);
  38. }
  39. /**
  40. * These defines should only be edited if you have cake installed in
  41. * a directory layout other than the way it is distributed.
  42. * When using custom settings be sure to use the DS and do not add a trailing DS.
  43. */
  44. /**
  45. * The full path to the directory which holds "app", WITHOUT a trailing DS.
  46. *
  47. */
  48. if (!defined('ROOT')) {
  49. define('ROOT', dirname(dirname(dirname(__FILE__))));
  50. }
  51. /**
  52. * The actual directory name for the "app".
  53. *
  54. */
  55. if (!defined('APP_DIR')) {
  56. define('APP_DIR', basename(dirname(dirname(__FILE__))));
  57. }
  58. /**
  59. * The absolute path to the "cake" directory, WITHOUT a trailing DS.
  60. *
  61. */
  62. if (!defined('CAKE_CORE_INCLUDE_PATH')) {
  63. define('CAKE_CORE_INCLUDE_PATH', ROOT);
  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. $corePath = Configure::corePaths('cake');
  89. if (isset($corePath[0])) {
  90. define('TEST_CAKE_CORE_INCLUDE_PATH', rtrim($corePath[0], DS) . DS);
  91. } else {
  92. define('TEST_CAKE_CORE_INCLUDE_PATH', CAKE_CORE_INCLUDE_PATH);
  93. }
  94. require_once CAKE_TESTS_LIB . 'test_manager.php';
  95. if (Configure::read('debug') < 1) {
  96. die(__('Debug setting does not allow access to this url.', true));
  97. }
  98. if (!isset($_SERVER['SERVER_NAME'])) {
  99. $_SERVER['SERVER_NAME'] = '';
  100. }
  101. if (empty( $_GET['output'])) {
  102. $_GET['output'] = 'html';
  103. }
  104. /**
  105. *
  106. * Used to determine output to display
  107. */
  108. define('CAKE_TEST_OUTPUT_HTML', 1);
  109. define('CAKE_TEST_OUTPUT_TEXT', 2);
  110. if (isset($_GET['output']) && $_GET['output'] == 'html') {
  111. define('CAKE_TEST_OUTPUT', CAKE_TEST_OUTPUT_HTML);
  112. } else {
  113. Debugger::output('txt');
  114. define('CAKE_TEST_OUTPUT', CAKE_TEST_OUTPUT_TEXT);
  115. }
  116. if (!App::import('Vendor', 'simpletest' . DS . 'reporter')) {
  117. CakePHPTestHeader();
  118. include CAKE_TESTS_LIB . 'simpletest.php';
  119. CakePHPTestSuiteFooter();
  120. exit();
  121. }
  122. $analyzeCodeCoverage = false;
  123. if (isset($_GET['code_coverage'])) {
  124. $analyzeCodeCoverage = true;
  125. require_once CAKE_TESTS_LIB . 'code_coverage_manager.php';
  126. if (!extension_loaded('xdebug')) {
  127. CakePHPTestHeader();
  128. include CAKE_TESTS_LIB . 'xdebug.php';
  129. CakePHPTestSuiteFooter();
  130. exit();
  131. }
  132. }
  133. CakePHPTestHeader();
  134. CakePHPTestSuiteHeader();
  135. define('RUN_TEST_LINK', $_SERVER['PHP_SELF']);
  136. if (isset($_GET['group'])) {
  137. if ('all' == $_GET['group']) {
  138. TestManager::runAllTests(CakeTestsGetReporter());
  139. } else {
  140. if ($analyzeCodeCoverage) {
  141. CodeCoverageManager::start($_GET['group'], CakeTestsGetReporter());
  142. }
  143. TestManager::runGroupTest(ucfirst($_GET['group']), CakeTestsGetReporter());
  144. if ($analyzeCodeCoverage) {
  145. CodeCoverageManager::report();
  146. }
  147. }
  148. CakePHPTestRunMore();
  149. CakePHPTestAnalyzeCodeCoverage();
  150. } elseif (isset($_GET['case'])) {
  151. if ($analyzeCodeCoverage) {
  152. CodeCoverageManager::start($_GET['case'], CakeTestsGetReporter());
  153. }
  154. TestManager::runTestCase($_GET['case'], CakeTestsGetReporter());
  155. if ($analyzeCodeCoverage) {
  156. CodeCoverageManager::report();
  157. }
  158. CakePHPTestRunMore();
  159. CakePHPTestAnalyzeCodeCoverage();
  160. } elseif (isset($_GET['show']) && $_GET['show'] == 'cases') {
  161. CakePHPTestCaseList();
  162. } else {
  163. CakePHPTestGroupTestList();
  164. }
  165. CakePHPTestSuiteFooter();
  166. $output = ob_get_clean();
  167. echo $output;
  168. ?>