/src/tests/bootstrap/CITestBase.php

https://github.com/dstockto/joind.in · PHP · 216 lines · 53 code · 25 blank · 138 comment · 6 complexity · 8d7e2ecd38abac803af415e2203a4698 MD5 · raw file

  1. <?php
  2. ob_start();
  3. /**
  4. * CodeIgniter
  5. *
  6. * An open source application development framework for PHP 4.3.2 or newer
  7. *
  8. * @package CodeIgniter
  9. * @author ExpressionEngine Dev Team
  10. * @copyright Copyright (c) 2008 - 2009, EllisLab, Inc.
  11. * @license http://codeigniter.com/user_guide/license.html
  12. * @link http://codeigniter.com
  13. * @since Version 1.0
  14. * @filesource
  15. */
  16. /*
  17. |---------------------------------------------------------------
  18. | PHP ERROR REPORTING LEVEL
  19. |---------------------------------------------------------------
  20. |
  21. | By default CI runs with error reporting set to ALL. For security
  22. | reasons you are encouraged to change this when your site goes live.
  23. | For more info visit: http://www.php.net/error_reporting
  24. |
  25. */
  26. error_reporting(E_ALL | E_STRICT);
  27. /*
  28. |---------------------------------------------------------------
  29. | SYSTEM FOLDER NAME
  30. |---------------------------------------------------------------
  31. |
  32. | This variable must contain the name of your "system" folder.
  33. | Include the path if the folder is not in the same directory
  34. | as this file.
  35. |
  36. | NO TRAILING SLASH!
  37. |
  38. */
  39. $system_folder = "../../system";
  40. /*
  41. |---------------------------------------------------------------
  42. | APPLICATION FOLDER NAME
  43. |---------------------------------------------------------------
  44. |
  45. | If you want this front controller to use a different "application"
  46. | folder then the default one you can set its name here. The folder
  47. | can also be renamed or relocated anywhere on your server.
  48. | For more info please see the user guide:
  49. | http://codeigniter.com/user_guide/general/managing_apps.html
  50. |
  51. |
  52. | NO TRAILING SLASH!
  53. |
  54. */
  55. $application_folder = "";
  56. /*
  57. |===============================================================
  58. | END OF USER CONFIGURABLE SETTINGS
  59. |===============================================================
  60. */
  61. /*
  62. |---------------------------------------------------------------
  63. | SET THE SERVER PATH
  64. |---------------------------------------------------------------
  65. |
  66. | Let's attempt to determine the full-server path to the "system"
  67. | folder in order to reduce the possibility of path problems.
  68. | Note: We only attempt this if the user hasn't specified a
  69. | full server path.
  70. |
  71. */
  72. if (function_exists('realpath') AND @realpath(dirname(__FILE__)) !== FALSE)
  73. {
  74. $system_folder = realpath(dirname(__FILE__)).'/'.$system_folder;
  75. }
  76. /*
  77. |---------------------------------------------------------------
  78. | DEFINE APPLICATION CONSTANTS
  79. |---------------------------------------------------------------
  80. |
  81. | EXT - The file extension. Typically ".php"
  82. | SELF - The name of THIS file (typically "index.php")
  83. | FCPATH - The full server path to THIS file
  84. | BASEPATH - The full server path to the "system" folder
  85. | APPPATH - The full server path to the "application" folder
  86. |
  87. */
  88. define('EXT', '.php');
  89. define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
  90. define('FCPATH', str_replace(SELF, '', __FILE__));
  91. define('BASEPATH', $system_folder.'/');
  92. if (is_dir($application_folder))
  93. {
  94. define('APPPATH', $application_folder.'/');
  95. }
  96. else
  97. {
  98. if ($application_folder == '')
  99. {
  100. $application_folder = 'application';
  101. }
  102. define('APPPATH', BASEPATH.$application_folder.'/');
  103. }
  104. // CI Version
  105. define('CI_VERSION', '1.7.2-UNIT_TEST');
  106. /*
  107. * ------------------------------------------------------
  108. * Load the global functions
  109. * ------------------------------------------------------
  110. */
  111. require(BASEPATH.'codeigniter/Common'.EXT);
  112. /*
  113. * ------------------------------------------------------
  114. * Load the compatibility override functions
  115. * ------------------------------------------------------
  116. */
  117. require(BASEPATH.'codeigniter/Compat'.EXT);
  118. /*
  119. * ------------------------------------------------------
  120. * Load the framework constants
  121. * ------------------------------------------------------
  122. */
  123. require(APPPATH.'config/constants'.EXT);
  124. /*
  125. * ------------------------------------------------------
  126. * Define a custom error handler so we can log PHP errors
  127. * ------------------------------------------------------
  128. */
  129. set_error_handler('_exception_handler');
  130. if ( ! is_php('5.3'))
  131. {
  132. @set_magic_quotes_runtime(0); // Kill magic quotes
  133. }
  134. /*
  135. * ------------------------------------------------------
  136. * Start the timer... tick tock tick tock...
  137. * ------------------------------------------------------
  138. */
  139. $BM =& load_class('Benchmark');
  140. $BM->mark('total_execution_time_start');
  141. $BM->mark('loading_time_base_classes_start');
  142. /*
  143. * ------------------------------------------------------
  144. * Instantiate the hooks class
  145. * ------------------------------------------------------
  146. */
  147. $EXT =& load_class('Hooks');
  148. /*
  149. * ------------------------------------------------------
  150. * Is there a "pre_system" hook?
  151. * ------------------------------------------------------
  152. */
  153. $EXT->_call_hook('pre_system');
  154. /*
  155. * ------------------------------------------------------
  156. * Instantiate the base classes
  157. * ------------------------------------------------------
  158. */
  159. $CFG =& load_class('Config');
  160. $URI =& load_class('URI');
  161. /*
  162. * ------------------------------------------------------
  163. * Load the remaining base classes
  164. * ------------------------------------------------------
  165. */
  166. $IN =& load_class('Input');
  167. $LANG =& load_class('Language');
  168. /*
  169. * ------------------------------------------------------
  170. * Load the app controller and local controller
  171. * ------------------------------------------------------
  172. *
  173. * Note: Due to the poor object handling in PHP 4 we'll
  174. * conditionally load different versions of the base
  175. * class. Retaining PHP 4 compatibility requires a bit of a hack.
  176. *
  177. * Note: The Loader class needs to be included first
  178. *
  179. */
  180. if ( ! is_php('5.0.0'))
  181. {
  182. load_class('Loader', FALSE);
  183. require(BASEPATH.'codeigniter/Base4'.EXT);
  184. }
  185. else
  186. {
  187. require(BASEPATH.'codeigniter/Base5'.EXT);
  188. }
  189. // Load the base controller class
  190. //load_class('Controller', FALSE);
  191. load_class('Controller');