Annotation of embedaddon/php/ext/standard/tests/array/array_combine_error2.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test array_combine() function : error conditions - empty array
3: --FILE--
4: <?php
5: /* Prototype : array array_combine(array $keys, array $values)
6: * Description: Creates an array by using the elements of the first parameter as keys
7: * and the elements of the second as the corresponding values
8: * Source code: ext/standard/array.c
9: */
10:
11: echo "*** Testing array_combine() : error conditions specific to array_combine() ***\n";
12:
13: // Testing array_combine by passing empty arrays to $keys and $values arguments
14: echo "\n-- Testing array_combine() function with empty arrays --\n";
15: var_dump( array_combine(array(), array()) );
16:
17: // Testing array_combine by passing empty array to $keys
18: echo "\n-- Testing array_combine() function with empty array for \$keys argument --\n";
19: var_dump( array_combine(array(), array(1, 2)) );
20:
21: // Testing array_combine by passing empty array to $values
22: echo "\n-- Testing array_combine() function with empty array for \$values argument --\n";
23: var_dump( array_combine(array(1, 2), array()) );
24:
25: // Testing array_combine with arrays having unequal number of elements
26: echo "\n-- Testing array_combine() function by passing array with unequal number of elements --\n";
27: var_dump( array_combine(array(1, 2), array(1, 2, 3)) );
28:
29: echo "Done";
30: ?>
31: --EXPECTF--
32: *** Testing array_combine() : error conditions specific to array_combine() ***
33:
34: -- Testing array_combine() function with empty arrays --
35:
36: Warning: array_combine(): Both parameters should have at least 1 element in %s on line %d
37: bool(false)
38:
39: -- Testing array_combine() function with empty array for $keys argument --
40:
41: Warning: array_combine(): Both parameters should have an equal number of elements in %s on line %d
42: bool(false)
43:
44: -- Testing array_combine() function with empty array for $values argument --
45:
46: Warning: array_combine(): Both parameters should have an equal number of elements in %s on line %d
47: bool(false)
48:
49: -- Testing array_combine() function by passing array with unequal number of elements --
50:
51: Warning: array_combine(): Both parameters should have an equal number of elements in %s on line %d
52: bool(false)
53: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>