xref: /PHP-7.0/ext/sysvshm/tests/005.phpt (revision ceb1ea37)
1--TEST--
2shm_get_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
14shm_put_var($s, -1, "test string");
15shm_put_var($s, 0, new stdclass);
16shm_put_var($s, 1, array(1,2,3));
17shm_put_var($s, 2, false);
18shm_put_var($s, 3, null);
19
20var_dump(shm_get_var());
21
22var_dump(shm_get_var(-1, -1));
23
24var_dump(shm_get_var($s, 1000));
25var_dump(shm_get_var($s, -10000));
26
27var_dump(shm_get_var($s, array()));
28var_dump(shm_get_var($s, -1));
29var_dump(shm_get_var($s, 0));
30var_dump(shm_get_var($s, 1));
31var_dump(shm_get_var($s, 2));
32var_dump(shm_get_var($s, 3));
33
34shm_put_var($s, 3, "test");
35shm_put_var($s, 3, 1);
36shm_put_var($s, 3, null);
37
38var_dump(shm_get_var($s, 3));
39shm_remove($s);
40
41echo "Done\n";
42?>
43--EXPECTF--
44
45Warning: shm_get_var() expects exactly 2 parameters, 0 given in %s005.php on line %d
46NULL
47
48Warning: shm_get_var() expects parameter 1 to be resource, integer given in %s005.php on line %d
49NULL
50
51Warning: shm_get_var(): variable key 1000 doesn't exist in %s005.php on line %d
52bool(false)
53
54Warning: shm_get_var(): variable key -10000 doesn't exist in %s005.php on line %d
55bool(false)
56
57Warning: shm_get_var() expects parameter 2 to be integer, array given in %s005.php on line %d
58NULL
59string(11) "test string"
60object(stdClass)#%d (0) {
61}
62array(3) {
63  [0]=>
64  int(1)
65  [1]=>
66  int(2)
67  [2]=>
68  int(3)
69}
70bool(false)
71NULL
72NULL
73Done
74