PageRenderTime 25ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/application/third_party/CIUnit/bootstrap_phpunit.php

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