1--TEST--
2bug 40459 - Test whether the constructor of the user-space stream wrapper is called when stream functions are called
3--INI--
4allow_url_fopen=1
5--FILE--
6<?php
7// Test whether the constructor of the user-space stream wrapper is called when stream functions are called
8class testwrapper {
9    private $constructorCalled = false;
10    function __construct() {
11        $this->constructorCalled = true;
12    }
13
14    function stream_open($path, $mode, $options, &$opened_path)
15    {
16        echo $this->constructorCalled ? 'yes' : 'no';
17        return true;
18    }
19
20    function url_stat($url, $flags)
21    {
22        echo $this->constructorCalled ? 'yes' : 'no';
23        return array();
24    }
25
26    function unlink($url)
27    {
28        echo $this->constructorCalled ? 'yes' : 'no';
29    }
30
31    function rename($from, $to)
32    {
33        echo $this->constructorCalled ? 'yes' : 'no';
34    }
35
36    function mkdir($dir, $mode, $options)
37    {
38        echo $this->constructorCalled ? 'yes' : 'no';
39    }
40
41    function rmdir($dir, $options)
42    {
43        echo $this->constructorCalled ? 'yes' : 'no';
44    }
45
46    function dir_opendir($url, $options)
47    {
48        echo $this->constructorCalled ? 'yes' : 'no';
49        return TRUE;
50    }
51    function stream_metadata()
52    {
53        echo $this->constructorCalled ? 'yes' : 'no';
54        return TRUE;
55    }
56}
57
58stream_wrapper_register('test', 'testwrapper', STREAM_IS_URL);
59
60echo 'stream_open: ';
61fopen('test://test', 'r');
62echo "\n";
63
64echo 'url_stat: ';
65stat('test://test');
66echo "\n";
67
68echo 'dir_opendir: ';
69opendir('test://test');
70echo "\n";
71
72echo 'rmdir: ';
73rmdir('test://test');
74echo "\n";
75
76echo 'mkdir: ';
77mkdir('test://test');
78echo "\n";
79
80echo 'rename: ';
81rename('test://test', 'test://test2');
82echo "\n";
83
84echo 'unlink: ';
85unlink('test://test');
86echo "\n";
87
88echo 'touch: ';
89touch('test://test', time());
90echo "\n";
91
92
93
94?>
95--EXPECT--
96stream_open: yes
97url_stat: yes
98dir_opendir: yes
99rmdir: yes
100mkdir: yes
101rename: yes
102unlink: yes
103touch: yes
104