Skip to content

Commit 30325e0

Browse files
minor symfony#25068 [Bridge/PhpUnit] fix installation path (nicolas-grekas)
This PR was merged into the 3.4 branch. Discussion ---------- [Bridge/PhpUnit] fix installation path | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony#25067 | License | MIT | Doc PR | - Fixes yesterdays's work on the bridge, tricky one... Commits ------- bd4fe8d [Bridge/PhpUnit] fix installation path
2 parents b40c84d + bd4fe8d commit 30325e0

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/Symfony/Bridge/PhpUnit/bin/simple-phpunit

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ if (PHP_VERSION_ID >= 70200) {
2626
$PHPUNIT_VERSION = '4.8';
2727
}
2828

29-
if (file_exists(($path = dirname(__DIR__)).'/composer.json')) {
30-
if (file_exists($path.'/vendor/symfony/phpunit-bridge/composer.json')) {
31-
$path .= '/vendor/symfony/phpunit-bridge';
29+
$root = __DIR__;
30+
while (!file_exists($root.'/composer.json') || file_exists($root.'/bin/simple-phpunit')) {
31+
if ($root === dirname($root)) {
32+
break;
3233
}
33-
} elseif (file_exists($path.'/symfony/phpunit-bridge/composer.json')) {
34-
$path .= '/symfony/phpunit-bridge';
34+
$root = dirname($root);
3535
}
3636

3737
$oldPwd = getcwd();
38-
$PHPUNIT_DIR = getenv('SYMFONY_PHPUNIT_DIR') ?: (dirname(dirname(__DIR__) === $path ? $path : __DIR__).'/.phpunit');
38+
$PHPUNIT_DIR = getenv('SYMFONY_PHPUNIT_DIR') ?: ($root.'/vendor/bin/.phpunit');
3939
$PHP = defined('PHP_BINARY') ? PHP_BINARY : 'php';
4040
$PHP = escapeshellarg($PHP);
4141
if ('phpdbg' === PHP_SAPI) {
@@ -76,9 +76,14 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__
7676
if (5.1 <= $PHPUNIT_VERSION && $PHPUNIT_VERSION < 5.4) {
7777
passthru("$COMPOSER require --no-update phpunit/phpunit-mock-objects \"~3.1.0\"");
7878
}
79-
passthru("$COMPOSER require --no-update symfony/phpunit-bridge \"*\"");
80-
if (file_exists($path)) {
79+
if (file_exists($path = $root.'/vendor/symfony/phpunit-bridge')) {
80+
passthru("$COMPOSER require --no-update symfony/phpunit-bridge \"*@dev\"");
8181
passthru("$COMPOSER config repositories.phpunit-bridge path ".escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, $path)));
82+
if ('\\' === DIRECTORY_SEPARATOR) {
83+
file_put_contents('composer.json', preg_replace('/^( {8})"phpunit-bridge": \{$/m', "$0\n$1 ".'"options": {"symlink": false},', file_get_contents('composer.json')));
84+
}
85+
} else {
86+
passthru("$COMPOSER require --no-update symfony/phpunit-bridge \"*\"");
8287
}
8388
$prevRoot = getenv('COMPOSER_ROOT_VERSION');
8489
putenv("COMPOSER_ROOT_VERSION=$PHPUNIT_VERSION.99");

0 commit comments

Comments
 (0)