Annotation of embedaddon/php/ext/mbstring/tests/mb_strlen_error1.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test mb_strlen() function : error conditions - pass incorrect number of args
3: --SKIPIF--
4: <?php
5: extension_loaded('mbstring') or die('skip');
6: function_exists('mb_strlen') or die("skip mb_strlen() is not available in this build");
7: ?>
8: --FILE--
9: <?php
10: /* Prototype : int mb_strlen(string $str [, string $encoding])
11: * Description: Get character numbers of a string
12: * Source code: ext/mbstring/mbstring.c
13: */
14:
15: /*
16: * Pass mb_strlen an incorrect number of arguments to test behaviour
17: */
18:
19: echo "*** Testing mb_strlen() : error conditions ***\n";
20:
21: // Zero arguments
22: echo "\n-- Testing mb_strlen() function with Zero arguments --\n";
23: var_dump( mb_strlen() );
24:
25: //Test mb_strlen with one more than the expected number of arguments
26: echo "\n-- Testing mb_strlen() function with more than expected no. of arguments --\n";
27: $str = 'string_val';
28: $encoding = 'string_val';
29: $extra_arg = 10;
30: var_dump( mb_strlen($str, $encoding, $extra_arg) );
31:
32: echo "Done";
33: ?>
34: --EXPECTF--
35: *** Testing mb_strlen() : error conditions ***
36:
37: -- Testing mb_strlen() function with Zero arguments --
38:
39: Warning: mb_strlen() expects at least 1 parameter, 0 given in %s on line %d
40: bool(false)
41:
42: -- Testing mb_strlen() function with more than expected no. of arguments --
43:
44: Warning: mb_strlen() expects at most 2 parameters, 3 given in %s on line %d
45: bool(false)
46: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>