diff --git a/src/Command/MigrationCheckCommand.php b/src/Command/MigrationCheckCommand.php index f2e557a..cb36b02 100644 --- a/src/Command/MigrationCheckCommand.php +++ b/src/Command/MigrationCheckCommand.php @@ -40,7 +40,7 @@ protected function configure(): void $this->setDescription('Check if entities are in sync with database and if migrations were executed'); } - public function run(InputInterface $input, OutputInterface $output): int + public function execute(InputInterface $input, OutputInterface $output): int { $exitCode = self::EXIT_OK; $exitCode |= $this->checkMigrationsExecuted($output); diff --git a/src/Command/MigrationGenerateCommand.php b/src/Command/MigrationGenerateCommand.php index 033ea5c..8cab127 100644 --- a/src/Command/MigrationGenerateCommand.php +++ b/src/Command/MigrationGenerateCommand.php @@ -31,7 +31,7 @@ protected function configure(): void $this->setDescription('Generate migration class'); } - public function run(InputInterface $input, OutputInterface $output): int + public function execute(InputInterface $input, OutputInterface $output): int { $sqls = $this->migrationService->generateDiffSqls(); diff --git a/src/Command/MigrationInitCommand.php b/src/Command/MigrationInitCommand.php index 6c708ae..02b2fe5 100644 --- a/src/Command/MigrationInitCommand.php +++ b/src/Command/MigrationInitCommand.php @@ -31,7 +31,7 @@ protected function configure(): void $this->setDescription('Create migration table in database'); } - public function run(InputInterface $input, OutputInterface $output): int + public function execute(InputInterface $input, OutputInterface $output): int { $output->write('Creating migration table... '); $initialized = $this->migrationService->initializeMigrationTable(); diff --git a/src/Command/MigrationRunCommand.php b/src/Command/MigrationRunCommand.php index 0553c74..3e254dd 100644 --- a/src/Command/MigrationRunCommand.php +++ b/src/Command/MigrationRunCommand.php @@ -43,7 +43,7 @@ protected function configure(): void ->addArgument(self::ARGUMENT_PHASE, InputArgument::REQUIRED, MigrationPhase::BEFORE . '|' . MigrationPhase::AFTER . '|' . self::PHASE_BOTH); } - public function run(InputInterface $input, OutputInterface $output): int + public function execute(InputInterface $input, OutputInterface $output): int { $phaseArgument = $input->getArgument(self::ARGUMENT_PHASE); diff --git a/src/Command/MigrationSkipCommand.php b/src/Command/MigrationSkipCommand.php index a7f128b..7e4cea6 100644 --- a/src/Command/MigrationSkipCommand.php +++ b/src/Command/MigrationSkipCommand.php @@ -32,7 +32,7 @@ protected function configure(): void $this->setDescription('Mark all not executed migrations as executed in both phases'); } - public function run(InputInterface $input, OutputInterface $output): int + public function execute(InputInterface $input, OutputInterface $output): int { $skipped = false; diff --git a/tests/Command/MigrationRunCommandTest.php b/tests/Command/MigrationRunCommandTest.php index 31abdf8..0694d7a 100644 --- a/tests/Command/MigrationRunCommandTest.php +++ b/tests/Command/MigrationRunCommandTest.php @@ -9,6 +9,7 @@ use ShipMonk\Doctrine\Migration\MigrationService; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\BufferedOutput; +use Symfony\Component\Console\Tester\CommandTester; use const PHP_EOL; class MigrationRunCommandTest extends TestCase @@ -72,6 +73,14 @@ public function testRunBoth(): void self::assertSame($output, $this->runPhase($command, MigrationRunCommand::PHASE_BOTH)); } + public function testFailureNoArgs(): void + { + self::expectExceptionMessage('Not enough arguments (missing: "phase").'); + + $tester = new CommandTester(new MigrationRunCommand($this->createMock(MigrationService::class))); + $tester->execute([]); + } + private function runPhase(MigrationRunCommand $command, string $phase): string { $input = new ArrayInput([MigrationRunCommand::ARGUMENT_PHASE => $phase], $command->getDefinition());