Skip to content

Commit

Permalink
Merge pull request #1308 from e-jevdokimovs/fix-all-or-nothing-bug
Browse files Browse the repository at this point in the history
Fixed `all-or-nothing` console input value determination.
  • Loading branch information
greg0ire committed Jan 17, 2023
2 parents d719811 + 5335951 commit e327d1f
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 e327d1f

Please sign in to comment.