function Composer::upgradePHPUnit
Same name in other branches
- 8.9.x core/lib/Drupal/Core/Composer/Composer.php \Drupal\Core\Composer\Composer::upgradePHPUnit()
- 10 core/lib/Drupal/Core/Composer/Composer.php \Drupal\Core\Composer\Composer::upgradePHPUnit()
- 11.x core/lib/Drupal/Core/Composer/Composer.php \Drupal\Core\Composer\Composer::upgradePHPUnit()
Fires the drupal-phpunit-upgrade script event if necessary.
@internal
Parameters
\Composer\Script\Event $event: The event.
File
-
core/
lib/ Drupal/ Core/ Composer/ Composer.php, line 324
Class
- Composer
- Provides static functions for composer script events.
Namespace
Drupal\Core\ComposerCode
public static function upgradePHPUnit(Event $event) {
$repository = $event->getComposer()
->getRepositoryManager()
->getLocalRepository();
// This is, essentially, a null constraint. We only care whether the package
// is present in the vendor directory yet, but findPackage() requires it.
$constraint = new Constraint('>', '');
$phpunit_package = $repository->findPackage('phpunit/phpunit', $constraint);
if (!$phpunit_package) {
// There is nothing to do. The user is probably installing using the
// --no-dev flag.
return;
}
// If the PHP version is 7.4 or above and PHPUnit is less than version 9
// call the drupal-phpunit-upgrade script to upgrade PHPUnit.
if (!static::upgradePHPUnitCheck($phpunit_package->getVersion())) {
$event->getComposer()
->getEventDispatcher()
->dispatchScript('drupal-phpunit-upgrade');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.