feat(test): add multi-engine integration matrix

This commit is contained in:
kj
2026-09-05 16:15:28 -03:00
parent 48d3ed6b3f
commit d0c4b3c503
15 changed files with 1278 additions and 38 deletions

View File

@@ -5,12 +5,52 @@
require_once __DIR__ . '/../vendor/autoload.php';
// Engine selection: DUCKBRAIN_TEST_DB=sqlite|mysql|pgsql (default: sqlite).
// sqlite uses an in-memory database, so the unit suite never needs services.
$engine = strtolower(getenv('DUCKBRAIN_TEST_DB') ?: 'sqlite');
$profiles = [
'sqlite' => [
'type' => 'sqlite',
'host' => 'localhost',
'name' => ':memory:',
'user' => '',
'pass' => '',
],
'mysql' => [
'type' => 'mysql',
'host' => '127.0.0.1',
'name' => 'duckbrain_test',
'user' => 'duckbrain',
'pass' => 'duckbrain',
],
'pgsql' => [
'type' => 'pgsql',
'host' => '127.0.0.1',
'name' => 'duckbrain_test',
'user' => 'duckbrain',
'pass' => 'duckbrain',
],
];
if (!isset($profiles[$engine])) {
fwrite(
STDERR,
"Invalid DUCKBRAIN_TEST_DB '{$engine}'. Expected one of: "
. implode(', ', array_keys($profiles)) . "\n"
);
exit(1);
}
// Define DB constants BEFORE config.php so the test database wins over the
// real configuration (config.php's define() warnings are suppressed by @).
define('DB_TYPE', 'sqlite');
define('DB_HOST', 'localhost');
define('DB_NAME', ':memory:');
define('DB_USER', '');
define('DB_PASS', '');
// Each field can be overridden without losing the engine's other defaults.
$profile = $profiles[$engine];
define('DB_TYPE', $profile['type']);
define('DB_HOST', getenv('DUCKBRAIN_TEST_HOST') ?: $profile['host']);
define('DB_NAME', getenv('DUCKBRAIN_TEST_NAME') ?: $profile['name']);
define('DB_USER', getenv('DUCKBRAIN_TEST_USER') ?: $profile['user']);
define('DB_PASS', getenv('DUCKBRAIN_TEST_PASS') ?: $profile['pass']);
@require_once __DIR__ . '/../autoload.php';