Annotation of embedaddon/php/ext/standard/tests/array/array_intersect_ukey_variation3.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test array_intersect_ukey() function : usage variation - Passing unexpected values to callback argument
                      3: --FILE--
                      4: <?php
                      5: /* Prototype  : array array_intersect_ukey(array arr1, array arr2 [, array ...], callback key_compare_func)
                      6:  * Description: Computes the intersection of arrays using a callback function on the keys for comparison. 
                      7:  * Source code: ext/standard/array.c
                      8:  */
                      9: 
                     10: echo "*** Testing array_intersect_ukey() : usage variation ***\n";
                     11: 
                     12: //Initialise arguments
                     13: $array1 = array('blue'  => 1, 'red'  => 2, 'green'  => 3, 'purple' => 4);
                     14: $array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan'   => 8);
                     15: $array3 = array('green' => 5, 'cyan'   => 8);
                     16: 
                     17: //get an unset variable
                     18: $unset_var = 10;
                     19: unset ($unset_var);
                     20: 
                     21: //resource variable
                     22: $fp = fopen(__FILE__, "r");
                     23: 
                     24: // define some classes
                     25: class classWithToString
                     26: {
                     27:        public function __toString() {
                     28:                return "Class A object";
                     29:        }
                     30: }
                     31: 
                     32: class classWithoutToString
                     33: {
                     34: }
                     35: 
                     36: // add arrays
                     37: $index_array = array (1, 2, 3);
                     38: $assoc_array = array ('one' => 1, 'two' => 2);
                     39: 
                     40: //array of values to iterate over
                     41: $inputs = array(
                     42: 
                     43:       // int data
                     44:       'int 0' => 0,
                     45:       'int 1' => 1,
                     46:       'int 12345' => 12345,
                     47:       'int -12345' => -12345,
                     48: 
                     49:       // float data
                     50:       'float 10.5' => 10.5,
                     51:       'float -10.5' => -10.5,
                     52:       'float 12.3456789000e10' => 12.3456789000e10,
                     53:       'float -12.3456789000e10' => -12.3456789000e10,
                     54:       'float .5' => .5,
                     55: 
                     56:       // array data
                     57:       'empty array' => array(),
                     58:       'int indexed array' => $index_array,
                     59:       'associative array' => $assoc_array,
                     60:       'nested arrays' => array('foo', $index_array, $assoc_array),
                     61: 
                     62:       // null data
                     63:       'uppercase NULL' => NULL,
                     64:       'lowercase null' => null,
                     65: 
                     66:       // boolean data
                     67:       'lowercase true' => true,
                     68:       'lowercase false' =>false,
                     69:       'uppercase TRUE' =>TRUE,
                     70:       'uppercase FALSE' =>FALSE,
                     71: 
                     72:       // object data
                     73:       'instance of classWithToString' => new classWithToString(),
                     74:       'instance of classWithoutToString' => new classWithoutToString(),
                     75: 
                     76:       // undefined data
                     77:       'undefined var' => @$undefined_var,
                     78: 
                     79:       // unset data
                     80:       'unset var' => @$unset_var,
                     81: 
                     82:       // resource data
                     83:       'resource var' => $fp,
                     84: );
                     85: 
                     86: // loop through each element of the array for key_compare_func
                     87: foreach($inputs as $key =>$value) {
                     88:       echo "\n--$key--\n";
                     89:       var_dump( array_intersect_ukey($array1, $array2, $value) );
                     90:       var_dump( array_intersect_ukey($array1, $array2, $array3, $value) );
                     91: };
                     92: 
                     93: fclose($fp);
                     94: ?>
                     95: ===DONE===
                     96: --EXPECTF--
                     97: *** Testing array_intersect_ukey() : usage variation ***
                     98: 
                     99: --int 0--
                    100: 
                    101: Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    102: NULL
                    103: 
                    104: Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    105: NULL
                    106: 
                    107: --int 1--
                    108: 
                    109: Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    110: NULL
                    111: 
                    112: Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    113: NULL
                    114: 
                    115: --int 12345--
                    116: 
                    117: Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    118: NULL
                    119: 
                    120: Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    121: NULL
                    122: 
                    123: --int -12345--
                    124: 
                    125: Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    126: NULL
                    127: 
                    128: Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    129: NULL
                    130: 
                    131: --float 10.5--
                    132: 
                    133: Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    134: NULL
                    135: 
                    136: Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    137: NULL
                    138: 
                    139: --float -10.5--
                    140: 
                    141: Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    142: NULL
                    143: 
                    144: Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    145: NULL
                    146: 
                    147: --float 12.3456789000e10--
                    148: 
                    149: Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    150: NULL
                    151: 
                    152: Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    153: NULL
                    154: 
                    155: --float -12.3456789000e10--
                    156: 
                    157: Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    158: NULL
                    159: 
                    160: Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    161: NULL
                    162: 
                    163: --float .5--
                    164: 
                    165: Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    166: NULL
                    167: 
                    168: Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    169: NULL
                    170: 
                    171: --empty array--
                    172: 
                    173: Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, array must have exactly two members in %s on line %d
                    174: NULL
                    175: 
                    176: Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, array must have exactly two members in %s on line %d
                    177: NULL
                    178: 
                    179: --int indexed array--
                    180: 
                    181: Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, array must have exactly two members in %s on line %d
                    182: NULL
                    183: 
                    184: Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, array must have exactly two members in %s on line %d
                    185: NULL
                    186: 
                    187: --associative array--
                    188: 
                    189: Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, first array member is not a valid class name or object in %s on line %d
                    190: NULL
                    191: 
                    192: Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, first array member is not a valid class name or object in %s on line %d
                    193: NULL
                    194: 
                    195: --nested arrays--
                    196: 
                    197: Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, array must have exactly two members in %s on line %d
                    198: NULL
                    199: 
                    200: Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, array must have exactly two members in %s on line %d
                    201: NULL
                    202: 
                    203: --uppercase NULL--
                    204: 
                    205: Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    206: NULL
                    207: 
                    208: Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    209: NULL
                    210: 
                    211: --lowercase null--
                    212: 
                    213: Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    214: NULL
                    215: 
                    216: Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    217: NULL
                    218: 
                    219: --lowercase true--
                    220: 
                    221: Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    222: NULL
                    223: 
                    224: Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    225: NULL
                    226: 
                    227: --lowercase false--
                    228: 
                    229: Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    230: NULL
                    231: 
                    232: Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    233: NULL
                    234: 
                    235: --uppercase TRUE--
                    236: 
                    237: Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    238: NULL
                    239: 
                    240: Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    241: NULL
                    242: 
                    243: --uppercase FALSE--
                    244: 
                    245: Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    246: NULL
                    247: 
                    248: Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    249: NULL
                    250: 
                    251: --instance of classWithToString--
                    252: 
                    253: Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    254: NULL
                    255: 
                    256: Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    257: NULL
                    258: 
                    259: --instance of classWithoutToString--
                    260: 
                    261: Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    262: NULL
                    263: 
                    264: Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    265: NULL
                    266: 
                    267: --undefined var--
                    268: 
                    269: Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    270: NULL
                    271: 
                    272: Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    273: NULL
                    274: 
                    275: --unset var--
                    276: 
                    277: Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    278: NULL
                    279: 
                    280: Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    281: NULL
                    282: 
                    283: --resource var--
                    284: 
                    285: Warning: array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    286: NULL
                    287: 
                    288: Warning: array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    289: NULL
                    290: ===DONE===

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>