From bf03e10b5446abdd3b1164df689a2f38a8111f0c Mon Sep 17 00:00:00 2001 From: kj Date: Sat, 5 Sep 2026 13:25:47 -0300 Subject: [PATCH] test(bootstrap): add smoke test for autoload and test DB --- tests/Unit/BootstrapTest.php | 51 ++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 tests/Unit/BootstrapTest.php diff --git a/tests/Unit/BootstrapTest.php b/tests/Unit/BootstrapTest.php new file mode 100644 index 0000000..114e159 --- /dev/null +++ b/tests/Unit/BootstrapTest.php @@ -0,0 +1,51 @@ +assertTrue( + class_exists(Neuron::class), + 'FALTA AUTOLOAD: autoload.php no resolvio Libs\Neuron; revisa ROOT_CORE y ejecuta desde la raiz' + ); + + $neuron = new Neuron(['clave' => 'valor']); + $this->assertSame('valor', $neuron->clave); + $this->assertNull($neuron->inexistente); + } + + public function testDatabaseConstantsPointToInMemorySqlite(): void + { + $this->assertSame( + 'sqlite', + DB_TYPE, + 'FALTA OVERRIDE: DB_TYPE viene de config.php; el bootstrap debe definir las constantes ANTES de require autoload.php' + ); + $this->assertSame(':memory:', DB_NAME, 'DB_NAME deberia ser :memory: para no tocar discos ni servidores'); + } + + public function testTestDatabaseIsUsable(): void + { + $db = self::db(); + $this->assertInstanceOf(PDO::class, $db, 'No se pudo obtener la PDO de prueba'); + $this->assertSame($db, self::db(), 'Database::getInstance deberia devolver el mismo singleton'); + + $db->exec('CREATE TABLE smoke (id INTEGER PRIMARY KEY, v TEXT)'); + $db->prepare('INSERT INTO smoke (v) VALUES (?)')->execute(['cuac']); + $this->assertSame('cuac', $db->query('SELECT v FROM smoke')->fetchColumn()); + $db->exec('DROP TABLE smoke'); + } +}