Skip to content

Commit

Permalink
Adding formatted option for migration command
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenRenaux committed Aug 14, 2023
1 parent 79c710b commit c3d8539
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Maker/MakeMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ public function configureCommand(Command $command, InputConfiguration $inputConf
->addOption('shard', null, InputOption::VALUE_REQUIRED, 'The shard connection name')
;
}

$command
->addOption('formatted', null, InputOption::VALUE_NONE, 'Format the generated SQL');
}

public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator)
Expand All @@ -88,6 +91,10 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
}
// end 2.x support

if ($input->hasOption('formatted') && null !== $input->getOption('formatted')) {
$options[] = '--formatted';
}

$generateMigrationCommand = $this->application->find('doctrine:migrations:diff');
$generateMigrationCommandInput = new ArgvInput($options);

Expand Down
12 changes: 12 additions & 0 deletions tests/Maker/MakeMigrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,17 @@ public function getTestDetails(): \Generator
$this->assertStringNotContainsString('Success', $output);
}),
];

yield 'it_generate_a_formatted_migration' => [$this->createMakeMigrationTest()
->addRequiredPackageVersion('doctrine/doctrine-migrations-bundle', '>=3')
->run(function (MakerTestRunner $runner) {

$runner->runConsole('make:migration', [], '--formatted');

$output = $runner->runMaker([/* no input */]);

$this->assertStringContainsString('Success', $output);
}),
];
}
}

0 comments on commit c3d8539

Please sign in to comment.