xref: /PHP-7.4/ext/shmop/tests/002.phpt (revision 1892e3ab)
1--TEST--
2shmop extension error messages
3--CREDITS--
4edgarsandi - <edgar.r.sandi@gmail.com>
5--SKIPIF--
6<?php
7	if( substr(PHP_OS, 0, 3) == "WIN") {
8		die('skip not for Windows');
9	}
10	if (!extension_loaded("shmop")) {
11		die("skip shmop() extension not available");
12	}
13?>
14--FILE--
15<?php
16
17echo PHP_EOL, '## shmop_open function tests ##';
18	// warning outputs: 4 parameters expected
19	var_dump($shm_id = shmop_open());
20
21	// warning outputs: invalid flag when the flags length != 1
22	var_dump(shmop_open(1338, '', 0644, 1024));
23
24	// warning outputs: invalid access mode
25	var_dump(shmop_open(1338, 'b', 0644, 1024));
26
27	// warning outputs: unable to attach or create shared memory segment
28	var_dump(shmop_open(null, 'a', 0644, 1024));
29
30	// warning outputs: Shared memory segment size must be greater than zero
31	var_dump(shmop_open(1338, "c", 0666, 0));
32
33echo PHP_EOL, '## shmop_read function tests ##';
34	// warning outputs: 3 parameters expected
35	var_dump(shmop_read());
36
37	// warning outputs: start is out of range
38	$shm_id = shmop_open(1338, 'n', 0600, 1024);
39	var_dump(shmop_read($shm_id, -10, 0));
40	shmop_delete($shm_id);
41
42	// warning outputs: count is out of range
43	$shm_id = shmop_open(1339, 'n', 0600, 1024);
44	var_dump(shmop_read($shm_id, 0, -10));
45	shmop_delete($shm_id);
46
47echo PHP_EOL, '## shmop_write function tests ##';
48	// warning outputs: 3 parameters expected
49	var_dump(shmop_write());
50
51	// warning outputs: offset out of range
52	$shm_id = shmop_open(1340, 'n', 0600, 1024);
53	var_dump(shmop_write($shm_id, 'text to try write', -10));
54	shmop_delete($shm_id);
55
56echo PHP_EOL, '## shmop_size function tests ##';
57	// warning outputs: 1 parameter expected
58	var_dump(shmop_size());
59
60echo PHP_EOL, '## shmop_delete function tests ##';
61	// warning outputs: 1 parameter expected
62	var_dump(shmop_delete());
63
64echo PHP_EOL, '## shmop_close function tests ##';
65	// warning outputs: 1 parameter expected
66	var_dump(shmop_close());
67?>
68--EXPECTF--
69## shmop_open function tests ##
70Warning: shmop_open() expects exactly 4 parameters, 0 given in %s on line %d
71NULL
72
73Warning: shmop_open():  is not a valid flag in %s on line %d
74bool(false)
75
76Warning: shmop_open(): invalid access mode in %s on line %d
77bool(false)
78
79Warning: shmop_open(): unable to attach or create shared memory segment 'Invalid argument' in %s on line %d
80bool(false)
81
82Warning: shmop_open(): Shared memory segment size must be greater than zero in %s on line %d
83bool(false)
84
85## shmop_read function tests ##
86Warning: shmop_read() expects exactly 3 parameters, 0 given in %s on line %d
87NULL
88
89Warning: shmop_read(): start is out of range in %s on line %d
90bool(false)
91
92Warning: shmop_read(): count is out of range in %s on line %d
93bool(false)
94
95## shmop_write function tests ##
96Warning: shmop_write() expects exactly 3 parameters, 0 given in %s on line %d
97NULL
98
99Warning: shmop_write(): offset out of range in %s on line %d
100bool(false)
101
102## shmop_size function tests ##
103Warning: shmop_size() expects exactly 1 parameter, 0 given in %s on line %d
104NULL
105
106## shmop_delete function tests ##
107Warning: shmop_delete() expects exactly 1 parameter, 0 given in %s on line %d
108NULL
109
110## shmop_close function tests ##
111Warning: shmop_close() expects exactly 1 parameter, 0 given in %s on line %d
112NULL
113