-
Notifications
You must be signed in to change notification settings - Fork 254
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
17 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,24 @@ | ||
<?php | ||
// @codingStandardsIgnoreFile | ||
|
||
$findRoot = function () { | ||
$root = __DIR__; | ||
for ($i = 0; $i < 3; $i++) { | ||
/* | ||
* Test suite bootstrap | ||
* | ||
* This function is used to find the location of CakePHP whether CakePHP | ||
* has been installed as a dependency of the plugin, or the plugin is itself | ||
* installed as a dependency of an application. | ||
*/ | ||
$findRoot = function ($root) { | ||
do { | ||
$lastRoot = $root; | ||
$root = dirname($root); | ||
if (is_dir($root . '/vendor/cakephp/cakephp')) { | ||
return $root; | ||
} | ||
} | ||
} while ($root !== $lastRoot); | ||
throw new Exception('Cannot find the root of the application, unable to run tests'); | ||
}; | ||
|
||
if (!defined('DS')) { | ||
define('DS', DIRECTORY_SEPARATOR); | ||
} | ||
define('ROOT', $findRoot()); | ||
define('APP_DIR', 'App'); | ||
define('WEBROOT_DIR', 'webroot'); | ||
define('APP', ROOT . '/tests/App/'); | ||
define('CONFIG', ROOT . '/tests/config/'); | ||
define('WWW_ROOT', ROOT . DS . WEBROOT_DIR . DS); | ||
define('TESTS', ROOT . DS . 'tests' . DS); | ||
define('TMP', ROOT . DS . 'tmp' . DS); | ||
define('LOGS', TMP . 'logs' . DS); | ||
define('CACHE', TMP . 'cache' . DS); | ||
define('CAKE_CORE_INCLUDE_PATH', ROOT . '/vendor/cakephp/cakephp'); | ||
define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS); | ||
define('CAKE', CORE_PATH . 'src' . DS); | ||
|
||
require ROOT . '/vendor/autoload.php'; | ||
require CORE_PATH . 'config/bootstrap.php'; | ||
|
||
Cake\Core\Configure::write('App', ['namespace' => 'App']); | ||
Cake\Core\Configure::write('debug', true); | ||
|
||
$TMP = new \Cake\Filesystem\Folder(TMP); | ||
$TMP->create(TMP . 'cache/models', 0777); | ||
$TMP->create(TMP . 'cache/persistent', 0777); | ||
$TMP->create(TMP . 'cache/views', 0777); | ||
|
||
$cache = [ | ||
'default' => [ | ||
'engine' => 'File' | ||
], | ||
'_cake_core_' => [ | ||
'className' => 'File', | ||
'prefix' => 'upload_myapp_cake_core_', | ||
'path' => CACHE . 'persistent/', | ||
'serialize' => true, | ||
'duration' => '+10 seconds' | ||
], | ||
'_cake_model_' => [ | ||
'className' => 'File', | ||
'prefix' => 'upload_my_app_cake_model_', | ||
'path' => CACHE . 'models/', | ||
'serialize' => 'File', | ||
'duration' => '+10 seconds' | ||
] | ||
]; | ||
|
||
Cake\Cache\Cache::setConfig($cache); | ||
Cake\Core\Configure::write('Session', [ | ||
'defaults' => 'php' | ||
]); | ||
|
||
// Ensure default test connection is defined | ||
if (!getenv('db_dsn')) { | ||
putenv('db_dsn=sqlite:///:memory:'); | ||
} | ||
|
||
Cake\Datasource\ConnectionManager::setConfig('test', [ | ||
'url' => getenv('db_dsn'), | ||
'timezone' => 'UTC' | ||
]); | ||
$root = $findRoot(__FILE__); | ||
unset($findRoot); | ||
chdir($root); | ||
|
||
loadPHPUnitAliases(); | ||
require $root . '/vendor/cakephp/cakephp/tests/bootstrap.php'; |