xref: /PHP-8.0/ext/sysvshm/tests/006.phpt (revision 2e18b30d)
1--TEST--
2shm_remove_var() tests
3--SKIPIF--
4<?php
5if (!extension_loaded("sysvshm")){ print 'skip'; }
6if (!function_exists('ftok')){ print 'skip'; }
7?>
8--FILE--
9<?php
10
11$key = ftok(__FILE__, 't');
12$s = shm_attach($key, 1024);
13
14try {
15    shm_put_var($s, 1, "test string");
16} catch (TypeError $exception) {
17    echo $exception->getMessage() . "\n";
18}
19
20var_dump(shm_remove_var($s, -10));
21
22var_dump(shm_get_var($s, 1));
23
24var_dump(shm_remove_var($s, 1));
25var_dump(shm_get_var($s, 1));
26
27var_dump(shm_remove_var($s, 1));
28var_dump(shm_get_var($s, 1));
29
30shm_remove($s);
31echo "Done\n";
32?>
33--EXPECTF--
34Warning: shm_remove_var(): Variable key -10 doesn't exist in %s006.php on line %d
35bool(false)
36string(11) "test string"
37bool(true)
38
39Warning: shm_get_var(): Variable key 1 doesn't exist in %s006.php on line %d
40bool(false)
41
42Warning: shm_remove_var(): Variable key 1 doesn't exist in %s006.php on line %d
43bool(false)
44
45Warning: shm_get_var(): Variable key 1 doesn't exist in %s006.php on line %d
46bool(false)
47Done
48