Annotation of embedaddon/php/ext/standard/tests/file/userstreams_004.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: User-space streams: stream_lock()
                      3: --FILE--
                      4: <?php
                      5: class test_wrapper_base {
                      6:        public $mode;
                      7:        function stream_open($path, $mode, $openedpath) {
                      8:                return true;
                      9:        }
                     10:        function stream_eof() {
                     11:                return false;
                     12:        }
                     13: }
                     14: class test_wrapper extends test_wrapper_base {
                     15:        function stream_lock($mode) {
                     16:                $this->mode = $mode;
                     17:        }
                     18: }
                     19: function test($name, $fd, $mode) {
                     20:        echo "------ $name: -------\n";
                     21:        flock($fd, $mode);
                     22:        $data = stream_get_meta_data($fd);
                     23:        var_dump($data['wrapper_data']->mode === $mode);
                     24: }
                     25: 
                     26: var_dump(stream_wrapper_register('test', 'test_wrapper'));
                     27: var_dump(stream_wrapper_register('test2', 'test_wrapper_base'));
                     28: 
                     29: $fd = fopen("test://foo","r");
                     30: $fd2 = fopen("test2://foo","r");
                     31: 
                     32: test("stream_lock not implemented", $fd2, LOCK_EX);
                     33: 
                     34: foreach(array("LOCK_SH","LOCK_EX","LOCK_UN") as $mode) {
                     35:        test("fclock($mode)", $fd, constant($mode));
                     36:        test("fclock($mode|LOCK_NB)", $fd, constant($mode)|LOCK_NB);
                     37: }
                     38: 
                     39: ?>
                     40: --EXPECTF--
                     41: bool(true)
                     42: bool(true)
                     43: ------ stream_lock not implemented: -------
                     44: 
                     45: Warning: flock(): test_wrapper_base::stream_lock is not implemented! in %s
                     46: bool(false)
                     47: ------ fclock(LOCK_SH): -------
                     48: bool(true)
                     49: ------ fclock(LOCK_SH|LOCK_NB): -------
                     50: bool(true)
                     51: ------ fclock(LOCK_EX): -------
                     52: bool(true)
                     53: ------ fclock(LOCK_EX|LOCK_NB): -------
                     54: bool(true)
                     55: ------ fclock(LOCK_UN): -------
                     56: bool(true)
                     57: ------ fclock(LOCK_UN|LOCK_NB): -------
                     58: bool(true)

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>