1--TEST--
2Test Imagick, setRegistry and getRegistry
3--SKIPIF--
4<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
5--FILE--
6<?php
7
8require_once(dirname(__FILE__) . '/functions.inc');
9
10$tmpPath = Imagick::getRegistry("temporary-path");
11if ($tmpPath == null) {
12	//I am unsure if this is guaranteed - it might be set via policy.xml
13	echo "Temporary-path was empty at start.".PHP_EOL;
14}
15
16$currentPath = realpath(dirname(__FILE__));
17
18Imagick::setRegistry("temporary-path", $currentPath);
19
20$tmpPath = Imagick::getRegistry("temporary-path");
21if ($tmpPath === false) {
22	echo "Failed to set temporary-path".PHP_EOL;
23}
24else if ($tmpPath == $currentPath) {
25	echo "Temporary path was set correctly.".PHP_EOL;
26}
27
28$registry = Imagick::listRegistry();
29
30if (array_key_exists("temporary-path", $registry) == true) {
31
32	if ($registry["temporary-path"] === $currentPath) {
33		echo "Temporary path was listed correctly.".PHP_EOL;
34	}
35}
36
37// Since 6.9.9-26, no exception raised
38$exceptionExpected = true;
39
40if (isVersionGreaterEqual('6.9.9-26', '7.0.7-15')) {
41    $exceptionExpected = false;
42}
43
44try {
45	$tmpPath = Imagick::getRegistry("non-existent string");
46
47	if ($exceptionExpected === true) {
48		echo "Expected exception not thrown.\n";
49	}
50	else {
51		echo "This is fine.";
52	}
53}
54catch (\ImagickException $ie) {
55	if ($exceptionExpected === true) {
56		echo "This is fine.";
57	}
58	else {
59		echo "Unexpected exception" . $ie->getMessage() . "\n";
60	}
61}
62
63
64?>
65--EXPECTF--
66Temporary-path was empty at start.
67Temporary path was set correctly.
68Temporary path was listed correctly.
69This is fine.
70