1--TEST--
2finfo_open(): Testing magic_file names
3--SKIPIF--
4<?php require_once(__DIR__ . '/skipif.inc'); ?>
5--FILE--
6<?php
7
8try {
9    var_dump(finfo_open(FILEINFO_MIME, "\0"));
10} catch (ValueError $e) {
11    echo $e->getMessage(), "\n";
12}
13
14var_dump(finfo_open(FILEINFO_MIME, NULL));
15var_dump(finfo_open(FILEINFO_MIME, ''));
16var_dump(finfo_open(FILEINFO_MIME, 123));
17var_dump(finfo_open(FILEINFO_MIME, 1.0));
18var_dump(finfo_open(FILEINFO_MIME, '/foo/bar/inexistent'));
19
20?>
21--EXPECTF--
22finfo_open(): Argument #2 ($magic_database) must not contain any null bytes
23resource(%d) of type (file_info)
24resource(%d) of type (file_info)
25
26Warning: finfo_open(%s123): Failed to open stream: No such file or directory in %s on line %d
27
28Warning: finfo_open(%s123): Failed to open stream: No such file or directory in %s on line %d
29
30Warning: finfo_open(): Failed to load magic database at "%s123" in %s on line %d
31bool(false)
32
33Warning: finfo_open(%s1): Failed to open stream: No such file or directory in %s on line %d
34
35Warning: finfo_open(%s1): Failed to open stream: No such file or directory in %s on line %d
36
37Warning: finfo_open(): Failed to load magic database at "%s1" in %s on line %d
38bool(false)
39
40Warning: finfo_open(%sinexistent): Failed to open stream: No such file or directory in %s on line %d
41
42Warning: finfo_open(%sinexistent): Failed to open stream: No such file or directory in %s on line %d
43
44Warning: finfo_open(): Failed to load magic database at "%sinexistent" in %s on line %d
45bool(false)
46