xref: /PHP-7.3/ext/bz2/tests/002.phpt (revision 2576c57a)
1--TEST--
2bzopen() using fd opened in wrong mode
3--SKIPIF--
4<?php if (!extension_loaded("bz2")) print "skip"; ?>
5--FILE--
6<?php
7
8@unlink("bz_open_002.txt");
9
10$fp = fopen("bz_open_002.txt", "w");
11var_dump(bzopen($fp, "w"));
12
13$fp = fopen("bz_open_002.txt", "r");
14var_dump(bzopen($fp, "r"));
15
16@unlink("bz_open_002.txt");
17$fp = fopen("bz_open_002.txt", "x");
18var_dump(bzopen($fp, "w"));
19
20@unlink("bz_open_002.txt");
21$fp = fopen("bz_open_002.txt", "x");
22var_dump(bzopen($fp, "r"));
23
24$fp = fopen("bz_open_002.txt", "rb");
25var_dump(bzopen($fp, "r"));
26
27$fp = fopen("bz_open_002.txt", "wb");
28var_dump(bzopen($fp, "w"));
29
30$fp = fopen("bz_open_002.txt", "br");
31var_dump(bzopen($fp, "r"));
32
33$fp = fopen("bz_open_002.txt", "br");
34var_dump(bzopen($fp, "w"));
35
36$fp = fopen("bz_open_002.txt", "r");
37var_dump(bzopen($fp, "w"));
38
39$fp = fopen("bz_open_002.txt", "w");
40var_dump(bzopen($fp, "r"));
41
42$fp = fopen("bz_open_002.txt", "rw");
43var_dump(bzopen($fp, "w"));
44
45$fp = fopen("bz_open_002.txt", "rw");
46var_dump(bzopen($fp, "r"));
47
48$fp = fopen("bz_open_002.txt", "wr");
49var_dump(bzopen($fp, "w"));
50
51$fp = fopen("bz_open_002.txt", "wr");
52var_dump(bzopen($fp, "r"));
53
54$fp = fopen("bz_open_002.txt", "r+");
55var_dump(bzopen($fp, "r"));
56
57$fp = fopen("bz_open_002.txt", "r+");
58var_dump(bzopen($fp, "w"));
59
60$fp = fopen("bz_open_002.txt", "w+");
61var_dump(bzopen($fp, "r"));
62
63$fp = fopen("bz_open_002.txt", "w+");
64var_dump(bzopen($fp, "w"));
65
66$fp = fopen("bz_open_002.txt", "a");
67var_dump(bzopen($fp, "r"));
68
69$fp = fopen("bz_open_002.txt", "a");
70var_dump(bzopen($fp, "w"));
71
72@unlink("bz_open_002.txt");
73
74echo "Done\n";
75?>
76--EXPECTF--
77resource(%d) of type (stream)
78resource(%d) of type (stream)
79resource(%d) of type (stream)
80
81Warning: bzopen(): cannot read from a stream opened in write only mode in %s on line %d
82bool(false)
83resource(%d) of type (stream)
84resource(%d) of type (stream)
85
86Warning: fopen(bz_open_002.txt): failed to open stream: `br' is not a valid mode for fopen in %s on line %d
87
88Warning: bzopen(): first parameter has to be string or file-resource in %s on line %d
89bool(false)
90
91Warning: fopen(bz_open_002.txt): failed to open stream: `br' is not a valid mode for fopen in %s on line %d
92
93Warning: bzopen(): first parameter has to be string or file-resource in %s on line %d
94bool(false)
95
96Warning: bzopen(): cannot write to a stream opened in read only mode in %s on line %d
97bool(false)
98
99Warning: bzopen(): cannot read from a stream opened in write only mode in %s on line %d
100bool(false)
101
102Warning: bzopen(): cannot use stream opened in mode 'rw' in %s on line %d
103bool(false)
104
105Warning: bzopen(): cannot use stream opened in mode 'rw' in %s on line %d
106bool(false)
107
108Warning: bzopen(): cannot use stream opened in mode 'wr' in %s on line %d
109bool(false)
110
111Warning: bzopen(): cannot use stream opened in mode 'wr' in %s on line %d
112bool(false)
113
114Warning: bzopen(): cannot use stream opened in mode 'r+' in %s on line %d
115bool(false)
116
117Warning: bzopen(): cannot use stream opened in mode 'r+' in %s on line %d
118bool(false)
119
120Warning: bzopen(): cannot use stream opened in mode 'w+' in %s on line %d
121bool(false)
122
123Warning: bzopen(): cannot use stream opened in mode 'w+' in %s on line %d
124bool(false)
125
126Warning: bzopen(): cannot read from a stream opened in write only mode in %s on line %d
127bool(false)
128resource(%d) of type (stream)
129Done
130