Skip to content

Commit 1adfede

Browse files
committed
feature #40059 [PhpUnitBridge] Add SYMFONY_PHPUNIT_REQUIRE env variable (acasademont)
This PR was merged into the 5.3-dev branch. Discussion ---------- [PhpUnitBridge] Add SYMFONY_PHPUNIT_REQUIRE env variable | Q | A | ------------- | --- | Branch? | 5.x | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Fix #39387 | License | MIT | Doc PR | symfony/symfony-docs#14913 As discussed on #39387, this PR adds a new `SYMFONY_PHPUNIT_REQUIRE` env variable to add packages to the phpunit bridge installation. This is useful for adding phpunit plugins (ie: https://github.com/phpspec/prophecy-phpunit) without having to add them directly to the main app composer.json. On my `phpunit.xml.dist` file I can now add ```xml <server name="SYMFONY_PHPUNIT_REQUIRE" value="phpspec/prophecy-phpunit"/> ``` And the `phpspec/prophecy-phpunit` will be installed along the rest of the phpunit packages Commits ------- 94e1d87 Add SYMFONY_PHPUNIT_REQUIRE env variable Fixes #39387
2 parents 627b6b7 + 94e1d87 commit 1adfede

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@
167167
}
168168
}
169169
$SYMFONY_PHPUNIT_REMOVE = $getEnvVar('SYMFONY_PHPUNIT_REMOVE', 'phpspec/prophecy'.($PHPUNIT_VERSION < 6.0 ? ' symfony/yaml' : ''));
170-
$configurationHash = md5(implode(\PHP_EOL, [md5_file(__FILE__), $SYMFONY_PHPUNIT_REMOVE, (int) $PHPUNIT_REMOVE_RETURN_TYPEHINT]));
170+
$SYMFONY_PHPUNIT_REQUIRE = $getEnvVar('SYMFONY_PHPUNIT_REQUIRE', '');
171+
$configurationHash = md5(implode(\PHP_EOL, [md5_file(__FILE__), $SYMFONY_PHPUNIT_REMOVE, $SYMFONY_PHPUNIT_REQUIRE, (int) $PHPUNIT_REMOVE_RETURN_TYPEHINT]));
171172
$PHPUNIT_VERSION_DIR = sprintf('phpunit-%s-%d', $PHPUNIT_VERSION, $PHPUNIT_REMOVE_RETURN_TYPEHINT);
172173
if (!file_exists("$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit") || $configurationHash !== @file_get_contents("$PHPUNIT_DIR/.$PHPUNIT_VERSION_DIR.md5")) {
173174
// Build a standalone phpunit without symfony/yaml nor prophecy by default
@@ -224,6 +225,9 @@
224225
if ($SYMFONY_PHPUNIT_REMOVE) {
225226
$passthruOrFail("$COMPOSER remove --no-update ".$SYMFONY_PHPUNIT_REMOVE);
226227
}
228+
if ($SYMFONY_PHPUNIT_REQUIRE) {
229+
$passthruOrFail("$COMPOSER require --no-update ".$SYMFONY_PHPUNIT_REQUIRE);
230+
}
227231
if (5.1 <= $PHPUNIT_VERSION && $PHPUNIT_VERSION < 5.4) {
228232
$passthruOrFail("$COMPOSER require --no-update phpunit/phpunit-mock-objects \"~3.1.0\"");
229233
}

0 commit comments

Comments
 (0)