clqms-be/tests/phpunit-bootstrap.php
root 30c4e47304 chore(repo): normalize EOL and harden contact patch flow
- handle contact PATCH failures by checking model save result and returning HTTP 400 with the model error message
- update ContactDetailModel nested updates to enforce active-detail checks and use model update() with explicit failure propagation
- extend contact patch assertions and align test-create variants expectations to status=success for POST responses
- refresh composer lock metadata/dependency constraints and include generated docs/data/test files updated during normalization
- impact: API contract unchanged except clearer 400 error responses on invalid contact detail updates
2026-04-17 05:38:11 +07:00

51 lines
1.3 KiB
PHP
Executable File

<?php
declare(strict_types=1);
require_once __DIR__ . '/../vendor/codeigniter4/framework/system/Test/bootstrap.php';
use CodeIgniter\Config\DotEnv;
use CodeIgniter\Database\Exceptions\DatabaseException;
use CodeIgniter\Database\MigrationRunner;
use Config\Database;
use Config\Migrations as MigrationsConfig;
if (defined('CLQMS_PHPUNIT_BOOTSTRAPPED') || ENVIRONMENT !== 'testing') {
return;
}
define('CLQMS_PHPUNIT_BOOTSTRAPPED', true);
(new DotEnv(ROOTPATH))->load();
$db = Database::connect('tests');
$forge = Database::forge('tests');
$db->query('SET FOREIGN_KEY_CHECKS=0');
foreach ($db->listTables() as $table) {
$forge->dropTable($table, true);
}
$db->query('SET FOREIGN_KEY_CHECKS=1');
$migrationsConfig = config(MigrationsConfig::class);
$migrationRunner = new MigrationRunner($migrationsConfig, 'tests');
try {
$migrationRunner->latest();
} catch (DatabaseException $e) {
$message = $e->getMessage();
if (strpos($message, 'already exists') === false) {
throw $e;
}
}
$initialBufferLevel = ob_get_level();
ob_start();
try {
$seeder = Database::seeder('tests');
$seeder->setSilent(true)->call('DBSeeder');
} finally {
while (ob_get_level() > $initialBufferLevel) {
ob_end_clean();
}
}