Files
cheese-cake/tests/bootstrap.php

86 lines
2.4 KiB
PHP
Raw Normal View History

2024-03-31 01:45:24 -07:00
<?php
declare(strict_types=1);
2026-03-17 01:35:40 -07:00
use Cake\Core\Configure;
//use Cake\TestSuite\Fixture\SchemaLoader;
define('PLUGIN_ROOT', dirname(__DIR__));
define('ROOT', PLUGIN_ROOT . DS . 'tests' . DS . 'test_app');
define('TMP', PLUGIN_ROOT . DS . 'tmp' . DS);
define('LOGS', TMP . 'logs' . DS);
define('CACHE', TMP . 'cache' . DS);
define('APP', ROOT . DS . 'src' . DS);
define('APP_DIR', 'src');
define('CAKE_CORE_INCLUDE_PATH', PLUGIN_ROOT . '/vendor/cakephp/cakephp');
define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
define('CAKE', CORE_PATH . APP_DIR . DS);
define('WWW_ROOT', PLUGIN_ROOT . DS . 'webroot' . DS);
define('TESTS', __DIR__ . DS);
define('CONFIG', TESTS . 'config' . DS);
ini_set('intl.default_locale', 'en-US');
2024-03-31 01:45:24 -07:00
/**
* Test suite bootstrap for CheeseCakePlugin.
*
* 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) {
2026-03-17 01:35:40 -07:00
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');
2024-03-31 01:45:24 -07:00
};
$root = $findRoot(__FILE__);
unset($findRoot);
chdir($root);
require_once $root . '/vendor/autoload.php';
/**
* Define fallback values for required constants and configuration.
* To customize constants and configuration remove this require
* and define the data required by your plugin here.
*/
require_once $root . '/vendor/cakephp/cakephp/tests/bootstrap.php';
if (file_exists($root . '/config/bootstrap.php')) {
2026-03-17 01:35:40 -07:00
require $root . '/config/bootstrap.php';
2024-03-31 01:45:24 -07:00
2026-03-17 01:35:40 -07:00
return;
2024-03-31 01:45:24 -07:00
}
2026-03-17 01:35:40 -07:00
Configure::write('App', [
'namespace' => 'TestApp',
'encoding' => 'UTF-8',
'paths' => [
'testWebroot' => PLUGIN_ROOT . DS . 'tests' . DS . 'test_app' . DS . 'webroot' . DS,
'webroot' => PLUGIN_ROOT . DS . 'webroot' . DS,
'templates' => [
PLUGIN_ROOT . DS . 'tests' . DS . 'test_app' . DS . 'templates' . DS,
],
],
]);
2024-03-31 01:45:24 -07:00
/**
* Load schema from a SQL dump file.
*
* If your plugin does not use database fixtures you can
* safely delete this.
*
* If you want to support multiple databases, consider
* using migrations to provide schema for your plugin,
* and using \Migrations\TestSuite\Migrator to load schema.
*/
// Load a schema dump file.
2026-03-17 01:35:40 -07:00
//(new SchemaLoader())->loadSqlFiles('tests/schema.sql', 'test');