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

1.1       misho       1: --TEST--
                      2: Test array_intersect_uassoc() function : usage variation - Passing unexpected values to mandatory third argument
                      3: --FILE--
                      4: <?php
                      5: /* Prototype  : array array_intersect_uassoc(array arr1, array arr2 [, array ...], callback key_compare_func)
                      6:  * Description: Computes the intersection of arrays with additional index check, compares indexes by a callback function
                      7:  * Source code: ext/standard/array.c
                      8:  */
                      9: 
                     10: echo "*** Testing array_intersect_uassoc() : usage variation ***\n";
                     11: 
                     12: // Initialise function arguments 
                     13: $array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red");
                     14: $array2 = array("a" => "green", "yellow", "red");
                     15: $array3 = array("a"=>"green", "brown");
                     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: // heredoc string
                     37: $heredoc = <<<EOT
                     38: hello world
                     39: EOT;
                     40: 
                     41: // add arrays
                     42: $index_array = array (1, 2, 3);
                     43: $assoc_array = array ('one' => 1, 'two' => 2);
                     44: 
                     45: //array of values to iterate over
                     46: $inputs = array(
                     47: 
                     48:       // int data
                     49:       'int 0' => 0,
                     50:       'int 1' => 1,
                     51:       'int 12345' => 12345,
                     52:       'int -12345' => -12345,
                     53: 
                     54:       // float data
                     55:       'float 10.5' => 10.5,
                     56:       'float -10.5' => -10.5,
                     57:       'float 12.3456789000e10' => 12.3456789000e10,
                     58:       'float -12.3456789000e10' => -12.3456789000e10,
                     59:       'float .5' => .5,
                     60: 
                     61:       // null data
                     62:       'uppercase NULL' => NULL,
                     63:       'lowercase null' => null,
                     64: 
                     65:       // boolean data
                     66:       'lowercase true' => true,
                     67:       'lowercase false' =>false,
                     68:       'uppercase TRUE' =>TRUE,
                     69:       'uppercase FALSE' =>FALSE,
                     70: 
                     71:       // object data
                     72:       'instance of classWithToString' => new classWithToString(),
                     73:       'instance of classWithoutToString' => new classWithoutToString(),
                     74: 
                     75:       // undefined data
                     76:       'undefined var' => @$undefined_var,
                     77: 
                     78:       // unset data
                     79:       'unset var' => @$unset_var,
                     80: 
                     81:       // resource data
                     82:       'resource' => $fp,
                     83: );
                     84: 
                     85: // loop through each element of the array for arr1
                     86: foreach($inputs as $key =>$value) {
                     87:       echo "\n--$key--\n";
                     88:       var_dump( array_intersect_uassoc($array1, $array2, $value) );
                     89:       var_dump( array_intersect_uassoc($array1, $array2, $array3, $value) );
                     90: };
                     91: 
                     92: fclose($fp);
                     93: ?>
                     94: ===DONE===
                     95: --EXPECTF--
                     96: *** Testing array_intersect_uassoc() : usage variation ***
                     97: 
                     98: --int 0--
                     99: 
                    100: Warning: array_intersect_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    101: NULL
                    102: 
                    103: Warning: array_intersect_uassoc() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    104: NULL
                    105: 
                    106: --int 1--
                    107: 
                    108: Warning: array_intersect_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    109: NULL
                    110: 
                    111: Warning: array_intersect_uassoc() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    112: NULL
                    113: 
                    114: --int 12345--
                    115: 
                    116: Warning: array_intersect_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    117: NULL
                    118: 
                    119: Warning: array_intersect_uassoc() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    120: NULL
                    121: 
                    122: --int -12345--
                    123: 
                    124: Warning: array_intersect_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    125: NULL
                    126: 
                    127: Warning: array_intersect_uassoc() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    128: NULL
                    129: 
                    130: --float 10.5--
                    131: 
                    132: Warning: array_intersect_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    133: NULL
                    134: 
                    135: Warning: array_intersect_uassoc() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    136: NULL
                    137: 
                    138: --float -10.5--
                    139: 
                    140: Warning: array_intersect_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    141: NULL
                    142: 
                    143: Warning: array_intersect_uassoc() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    144: NULL
                    145: 
                    146: --float 12.3456789000e10--
                    147: 
                    148: Warning: array_intersect_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    149: NULL
                    150: 
                    151: Warning: array_intersect_uassoc() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    152: NULL
                    153: 
                    154: --float -12.3456789000e10--
                    155: 
                    156: Warning: array_intersect_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    157: NULL
                    158: 
                    159: Warning: array_intersect_uassoc() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    160: NULL
                    161: 
                    162: --float .5--
                    163: 
                    164: Warning: array_intersect_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    165: NULL
                    166: 
                    167: Warning: array_intersect_uassoc() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    168: NULL
                    169: 
                    170: --uppercase NULL--
                    171: 
                    172: Warning: array_intersect_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    173: NULL
                    174: 
                    175: Warning: array_intersect_uassoc() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    176: NULL
                    177: 
                    178: --lowercase null--
                    179: 
                    180: Warning: array_intersect_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    181: NULL
                    182: 
                    183: Warning: array_intersect_uassoc() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    184: NULL
                    185: 
                    186: --lowercase true--
                    187: 
                    188: Warning: array_intersect_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    189: NULL
                    190: 
                    191: Warning: array_intersect_uassoc() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    192: NULL
                    193: 
                    194: --lowercase false--
                    195: 
                    196: Warning: array_intersect_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    197: NULL
                    198: 
                    199: Warning: array_intersect_uassoc() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    200: NULL
                    201: 
                    202: --uppercase TRUE--
                    203: 
                    204: Warning: array_intersect_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    205: NULL
                    206: 
                    207: Warning: array_intersect_uassoc() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    208: NULL
                    209: 
                    210: --uppercase FALSE--
                    211: 
                    212: Warning: array_intersect_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    213: NULL
                    214: 
                    215: Warning: array_intersect_uassoc() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    216: NULL
                    217: 
                    218: --instance of classWithToString--
                    219: 
                    220: Warning: array_intersect_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    221: NULL
                    222: 
                    223: Warning: array_intersect_uassoc() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    224: NULL
                    225: 
                    226: --instance of classWithoutToString--
                    227: 
                    228: Warning: array_intersect_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    229: NULL
                    230: 
                    231: Warning: array_intersect_uassoc() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    232: NULL
                    233: 
                    234: --undefined var--
                    235: 
                    236: Warning: array_intersect_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    237: NULL
                    238: 
                    239: Warning: array_intersect_uassoc() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    240: NULL
                    241: 
                    242: --unset var--
                    243: 
                    244: Warning: array_intersect_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    245: NULL
                    246: 
                    247: Warning: array_intersect_uassoc() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    248: NULL
                    249: 
                    250: --resource--
                    251: 
                    252: Warning: array_intersect_uassoc() expects parameter 3 to be a valid callback, no array or string given in %s on line %d
                    253: NULL
                    254: 
                    255: Warning: array_intersect_uassoc() expects parameter 4 to be a valid callback, no array or string given in %s on line %d
                    256: NULL
                    257: ===DONE===

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