Annotation of embedaddon/php/ext/standard/tests/strings/basename_error.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test 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: */
10: echo "*** Testing error conditions ***\n";
11: // zero arguments
12: var_dump( basename() );
13:
14: // more than expected no. of arguments
15: var_dump( basename("/var/tmp/bar.gz", ".gz", ".gz") );
16:
17: // passing invalid type arguments
18: $object = new stdclass;
19: var_dump( basename( array("string/bar") ) );
20: var_dump( basename( array("string/bar"), "bar" ) );
21: var_dump( basename( "bar", array("string/bar") ) );
22: var_dump( basename( $object, "bar" ) );
23: var_dump( basename( $object ) );
24: var_dump( basename( $object, $object ) );
25: var_dump( basename( "bar", $object ) );
26:
27: echo "Done\n";
28: ?>
29: --EXPECTF--
30: *** Testing error conditions ***
31:
32: Warning: basename() expects at least 1 parameter, 0 given in %s on line %d
33: NULL
34:
35: Warning: basename() expects at most 2 parameters, 3 given in %s on line %d
36: NULL
37:
38: Warning: basename() expects parameter 1 to be string, array given in %s on line %d
39: NULL
40:
41: Warning: basename() expects parameter 1 to be string, array given in %s on line %d
42: NULL
43:
44: Warning: basename() expects parameter 2 to be string, array given in %s on line %d
45: NULL
46:
47: Warning: basename() expects parameter 1 to be string, object given in %s on line %d
48: NULL
49:
50: Warning: basename() expects parameter 1 to be string, object given in %s on line %d
51: NULL
52:
53: Warning: basename() expects parameter 1 to be string, object given in %s on line %d
54: NULL
55:
56: Warning: basename() expects parameter 2 to be string, object given in %s on line %d
57: NULL
58: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>