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

Commit 32558cb

Browse files
committed
bug #261 Fixed the SymfonyRequirements check for the demo application (javiereguiluz)
This PR was squashed before being merged into the 1.0-dev branch (closes #261). Discussion ---------- Fixed the SymfonyRequirements check for the demo application The Symfony Demo was upgraded to Symfony 3 yesterday. If you install it, you get this error: ![symfony_demo_error](https://cloud.githubusercontent.com/assets/73419/16355615/9c6e758c-3abc-11e6-819b-528f903f8711.png) The problem is that the `isSymfony3()` method is not suitable for the demo application. We cannot improve that method to get the Symfony version via the `--version` option because at that point we are about to check the Symfony Requirements to see if the computer can run the demo application. Commits ------- 4700ab9 Fixed the SymfonyRequirements check for the demo application
2 parents bdad979 + 4700ab9 commit 32558cb

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

src/Symfony/Installer/DownloadCommand.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,12 @@ protected function extract()
308308
*/
309309
protected function checkSymfonyRequirements()
310310
{
311+
if (null === $requirementsFile = $this->getSymfonyRequirementsFilePath()) {
312+
return $this;
313+
}
314+
311315
try {
312-
$requirementsDir = $this->isSymfony3() ? 'var' : 'app';
313-
require $this->projectDir.'/'.$requirementsDir.'/SymfonyRequirements.php';
316+
require $requirementsFile;
314317
$symfonyRequirements = new \SymfonyRequirements();
315318
$this->requirementsErrors = array();
316319
foreach ($symfonyRequirements->getRequirements() as $req) {
@@ -325,6 +328,22 @@ protected function checkSymfonyRequirements()
325328
return $this;
326329
}
327330

331+
private function getSymfonyRequirementsFilePath()
332+
{
333+
$paths = array(
334+
$this->projectDir.'/app/SymfonyRequirements.php',
335+
$this->projectDir.'/var/SymfonyRequirements.php',
336+
);
337+
338+
foreach ($paths as $path) {
339+
if (file_exists($path)) {
340+
return $path;
341+
}
342+
}
343+
344+
return null;
345+
}
346+
328347
/**
329348
* Updates the composer.json file to provide better values for some of the
330349
* default configuration values.

tests/Symfony/Installer/Tests/IntegrationTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,19 @@ public function setUp()
4141

4242
public function testDemoApplicationInstallation()
4343
{
44+
if (PHP_VERSION_ID < 50500) {
45+
$this->markTestSkipped('Symfony 3 requires PHP 5.5.9 or higher.');
46+
}
47+
4448
$projectDir = sprintf('%s/my_test_project', sys_get_temp_dir());
4549
$this->fs->remove($projectDir);
4650

4751
$output = $this->runCommand(sprintf('php symfony.phar demo %s', ProcessUtils::escapeArgument($projectDir)));
4852
$this->assertContains('Downloading the Symfony Demo Application', $output);
4953
$this->assertContains('Symfony Demo Application was successfully installed.', $output);
5054

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

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

0 commit comments

Comments
 (0)