|
| 1 | +<?php |
| 2 | + |
| 3 | +ini_set('error_reporting', E_ALL); |
| 4 | + |
| 5 | +ini_set('display_errors', '1'); |
| 6 | +ini_set('display_startup_errors', '1'); |
| 7 | + |
| 8 | +// Make sure it recognizes that we're testing. |
| 9 | +$_SERVER['CI_ENVIRONMENT'] = 'testing'; |
| 10 | +define('ENVIRONMENT', 'testing'); |
| 11 | + |
| 12 | +// Load our paths config file |
| 13 | +require __DIR__ . '/../vendor/codeigniter4/codeigniter4/app/Config/Paths.php'; |
| 14 | +$paths = new Config\Paths(); |
| 15 | + |
| 16 | +// Define necessary framework path constants |
| 17 | +define('APPPATH', realpath($paths->appDirectory) . DIRECTORY_SEPARATOR); |
| 18 | +define('ROOTPATH', realpath(APPPATH . '../') . DIRECTORY_SEPARATOR); |
| 19 | +define('FCPATH', realpath(ROOTPATH . 'public') . DIRECTORY_SEPARATOR); |
| 20 | +define('SYSTEMPATH', realpath($paths->systemDirectory) . DIRECTORY_SEPARATOR); |
| 21 | +define('WRITEPATH', realpath($paths->writableDirectory) . DIRECTORY_SEPARATOR); |
| 22 | + |
| 23 | +// Define necessary module test path constants |
| 24 | +define('MODULEPATH', realpath(__DIR__ . '/../') . DIRECTORY_SEPARATOR); |
| 25 | +define('TESTPATH', realpath(__DIR__) . DIRECTORY_SEPARATOR); |
| 26 | +define('SUPPORTPATH', realpath(TESTPATH . '_support/') . DIRECTORY_SEPARATOR); |
| 27 | +define('COMPOSER_PATH', MODULEPATH . 'vendor/autoload.php'); |
| 28 | + |
| 29 | +// Set environment values that would otherwise stop the framework from functioning during tests. |
| 30 | +if (! isset($_SERVER['app.baseURL'])) |
| 31 | +{ |
| 32 | + $_SERVER['app.baseURL'] = 'http://example.com'; |
| 33 | +} |
| 34 | + |
| 35 | +// Load necessary modules |
| 36 | +require_once APPPATH . 'Config/Autoload.php'; |
| 37 | +require_once APPPATH . 'Config/Constants.php'; |
| 38 | +require_once APPPATH . 'Config/Modules.php'; |
| 39 | + |
| 40 | +require_once SYSTEMPATH . 'Autoloader/Autoloader.php'; |
| 41 | +require_once SYSTEMPATH . 'Config/BaseService.php'; |
| 42 | +require_once APPPATH . 'Config/Services.php'; |
| 43 | + |
| 44 | +// Use Config\Services as CodeIgniter\Services |
| 45 | +if (! class_exists('CodeIgniter\Services', false)) |
| 46 | +{ |
| 47 | + class_alias('Config\Services', 'CodeIgniter\Services'); |
| 48 | +} |
| 49 | + |
| 50 | +// Launch the autoloader to gather namespaces (includes composer.json's "autoload-dev") |
| 51 | +$loader = \CodeIgniter\Services::autoloader(); |
| 52 | +$loader->initialize(new Config\Autoload(), new Config\Modules()); |
| 53 | +$loader->register(); // Register the loader with the SPL autoloader stack. |
0 commit comments