|
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 >= 70200) { |
57 | 65 | // PHPUnit 8 requires PHP 7.2+ |
58 | 66 | $PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '8.3'); |
|
63 | 71 | // PHPUnit 6 requires PHP 7.0+ |
64 | 72 | $PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '6.5'); |
65 | 73 | } elseif (PHP_VERSION_ID >= 50600) { |
66 | | - // PHPUnit 5 requires PHP 5.6+ |
| 74 | + // PHPUnit 4 does not support PHP 7 |
67 | 75 | $PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '5.7'); |
68 | 76 | } else { |
| 77 | + // PHPUnit 5.1 requires PHP 5.6+ |
69 | 78 | $PHPUNIT_VERSION = '4.8'; |
70 | 79 | } |
71 | 80 |
|
|
106 | 115 | || ($COMPOSER = rtrim('\\' === DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer.phar`) : `which composer.phar 2> /dev/null`)) |
107 | 116 | || ($COMPOSER = rtrim('\\' === DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer`) : `which composer 2> /dev/null`)) |
108 | 117 | || file_exists($COMPOSER = rtrim('\\' === DIRECTORY_SEPARATOR ? `git rev-parse --show-toplevel 2> NUL` : `git rev-parse --show-toplevel 2> /dev/null`).DIRECTORY_SEPARATOR.'composer.phar') |
109 | | - ? (file_get_contents($COMPOSER, null, 0, 18) === '#!/usr/bin/env php' ? $PHP : '').' '.escapeshellarg($COMPOSER) // detect shell wrappers by looking at the shebang |
| 118 | + ? (file_get_contents($COMPOSER, false, null, 0, 18) === '#!/usr/bin/env php' ? $PHP : '').' '.escapeshellarg($COMPOSER) // detect shell wrappers by looking at the shebang |
110 | 119 | : 'composer'; |
111 | 120 |
|
112 | 121 | $SYMFONY_PHPUNIT_REMOVE = $getEnvVar('SYMFONY_PHPUNIT_REMOVE', 'phpspec/prophecy'.($PHPUNIT_VERSION < 6.0 ? ' symfony/yaml': '')); |
|
122 | 131 | rename("$PHPUNIT_VERSION_DIR", "$PHPUNIT_VERSION_DIR.old"); |
123 | 132 | passthru(sprintf('\\' === DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s': 'rm -rf %s', "$PHPUNIT_VERSION_DIR.old")); |
124 | 133 | } |
125 | | - passthru("$COMPOSER create-project --no-install --prefer-dist --no-scripts --no-plugins --no-progress --ansi phpunit/phpunit $PHPUNIT_VERSION_DIR \"$PHPUNIT_VERSION.*\""); |
| 134 | + $passthruOrFail("$COMPOSER create-project --no-install --prefer-dist --no-scripts --no-plugins --no-progress --ansi phpunit/phpunit $PHPUNIT_VERSION_DIR \"$PHPUNIT_VERSION.*\""); |
126 | 135 | @copy("$PHPUNIT_VERSION_DIR/phpunit.xsd", 'phpunit.xsd'); |
127 | 136 | chdir("$PHPUNIT_VERSION_DIR"); |
128 | 137 | if ($SYMFONY_PHPUNIT_REMOVE) { |
129 | | - passthru("$COMPOSER remove --no-update ".$SYMFONY_PHPUNIT_REMOVE); |
| 138 | + $passthruOrFail("$COMPOSER remove --no-update ".$SYMFONY_PHPUNIT_REMOVE); |
130 | 139 | } |
131 | 140 | if (5.1 <= $PHPUNIT_VERSION && $PHPUNIT_VERSION < 5.4) { |
132 | | - passthru("$COMPOSER require --no-update phpunit/phpunit-mock-objects \"~3.1.0\""); |
| 141 | + $passthruOrFail("$COMPOSER require --no-update phpunit/phpunit-mock-objects \"~3.1.0\""); |
133 | 142 | } |
134 | 143 |
|
135 | | - passthru("$COMPOSER config --unset platform"); |
| 144 | + $passthruOrFail("$COMPOSER config --unset platform"); |
136 | 145 | if (file_exists($path = $root.'/vendor/symfony/phpunit-bridge')) { |
137 | | - passthru("$COMPOSER require --no-update symfony/phpunit-bridge \"*@dev\""); |
138 | | - passthru("$COMPOSER config repositories.phpunit-bridge path ".escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, $path))); |
| 146 | + $passthruOrFail("$COMPOSER require --no-update symfony/phpunit-bridge \"*@dev\""); |
| 147 | + $passthruOrFail("$COMPOSER config repositories.phpunit-bridge path ".escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, $path))); |
139 | 148 | if ('\\' === DIRECTORY_SEPARATOR) { |
140 | 149 | file_put_contents('composer.json', preg_replace('/^( {8})"phpunit-bridge": \{$/m', "$0\n$1 ".'"options": {"symlink": false},', file_get_contents('composer.json'))); |
141 | 150 | } |
142 | 151 | } else { |
143 | | - passthru("$COMPOSER require --no-update symfony/phpunit-bridge \"*\""); |
| 152 | + $passthruOrFail("$COMPOSER require --no-update symfony/phpunit-bridge \"*\""); |
144 | 153 | } |
145 | 154 | $prevRoot = getenv('COMPOSER_ROOT_VERSION'); |
146 | 155 | putenv("COMPOSER_ROOT_VERSION=$PHPUNIT_VERSION.99"); |
@@ -206,7 +215,7 @@ class SymfonyBlacklistPhpunit {} |
206 | 215 | $argv[1] = 'src/Symfony'; |
207 | 216 | } |
208 | 217 | if (isset($argv[1]) && is_dir($argv[1]) && !file_exists($argv[1].'/phpunit.xml.dist')) { |
209 | | - // Find Symfony components in plain PHP for Windows portability |
| 218 | + // Find Symfony components in plain php for Windows portability |
210 | 219 |
|
211 | 220 | $finder = new RecursiveDirectoryIterator($argv[1], FilesystemIterator::KEY_AS_FILENAME | FilesystemIterator::UNIX_PATHS); |
212 | 221 | $finder = new RecursiveIteratorIterator($finder); |
|
0 commit comments