com php-src: Added php tests to improve extension coverage: ext/shmop/tests/002.phpt
| From: | Xinchen Hui | Date: | Tue, 07 Jul 2015 13:50:23 +0000 |
| Subject: | com php-src: Added php tests to improve extension coverage: ext/shmop/tests/002.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-87950@lists.php.net to get a copy of this message | ||
Commit: 18dfbf90089409aedd36901933714241b22ddc2d
Author: Edgar R. Sandi <edgar.r.sandi@gmail.com> Tue, 7 Jul 2015 10:46:20 -0300
Parents: 015d20ab8398bb337cfddd2e0ec6a81cd270d82f
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=18dfbf90089409aedd36901933714241b22ddc2d
Log:
Added php tests to improve extension coverage
Changed paths:
A ext/shmop/tests/002.phpt
Diff:
diff --git a/ext/shmop/tests/002.phpt b/ext/shmop/tests/002.phpt
new file mode 100644
index 0000000..3ca0a0b
--- /dev/null
+++ b/ext/shmop/tests/002.phpt
@@ -0,0 +1,116 @@
+--TEST--
+shmop extension error messages
+--CREDITS--
+edgarsandi - <edgar.r.sandi@gmail.com>
+--SKIPIF--
+<?php
+ if (!extension_loaded("shmop")) {
+
+ die("skip shmop() extension not available");
+ }
+?>
+--FILE--
+<?php
+ $hex_shm_id = function(){
+ return rand(0, 9999);
+ };
+
+echo PHP_EOL, '## shmop_open function tests ##';
+ // warning outputs: 4 parameters expected
+ var_dump($shm_id = shmop_open());
+
+ // warning outputs: invalid flag when the flags length != 1
+ var_dump(shmop_open($hex_shm_id(), '', 0644, 1024));
+
+ // warning outputs: invalid access mode
+ var_dump(shmop_open($hex_shm_id(), 'b', 0644, 1024));
+
+ // warning outputs: unable to attach or create shared memory segment
+ var_dump(shmop_open(null, 'a', 0644, 1024));
+
+ // warning outputs: Shared memory segment size must be greater than zero
+ var_dump(shmop_open($hex_shm_id(), "c", 0666, 0));
+
+ // warning outputs: unable to get shared memory segment information
+ var_dump(shmop_open($hex_shm_id(), 'n', 0, 1024));
+
+echo PHP_EOL, '## shmop_read function tests ##';
+ // warning outputs: 3 parameters expected
+ var_dump(shmop_read());
+
+ // warning outputs: start is out of range
+ $shm_id = shmop_open($hex_shm_id(), 'n', 0600, 1024);
+ var_dump(shmop_read($shm_id, -10, 0));
+
+ // warning outputs: count is out of range
+ $shm_id = shmop_open($hex_shm_id(), 'n', 0600, 1024);
+ var_dump(shmop_read($shm_id, 0, -10));
+
+echo PHP_EOL, '## shmop_write function tests ##';
+ // warning outputs: 3 parameters expected
+ var_dump(shmop_write());
+
+ // warning outputs: offset out of range
+ $shm_id = shmop_open($hex_shm_id(), 'n', 0600, 1024);
+ var_dump(shmop_write($shm_id, 'text to try write', -10));
+
+echo PHP_EOL, '## shmop_size function tests ##';
+ // warning outputs: 1 parameter expected
+ var_dump(shmop_size());
+
+echo PHP_EOL, '## shmop_delete function tests ##';
+ // warning outputs: 1 parameter expected
+ var_dump(shmop_delete());
+
+echo PHP_EOL, '## shmop_close function tests ##';
+ // warning outputs: 1 parameter expected
+ var_dump(shmop_close());
+?>
+--EXPECTF--
+## shmop_open function tests ##
+Warning: shmop_open() expects exactly 4 parameters, 0 given in %s on line %d
+NULL
+
+Warning: shmop_open(): is not a valid flag in %s on line %d
+bool(false)
+
+Warning: shmop_open(): invalid access mode in %s on line %d
+bool(false)
+
+Warning: shmop_open(): unable to attach or create shared memory segment 'Invalid
argument' in %s on line %d
+bool(false)
+
+Warning: shmop_open(): Shared memory segment size must be greater than zero in %s on line %d
+bool(false)
+
+Warning: shmop_open(): unable to get shared memory segment information 'Permission
denied' in %s on line %d
+bool(false)
+
+## shmop_read function tests ##
+Warning: shmop_read() expects exactly 3 parameters, 0 given in %s on line %d
+NULL
+
+Warning: shmop_read(): start is out of range in %s on line %d
+bool(false)
+
+Warning: shmop_read(): count is out of range in %s on line %d
+bool(false)
+
+## shmop_write function tests ##
+Warning: shmop_write() expects exactly 3 parameters, 0 given in %s on line %d
+NULL
+
+Warning: shmop_write(): offset out of range in %s on line %d
+bool(false)
+
+## shmop_size function tests ##
+Warning: shmop_size() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+## shmop_delete function tests ##
+Warning: shmop_delete() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+## shmop_close function tests ##
+Warning: shmop_close() expects exactly 1 parameter, 0 given in %s on line %d
+NULL