Annotation of embedaddon/php/ext/standard/tests/array/array_fill_keys_variation4.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test array_fill_keys() function : variation of parameter
! 3: --FILE--
! 4: <?php
! 5: /* Prototype : proto array array_fill_keys(array keys, mixed val)
! 6: * Description: Create an array using the elements of the first parameter as keys each initialized to val
! 7: * Source code: ext/standard/array.c
! 8: * Alias to functions:
! 9: */
! 10:
! 11: /* Testing with unexpected argument types */
! 12:
! 13: echo "*** Testing array_fill_keys() : parameter variations ***\n";
! 14:
! 15: $fp = fopen(__FILE__, "r");
! 16: $bool = false;
! 17: $float = 2.4;
! 18: $array = array("one");
! 19: $nullVal = null;
! 20: $unset_var = 10;
! 21: unset ($unset_var);
! 22:
! 23:
! 24: class classA {
! 25: public function __toString() { return "Class A object"; }
! 26: }
! 27: $obj = new classA();
! 28:
! 29: echo "\n-- Testing array_fill_keys() function with float --\n";
! 30: var_dump( array_fill_keys($array, $float) );
! 31:
! 32: echo "\n-- Testing array_fill_keys() function with null --\n";
! 33: var_dump( array_fill_keys($array, $nullVal) );
! 34:
! 35: echo "\n-- Testing array_fill_keys() function with object --\n";
! 36: var_dump( array_fill_keys($array, $obj) );
! 37:
! 38: echo "\n-- Testing array_fill_keys() function with boolean --\n";
! 39: var_dump( array_fill_keys($array, $bool) );
! 40:
! 41: echo "\n-- Testing array_fill_keys() function with resource --\n";
! 42: var_dump( array_fill_keys($array, $fp) );
! 43:
! 44: echo "\n-- Testing array_fill_keys() function with unset var --\n";
! 45: var_dump( array_fill_keys($array, $unset_var) );
! 46:
! 47: fclose($fp);
! 48: echo "Done";
! 49: ?>
! 50: --EXPECTF--
! 51: *** Testing array_fill_keys() : parameter variations ***
! 52:
! 53: -- Testing array_fill_keys() function with float --
! 54: array(1) {
! 55: ["one"]=>
! 56: float(2.4)
! 57: }
! 58:
! 59: -- Testing array_fill_keys() function with null --
! 60: array(1) {
! 61: ["one"]=>
! 62: NULL
! 63: }
! 64:
! 65: -- Testing array_fill_keys() function with object --
! 66: array(1) {
! 67: ["one"]=>
! 68: object(classA)#%d (0) {
! 69: }
! 70: }
! 71:
! 72: -- Testing array_fill_keys() function with boolean --
! 73: array(1) {
! 74: ["one"]=>
! 75: bool(false)
! 76: }
! 77:
! 78: -- Testing array_fill_keys() function with resource --
! 79: array(1) {
! 80: ["one"]=>
! 81: resource(%d) of type (stream)
! 82: }
! 83:
! 84: -- Testing array_fill_keys() function with unset var --
! 85:
! 86: Notice: Undefined variable: unset_var in %sarray_fill_keys_variation4.php on line %d
! 87: array(1) {
! 88: ["one"]=>
! 89: NULL
! 90: }
! 91: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>