|
1 | 1 | <?php |
2 | | -/** |
3 | | - * Test suite bootstrap. |
4 | | - * |
5 | | - * This function is used to find the location of CakePHP whether CakePHP |
6 | | - * has been installed as a dependency of the plugin, or the plugin is itself |
7 | | - * installed as a dependency of an application. |
8 | | - */ |
9 | | -$findRoot = function ($root) { |
10 | | - do { |
11 | | - $lastRoot = $root; |
12 | | - $root = dirname($root); |
13 | | - if (is_dir($root . '/vendor/cakephp/cakephp')) { |
14 | | - return $root; |
15 | | - } |
16 | | - } while ($root !== $lastRoot); |
17 | | - throw new Exception("Cannot find the root of the application, unable to run tests"); |
18 | | -}; |
19 | | -$root = $findRoot(__FILE__); |
20 | | -unset($findRoot); |
21 | | -chdir($root); |
22 | | -if (file_exists($root . '/config/bootstrap.php')) { |
23 | | - require $root . '/config/bootstrap.php'; |
24 | | - return; |
| 2 | +// @codingStandardsIgnoreFile |
| 3 | +use Cake\Cache\Cache; |
| 4 | +use Cake\Core\Configure; |
| 5 | +use Cake\Core\Plugin; |
| 6 | +use Cake\Datasource\ConnectionManager; |
| 7 | +use Cake\I18n\I18n; |
| 8 | + |
| 9 | +require_once 'vendor/autoload.php'; |
| 10 | + |
| 11 | +// Path constants to a few helpful things. |
| 12 | +if (!defined('DS')) { |
| 13 | + define('DS', DIRECTORY_SEPARATOR); |
25 | 14 | } |
26 | | -require $root . '/vendor/cakephp/cakephp/tests/bootstrap.php'; |
27 | | -\Cake\Core\Plugin::load('Bootstrap', ['path' => dirname(dirname(__FILE__)) . DS]); |
| 15 | + |
| 16 | +define('ROOT', dirname(__DIR__) . DS); |
| 17 | +define('CAKE_CORE_INCLUDE_PATH', ROOT . 'vendor' . DS . 'cakephp' . DS . 'cakephp'); |
| 18 | +define('CORE_PATH', ROOT . 'vendor' . DS . 'cakephp' . DS . 'cakephp' . DS); |
| 19 | +define('CAKE', CORE_PATH . 'src' . DS); |
| 20 | +define('TESTS', ROOT . 'tests'); |
| 21 | +define('APP', ROOT . 'tests' . DS . 'test_app' . DS); |
| 22 | +define('APP_DIR', 'app'); |
| 23 | +define('WEBROOT_DIR', 'webroot'); |
| 24 | +define('WWW_ROOT', dirname(APP) . DS . 'webroot' . DS); |
| 25 | +define('TMP', sys_get_temp_dir() . DS); |
| 26 | +define('CONFIG', APP . 'config' . DS); |
| 27 | +define('CACHE', TMP); |
| 28 | +define('LOGS', TMP); |
| 29 | + |
| 30 | +//@codingStandardsIgnoreStart |
| 31 | +@mkdir(LOGS); |
| 32 | +@mkdir(SESSIONS); |
| 33 | +@mkdir(CACHE); |
| 34 | +@mkdir(CACHE . 'views'); |
| 35 | +@mkdir(CACHE . 'models'); |
| 36 | + |
| 37 | +require_once CORE_PATH . 'config/bootstrap.php'; |
| 38 | +date_default_timezone_set('UTC'); |
| 39 | +mb_internal_encoding('UTF-8'); |
| 40 | + |
| 41 | +Cache::config([ |
| 42 | + '_cake_core_' => [ |
| 43 | + 'engine' => 'File', |
| 44 | + 'prefix' => 'cake_core_', |
| 45 | + 'serialize' => true |
| 46 | + ], |
| 47 | + '_cake_model_' => [ |
| 48 | + 'engine' => 'File', |
| 49 | + 'prefix' => 'cake_model_', |
| 50 | + 'serialize' => true |
| 51 | + ] |
| 52 | +]); |
| 53 | + |
| 54 | + |
| 55 | +Plugin::load('Search', ['path' => ROOT]); |
0 commit comments