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