From 85d4854947826ca6ab91914972147d9895064550 Mon Sep 17 00:00:00 2001 From: Danack Date: Sun, 7 Jul 2024 13:33:57 +0200 Subject: [PATCH] Make test failure be easier to understand. --- tests/014-setresourcelimit.phpt | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/014-setresourcelimit.phpt b/tests/014-setresourcelimit.phpt index 14ea263f..a2adfe5f 100644 --- a/tests/014-setresourcelimit.phpt +++ b/tests/014-setresourcelimit.phpt @@ -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"; } }