1--TEST--
2Imagick::setResourceLimit test
3--SKIPIF--
4<?php
5$imageMagickRequiredVersion=0x692;
6require_once(dirname(__FILE__) . '/skipif.inc');
7?>
8--FILE--
9<?php
10
11
12
13$k = 1024;
14$m = $k * $k;
15$g = $k * $m;
16$t = $k * $g;
17
18// These tests are flaky as the values ImageMagick will accept
19// are limited by the policy.xml of the system.
20
21$tests = array(
22	Imagick::RESOURCETYPE_AREA =>  100000000,
23
24	// Set maximum amount of disk space in bytes permitted for use by the pixel cache. When this limit is exceeded, the pixel cache is not be created and an error message is returned.
25	Imagick::RESOURCETYPE_DISK =>  100,
26
27
28	//Set maximum number of open pixel cache files. When this limit is exceeded, any subsequent pixels cached to disk are closed and reopened on demand. This behavior permits a large number of images to be accessed simultaneously on disk, but with a speed penalty due to repeated open/close calls.
29	Imagick::RESOURCETYPE_FILE => 100,
30
31	// Set maximum amount of memory map in bytes to allocate for the pixel cache. When this limit is exceeded, the image pixels are cached to disk
32	Imagick::RESOURCETYPE_MAP => 10 * $g,
33
34	// Set maximum amount of memory in bytes to allocate for the pixel cache from the heap. When this limit is exceeded, the image pixels are cached to memory-mapped disk
35	Imagick::RESOURCETYPE_MEMORY => 10 * $g,
36);
37
38if (defined('Imagick::RESOURCETYPE_TIME')) {
39	$tests[Imagick::RESOURCETYPE_TIME] = 30;
40}
41
42if (defined('Imagick::RESOURCETYPE_THROTTLE')) {
43	$tests[Imagick::RESOURCETYPE_THROTTLE] = 1;
44}
45if (defined('Imagick::RESOURCETYPE_THREAD')) {
46	$tests[Imagick::RESOURCETYPE_THREAD] = 1;
47}
48if (defined('Imagick::RESOURCETYPE_WIDTH')) {
49	$tests[Imagick::RESOURCETYPE_WIDTH] = $g;
50}
51if (defined('Imagick::RESOURCETYPE_HEIGHT')) {
52	$tests[Imagick::RESOURCETYPE_HEIGHT] = $g;
53}
54
55foreach ($tests as $resourceType => $value) {
56	Imagick::setResourceLimit($resourceType, $value);
57	$actualValue = Imagick::getResourceLimit($resourceType);
58
59	if ($actualValue != $value) {
60		echo "Error testing $resourceType, value returned $actualValue is not $value \n";
61	}
62}
63
64echo 'success';
65
66?>
67--EXPECTF--
68success