You are here

public function ComposerExecutableValidatorTest::providerComposerVersionValidation in Automatic Updates 8.2

Data provider for ::testComposerVersionValidation().

Return value

array[] Sets of arguments to pass to the test method.

File

tests/src/Kernel/ReadinessValidation/ComposerExecutableValidatorTest.php, line 54

Class

ComposerExecutableValidatorTest
@covers \Drupal\automatic_updates\Validator\ComposerExecutableValidator

Namespace

Drupal\Tests\automatic_updates\Kernel\ReadinessValidation

Code

public function providerComposerVersionValidation() : array {

  // Invalid or undetectable Composer versions will always produce the same
  // error.
  $invalid_version = ValidationResult::createError([
    'The Composer version could not be detected.',
  ]);

  // Unsupported Composer versions will report the detected version number
  // in the validation result, so we need a function to churn out those fake
  // results for the test method.
  $unsupported_version = function (string $version) : ValidationResult {
    return ValidationResult::createError([
      "Composer 2 or later is required, but version {$version} was detected.",
    ]);
  };
  return [
    // A valid 2.x version of Composer should not produce any errors.
    [
      '2.1.6',
      [],
    ],
    [
      '1.10.22',
      [
        $unsupported_version('1.10.22'),
      ],
    ],
    [
      '1.7.3',
      [
        $unsupported_version('1.7.3'),
      ],
    ],
    [
      '2.0.0-alpha3',
      [],
    ],
    [
      '2.1.0-RC1',
      [],
    ],
    [
      '1.0.0-RC',
      [
        $unsupported_version('1.0.0-RC'),
      ],
    ],
    [
      '1.0.0-beta1',
      [
        $unsupported_version('1.0.0-beta1'),
      ],
    ],
    [
      '1.9-dev',
      [
        $invalid_version,
      ],
    ],
    [
      '@package_version@',
      [
        $invalid_version,
      ],
    ],
  ];
}