1--TEST--
2Test basename() function : error conditions
3--FILE--
4<?php
5/* Prototype: string basename ( string $path [, string $suffix] );
6   Description: Given a string containing a path to a file,
7                this function will return the base name of the file.
8                If the filename ends in suffix this will also be cut off.
9*/
10echo "*** Testing error conditions ***\n";
11// zero arguments
12var_dump( basename() );
13
14// more than expected no. of arguments
15var_dump( basename("/var/tmp/bar.gz", ".gz", ".gz") );
16
17// passing invalid type arguments
18$object = new stdclass;
19var_dump( basename( array("string/bar") ) );
20var_dump( basename( array("string/bar"), "bar" ) );
21var_dump( basename( "bar", array("string/bar") ) );
22var_dump( basename( $object, "bar" ) );
23var_dump( basename( $object ) );
24var_dump( basename( $object, $object ) );
25var_dump( basename( "bar", $object ) );
26
27echo "Done\n";
28?>
29--EXPECTF--
30*** Testing error conditions ***
31
32Warning: basename() expects at least 1 parameter, 0 given in %s on line %d
33NULL
34
35Warning: basename() expects at most 2 parameters, 3 given in %s on line %d
36NULL
37
38Warning: basename() expects parameter 1 to be string, array given in %s on line %d
39NULL
40
41Warning: basename() expects parameter 1 to be string, array given in %s on line %d
42NULL
43
44Warning: basename() expects parameter 2 to be string, array given in %s on line %d
45NULL
46
47Warning: basename() expects parameter 1 to be string, object given in %s on line %d
48NULL
49
50Warning: basename() expects parameter 1 to be string, object given in %s on line %d
51NULL
52
53Warning: basename() expects parameter 1 to be string, object given in %s on line %d
54NULL
55
56Warning: basename() expects parameter 2 to be string, object given in %s on line %d
57NULL
58Done
59