-
-
Notifications
You must be signed in to change notification settings - Fork 389
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't Prompt the User for Confirmation on the
migrations:migrate
Co…
…mmand When There is Nothing to Do (#480) * Improve the Tests for the Migrate Command This brings them inline with some of the other, newer command tests that use Symfony's command tester. There's more coverage as well. Done so some changes can be made to `MigrateCommand`. * Bail out of MigrationCommand::execute Early on --write-sql Removes a level of nesting from the rest of the method so some changes can be a bit nicer later on. * Move the "No Migrations..." Message into Migrations::migrate Provides the same output to the user as before. * Add a Confirmation Callback to Migration::migrate Provides a way to hook into the migration and ask the user for confirmation. Right now that happens further up stream in a console command. * Convert MigrateCommand to use the Confirmation Callback Means there's no longer a big warning or confirmation when no migrations are to be executed. * Re-Add Some Newlines Between @param, @return, and @throws * Don't Return `false` from Migrations::migrate on Cancel Because it's not really an error. This also reworks the console command to keep the same interface: returns a 1 status code on cancel and outputs "migrations cancelled"
- Loading branch information
1 parent
dbbcc24
commit 073195c
Showing
6 changed files
with
348 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
tests/Doctrine/DBAL/Migrations/Tests/Tools/Console/Command/DialogSupport.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace Doctrine\DBAL\Migrations\Tests\Tools\Console\Command; | ||
|
||
use Symfony\Component\Console\Application; | ||
use Symfony\Component\Console\Helper\QuestionHelper; | ||
use Symfony\Component\Console\Helper\DialogHelper; | ||
|
||
trait DialogSupport | ||
{ | ||
protected $questions, $isDialogHelper; | ||
|
||
protected function configureDialogs(Application $app) | ||
{ | ||
if (class_exists(QuestionHelper::class)) { | ||
$this->isDialogHelper = false; | ||
$this->questions = $this->getMock(QuestionHelper::class); | ||
} else { | ||
$this->isDialogHelper = true; | ||
$this->questions = $this->getMock(DialogHelper::class); | ||
} | ||
$app->getHelperSet()->set($this->questions, $this->isDialogHelper ? 'dialog' : 'question'); | ||
} | ||
|
||
protected function willAskConfirmationAndReturn($bool) | ||
{ | ||
$this->questions->expects($this->once()) | ||
->method($this->isDialogHelper ? 'askConfirmation' : 'ask') | ||
->willReturn($bool); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.