|
| 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 | + * For full copyright and license information, please see the LICENSE.txt |
| 8 | + * Redistributions of files must retain the above copyright notice. |
| 9 | + * |
| 10 | + * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) |
| 11 | + * @link http://cakephp.org CakePHP(tm) Project |
| 12 | + * @since 0.1.0 |
| 13 | + * @license http://www.opensource.org/licenses/mit-license.php MIT License |
| 14 | + */ |
| 15 | + |
| 16 | +// @codingStandardsIgnoreFile |
| 17 | + |
| 18 | +use Cake\Core\Configure; |
| 19 | +use Cake\Core\Plugin; |
| 20 | +use Cake\Datasource\ConnectionManager; |
| 21 | + |
| 22 | +$findRoot = function ($root) { |
| 23 | + do { |
| 24 | + $lastRoot = $root; |
| 25 | + $root = dirname($root); |
| 26 | + if (is_dir($root . '/vendor/cakephp/cakephp')) { |
| 27 | + return $root; |
| 28 | + } |
| 29 | + } while ($root !== $lastRoot); |
| 30 | + throw new Exception('Cannot find the root of the application, unable to run tests'); |
| 31 | +}; |
| 32 | +$root = $findRoot(__FILE__); |
| 33 | +unset($findRoot); |
| 34 | +chdir($root); |
| 35 | + |
| 36 | +require_once 'vendor/cakephp/cakephp/src/basics.php'; |
| 37 | +require_once 'vendor/autoload.php'; |
| 38 | + |
| 39 | +define('ROOT', $root . DS . 'tests' . DS . 'test_app' . DS); |
| 40 | +define('APP', ROOT . 'App' . DS); |
| 41 | +define('TMP', sys_get_temp_dir() . DS); |
| 42 | + |
| 43 | +Configure::write('debug', true); |
| 44 | +Configure::write('App', [ |
| 45 | + 'namespace' => 'App', |
| 46 | + 'paths' => [ |
| 47 | + 'plugins' => [ROOT . 'Plugin' . DS], |
| 48 | + 'templates' => [ROOT . 'App' . DS . 'Template' . DS] |
| 49 | + ] |
| 50 | +]); |
| 51 | + |
| 52 | +if (!getenv('db_dsn')) { |
| 53 | + putenv('db_dsn=sqlite:///:memory:'); |
| 54 | +} |
| 55 | +ConnectionManager::config('test', ['url' => getenv('db_dsn')]); |
| 56 | + |
| 57 | +Plugin::load('ConfigReadShell', [ |
| 58 | + 'path' => dirname(dirname(__FILE__)) . DS, |
| 59 | +]); |
0 commit comments