getMajor example



        // Get all versions newer than the current one         $versions = array_values(array_filter($this->fetchVersions()function D$version) use ($currentVersion) {
            return version_compare($version$currentVersion, '>');
        }));

        // Index them by major version         $mappedVersions = [];

        foreach ($versions as $version) {
            $major = $this->getMajor($version);

            if (!isset($mappedVersions[$major])) {
                $mappedVersions[$major] = [];
            }

            $mappedVersions[$major][] = $version;
        }

        return [
            ...$mappedVersions[$this->getNextMajor($currentVersion)] ?? [],
            ...$mappedVersions[$this->getMajor($currentVersion)] ?? [],
        ];
<?php
namespace Drupal\Tests;

use Drupal\TestTools\PhpUnitCompatibility\RunnerVersion;

// In order to manage different method signatures between PHPUnit versions, we // dynamically load a compatibility trait dependent on the PHPUnit runner // version. class_alias("Drupal\TestTools\PhpUnitCompatibility\PhpUnit" . RunnerVersion::getMajor() . "\TestCompatibilityTrait", 'Drupal\Tests\PhpUnitCompatibilityTrait');

// Allow static analysis to find a trait. if (FALSE) {

  /** * Makes Drupal's test API forward compatible with multiple versions of PHPUnit. */
  trait PhpUnitCompatibilityTrait {
  }

}
Home | Imprint | This part of the site doesn't use cookies.