Annotation of embedaddon/php/ext/standard/tests/strings/substr_replace_error.phpt, revision 1.1.1.2
1.1 misho 1: --TEST--
2: Test substr_replace() function : error conditions
3: --FILE--
4: <?php
5: /* Prototype : mixed substr_replace ( mixed $string , string $replacement , int $start [, int $length ] )
6: * Description: Replace text within a portion of a string
7: * Source code: ext/standard/string.c
8: */
9:
10: /*
11: * Testing substr_replace() for error conditions
12: */
13:
14: echo "*** Testing substr_replace() : error conditions ***\n";
15:
16: $s1 = "Good morning";
17:
18: echo "\n-- Testing substr_replace() function with less than expected no. of arguments --\n";
19: var_dump(substr_replace());
20: var_dump(substr_replace($s1, "evening"));
21:
22: echo "\n-- Testing substr_replace() function with more than expected no. of arguments --\n";
23: var_dump(substr_replace($s1, "evening", 5, 7, true));
24:
25: echo "\n-- Testing substr_replace() function with start and length different types --\n";
26: var_dump(substr_replace($s1, "evening", array(5)));
27: var_dump(substr_replace($s1, "evening", 5, array(8)));
28:
1.1.1.2 ! misho 29: echo "\n-- Testing substr_replace() function with start and length with a different number of elements --\n";
1.1 misho 30: var_dump(substr_replace($s1, "evening", array(5, 1), array(8)));
31:
32: echo "\n-- Testing substr_replace() function with start and length as arrays but string not--\n";
33: var_dump(substr_replace($s1, "evening", array(5), array(8)));
34:
35: ?>
36: ===DONE===
37: --EXPECTF--
38: *** Testing substr_replace() : error conditions ***
39:
40: -- Testing substr_replace() function with less than expected no. of arguments --
41:
42: Warning: substr_replace() expects at least 3 parameters, 0 given in %s on line %d
43: NULL
44:
45: Warning: substr_replace() expects at least 3 parameters, 2 given in %s on line %d
46: NULL
47:
48: -- Testing substr_replace() function with more than expected no. of arguments --
49:
50: Warning: substr_replace() expects at most 4 parameters, 5 given in %s on line %d
51: NULL
52:
53: -- Testing substr_replace() function with start and length different types --
54:
55: Warning: substr_replace(): 'from' and 'len' should be of same type - numerical or array in %s on line %d
56: string(12) "Good morning"
57:
58: Warning: substr_replace(): 'from' and 'len' should be of same type - numerical or array in %s on line %d
59: string(12) "Good morning"
60:
1.1.1.2 ! misho 61: -- Testing substr_replace() function with start and length with a different number of elements --
1.1 misho 62:
63: Warning: substr_replace(): 'from' and 'len' should have the same number of elements in %s on line %d
64: string(12) "Good morning"
65:
66: -- Testing substr_replace() function with start and length as arrays but string not--
67:
68: Warning: substr_replace(): Functionality of 'from' and 'len' as arrays is not implemented in %s on line %d
69: string(12) "Good morning"
70: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>