function ConstraintTest::createTestsForVersions
Same name in other branches
- 9 core/tests/Drupal/Tests/Component/Version/ConstraintTest.php \Drupal\Tests\Component\Version\ConstraintTest::createTestsForVersions()
- 8.9.x core/tests/Drupal/Tests/Component/Version/ConstraintTest.php \Drupal\Tests\Component\Version\ConstraintTest::createTestsForVersions()
- 11.x core/tests/Drupal/Tests/Component/Version/ConstraintTest.php \Drupal\Tests\Component\Version\ConstraintTest::createTestsForVersions()
Create testIsCompatible() test cases for constraints and versions.
Parameters
string $constraint_string: The constraint string to be used in \Drupal\Component\Version\Constraint for example ">8.x-2.4".
string[] $versions: Version strings be passed to \Drupal\Component\Version\Constraint::isCompatible(), for example "8.x-2.4". One test case will be returned for every version.
bool $expected_result: The expect result for all versions.
string $core_compatibility: (optional) The core compatibility to be used in \Drupal\Component\Version\Constraint, for example "7.x". Defaults to "8.x".
Return value
array[] The test cases to be used with ::testIsCompatible().
1 call to ConstraintTest::createTestsForVersions()
- ConstraintTest::providerIsCompatible in core/
tests/ Drupal/ Tests/ Component/ Version/ ConstraintTest.php - Provider for testIsCompatible.
File
-
core/
tests/ Drupal/ Tests/ Component/ Version/ ConstraintTest.php, line 174
Class
- ConstraintTest
- @coversDefaultClass \Drupal\Component\Version\Constraint @group Version
Namespace
Drupal\Tests\Component\VersionCode
private static function createTestsForVersions(string $constraint_string, array $versions, bool $expected_result, string $core_compatibility = '8.x') : array {
$constraint = new Constraint($constraint_string, $core_compatibility);
$tests = [];
foreach ($versions as $version) {
$tests["{$core_compatibility}::({$constraint_string})::{$version}"] = [
$constraint,
$version,
$expected_result,
];
}
return $tests;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.