57 lines
1.7 KiB
PHP
57 lines
1.7 KiB
PHP
<?php
|
|
|
|
// Test bootstrap for the DuckBrain development harness.
|
|
// Run PHPUnit from the project root (autoload.php resolves config.php via cwd).
|
|
|
|
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 @).
|
|
// 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';
|