1--TEST--
2Test fnmatch() function: Error conditions
3--SKIPIF--
4<?php
5if (!function_exists('fnmatch'))
6    die("skip fnmatch() function is not available");
7?>
8--FILE--
9<?php
10/* Prototype: bool fnmatch ( string $pattern, string $string [, int $flags] )
11   Description: fnmatch() checks if the passed string would match
12     the given shell wildcard pattern.
13*/
14
15echo "*** Testing error conditions for fnmatch() ***";
16
17/* Invalid arguments */
18var_dump( fnmatch(array(), array()) );
19
20$file_handle = fopen(__FILE__, "r");
21var_dump( fnmatch($file_handle, $file_handle) );
22fclose( $file_handle );
23
24$std_obj = new stdClass();
25var_dump( fnmatch($std_obj, $std_obj) );
26
27
28/* No.of arguments less than expected */
29var_dump( fnmatch("match.txt") );
30var_dump( fnmatch("") );
31
32/* No.of arguments greater than expected */
33var_dump( fnmatch("match.txt", "match.txt", TRUE, 100) );
34
35echo "\n*** Done ***\n";
36?>
37--EXPECTF--
38*** Testing error conditions for fnmatch() ***
39Warning: fnmatch() expects parameter 1 to be string, array given in %s on line %d%d
40NULL
41
42Warning: fnmatch() expects parameter 1 to be string, resource given in %s on line %d%d
43NULL
44
45Warning: fnmatch() expects parameter 1 to be string, object given in %s on line %d%d
46NULL
47
48Warning: fnmatch() expects at least 2 parameters, 1 given in %s on line %d%d
49NULL
50
51Warning: fnmatch() expects at least 2 parameters, 1 given in %s on line %d%d
52NULL
53
54Warning: fnmatch() expects at most 3 parameters, 4 given in %s on line %d%d
55NULL
56
57*** Done ***
58