bootstrap.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. define('DS', DIRECTORY_SEPARATOR);
  20. define('ROOT', dirname(__DIR__));
  21. define('APP_DIR', 'TestApp');
  22. define('TMP', sys_get_temp_dir() . DS);
  23. define('LOGS', TMP . 'logs' . DS);
  24. define('CACHE', TMP . 'cache' . DS);
  25. define('SESSIONS', TMP . 'sessions' . DS);
  26. define('CAKE_CORE_INCLUDE_PATH', ROOT);
  27. define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
  28. define('CAKE', CORE_PATH . 'src' . DS);
  29. define('CORE_TESTS', CORE_PATH . 'tests' . DS);
  30. define('CORE_TEST_CASES', CORE_TESTS . 'TestCase');
  31. define('TEST_APP', CORE_TESTS . 'test_app' . DS);
  32. // Point app constants to the test app.
  33. define('APP', TEST_APP . 'TestApp' . DS);
  34. define('WWW_ROOT', TEST_APP . 'webroot' . DS);
  35. define('CONFIG', TEST_APP . 'config' . DS);
  36. //@codingStandardsIgnoreStart
  37. @mkdir(LOGS);
  38. @mkdir(SESSIONS);
  39. @mkdir(CACHE);
  40. @mkdir(CACHE . 'views');
  41. @mkdir(CACHE . 'models');
  42. //@codingStandardsIgnoreEnd
  43. require CAKE . 'Core/ClassLoader.php';
  44. $loader = new Cake\Core\ClassLoader;
  45. $loader->register();
  46. $loader->addNamespace('TestApp', APP);
  47. $loader->addNamespace('TestPlugin', TEST_APP . 'Plugin' . DS . 'TestPlugin' . DS . 'src');
  48. $loader->addNamespace('TestPlugin\Test', TEST_APP . 'Plugin' . DS . 'TestPlugin' . DS . 'tests');
  49. $loader->addNamespace('TestPluginTwo', TEST_APP . 'Plugin' . DS . 'TestPluginTwo' . DS . 'src');
  50. $loader->addNamespace('PluginJs', TEST_APP . 'Plugin' . DS . 'PluginJs' . DS . 'src');
  51. require_once CORE_PATH . 'config/bootstrap.php';
  52. date_default_timezone_set('UTC');
  53. mb_internal_encoding('UTF-8');
  54. Configure::write('debug', true);
  55. Configure::write('App', [
  56. 'namespace' => 'App',
  57. 'encoding' => 'UTF-8',
  58. 'base' => false,
  59. 'baseUrl' => false,
  60. 'dir' => APP_DIR,
  61. 'webroot' => 'webroot',
  62. 'wwwRoot' => WWW_ROOT,
  63. 'fullBaseUrl' => 'http://localhost',
  64. 'imageBaseUrl' => 'img/',
  65. 'jsBaseUrl' => 'js/',
  66. 'cssBaseUrl' => 'css/',
  67. 'paths' => [
  68. 'plugins' => [TEST_APP . 'Plugin' . DS],
  69. 'templates' => [APP . 'Template' . DS],
  70. 'locales' => [APP . 'Locale' . DS],
  71. ]
  72. ]);
  73. Cache::config([
  74. '_cake_core_' => [
  75. 'engine' => 'File',
  76. 'prefix' => 'cake_core_',
  77. 'serialize' => true
  78. ],
  79. '_cake_model_' => [
  80. 'engine' => 'File',
  81. 'prefix' => 'cake_model_',
  82. 'serialize' => true
  83. ]
  84. ]);
  85. // Ensure default test connection is defined
  86. if (!getenv('db_dsn')) {
  87. putenv('db_dsn=sqlite:///:memory:');
  88. }
  89. ConnectionManager::config('test', ['url' => getenv('db_dsn')]);
  90. Configure::write('Session', [
  91. 'defaults' => 'php'
  92. ]);
  93. Log::config([
  94. 'debug' => [
  95. 'engine' => 'Cake\Log\Engine\FileLog',
  96. 'levels' => ['notice', 'info', 'debug'],
  97. 'file' => 'debug',
  98. ],
  99. 'error' => [
  100. 'engine' => 'Cake\Log\Engine\FileLog',
  101. 'levels' => ['warning', 'error', 'critical', 'alert', 'emergency'],
  102. 'file' => 'error',
  103. ]
  104. ]);
  105. Carbon\Carbon::setTestNow(Carbon\Carbon::now());
  106. ini_set('intl.default_locale', 'en_US');