57 lines
1.7 KiB
PHP
57 lines
1.7 KiB
PHP
<?php
|
|
// tests/_support/bootstrap.php
|
|
|
|
if (! getenv('CI_ENVIRONMENT')) {
|
|
putenv('CI_ENVIRONMENT=testing');
|
|
$_ENV['CI_ENVIRONMENT'] = 'testing';
|
|
$_SERVER['CI_ENVIRONMENT'] = 'testing';
|
|
}
|
|
|
|
// Minimal Locale polyfill when the intl extension is unavailable in the test PHP build.
|
|
if (! class_exists(\Locale::class, false)) {
|
|
class Locale
|
|
{
|
|
private static string $default = 'en';
|
|
|
|
public static function setDefault(string $locale): bool
|
|
{
|
|
self::$default = $locale;
|
|
|
|
return true;
|
|
}
|
|
|
|
public static function getDefault(): string
|
|
{
|
|
return self::$default;
|
|
}
|
|
}
|
|
}
|
|
|
|
$writablePath = realpath(__DIR__ . '/../..') . DIRECTORY_SEPARATOR . 'writable';
|
|
$runtimeDirectories = [
|
|
$writablePath . DIRECTORY_SEPARATOR . 'cache',
|
|
$writablePath . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'testing',
|
|
$writablePath . DIRECTORY_SEPARATOR . 'logs',
|
|
$writablePath . DIRECTORY_SEPARATOR . 'session',
|
|
$writablePath . DIRECTORY_SEPARATOR . 'uploads',
|
|
$writablePath . DIRECTORY_SEPARATOR . 'debugbar',
|
|
];
|
|
|
|
foreach ($runtimeDirectories as $directory) {
|
|
if (! is_dir($directory) && ! mkdir($directory, 0775, true) && ! is_dir($directory)) {
|
|
fwrite(STDERR, "Unable to create writable test directory: {$directory}" . PHP_EOL);
|
|
exit(1);
|
|
}
|
|
|
|
if (! is_writable($directory)) {
|
|
fwrite(STDERR, "Writable test directory is not writable: {$directory}" . PHP_EOL);
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
// Load Composer autoloader
|
|
require __DIR__ . '/../../vendor/autoload.php';
|
|
|
|
// Load CodeIgniter testing bootstrap from Composer package
|
|
require __DIR__ . '/../../vendor/codeigniter4/framework/system/Test/bootstrap.php';
|