bug #26482 [PhpUnitBridge] Ability to use different composer.json file (amcastror)

This PR was submitted for the master branch but it was squashed and merged into the 3.4 branch instead (closes #26482).

Discussion
----------

[PhpUnitBridge] Ability to use different composer.json file

Hi, I have a project where I use a different composer.json via environment variable. Look [here](https://getcomposer.org/doc/03-cli.md#composer). Because of this, $root gets set to "/" and everything fails.

Hope this helps.

| Q             | A
| ------------- | ---
| Branch?       | master for features / 2.7 up to 4.0 for bug fixes <!-- see below -->
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | I'll add if this is useful.
| Fixed tickets |
| License       | MIT
| Doc PR        | symfony/symfony-docs

<!--
Write a short README entry for your feature/bugfix here (replace this comment block.)
This will help people understand your PR and can be used as a start of the Doc PR.
Additionally:
 - Bug fixes must be submitted against the lowest branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too).
 - Features and deprecations must be submitted against the master branch.
-->

Commits
-------

77e643d0ba [PhpUnitBridge] Ability to use different composer.json file
This commit is contained in:
Fabien Potencier 2018-03-13 07:34:33 -05:00
commit 822483b9bf

View File

@ -26,8 +26,13 @@ if (PHP_VERSION_ID >= 70200) {
$PHPUNIT_VERSION = '4.8';
}
if ('composer.json' !== $COMPOSER_JSON = getenv('COMPOSER') ?: 'composer.json') {
putenv('COMPOSER=composer.json');
$_SERVER['COMPOSER'] = $_ENV['COMPOSER'] = 'composer.json';
}
$root = __DIR__;
while (!file_exists($root.'/composer.json') || file_exists($root.'/DeprecationErrorHandler.php')) {
while (!file_exists($root.'/'.$COMPOSER_JSON) || file_exists($root.'/DeprecationErrorHandler.php')) {
if ($root === dirname($root)) {
break;
}