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

Added a tip for people installing the Symfony Demo application #295

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ matrix:
- php: 5.5
- php: 5.6
- php: 7.0
- php: hhvm
allow_failures:
- php: hhvm
- php: 7.1

before_install:
- composer self-update
Expand All @@ -27,4 +25,4 @@ install:
- ~/.phpenv/versions/5.6/bin/php box build

script:
- phpunit
- ./vendor/bin/simple-phpunit
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"raulfraile/distill": "~0.9,!=0.9.3,!=0.9.4"
},
"require-dev": {
"symfony/process": "~2.5"
"symfony/process": "~2.5",
"symfony/phpunit-bridge": "^4.0"
},
"extra": {
"branch-alias": {
Expand Down
86 changes: 74 additions & 12 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 9 additions & 5 deletions src/Symfony/Installer/DownloadCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ protected function download()
$symfonyArchiveFile = $distill
->getChooser()
->setStrategy(new MinimumSize())
->addFilesWithDifferentExtensions($this->getRemoteFileUrl(), ['tgz', 'zip'])
->addFilesWithDifferentExtensions($this->getRemoteFileUrl(), array('tgz', 'zip'))
->getPreferredFile()
;

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

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

return $this;
}

Expand Down Expand Up @@ -413,7 +417,7 @@ protected function getInstalledSymfonyVersion()

if (!empty($symfonyVersion) && 'v' === substr($symfonyVersion, 0, 1)) {
return substr($symfonyVersion, 1);
};
}

return $symfonyVersion;
}
Expand Down Expand Up @@ -570,15 +574,15 @@ protected function getUrlContents($url)
/**
* Enables the signal handler.
*
* @throws AbortException If the execution has been aborted with SIGINT signal.
* @throws AbortException if the execution has been aborted with SIGINT signal
*/
private function enableSignalHandler()
{
if (!function_exists('pcntl_signal')) {
return;
}

declare(ticks = 1);
declare(ticks=1);

pcntl_signal(SIGINT, function () {
error_reporting(0);
Expand Down
40 changes: 18 additions & 22 deletions tests/Symfony/Installer/Tests/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,7 @@ public function testDemoApplicationInstallation()
$this->assertContains('Downloading the Symfony Demo Application', $output);
$this->assertContains('Symfony Demo Application was successfully installed.', $output);

$output = $this->runCommand('php bin/console --version', $projectDir);
$this->assertRegExp('/Symfony version 3\.\d+\.\d+(-DEV)? - app\/dev\/debug/', $output);

$composerConfig = json_decode(file_get_contents($projectDir.'/composer.json'), true);

$this->assertArrayNotHasKey('platform', $composerConfig['config'], 'The composer.json file does not define any platform configuration.');
}

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

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

if ('3' === substr($versionToInstall, 0, 1) || '' === $versionToInstall) {
if (PHP_VERSION_ID < 50500) {
$this->markTestSkipped('Symfony 3 requires PHP 5.5.9 or higher.');
}

$output = $this->runCommand('php bin/console --version', $projectDir);
} else {
if (file_exists($projectDir.'/app/console')) {
$output = $this->runCommand('php app/console --version', $projectDir);
} else {
$output = $this->runCommand('php bin/console --version', $projectDir);
}

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

public function testSymfonyDemoInstallationWithNewCommand()
{
if (PHP_VERSION_ID < 50500) {
$this->markTestSkipped('This test requires PHP 5.5 or higher.');
}

$output = $this->runCommand(sprintf('php %s/symfony.phar new demo 3.4', $this->rootDir));
$this->assertContains("If you want to download the Symfony Demo app, execute 'symfony demo' instead of 'symfony new demo'", $output);
$this->fs->remove('demo');
}

/**
* Runs the given string as a command and returns the resulting output.
* The CWD is set to the root project directory to simplify command paths.
Expand Down Expand Up @@ -150,13 +153,6 @@ private function runCommand($command, $workingDirectory = null)
public function provideSymfonyInstallationData()
{
return array(
array(
'',
'/.*Symfony 3\.1\.\d+ was successfully installed.*/',
'/Symfony version 3\.1\.\d+(-DEV)? - app\/dev\/debug/',
'5.5.9',
),

array(
'3.0',
'/.*Symfony 3\.0\.\d+ was successfully installed.*/',
Expand All @@ -166,9 +162,9 @@ public function provideSymfonyInstallationData()

array(
'lts',
'/.*Symfony 2\.8\.\d+ was successfully installed.*/',
'/Symfony version 2\.8\.\d+(-DEV)? - app\/dev\/debug/',
'5.3.9',
'/.*Symfony 3\.4\.\d+ was successfully installed.*/',
'/Symfony 3\.4\.\d+ \(kernel: app, env: dev, debug: true\)/',
'5.5.9',
),

array(
Expand Down