|
53 | 53 | return $default;
|
54 | 54 | };
|
55 | 55 |
|
| 56 | +$passthruOrFail = function ($command) { |
| 57 | + passthru($command, $status); |
| 58 | + |
| 59 | + if ($status) { |
| 60 | + exit($status); |
| 61 | + } |
| 62 | +}; |
| 63 | + |
56 | 64 | if (PHP_VERSION_ID >= 70100) {
|
57 | 65 | // PHPUnit 7 requires PHP 7.1+
|
58 | 66 | $PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '7.4');
|
59 | 67 | } elseif (PHP_VERSION_ID >= 70000) {
|
60 | 68 | // PHPUnit 6 requires PHP 7.0+
|
61 | 69 | $PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '6.5');
|
62 | 70 | } elseif (PHP_VERSION_ID >= 50600) {
|
63 |
| - // PHPUnit 5 requires PHP 5.6+ |
| 71 | + // PHPUnit 4 does not support PHP 7 |
64 | 72 | $PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '5.7');
|
65 | 73 | } else {
|
| 74 | + // PHPUnit 5.1 requires PHP 5.6+ |
66 | 75 | $PHPUNIT_VERSION = '4.8';
|
67 | 76 | }
|
68 | 77 |
|
|
100 | 109 | $COMPOSER = file_exists($COMPOSER = $oldPwd.'/composer.phar')
|
101 | 110 | || ($COMPOSER = rtrim('\\' === DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer.phar`) : `which composer.phar 2> /dev/null`))
|
102 | 111 | || ($COMPOSER = rtrim('\\' === DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer`) : `which composer 2> /dev/null`))
|
103 |
| - ? (file_get_contents($COMPOSER, null, 0, 18) === '#!/usr/bin/env php' ? $PHP : '').' '.escapeshellarg($COMPOSER) // detect shell wrappers by looking at the shebang |
| 112 | + ? (file_get_contents($COMPOSER, false, null, 0, 18) === '#!/usr/bin/env php' ? $PHP : '').' '.escapeshellarg($COMPOSER) // detect shell wrappers by looking at the shebang |
104 | 113 | : 'composer';
|
105 | 114 |
|
106 | 115 | $SYMFONY_PHPUNIT_REMOVE = $getEnvVar('SYMFONY_PHPUNIT_REMOVE', 'phpspec/prophecy'.($PHPUNIT_VERSION < 6.0 ? ' symfony/yaml': ''));
|
|
115 | 124 | rename("phpunit-$PHPUNIT_VERSION", "phpunit-$PHPUNIT_VERSION.old");
|
116 | 125 | passthru(sprintf('\\' === DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s': 'rm -rf %s', "phpunit-$PHPUNIT_VERSION.old"));
|
117 | 126 | }
|
118 |
| - passthru("$COMPOSER create-project --no-install --prefer-dist --no-scripts --no-plugins --no-progress --ansi phpunit/phpunit phpunit-$PHPUNIT_VERSION \"$PHPUNIT_VERSION.*\""); |
| 127 | + $passthruOrFail("$COMPOSER create-project --no-install --prefer-dist --no-scripts --no-plugins --no-progress --ansi phpunit/phpunit phpunit-$PHPUNIT_VERSION \"$PHPUNIT_VERSION.*\""); |
119 | 128 | @copy("phpunit-$PHPUNIT_VERSION/phpunit.xsd", 'phpunit.xsd');
|
120 | 129 | chdir("phpunit-$PHPUNIT_VERSION");
|
121 | 130 | if ($SYMFONY_PHPUNIT_REMOVE) {
|
122 |
| - passthru("$COMPOSER remove --no-update ".$SYMFONY_PHPUNIT_REMOVE); |
| 131 | + $passthruOrFail("$COMPOSER remove --no-update ".$SYMFONY_PHPUNIT_REMOVE); |
123 | 132 | }
|
124 | 133 | if (5.1 <= $PHPUNIT_VERSION && $PHPUNIT_VERSION < 5.4) {
|
125 |
| - passthru("$COMPOSER require --no-update phpunit/phpunit-mock-objects \"~3.1.0\""); |
| 134 | + $passthruOrFail("$COMPOSER require --no-update phpunit/phpunit-mock-objects \"~3.1.0\""); |
126 | 135 | }
|
127 | 136 |
|
128 |
| - passthru("$COMPOSER config --unset platform"); |
| 137 | + $passthruOrFail("$COMPOSER config --unset platform"); |
129 | 138 | if (file_exists($path = $root.'/vendor/symfony/phpunit-bridge')) {
|
130 |
| - passthru("$COMPOSER require --no-update symfony/phpunit-bridge \"*@dev\""); |
131 |
| - passthru("$COMPOSER config repositories.phpunit-bridge path ".escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, $path))); |
| 139 | + $passthruOrFail("$COMPOSER require --no-update symfony/phpunit-bridge \"*@dev\""); |
| 140 | + $passthruOrFail("$COMPOSER config repositories.phpunit-bridge path ".escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, $path))); |
132 | 141 | if ('\\' === DIRECTORY_SEPARATOR) {
|
133 | 142 | file_put_contents('composer.json', preg_replace('/^( {8})"phpunit-bridge": \{$/m', "$0\n$1 ".'"options": {"symlink": false},', file_get_contents('composer.json')));
|
134 | 143 | }
|
135 | 144 | } else {
|
136 |
| - passthru("$COMPOSER require --no-update symfony/phpunit-bridge \"*\""); |
| 145 | + $passthruOrFail("$COMPOSER require --no-update symfony/phpunit-bridge \"*\""); |
137 | 146 | }
|
138 | 147 | $prevRoot = getenv('COMPOSER_ROOT_VERSION');
|
139 | 148 | putenv("COMPOSER_ROOT_VERSION=$PHPUNIT_VERSION.99");
|
@@ -186,7 +195,7 @@ class SymfonyBlacklistPhpunit {}
|
186 | 195 | $argv[1] = 'src/Symfony';
|
187 | 196 | }
|
188 | 197 | if (isset($argv[1]) && is_dir($argv[1]) && !file_exists($argv[1].'/phpunit.xml.dist')) {
|
189 |
| - // Find Symfony components in plain PHP for Windows portability |
| 198 | + // Find Symfony components in plain php for Windows portability |
190 | 199 |
|
191 | 200 | $finder = new RecursiveDirectoryIterator($argv[1], FilesystemIterator::KEY_AS_FILENAME | FilesystemIterator::UNIX_PATHS);
|
192 | 201 | $finder = new RecursiveIteratorIterator($finder);
|
|
0 commit comments