bootstrap_phpunit.php 8.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <?php
  2. /*
  3. echo '<pre>';
  4. var_dump($GLOBALS);
  5. echo '</pre>';
  6. exit;
  7. */
  8. /*
  9. * ------------------------------------------------------
  10. * CIUnit Version
  11. * ------------------------------------------------------
  12. */
  13. define('CIUnit_Version', '0.18-dev_for_CI2.1.0');
  14. /*
  15. *---------------------------------------------------------------
  16. * APPLICATION ENVIRONMENT
  17. *---------------------------------------------------------------
  18. *
  19. * You can load different configurations depending on your
  20. * current environment. Setting the environment also influences
  21. * things like logging and error reporting.
  22. *
  23. * This can be set to anything, but default usage is:
  24. *
  25. * development
  26. * testing
  27. * production
  28. *
  29. * NOTE: If you change these, also change the error_reporting() code below
  30. *
  31. */
  32. $env_part = (isset($_ENV['DB'])) ? $_ENV['DB'] : '';
  33. define('ENVIRONMENT', ( ! empty($env_part)) ? "testing-{$env_part}" : 'testing');
  34. /*
  35. *---------------------------------------------------------------
  36. * ERROR REPORTING
  37. *---------------------------------------------------------------
  38. *
  39. * By default CI runs with error reporting set to -1.
  40. *
  41. */
  42. error_reporting(-1);
  43. /*
  44. *---------------------------------------------------------------
  45. * SYSTEM FOLDER NAME
  46. *---------------------------------------------------------------
  47. *
  48. * This variable must contain the name of your "system" folder.
  49. * Include the path if the folder is not in the same directory
  50. * as this file.
  51. *
  52. * NO TRAILING SLASH!
  53. *
  54. * The test should be run from inside the tests folder. The assumption
  55. * is that the tests folder is in the same directory path as system. If
  56. * it is not, update the paths appropriately.
  57. */
  58. $system_path = dirname(__FILE__) . '/../../../system';
  59. /*
  60. *---------------------------------------------------------------
  61. * APPLICATION FOLDER NAME
  62. *---------------------------------------------------------------
  63. *
  64. * If you want this front controller to use a different "application"
  65. * folder then the default one you can set its name here. The folder
  66. * can also be renamed or relocated anywhere on your server. If
  67. * you do, use a full server path. For more info please see the user guide:
  68. * http://codeigniter.com/user_guide/general/managing_apps.html
  69. *
  70. * NO TRAILING SLASH!
  71. *
  72. * The tests should be run from inside the tests folder. The assumption
  73. * is that the tests folder is in the same directory as the application
  74. * folder. If it is not, update the path accordingly.
  75. */
  76. $application_folder = dirname(__FILE__) . '/../..';
  77. /*
  78. *---------------------------------------------------------------
  79. * VIEW FOLDER NAME
  80. *---------------------------------------------------------------
  81. *
  82. * If you want to move the view folder out of the application
  83. * folder set the path to the folder here. The folder can be renamed
  84. * and relocated anywhere on your server. If blank, it will default
  85. * to the standard location inside your application folder. If you
  86. * do move this, use the full server path to this folder
  87. *
  88. * NO TRAILING SLASH!
  89. *
  90. */
  91. $view_folder = '';
  92. /*
  93. * -------------------------------------------------------------------
  94. * CUSTOM CONFIG VALUES
  95. * -------------------------------------------------------------------
  96. *
  97. * The $assign_to_config array below will be passed dynamically to the
  98. * config class when initialized. This allows you to set custom config
  99. * items or override any default config values found in the config.php file.
  100. * This can be handy as it permits you to share one application between
  101. * multiple front controller files, with each file containing different
  102. * config values.
  103. *
  104. * Un-comment the $assign_to_config array below to use this feature
  105. *
  106. */
  107. // $assign_to_config['name_of_config_item'] = 'value of config item';
  108. /**
  109. * --------------------------------------------------------------
  110. * CIUNIT FOLDER NAME
  111. * --------------------------------------------------------------
  112. *
  113. * Typically this folder will be within the application's third-party
  114. * folder. However, you can place the folder in any directory. Just
  115. * be sure to update this path.
  116. *
  117. * NO TRAILING SLASH!
  118. *
  119. */
  120. $ciunit_folder = dirname(__FILE__);
  121. /**
  122. * --------------------------------------------------------------
  123. * UNIT TESTS FOLDER NAME
  124. * --------------------------------------------------------------
  125. *
  126. * This is the path to the tests folder.
  127. */
  128. $tests_folder = dirname(__FILE__) . "/../../../tests";
  129. // --------------------------------------------------------------------
  130. // END OF USER CONFIGURABLE SETTINGS. DO NOT EDIT BELOW THIS LINE
  131. // --------------------------------------------------------------------
  132. /*
  133. * ---------------------------------------------------------------
  134. * Resolve the system path for increased reliability
  135. * ---------------------------------------------------------------
  136. */
  137. /* This chdir() causes error when run tests by folder.
  138. // Set the current directory correctly for CLI requests
  139. if (defined('STDIN'))
  140. {
  141. chdir(dirname(__FILE__));
  142. }
  143. */
  144. if (realpath($system_path) !== FALSE)
  145. {
  146. $system_path = realpath($system_path).'/';
  147. }
  148. // ensure there's a trailing slash
  149. $system_path = rtrim($system_path, '/').'/';
  150. // Is the system path correct?
  151. if ( ! is_dir($system_path))
  152. {
  153. exit("Your system folder path does not appear to be set correctly. Please open the following file and correct this: ".pathinfo(__FILE__, PATHINFO_BASENAME));
  154. }
  155. /*
  156. * -------------------------------------------------------------------
  157. * Now that we know the path, set the main path constants
  158. * -------------------------------------------------------------------
  159. */
  160. // The name of THIS file
  161. define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
  162. // The PHP file extension
  163. // this global constant is deprecated.
  164. define('EXT', '.php');
  165. // Path to the system folder
  166. define('BASEPATH', str_replace("\\", "/", $system_path));
  167. // Path to the front controller (this file)
  168. define('FCPATH', str_replace(SELF, '', __FILE__));
  169. // Name of the "system folder"
  170. define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/'));
  171. // The path to the "application" folder
  172. if (is_dir($application_folder))
  173. {
  174. define('APPPATH', realpath($application_folder) . '/');
  175. }
  176. else
  177. {
  178. if ( ! is_dir(BASEPATH.$application_folder.'/'))
  179. {
  180. exit("Your application folder path does not appear to be set correctly. Please open the following file and correct this: ".SELF);
  181. }
  182. define('APPPATH', realpath(BASEPATH.$application_folder) . '/');
  183. }
  184. // The path to the "views" folder
  185. if (is_dir($view_folder))
  186. {
  187. define ('VIEWPATH', $view_folder .'/');
  188. }
  189. else
  190. {
  191. if ( ! is_dir(APPPATH.'views/'))
  192. {
  193. exit("Your view folder path does not appear to be set correctly. Please open the following file and correct this: ".SELF);
  194. }
  195. define ('VIEWPATH', APPPATH.'views/' );
  196. }
  197. // The path to CIUnit
  198. if (is_dir($ciunit_folder))
  199. {
  200. define('CIUPATH', $ciunit_folder . '/');
  201. }
  202. else
  203. {
  204. if ( ! is_dir(APPPATH . 'third_party/' . $ciunit_folder))
  205. {
  206. exit("Your CIUnit folder path does not appear to be set correctly. Please open the following file and correct this: ".SELF);
  207. }
  208. define ('CIUPATH', APPPATH . 'third_party/' . $ciunit_folder);
  209. }
  210. // The path to the Tests folder
  211. define('TESTSPATH', realpath($tests_folder) . '/');
  212. /*
  213. * --------------------------------------------------------------------
  214. * LOAD THE BOOTSTRAP FILE
  215. * --------------------------------------------------------------------
  216. *
  217. * And away we go...
  218. *
  219. */
  220. // Load the CIUnit CodeIgniter Core
  221. require_once CIUPATH . 'core/CodeIgniter.php';
  222. // Autoload the PHPUnit Framework
  223. //require_once ('PHPUnit/Autoload.php');
  224. // Load the CIUnit Framework
  225. require_once CIUPATH. 'libraries/CIUnit.php';
  226. //=== and off we go ===
  227. $CI =& set_controller('CIU_Controller', CIUPATH . 'core/');
  228. $CI->load->add_package_path(CIUPATH);
  229. require_once(CIUPATH . 'libraries/spyc/spyc.php');
  230. CIUnit::$spyc = new Spyc();
  231. require_once(CIUPATH . 'libraries/Fixture.php');
  232. $CI->fixture = new Fixture();
  233. CIUnit::$fixture =& $CI->fixture;
  234. /* End of file bootstrap_phpunit.php */
  235. /* Location: ./application/third_party/CIUnit/bootstrap_phpunit.php */