1--TEST--
2Test finfo_open() function : error functionality
3--EXTENSIONS--
4fileinfo
5--FILE--
6<?php
7$magicFile = __DIR__ . DIRECTORY_SEPARATOR . 'magic';
8
9echo "*** Testing finfo_open() : error functionality ***\n";
10
11var_dump( finfo_open( FILEINFO_MIME, 'foobarfile' ) );
12var_dump( finfo_open( PHP_INT_MAX - 1, $magicFile ) );
13
14try {
15    var_dump( finfo_open( 'foobar' ) );
16} catch (TypeError $e) {
17    echo $e->getMessage(), "\n";
18}
19
20try {
21    var_dump( new finfo('foobar') );
22} catch (TypeError $e) {
23    echo $e->getMessage(), "\n";
24}
25
26?>
27--EXPECTF--
28*** Testing finfo_open() : error functionality ***
29
30Warning: finfo_open(%sfoobarfile): Failed to open stream: No such file or directory in %sfinfo_open_error.php on line %d
31
32Warning: finfo_open(%sfoobarfile): Failed to open stream: No such file or directory in %sfinfo_open_error.php on line %d
33
34Warning: finfo_open(): Failed to load magic database at "%sfoobarfile" in %sfinfo_open_error.php on line %d
35bool(false)
36
37Warning: finfo_open(): using regular magic file `%smagic' in %sfinfo_open_error.php on line %d
38object(finfo)#%d (0) {
39}
40finfo_open(): Argument #1 ($flags) must be of type int, string given
41finfo::__construct(): Argument #1 ($flags) must be of type int, string given
42