Skip to content
This repository was archived by the owner on Jul 8, 2024. It is now read-only.

Commit 251e618

Browse files
committed
Merge pull request #131 from lexxorlov/master
Updates to Symfony >= 2.5 components
2 parents 46d6248 + 442ad7b commit 251e618

5 files changed

Lines changed: 47 additions & 29 deletions

File tree

composer.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,24 @@
2626
"php": ">=5.3.6",
2727
"ext-zip": "*",
2828
"ext-fileinfo": "*",
29-
"symfony/console": "~2.3",
30-
"symfony/finder": "~2.2",
31-
"symfony/filesystem": "~2.1",
32-
"symfony/process": "~2.1",
29+
"symfony/console": "~2.3|~3.0",
30+
"symfony/finder": "~2.3|~3.0",
31+
"symfony/filesystem": "~2.3|~3.0",
32+
"symfony/process": "~2.3|~3.0",
3333
"camspiers/json-pretty": "1.0.*",
3434
"knplabs/github-api": "1.4.*",
3535
"vierbergenlars/php-semver": "~3.0"
3636
},
37-
"require-dev":{
37+
"require-dev": {
3838
"ext-phar": "*",
3939
"phpunit/phpunit": "4.*",
4040
"mockery/mockery": "~0.9.3",
4141
"fabpot/php-cs-fixer": "~1.5"
4242
},
4343
"autoload": {
44-
"psr-4": { "Bowerphp\\": "src/Bowerphp" }
44+
"psr-4": {
45+
"Bowerphp\\": "src/Bowerphp"
46+
}
4547
},
4648
"bin": ["bin/bowerphp"],
4749
"extra": {

src/Bowerphp/Command/InitCommand.php

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,29 @@ protected function execute(InputInterface $input, OutputInterface $output)
5050

5151
// @codeCoverageIgnoreStart
5252
if ($input->isInteractive()) {
53-
$dialog = $this->getHelperSet()->get('dialog');
53+
if (class_exists('Symfony\Component\Console\Helper\DialogHelper')) {
54+
$dialog = $this->getHelperSet()->get('dialog');
55+
$params['name'] = $dialog->ask(
56+
$output,
57+
$dialog->getQuestion('Please specify a name for project', $params['name']),
58+
$params['name']
59+
);
60+
$params['author'] = $dialog->ask(
61+
$output,
62+
$dialog->getQuestion('Please specify an author', $params['author']),
63+
$params['author']
64+
);
65+
} else {
66+
$dialog = $this->getHelperSet()->get('question');
5467

55-
$params['name'] = $dialog->ask(
56-
$output,
57-
$dialog->getQuestion('Please specify a name for project', $params['name']),
58-
$params['name']
59-
);
68+
$params['name'] = $dialog->ask(
69+
$input, $output, $dialog->getQuestion('Please specify a name for project', $params['name'])
70+
);
6071

61-
$params['author'] = $dialog->ask(
62-
$output,
63-
$dialog->getQuestion('Please specify an author', $params['author']),
64-
$params['author']
65-
);
72+
$params['author'] = $dialog->ask(
73+
$input, $output, $dialog->getQuestion('Please specify an author', $params['author'])
74+
);
75+
}
6676
}
6777
// @codeCoverageIgnoreEnd
6878
$bowerphp = $this->getBowerphp($output);

src/Bowerphp/Console/Application.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Bowerphp\Console;
1313

1414
use Bowerphp\Command;
15-
use Bowerphp\Command\Helper\DialogHelper;
1615
use Bowerphp\Util\ErrorHandler;
1716
use Symfony\Component\Console\Application as BaseApplication;
1817
use Symfony\Component\Console\Input\ArrayInput;
@@ -125,8 +124,11 @@ protected function getDefaultInputDefinition()
125124
protected function getDefaultHelperSet()
126125
{
127126
$helperSet = parent::getDefaultHelperSet();
128-
129-
$helperSet->set(new DialogHelper());
127+
if (class_exists('Symfony\Component\Console\Helper\DialogHelper')) {
128+
$helperSet->set(new \Bowerphp\Command\Helper\DialogHelper());
129+
} else {
130+
$helperSet->set(new \Bowerphp\Command\Helper\QuestionHelper());
131+
}
130132

131133
return $helperSet;
132134
}

tests/Bowerphp/Test/Command/Helper/DialogHelperTest.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@
22

33
namespace Bowerphp\Test\Command\Helper;
44

5-
use Bowerphp\Command\Helper\DialogHelper;
6-
75
class DialogHelperTest extends \PHPUnit_Framework_TestCase
86
{
97
public function testGetQuestion()
108
{
11-
$helper = new DialogHelper();
12-
$this->assertEquals('<info>This is a question</info> [<comment>default reply</comment>]: ', $helper->getQuestion('This is a question', 'default reply'));
13-
$this->assertEquals('<info>Another question</info>- ', $helper->getQuestion('Another question', null, '-'));
9+
if (class_exists('Symfony\Component\Console\Helper\DialogHelper')) {
10+
$helper = new \Bowerphp\Command\Helper\DialogHelper();
11+
$this->assertEquals('<info>This is a question</info> [<comment>default reply</comment>]: ', $helper->getQuestion('This is a question', 'default reply'));
12+
$this->assertEquals('<info>Another question</info>- ', $helper->getQuestion('Another question', null, '-'));
13+
} else {
14+
$helper = new \Bowerphp\Command\Helper\QuestionHelper();
15+
$this->assertEquals('<info>This is a question</info> [<comment>default reply</comment>]: ', $helper->getQuestion('This is a question', 'default reply')->getQuestion());
16+
$this->assertEquals('<info>Another question</info>- ', $helper->getQuestion('Another question', null, '-')->getQuestion());
17+
}
1418
}
1519
}

tests/Bowerphp/Test/Command/InstallCommandTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function testExecute()
2222
$commandTester = new CommandTester($command = $application->get('install'));
2323
$commandTester->execute(array('command' => $command->getName(), 'package' => 'jquery'), array('decorated' => false));
2424

25-
$this->assertRegExp('/jquery#2.1/m', $commandTester->getDisplay());
25+
$this->assertRegExp('/jquery#/m', $commandTester->getDisplay());
2626
$this->assertFileExists(getcwd() . '/bower_components/jquery/.bower.json');
2727
$this->assertFileExists(getcwd() . '/bower_components/jquery/src/jquery.js');
2828
$this->assertFileNotExists(getcwd() . '/bower.json');
@@ -39,7 +39,7 @@ public function testExecuteAndSave()
3939
$commandTester->execute(array('command' => $command->getName(), 'package' => 'jquery', '--save' => true), array('decorated' => false));
4040

4141
//Check that the install worked
42-
$this->assertRegExp('/jquery#2.1/m', $commandTester->getDisplay());
42+
$this->assertRegExp('/jquery#/m', $commandTester->getDisplay());
4343
$this->assertFileExists(getcwd() . '/bower_components/jquery/.bower.json');
4444
$this->assertFileExists(getcwd() . '/bower_components/jquery/src/jquery.js');
4545

@@ -66,7 +66,7 @@ public function testExecuteAndThenTestSave()
6666
$commandTester->execute(array('command' => $command->getName(), 'package' => 'jquery'), array('decorated' => false));
6767

6868
//Check that the install worked
69-
$this->assertRegExp('/jquery#2.1/m', $commandTester->getDisplay());
69+
$this->assertRegExp('/jquery#/m', $commandTester->getDisplay());
7070
$this->assertFileExists(getcwd() . '/bower_components/jquery/.bower.json');
7171
$this->assertFileExists(getcwd() . '/bower_components/jquery/src/jquery.js');
7272

@@ -88,7 +88,7 @@ public function testExecuteVerbose()
8888
$commandTester = new CommandTester($command = $application->get('install'));
8989
$commandTester->execute(array('command' => $command->getName(), 'package' => 'jquery'), array('decorated' => false, 'verbosity' => OutputInterface::VERBOSITY_DEBUG));
9090

91-
$this->assertRegExp('/jquery#2.1/', $commandTester->getDisplay());
91+
$this->assertRegExp('/jquery#/', $commandTester->getDisplay());
9292
$this->assertFileExists(getcwd() . '/bower_components/jquery/.bower.json');
9393
$this->assertFileExists(getcwd() . '/bower_components/jquery/src/jquery.js');
9494
}

0 commit comments

Comments
 (0)