Skip to content

Commit

Permalink
Make test failure be easier to understand.
Browse files Browse the repository at this point in the history
  • Loading branch information
Danack committed Jul 7, 2024
1 parent 978c0ff commit 85d4854
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/014-setresourcelimit.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,24 @@ if (defined('Imagick::RESOURCETYPE_HEIGHT')) {
$tests[Imagick::RESOURCETYPE_HEIGHT] = $g;
}

$reflection_class = new ReflectionClass(Imagick::class);
$constants = $reflection_class->getConstants();
$resource_constants = [];
foreach ($constants as $name => $value) {
if (strpos($name, "RESOURCETYPE") === 0) {
// echo "Name: $name, value: $value\n";
$resource_constants[$value] = $name;
}
}


foreach ($tests as $resourceType => $value) {
Imagick::setResourceLimit($resourceType, $value);
$actualValue = Imagick::getResourceLimit($resourceType);

if ($actualValue != $value) {
echo "Error testing $resourceType, value returned $actualValue is not $value \n";
$resourceTypeString = $resource_constants[$resourceType];
echo "Error testing $resourceTypeString, value returned $actualValue is not $value \n";
}
}

Expand Down

0 comments on commit 85d4854

Please sign in to comment.