Skip to content

Commit 50dcf47

Browse files
committed
Merge branch 'feature/symfony-3.1'
2 parents 7aa18e5 + f3db292 commit 50dcf47

File tree

6 files changed

+47
-21
lines changed

6 files changed

+47
-21
lines changed

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
"require": {
1313
"php": ">=5.3.2",
1414
"doctrine/mongodb": "1.*",
15-
"symfony/console": "2.*",
16-
"symfony/yaml": "2.*"
15+
"symfony/console": "^2.5|^3.0",
16+
"symfony/yaml": "^2.5|^3.0"
1717
},
1818
"require-dev": {
1919
"antimattr/test-case": "~1.0@stable",
2020
"phpunit/phpunit": "~4.0",
21-
"fabpot/php-cs-fixer": "0.5.*@dev",
21+
"friendsofphp/php-cs-fixer": "^1.0",
2222
"mikey179/vfsStream": "1.*"
2323
},
2424
"minimum-stability": "dev",

src/AntiMattr/MongoDB/Migrations/Configuration/YamlConfiguration.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
class YamlConfiguration extends AbstractFileConfiguration
2020
{
2121
/**
22-
* @inheritdoc
22+
* {@inheritdoc}
2323
*/
2424
protected function doLoad($file)
2525
{
26-
$array = Yaml::parse($file);
26+
$array = Yaml::parse(file_get_contents($file));
2727

2828
if (isset($array['name'])) {
2929
$this->setName($array['name']);

src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/ExecuteCommand.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symfony\Component\Console\Input\InputInterface;
1818
use Symfony\Component\Console\Input\InputOption;
1919
use Symfony\Component\Console\Output\OutputInterface;
20+
use Symfony\Component\Console\Question\ConfirmationQuestion;
2021

2122
/**
2223
* @author Matthew Fitzgerald <matthewfitz@gmail.com>
@@ -66,7 +67,15 @@ public function execute(InputInterface $input, OutputInterface $output)
6667
if (!$input->isInteractive()) {
6768
$version->execute($direction);
6869
} else {
69-
$confirmation = $this->getHelper('dialog')->askConfirmation($output, '<question>WARNING! You are about to execute a database migration that could result in data lost. Are you sure you wish to continue? (y/n)</question>', false);
70+
$question = new ConfirmationQuestion(
71+
'<question>WARNING! You are about to execute a database migration that could result in data lost. Are you sure you wish to continue? (y/n)</question> ',
72+
'n'
73+
);
74+
75+
$confirmation = $this
76+
->getHelper('question')
77+
->ask($input, $output, $question);
78+
7079
if ($confirmation === true) {
7180
$version->execute($direction);
7281
} else {

src/AntiMattr/MongoDB/Migrations/Tools/Console/Command/MigrateCommand.php

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\Console\Input\InputArgument;
1717
use Symfony\Component\Console\Input\InputInterface;
1818
use Symfony\Component\Console\Output\OutputInterface;
19+
use Symfony\Component\Console\Question\ConfirmationQuestion;
1920

2021
/**
2122
* @author Matthew Fitzgerald <matthewfitz@gmail.com>
@@ -81,8 +82,16 @@ public function execute(InputInterface $input, OutputInterface $output)
8182
}
8283

8384
if (! $noInteraction) {
84-
$confirmation = $this->getHelper('dialog')->askConfirmation($output, '<question>Are you sure you wish to continue? (y/n)</question>', false);
85-
if (! $confirmation) {
85+
$question = new ConfirmationQuestion(
86+
'<question>Are you sure you wish to continue? (y/n)</question> ',
87+
'n'
88+
);
89+
90+
$confirmation = $this
91+
->getHelper('question')
92+
->ask($input, $output, $question);
93+
94+
if (!$confirmation) {
8695
$output->writeln('<error>Migration cancelled!</error>');
8796

8897
return 1;
@@ -92,7 +101,15 @@ public function execute(InputInterface $input, OutputInterface $output)
92101

93102
// warn the user if no dry run and interaction is on
94103
if (! $noInteraction) {
95-
$confirmation = $this->getHelper('dialog')->askConfirmation($output, '<question>WARNING! You are about to execute a database migration that could result in data lost. Are you sure you wish to continue? (y/n)</question>', false);
104+
$question = new ConfirmationQuestion(
105+
'<question>WARNING! You are about to execute a database migration that could result in data lost. Are you sure you wish to continue? (y/n)</question> ',
106+
'n'
107+
);
108+
109+
$confirmation = $this
110+
->getHelper('question')
111+
->ask($input, $output, $question);
112+
96113
if (! $confirmation) {
97114
$output->writeln('<error>Migration cancelled!</error>');
98115

tests/AntiMattr/Tests/MongoDB/Migrations/Tools/Console/Command/ExecuteCommandTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function testExecuteDownWithoutInteraction()
3939
'application-name',
4040
ExecuteCommand::NAME,
4141
$numVersion,
42-
'--down'
42+
'--down',
4343
)
4444
);
4545

@@ -72,13 +72,13 @@ public function testExecuteDownWithoutInteraction()
7272
public function testExecuteUpWithInteraction()
7373
{
7474
// Mocks
75-
$dialog = $this->buildMock('Symfony\Component\Console\Helper\DialogHelper');
75+
$question = $this->buildMock('Symfony\Component\Console\Helper\QuestionHelper');
7676

7777
// Variables and Objects
7878
$application = new Application();
7979
$helperSet = new HelperSet(
8080
array(
81-
'dialog' => $dialog
81+
'question' => $question,
8282
)
8383
);
8484
$numVersion = '1234567890';
@@ -89,7 +89,7 @@ public function testExecuteUpWithInteraction()
8989
array(
9090
'application-name',
9191
ExecuteCommand::NAME,
92-
$numVersion
92+
$numVersion,
9393
)
9494
);
9595

@@ -108,8 +108,8 @@ public function testExecuteUpWithInteraction()
108108
)
109109
;
110110

111-
$dialog->expects($this->once())
112-
->method('askConfirmation')
111+
$question->expects($this->once())
112+
->method('ask')
113113
->will(
114114
$this->returnValue(true)
115115
)

tests/AntiMattr/Tests/MongoDB/Migrations/Tools/Console/Command/MigrateCommandTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ public function testExecuteWithExectedUnavailableVersionAndInteraction()
2828
$configuration = $this->buildMock('AntiMattr\MongoDB\Migrations\Configuration\Configuration');
2929
$executedVersion = $this->buildMock('AntiMattr\MongoDB\Migrations\Version');
3030
$migration = $this->buildMock('AntiMattr\MongoDB\Migrations\Migration');
31-
$dialog = $this->buildMock('Symfony\Component\Console\Helper\DialogHelper');
31+
$question = $this->buildMock('Symfony\Component\Console\Helper\QuestionHelper');
3232

3333
// Variables and Objects
3434
$numVersion = '000123456789';
3535
$input = new ArgvInput(
3636
array(
3737
'application-name',
3838
MigrateCommand::NAME,
39-
$numVersion
39+
$numVersion,
4040
)
4141
);
4242
$interactive = true;
@@ -45,7 +45,7 @@ public function testExecuteWithExectedUnavailableVersionAndInteraction()
4545
$application = new Application();
4646
$helperSet = new HelperSet(
4747
array(
48-
'dialog' => $dialog
48+
'question' => $question,
4949
)
5050
);
5151

@@ -71,8 +71,8 @@ public function testExecuteWithExectedUnavailableVersionAndInteraction()
7171
)
7272
;
7373

74-
$dialog->expects($this->exactly(2))
75-
->method('askConfirmation')
74+
$question->expects($this->exactly(2))
75+
->method('ask')
7676
->will(
7777
$this->returnValue(true)
7878
)
@@ -102,7 +102,7 @@ public function testExecute()
102102
$input = new ArgvInput(
103103
array(
104104
MigrateCommand::NAME,
105-
$numVersion
105+
$numVersion,
106106
)
107107
);
108108
$interactive = false;

0 commit comments

Comments
 (0)