File: 150_Imagick_setregistry.phpt

package info (click to toggle)
php-imagick 3.8.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,288 kB
  • sloc: ansic: 17,876; php: 1,440; xml: 444; pascal: 80; sh: 19; makefile: 2
file content (69 lines) | stat: -rw-r--r-- 1,560 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
--TEST--
Test Imagick, setRegistry and getRegistry
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php

require_once(dirname(__FILE__) . '/functions.inc');

$tmpPath = Imagick::getRegistry("temporary-path");
if ($tmpPath == null) {
	//I am unsure if this is guaranteed - it might be set via policy.xml
	echo "Temporary-path was empty at start.".PHP_EOL;
}

$currentPath = realpath(dirname(__FILE__));

Imagick::setRegistry("temporary-path", $currentPath);

$tmpPath = Imagick::getRegistry("temporary-path");
if ($tmpPath === false) {
	echo "Failed to set temporary-path".PHP_EOL;
}
else if ($tmpPath == $currentPath) {
	echo "Temporary path was set correctly.".PHP_EOL;
}

$registry = Imagick::listRegistry();

if (array_key_exists("temporary-path", $registry) == true) {

	if ($registry["temporary-path"] === $currentPath) {
		echo "Temporary path was listed correctly.".PHP_EOL;
	}
}

// Since 6.9.9-26, no exception raised
$exceptionExpected = true;

if (isVersionGreaterEqual('6.9.9-26', '7.0.7-15')) {
    $exceptionExpected = false;
}

try {
	$tmpPath = Imagick::getRegistry("non-existent string");

	if ($exceptionExpected === true) {
		echo "Expected exception not thrown.\n";
	}
	else {
		echo "This is fine.";
	}
}
catch (\ImagickException $ie) {
	if ($exceptionExpected === true) {
		echo "This is fine.";
	}
	else {
		echo "Unexpected exception" . $ie->getMessage() . "\n";
	}
}


?>
--EXPECTF--
Temporary-path was empty at start.
Temporary path was set correctly.
Temporary path was listed correctly.
This is fine.