Skip to content

Commit a6b142e

Browse files
committed
bug #795 Support running make:migration non-interactively (kick-the-bucket)
This PR was squashed before being merged into the 1.0-dev branch. Discussion ---------- Support running make:migration non-interactively Commits ------- b99d4bf Support running make:migration non-interactively
2 parents 4a3a729 + b99d4bf commit a6b142e

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

src/Maker/MakeMigration.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,15 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
9191
// end 2.x support
9292

9393
$generateMigrationCommand = $this->application->find('doctrine:migrations:diff');
94+
$generateMigrationCommandInput = new ArgvInput($options);
95+
96+
if (!$input->isInteractive()) {
97+
$generateMigrationCommandInput->setInteractive(false);
98+
}
9499

95100
$commandOutput = new MigrationDiffFilteredOutput($io->getOutput());
96101
try {
97-
$returnCode = $generateMigrationCommand->run(new ArgvInput($options), $commandOutput);
102+
$returnCode = $generateMigrationCommand->run($generateMigrationCommandInput, $commandOutput);
98103

99104
// non-zero code would ideally mean the internal command has already printed an errror
100105
// this happens if you "decline" generating a migration when you already

src/MakerInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
/**
1818
* Interface that all maker commands must implement.
1919
*
20-
* @method string getCommandDescription()
20+
* @method static string getCommandDescription()
2121
*
2222
* @author Ryan Weaver <[email protected]>
2323
*/

tests/Maker/FunctionalTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Bundle\FrameworkBundle\Console\Application;
1717
use Symfony\Bundle\MakerBundle\Command\MakerCommand;
1818
use Symfony\Bundle\MakerBundle\Test\MakerTestKernel;
19+
use Symfony\Component\Console\Command\LazyCommand;
1920
use Symfony\Component\Finder\Finder;
2021

2122
class FunctionalTest extends TestCase
@@ -44,6 +45,10 @@ public function testWiring()
4445
$maker->getMethod('getCommandName')->invoke(null)
4546
);
4647

48+
if ($command instanceof LazyCommand) {
49+
$command = $command->getCommand();
50+
}
51+
4752
// just a smoke test assert
4853
self::assertInstanceOf(MakerCommand::class, $command);
4954
}

tests/fixtures/MakeCommandInCustomRootNamespace/tests/GeneratedCommandTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Symfony\Bundle\FrameworkBundle\Console\Application;
66
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
7+
use Symfony\Component\Console\Command\LazyCommand;
78
use Symfony\Component\Console\Tester\CommandTester;
89

910
class GeneratedCommandTest extends KernelTestCase
@@ -14,6 +15,9 @@ public function testCommand()
1415
$application = new Application(self::$kernel);
1516

1617
$command = $application->find('app:foo');
18+
if ($command instanceof LazyCommand) {
19+
$command = $command->getCommand();
20+
}
1721

1822
$this->assertStringStartsWith('Custom\\', \get_class($command));
1923

0 commit comments

Comments
 (0)