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('TESTS', __DIR__ . 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');
|