xref: /imagick/tests/skipif.inc (revision ebe93bed)
1<?php
2
3if (!extension_loaded("imagick")) die("skip imagick not loaded");
4
5require_once(dirname(__FILE__) . '/functions.inc');
6
7if (isset($imageMagickRequiredVersion)) {
8	$versionInfo = \Imagick::getVersion();
9
10	if (array_key_exists("versionNumber", $versionInfo) == false) {
11		die("skip unable to determine ImageMagick version.");
12	}
13
14	$versionInstalled = $versionInfo["versionNumber"];
15
16	if ($versionInstalled < $imageMagickRequiredVersion) {
17		$message = sprintf(
18			"skip ImageMagick installed %x <= required %x",
19			$versionInstalled,
20			$imageMagickRequiredVersion
21		);
22		die($message);
23	}
24}
25
26
27if (isset($imageMagickBelowVersion)) {
28	$versionInfo = \Imagick::getVersion();
29
30	if (array_key_exists("versionNumber", $versionInfo) == false) {
31		die("skip unable to determine ImageMagick version.");
32	}
33
34	$versionInstalled = $versionInfo["versionNumber"];
35
36	if ($versionInstalled >= $imageMagickBelowVersion) {
37		$message = sprintf(
38			"skip ImageMagick installed %x >= limit check %x",
39			$versionInstalled,
40			$imageMagickBelowVersion
41		);
42		die($message);
43	}
44}
45
46
47if (isset($imageMagickBelowVersion)) {
48	$versionInfo = \Imagick::getVersion();
49
50	if (array_key_exists("versionNumber", $versionInfo) == false) {
51		die("skip unable to determine ImageMagick version.");
52	}
53
54	$versionInstalled = $versionInfo["versionNumber"];
55
56	if ($versionInstalled >= $imageMagickBelowVersion) {
57		$message = sprintf(
58			"skip ImageMagick installed %x >= %x",
59			$versionInstalled,
60			$imageMagickBelowVersion
61		);
62		die($message);
63	}
64}
65
66function checkClassMethods($class, $methods)
67{
68	foreach ($methods as $method) {
69		if (method_exists($class, $method) == false) {
70			die("skip Class method $class::$method not present");
71		}
72	}
73}
74
75function checkFormatPresent($format)
76{
77	$result = Imagick::queryFormats(strtoupper($format));
78	if (count($result) == false) {
79		die("skip format $format not supported by ImageMagick as compiled.");
80	}
81}
82
83function requirePHP($required)
84{
85	if (version_compare(PHP_VERSION, $required) < 0) {
86		die("skip PHP version $required required, but have ".PHP_VERSION.".");
87	}
88}
89
90function requireFormat($requiredFormat)
91{
92	$formats = \Imagick::queryformats();
93
94	foreach ($formats as $format) {
95		if (strcasecmp($format, $requiredFormat) === 0) {
96			return;
97		}
98	}
99
100	die("skip test suite requires format $requiredFormat but not available");
101}
102
103requireFormat("png");
104requireFormat("jpg");
105
106if (isset($minimumVersions) === true) {
107    if (isVersionGreaterEqual($minimumVersions[0], $minimumVersions[1]) !== true) {
108
109        $message = sprintf(
110            "skip either version '%s' or '%s' is minimum reliable for test.\n",
111            $minimumVersions[0],
112            $minimumVersions[1]
113        );
114
115        die($message);
116    }
117}
118
119?>
120