bootstrap.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  4. * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  5. *
  6. * Licensed under The MIT License
  7. * Redistributions of files must retain the above copyright notice.
  8. *
  9. * @copyright Cake Software Foundation, Inc. (http://cakefoundation.org)
  10. * @link http://cakephp.org CakePHP(tm) Project
  11. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  12. */
  13. use Cake\Cache\Cache;
  14. use Cake\Core\Configure;
  15. use Cake\Datasource\ConnectionManager;
  16. use Cake\I18n\I18n;
  17. use Cake\Log\Log;
  18. require_once 'vendor/autoload.php';
  19. if (!defined('DS')) {
  20. define('DS', DIRECTORY_SEPARATOR);
  21. }
  22. define('ROOT', dirname(__DIR__));
  23. define('APP_DIR', 'TestApp');
  24. define('TMP', sys_get_temp_dir() . DS);
  25. define('LOGS', TMP . 'logs' . DS);
  26. define('CACHE', TMP . 'cache' . DS);
  27. define('SESSIONS', TMP . 'sessions' . DS);
  28. define('CAKE_CORE_INCLUDE_PATH', ROOT);
  29. define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
  30. define('CAKE', CORE_PATH . 'src' . DS);
  31. define('CORE_TESTS', CORE_PATH . 'tests' . DS);
  32. define('CORE_TEST_CASES', CORE_TESTS . 'TestCase');
  33. define('TEST_APP', CORE_TESTS . 'test_app' . DS);
  34. // Point app constants to the test app.
  35. define('APP', TEST_APP . 'TestApp' . DS);
  36. define('WWW_ROOT', TEST_APP . 'webroot' . DS);
  37. define('CONFIG', TEST_APP . 'config' . DS);
  38. //@codingStandardsIgnoreStart
  39. @mkdir(LOGS);
  40. @mkdir(SESSIONS);
  41. @mkdir(CACHE);
  42. @mkdir(CACHE . 'views');
  43. @mkdir(CACHE . 'models');
  44. //@codingStandardsIgnoreEnd
  45. require_once CORE_PATH . 'config/bootstrap.php';
  46. date_default_timezone_set('UTC');
  47. mb_internal_encoding('UTF-8');
  48. Configure::write('debug', true);
  49. Configure::write('App', [
  50. 'namespace' => 'App',
  51. 'encoding' => 'UTF-8',
  52. 'base' => false,
  53. 'baseUrl' => false,
  54. 'dir' => APP_DIR,
  55. 'webroot' => 'webroot',
  56. 'wwwRoot' => WWW_ROOT,
  57. 'fullBaseUrl' => 'http://localhost',
  58. 'imageBaseUrl' => 'img/',
  59. 'jsBaseUrl' => 'js/',
  60. 'cssBaseUrl' => 'css/',
  61. 'paths' => [
  62. 'plugins' => [TEST_APP . 'Plugin' . DS],
  63. 'templates' => [APP . 'Template' . DS],
  64. 'locales' => [APP . 'Locale' . DS],
  65. ]
  66. ]);
  67. Cache::config([
  68. '_cake_core_' => [
  69. 'engine' => 'File',
  70. 'prefix' => 'cake_core_',
  71. 'serialize' => true
  72. ],
  73. '_cake_model_' => [
  74. 'engine' => 'File',
  75. 'prefix' => 'cake_model_',
  76. 'serialize' => true
  77. ]
  78. ]);
  79. // Ensure default test connection is defined
  80. if (!getenv('db_dsn')) {
  81. putenv('db_dsn=sqlite:///:memory:');
  82. }
  83. ConnectionManager::config('test', ['url' => getenv('db_dsn')]);
  84. ConnectionManager::config('test_custom_i18n_datasource', ['url' => getenv('db_dsn')]);
  85. Configure::write('Session', [
  86. 'defaults' => 'php'
  87. ]);
  88. Log::config([
  89. 'debug' => [
  90. 'engine' => 'Cake\Log\Engine\FileLog',
  91. 'levels' => ['notice', 'info', 'debug'],
  92. 'file' => 'debug',
  93. ],
  94. 'error' => [
  95. 'engine' => 'Cake\Log\Engine\FileLog',
  96. 'levels' => ['warning', 'error', 'critical', 'alert', 'emergency'],
  97. 'file' => 'error',
  98. ]
  99. ]);
  100. Carbon\Carbon::setTestNow(Carbon\Carbon::now());
  101. ini_set('intl.default_locale', 'en_US');