FIX: no borra todo
This commit is contained in:
@ -52,13 +52,17 @@ class TestBootstrap
|
||||
{
|
||||
public function __construct(protected array $configuration) {}
|
||||
|
||||
public function run(): void
|
||||
public function run(bool $resetDatabase = false): void
|
||||
{
|
||||
if ($resetDatabase) {
|
||||
if (Benchmark::execute([$this, 'isMigrated'])) {
|
||||
Benchmark::execute([$this, 'resetDatabase']);
|
||||
}
|
||||
}
|
||||
if (!Benchmark::execute([$this, 'isMigrated'])) {
|
||||
Benchmark::execute([$this, 'migrate']);
|
||||
}
|
||||
}
|
||||
|
||||
protected string $baseCommand = "bin/phinx";
|
||||
public function isMigrated(): bool
|
||||
@ -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) {
|
||||
|
Reference in New Issue
Block a user