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