FIX: no borra todo

This commit is contained in:
Juan Pablo Vial
2025-05-07 19:22:39 -04:00
parent a405b15410
commit 43eb8ec758

View File

@ -52,12 +52,16 @@ class TestBootstrap
{
public function __construct(protected array $configuration) {}
public function run(): void
public function run(bool $resetDatabase = false): void
{
if (Benchmark::execute([$this, 'isMigrated'])) {
Benchmark::execute([$this, 'resetDatabase']);
if ($resetDatabase) {
if (Benchmark::execute([$this, 'isMigrated'])) {
Benchmark::execute([$this, 'resetDatabase']);
}
}
if (!Benchmark::execute([$this, 'isMigrated'])) {
Benchmark::execute([$this, 'migrate']);
}
Benchmark::execute([$this, 'migrate']);
}
protected string $baseCommand = "bin/phinx";
@ -67,7 +71,7 @@ class TestBootstrap
$output = shell_exec($cmd);
$status = json_decode($output, true);
return $status['missing_count'] > 0;
return $status['missing_count'] === 0;
}
public function migrate(): void
{
@ -162,7 +166,8 @@ spl_autoload_register(function($className) {
});
$bootstrap = new TestBootstrap($_ENV);
Benchmark::execute([$bootstrap, 'run']);
$resetDatabase = $_ENV['RESET_DATABASE'] ?? false;
Benchmark::execute([$bootstrap, 'run'], ['resetDatabase' => $resetDatabase]);
Benchmark::print();
register_shutdown_function(function() use ($bootstrap) {