Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Composer.php

function 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 82

Class

Composer
Provides static functions for composer script events.

Namespace

Drupal\Core\Composer

Code

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');
    }
}
RSS feed
Powered by Drupal