xref: /php-src/ext/bz2/tests/001.phpt (revision 5853cdb7)
1--TEST--
2bzopen() and invalid parameters
3--EXTENSIONS--
4bz2
5--FILE--
6<?php
7
8try {
9    var_dump(bzopen("", "r"));
10} catch (\ValueError $e) {
11    echo $e->getMessage() . \PHP_EOL;
12}
13
14try {
15    var_dump(bzopen("", "w"));
16} catch (\ValueError $e) {
17    echo $e->getMessage() . \PHP_EOL;
18}
19
20try {
21    var_dump(bzopen("no_such_file", ""));
22} catch (\ValueError $e) {
23    echo $e->getMessage() . \PHP_EOL;
24}
25
26try {
27    var_dump(bzopen("no_such_file", "x"));
28} catch (\ValueError $e) {
29    echo $e->getMessage() . \PHP_EOL;
30}
31
32try {
33    var_dump(bzopen("no_such_file", "rw"));
34} catch (\ValueError $e) {
35    echo $e->getMessage() . \PHP_EOL;
36}
37
38var_dump(bzopen("no_such_file", "r"));
39
40$fp = fopen(__FILE__,"r");
41var_dump(bzopen($fp, "r"));
42
43?>
44--EXPECTF--
45bzopen(): Argument #1 ($file) must not be empty
46bzopen(): Argument #1 ($file) must not be empty
47bzopen(): Argument #2 ($mode) must be either "r" or "w"
48bzopen(): Argument #2 ($mode) must be either "r" or "w"
49bzopen(): Argument #2 ($mode) must be either "r" or "w"
50
51Warning: bzopen(no_such_file): Failed to open stream: No such file or directory in %s on line %d
52bool(false)
53resource(%d) of type (stream)
54