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:
kj
2026-10-05 17:36:08 -03:00
parent 0082cbe3f4
commit eb5e6eeed4
2 changed files with 31 additions and 4 deletions
+17
View File
@@ -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/');