fix(test): self-register Tests\ autoload and migrations dir in bootstrap
The harness failed under a real phpunit run because nothing mapped Tests\ -> tests/ and Commands\Migration needs migrations/ to exist. Declare commands:migration as the actual dependency.
This commit is contained in:
@@ -6,6 +6,18 @@ use Libs\Loader;
|
||||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
// Mapeo PSR-4 propio del arbol de pruebas (Tests\ -> tests/) sin exigir que el
|
||||
// proyecto declare autoload-dev en su composer.json.
|
||||
spl_autoload_register(function (string $class): void {
|
||||
if (!str_starts_with($class, 'Tests\\')) {
|
||||
return;
|
||||
}
|
||||
$file = __DIR__ . '/' . str_replace('\\', '/', substr($class, 6)) . '.php';
|
||||
if (is_file($file)) {
|
||||
require_once $file;
|
||||
}
|
||||
});
|
||||
|
||||
// ============================================
|
||||
// IMPORTANT: Definir constantes ANTES de cargar config.php
|
||||
// para sobreescribir la configuración para definir una
|
||||
@@ -20,6 +32,11 @@ define('DB_PASS', '');
|
||||
// Incluir config.php con el autoloader
|
||||
@require_once __DIR__ . '/../autoload.php';
|
||||
|
||||
// El ledger de migraciones (Commands\Migration) necesita el directorio.
|
||||
if (!is_dir(ROOT_DIR . '/migrations')) {
|
||||
mkdir(ROOT_DIR . '/migrations', 0777, true);
|
||||
}
|
||||
|
||||
// Router autoload
|
||||
Loader::load(ROOT_CORE . '/Routers/');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user