"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/Util/Test.php" between
phpunit-9.0.0.tar.gz and phpunit-9.0.1.tar.gz

About: PHPUnit is a unit testing software framework for software written in PHP.

Test.php  (phpunit-9.0.0):Test.php  (phpunit-9.0.1)
skipping to change at line 161 skipping to change at line 161
* @throws Warning * @throws Warning
* @psalm-param class-string $className * @psalm-param class-string $className
*/ */
public static function getMissingRequirements(string $className, string $met hodName): array public static function getMissingRequirements(string $className, string $met hodName): array
{ {
$required = static::getRequirements($className, $methodName); $required = static::getRequirements($className, $methodName);
$missing = []; $missing = [];
$hint = null; $hint = null;
if (!empty($required['PHP'])) { if (!empty($required['PHP'])) {
$operator = empty($required['PHP']['operator']) ? '>=' : $required[' PHP']['operator']; $operator = new VersionComparisonOperator(empty($required['PHP']['op erator']) ? '>=' : $required['PHP']['operator']);
self::ensureOperatorIsValid($operator); if (!\version_compare(\PHP_VERSION, $required['PHP']['version'], $op
erator->asString())) {
if (!\version_compare(\PHP_VERSION, $required['PHP']['version'], $op $missing[] = \sprintf('PHP %s %s is required.', $operator->asStr
erator)) { ing(), $required['PHP']['version']);
$missing[] = \sprintf('PHP %s %s is required.', $operator, $requ $hint = 'PHP';
ired['PHP']['version']);
$hint = $hint ?? 'PHP';
} }
} elseif (!empty($required['PHP_constraint'])) { } elseif (!empty($required['PHP_constraint'])) {
$version = new \PharIo\Version\Version(self::sanitizeVersionNumber(\ PHP_VERSION)); $version = new \PharIo\Version\Version(self::sanitizeVersionNumber(\ PHP_VERSION));
if (!$required['PHP_constraint']['constraint']->complies($version)) { if (!$required['PHP_constraint']['constraint']->complies($version)) {
$missing[] = \sprintf( $missing[] = \sprintf(
'PHP version does not match the required constraint %s.', 'PHP version does not match the required constraint %s.',
$required['PHP_constraint']['constraint']->asString() $required['PHP_constraint']['constraint']->asString()
); );
$hint = $hint ?? 'PHP_constraint'; $hint = 'PHP_constraint';
} }
} }
if (!empty($required['PHPUnit'])) { if (!empty($required['PHPUnit'])) {
$phpunitVersion = Version::id(); $phpunitVersion = Version::id();
$operator = empty($required['PHPUnit']['operator']) ? '>=' : $requir $operator = new VersionComparisonOperator(empty($required['PHPUnit']
ed['PHPUnit']['operator']; ['operator']) ? '>=' : $required['PHPUnit']['operator']);
self::ensureOperatorIsValid($operator);
if (!\version_compare($phpunitVersion, $required['PHPUnit']['version if (!\version_compare($phpunitVersion, $required['PHPUnit']['version
'], $operator)) { '], $operator->asString())) {
$missing[] = \sprintf('PHPUnit %s %s is required.', $operator, $ $missing[] = \sprintf('PHPUnit %s %s is required.', $operator->a
required['PHPUnit']['version']); sString(), $required['PHPUnit']['version']);
$hint = $hint ?? 'PHPUnit'; $hint = $hint ?? 'PHPUnit';
} }
} elseif (!empty($required['PHPUnit_constraint'])) { } elseif (!empty($required['PHPUnit_constraint'])) {
$phpunitVersion = new \PharIo\Version\Version(self::sanitizeVersionN umber(Version::id())); $phpunitVersion = new \PharIo\Version\Version(self::sanitizeVersionN umber(Version::id()));
if (!$required['PHPUnit_constraint']['constraint']->complies($phpuni tVersion)) { if (!$required['PHPUnit_constraint']['constraint']->complies($phpuni tVersion)) {
$missing[] = \sprintf( $missing[] = \sprintf(
'PHPUnit version does not match the required constraint %s.' , 'PHPUnit version does not match the required constraint %s.' ,
$required['PHPUnit_constraint']['constraint']->asString() $required['PHPUnit_constraint']['constraint']->asString()
); );
skipping to change at line 263 skipping to change at line 259
$missing[] = \sprintf('Extension %s is required.', $extensio n); $missing[] = \sprintf('Extension %s is required.', $extensio n);
$hint = $hint ?? 'extension_' . $extension; $hint = $hint ?? 'extension_' . $extension;
} }
} }
} }
if (!empty($required['extension_versions'])) { if (!empty($required['extension_versions'])) {
foreach ($required['extension_versions'] as $extension => $req) { foreach ($required['extension_versions'] as $extension => $req) {
$actualVersion = \phpversion($extension); $actualVersion = \phpversion($extension);
$operator = empty($req['operator']) ? '>=' : $req['operator']; $operator = new VersionComparisonOperator(empty($req['operator']
) ? '>=' : $req['operator']);
self::ensureOperatorIsValid($operator);
if ($actualVersion === false || !\version_compare($actualVersion if ($actualVersion === false || !\version_compare($actualVersion
, $req['version'], $operator)) { , $req['version'], $operator->asString())) {
$missing[] = \sprintf('Extension %s %s %s is required.', $ex $missing[] = \sprintf('Extension %s %s %s is required.', $ex
tension, $operator, $req['version']); tension, $operator->asString(), $req['version']);
$hint = $hint ?? 'extension_' . $extension; $hint = $hint ?? 'extension_' . $extension;
} }
} }
} }
if ($hint && isset($required['__OFFSET'])) { if ($hint && isset($required['__OFFSET'])) {
\array_unshift($missing, '__OFFSET_FILE=' . $required['__OFFSET']['_ _FILE']); \array_unshift($missing, '__OFFSET_FILE=' . $required['__OFFSET']['_ _FILE']);
\array_unshift($missing, '__OFFSET_LINE=' . ($required['__OFFSET'][$ hint] ?? 1)); \array_unshift($missing, '__OFFSET_LINE=' . ($required['__OFFSET'][$ hint] ?? 1));
} }
skipping to change at line 886 skipping to change at line 880
} else { } else {
$a[$key] = $value; $a[$key] = $value;
} }
} else { } else {
$a[$key] = $value; $a[$key] = $value;
} }
} }
return $a; return $a;
} }
/*
* @throws Exception
*/
private static function ensureOperatorIsValid(string $operator): void
{
if (!\in_array($operator, ['<', 'lt', '<=', 'le', '>', 'gt', '>=', 'ge',
'==', '=', 'eq', '!=', '<>', 'ne'])) {
throw new Exception(
\sprintf(
'"%s" is not a valid version_compare() operator',
$operator
)
);
}
}
} }
 End of changes. 8 change blocks. 
40 lines changed or deleted 19 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)