Skip to content
This repository was archived by the owner on Nov 14, 2019. It is now read-only.

Commit 36969e0

Browse files
committed
feature #295 Added a tip for people installing the Symfony Demo application (javiereguiluz)
This PR was squashed before being merged into the 1.0-dev branch (closes #295). Discussion ---------- Added a tip for people installing the Symfony Demo application After reading this: http://www.andreafiori.net/posts/symfony-3-demo-and-blog-applications I realized that some people think that the Symfony Demo application is installed as `symfony new demo` instead of `symfony demo` Commits ------- 0272c23 Added a tip for people installing the Symfony Demo application
2 parents 74b6692 + 0272c23 commit 36969e0

File tree

5 files changed

+105
-44
lines changed

5 files changed

+105
-44
lines changed

.travis.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ matrix:
1212
- php: 5.5
1313
- php: 5.6
1414
- php: 7.0
15-
- php: hhvm
16-
allow_failures:
17-
- php: hhvm
15+
- php: 7.1
1816

1917
before_install:
2018
- composer self-update
@@ -27,4 +25,4 @@ install:
2725
- ~/.phpenv/versions/5.6/bin/php box build
2826

2927
script:
30-
- phpunit
28+
- ./vendor/bin/simple-phpunit

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"raulfraile/distill": "~0.9,!=0.9.3,!=0.9.4"
2121
},
2222
"require-dev": {
23-
"symfony/process": "~2.5"
23+
"symfony/process": "~2.5",
24+
"symfony/phpunit-bridge": "^4.0"
2425
},
2526
"extra": {
2627
"branch-alias": {

composer.lock

Lines changed: 74 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Symfony/Installer/DownloadCommand.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ protected function download()
134134
$symfonyArchiveFile = $distill
135135
->getChooser()
136136
->setStrategy(new MinimumSize())
137-
->addFilesWithDifferentExtensions($this->getRemoteFileUrl(), ['tgz', 'zip'])
137+
->addFilesWithDifferentExtensions($this->getRemoteFileUrl(), array('tgz', 'zip'))
138138
->getPreferredFile()
139139
;
140140

@@ -184,7 +184,7 @@ protected function download()
184184
$request->getEmitter()->on('progress', $downloadCallback);
185185
$response = $client->send($request);
186186
} catch (ClientException $e) {
187-
if ('new' === $this->getName() && ($e->getCode() === 403 || $e->getCode() === 404)) {
187+
if ('new' === $this->getName() && (403 === $e->getCode() || 404 === $e->getCode())) {
188188
throw new \RuntimeException(sprintf(
189189
"The selected version (%s) cannot be installed because it does not exist.\n".
190190
"Execute the following command to install the latest stable Symfony release:\n".
@@ -229,6 +229,10 @@ protected function checkProjectName()
229229
));
230230
}
231231

232+
if ('demo' === $this->projectName && 'new' === $this->getName()) {
233+
$this->output->writeln("\n <bg=yellow> TIP </> If you want to download the Symfony Demo app, execute 'symfony demo' instead of 'symfony new demo'");
234+
}
235+
232236
return $this;
233237
}
234238

@@ -413,7 +417,7 @@ protected function getInstalledSymfonyVersion()
413417

414418
if (!empty($symfonyVersion) && 'v' === substr($symfonyVersion, 0, 1)) {
415419
return substr($symfonyVersion, 1);
416-
};
420+
}
417421

418422
return $symfonyVersion;
419423
}
@@ -570,15 +574,15 @@ protected function getUrlContents($url)
570574
/**
571575
* Enables the signal handler.
572576
*
573-
* @throws AbortException If the execution has been aborted with SIGINT signal.
577+
* @throws AbortException if the execution has been aborted with SIGINT signal
574578
*/
575579
private function enableSignalHandler()
576580
{
577581
if (!function_exists('pcntl_signal')) {
578582
return;
579583
}
580584

581-
declare(ticks = 1);
585+
declare(ticks=1);
582586

583587
pcntl_signal(SIGINT, function () {
584588
error_reporting(0);

tests/Symfony/Installer/Tests/IntegrationTest.php

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,7 @@ public function testDemoApplicationInstallation()
5252
$this->assertContains('Downloading the Symfony Demo Application', $output);
5353
$this->assertContains('Symfony Demo Application was successfully installed.', $output);
5454

55-
$output = $this->runCommand('php bin/console --version', $projectDir);
56-
$this->assertRegExp('/Symfony version 3\.\d+\.\d+(-DEV)? - app\/dev\/debug/', $output);
57-
5855
$composerConfig = json_decode(file_get_contents($projectDir.'/composer.json'), true);
59-
6056
$this->assertArrayNotHasKey('platform', $composerConfig['config'], 'The composer.json file does not define any platform configuration.');
6157
}
6258

@@ -65,7 +61,7 @@ public function testDemoApplicationInstallation()
6561
*/
6662
public function testSymfonyInstallation($versionToInstall, $messageRegexp, $versionRegexp, $requiredPhpVersion)
6763
{
68-
if (version_compare(phpversion(), $requiredPhpVersion, '<')) {
64+
if (version_compare(PHP_VERSION, $requiredPhpVersion, '<')) {
6965
$this->markTestSkipped(sprintf('This test requires PHP %s or higher.', $requiredPhpVersion));
7066
}
7167

@@ -76,14 +72,10 @@ public function testSymfonyInstallation($versionToInstall, $messageRegexp, $vers
7672
$this->assertContains('Downloading Symfony...', $output);
7773
$this->assertRegExp($messageRegexp, $output);
7874

79-
if ('3' === substr($versionToInstall, 0, 1) || '' === $versionToInstall) {
80-
if (PHP_VERSION_ID < 50500) {
81-
$this->markTestSkipped('Symfony 3 requires PHP 5.5.9 or higher.');
82-
}
83-
84-
$output = $this->runCommand('php bin/console --version', $projectDir);
85-
} else {
75+
if (file_exists($projectDir.'/app/console')) {
8676
$output = $this->runCommand('php app/console --version', $projectDir);
77+
} else {
78+
$output = $this->runCommand('php bin/console --version', $projectDir);
8779
}
8880

8981
$this->assertRegExp($versionRegexp, $output);
@@ -122,6 +114,17 @@ public function testSymfonyInstallationInCurrentDirectory()
122114
$this->assertContains('Symfony version 2.7.5 - app/dev/debug', $output);
123115
}
124116

117+
public function testSymfonyDemoInstallationWithNewCommand()
118+
{
119+
if (PHP_VERSION_ID < 50500) {
120+
$this->markTestSkipped('This test requires PHP 5.5 or higher.');
121+
}
122+
123+
$output = $this->runCommand(sprintf('php %s/symfony.phar new demo 3.4', $this->rootDir));
124+
$this->assertContains("If you want to download the Symfony Demo app, execute 'symfony demo' instead of 'symfony new demo'", $output);
125+
$this->fs->remove('demo');
126+
}
127+
125128
/**
126129
* Runs the given string as a command and returns the resulting output.
127130
* The CWD is set to the root project directory to simplify command paths.
@@ -150,13 +153,6 @@ private function runCommand($command, $workingDirectory = null)
150153
public function provideSymfonyInstallationData()
151154
{
152155
return array(
153-
array(
154-
'',
155-
'/.*Symfony 3\.1\.\d+ was successfully installed.*/',
156-
'/Symfony version 3\.1\.\d+(-DEV)? - app\/dev\/debug/',
157-
'5.5.9',
158-
),
159-
160156
array(
161157
'3.0',
162158
'/.*Symfony 3\.0\.\d+ was successfully installed.*/',
@@ -166,9 +162,9 @@ public function provideSymfonyInstallationData()
166162

167163
array(
168164
'lts',
169-
'/.*Symfony 2\.8\.\d+ was successfully installed.*/',
170-
'/Symfony version 2\.8\.\d+(-DEV)? - app\/dev\/debug/',
171-
'5.3.9',
165+
'/.*Symfony 3\.4\.\d+ was successfully installed.*/',
166+
'/Symfony 3\.4\.\d+ \(kernel: app, env: dev, debug: true\)/',
167+
'5.5.9',
172168
),
173169

174170
array(

0 commit comments

Comments
 (0)