FIX: no borra todo
This commit is contained in:
@ -52,12 +52,16 @@ class TestBootstrap
|
|||||||
{
|
{
|
||||||
public function __construct(protected array $configuration) {}
|
public function __construct(protected array $configuration) {}
|
||||||
|
|
||||||
public function run(): void
|
public function run(bool $resetDatabase = false): void
|
||||||
{
|
{
|
||||||
if (Benchmark::execute([$this, 'isMigrated'])) {
|
if ($resetDatabase) {
|
||||||
Benchmark::execute([$this, '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";
|
protected string $baseCommand = "bin/phinx";
|
||||||
@ -67,7 +71,7 @@ class TestBootstrap
|
|||||||
$output = shell_exec($cmd);
|
$output = shell_exec($cmd);
|
||||||
$status = json_decode($output, true);
|
$status = json_decode($output, true);
|
||||||
|
|
||||||
return $status['missing_count'] > 0;
|
return $status['missing_count'] === 0;
|
||||||
}
|
}
|
||||||
public function migrate(): void
|
public function migrate(): void
|
||||||
{
|
{
|
||||||
@ -162,7 +166,8 @@ spl_autoload_register(function($className) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$bootstrap = new TestBootstrap($_ENV);
|
$bootstrap = new TestBootstrap($_ENV);
|
||||||
Benchmark::execute([$bootstrap, 'run']);
|
$resetDatabase = $_ENV['RESET_DATABASE'] ?? false;
|
||||||
|
Benchmark::execute([$bootstrap, 'run'], ['resetDatabase' => $resetDatabase]);
|
||||||
Benchmark::print();
|
Benchmark::print();
|
||||||
|
|
||||||
register_shutdown_function(function() use ($bootstrap) {
|
register_shutdown_function(function() use ($bootstrap) {
|
||||||
|
Reference in New Issue
Block a user