Skip to content

Commit

Permalink
Fixed all-or-nothing console input value determination.
Browse files Browse the repository at this point in the history
This fixes a bug that was introduced in #1296 where the configuration
value of allOrNothing got set to true if the command didn't have an
all-or-nothing option. Now the value is set from input options only if
the command that is being executed has an `all-or-nothing` option.
  • Loading branch information
e-jevdokimovs committed Jan 17, 2023
1 parent d719811 commit 5335951
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
Expand Up @@ -31,12 +31,12 @@ public function getMigratorConfiguration(InputInterface $input): MigratorConfigu

private function determineAllOrNothingValueFrom(InputInterface $input): ?bool
{
$allOrNothingOption = null;

if ($input->hasOption('all-or-nothing')) {
$allOrNothingOption = $input->getOption('all-or-nothing');
if (! $input->hasOption('all-or-nothing')) {
return null;
}

$allOrNothingOption = $input->getOption('all-or-nothing');

if ($allOrNothingOption === 'notprovided') {
return null;
}
Expand Down
Expand Up @@ -177,6 +177,28 @@ public function testExecuteCancel(): void
self::assertSame(1, $this->executeCommandTester->getStatusCode());
}

public function testExecuteAllOrNothingDefaultsToFalse(): void
{
$this->executeCommandTester->setInputs(['yes']);

$this->migrator
->expects(self::once())
->method('migrate')
->willReturnCallback(static function (MigrationPlanList $planList, MigratorConfiguration $configuration): array {
self::assertFalse($configuration->isAllOrNothing());

return ['A'];
});

$this->executeCommandTester->execute([
'versions' => ['1'],
'--down' => true,
]);

self::assertSame(0, $this->executeCommandTester->getStatusCode());
self::assertStringContainsString('[notice] Executing 1 up', trim($this->executeCommandTester->getDisplay(true)));
}

protected function setUp(): void
{
$connection = $this->getSqliteConnection();
Expand Down

0 comments on commit 5335951

Please sign in to comment.