init.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  4. * Copyright 2005-2012, 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 MIT License (http://www.opensource.org/licenses/mit-license.php)
  12. */
  13. use Cake\Cache\Cache;
  14. use Cake\Core\Configure;
  15. use Cake\Database\ConnectionManager;
  16. use Cake\I18n\I18n;
  17. use Cake\Log\Log;
  18. define('DS', DIRECTORY_SEPARATOR);
  19. define('ROOT', dirname(__DIR__));
  20. define('APP_DIR', 'TestApp');
  21. define('WEBROOT_DIR', 'webroot');
  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. define('LOG_ERROR', LOG_ERR);
  33. // Point app constants to the test app.
  34. define('APP', TEST_APP . 'TestApp' . DS);
  35. define('WWW_ROOT', TEST_APP . WEBROOT_DIR . DS);
  36. define('TESTS', TEST_APP . 'tests' . DS);
  37. //@codingStandardsIgnoreStart
  38. @mkdir(LOGS);
  39. @mkdir(SESSIONS);
  40. @mkdir(CACHE);
  41. @mkdir(CACHE . 'views');
  42. @mkdir(CACHE . 'models');
  43. //@codingStandardsIgnoreEnd
  44. require CAKE . 'Core/ClassLoader.php';
  45. $loader = new Cake\Core\ClassLoader;
  46. $loader->register();
  47. $loader->addNamespace('Cake', CAKE);
  48. $loader->addNamespace('Cake\Test', CORE_TESTS);
  49. $loader->addNamespace('TestApp', APP);
  50. $loader->addNamespace('TestPlugin', TEST_APP . 'Plugin/TestPlugin');
  51. $loader->addNamespace('TestPluginTwo', TEST_APP . 'Plugin/TestPluginTwo');
  52. $loader->addNamespace('PluginJs', TEST_APP . 'Plugin/PluginJs');
  53. require CAKE . 'bootstrap.php';
  54. mb_internal_encoding('UTF-8');
  55. Configure::write('debug', 2);
  56. Configure::write('App', [
  57. 'namespace' => 'App',
  58. 'encoding' => 'UTF-8',
  59. 'base' => false,
  60. 'baseUrl' => false,
  61. 'dir' => APP_DIR,
  62. 'webroot' => WEBROOT_DIR,
  63. 'www_root' => WWW_ROOT,
  64. 'fullBaseUrl' => 'http://localhost',
  65. 'imageBaseUrl' => 'img/',
  66. 'jsBaseUrl' => 'js/',
  67. 'cssBaseUrl' => 'css/',
  68. 'paths' => [
  69. 'plugins' => [TEST_APP . 'Plugin/'],
  70. 'views' => [APP . 'View/']
  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. ConnectionManager::config('test', [
  86. 'className' => getenv('db_class'),
  87. 'dsn' => getenv('db_dsn'),
  88. 'database' => getenv('db_database'),
  89. 'login' => getenv('db_login'),
  90. 'password' => getenv('db_password')
  91. ]);
  92. Configure::write('Session', [
  93. 'defaults' => 'php'
  94. ]);
  95. Log::config([
  96. 'debug' => [
  97. 'engine' => 'Cake\Log\Engine\FileLog',
  98. 'levels' => ['notice', 'info', 'debug'],
  99. 'file' => 'debug',
  100. ],
  101. 'error' => [
  102. 'engine' => 'Cake\Log\Engine\FileLog',
  103. 'levels' => ['warning', 'error', 'critical', 'alert', 'emergency'],
  104. 'file' => 'error',
  105. ]
  106. ]);
  107. // Initialize the empty language.
  108. I18n::translate('empty');