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

1.1       misho       1: --TEST--
                      2: Test array_diff_assoc() function : usage variations  - unexpected values for 'arr1' argument
                      3: --FILE--
                      4: <?php
                      5: /* Prototype  : array array_diff_assoc(array $arr1, array $arr2 [, array ...])
                      6:  * Description: Returns the entries of $arr1 that have values which are not present 
                      7:  * in any of the others arguments but do additional checks whether the keys are equal 
                      8:  * Source code: ext/standard/array.c 
                      9:  */
                     10: 
                     11: /*
                     12:  * Pass array_diff_assoc arguments that are not arrays in place of $arr1
                     13:  */
                     14:  
                     15: echo "*** Testing array_diff_assoc() : usage variations ***\n";
                     16: 
                     17: $array = array(1, 2, 3);
                     18: 
                     19: //get an unset variable
                     20: $unset_var = 10;
                     21: unset ($unset_var);
                     22: 
                     23: // get a class
                     24: class classA
                     25: {
                     26:   public function __toString() {
                     27:     return "Class A object";
                     28:   }
                     29: }
                     30: 
                     31: // heredoc string
                     32: $heredoc = <<<EOT
                     33: hello world
                     34: EOT;
                     35: 
                     36: // get a resource variable
                     37: $fp = fopen(__FILE__, "r");
                     38: 
                     39: //array of unexpected values to be passed to $arr1 argument 
                     40: $inputs = array(
                     41: 
                     42:        // int data
                     43: /*1*/  0,
                     44:        1,
                     45:        12345,
                     46:        -2345,
                     47: 
                     48:        // float data
                     49: /*5*/  10.5,
                     50:        -10.5,
                     51:        12.3456789000e10,
                     52:        12.3456789000E-10,
                     53:        .5,
                     54: 
                     55:        // null data
                     56: /*10*/ NULL,
                     57:        null,
                     58: 
                     59:        // boolean data
                     60: /*12*/ true,
                     61:        false,
                     62:        TRUE,
                     63:        FALSE,
                     64:        
                     65:        // empty data
                     66: /*16*/ "",
                     67:        '',
                     68: 
                     69:        // string data
                     70: /*18*/ "string",
                     71:        'string',
                     72:        $heredoc,
                     73:        
                     74:        // binary data
                     75: /*21*/ b"binary",
                     76:           (binary)"binary",
                     77:           
                     78:        // object data
                     79: /*23*/ new classA(),
                     80: 
                     81:        // undefined data
                     82: /*24*/ @$undefined_var,
                     83: 
                     84:        // unset data
                     85: /*25*/ @$unset_var,
                     86: 
                     87:        // resource variable
                     88: /*26*/ $fp,
                     89: );
                     90: 
                     91: // loop through each element of $inputs to check the behavior of array_diff_assoc
                     92: $iterator = 1;
                     93: foreach($inputs as $input) {
                     94:   echo "\n-- Iteration $iterator --\n";
                     95:   var_dump( array_diff_assoc($input, $array));
                     96:   $iterator++;
                     97: };
                     98: fclose($fp);
                     99: echo "Done";
                    100: ?>
                    101: 
                    102: --EXPECTF--
                    103: *** Testing array_diff_assoc() : usage variations ***
                    104: 
                    105: -- Iteration 1 --
                    106: 
                    107: Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
                    108: NULL
                    109: 
                    110: -- Iteration 2 --
                    111: 
                    112: Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
                    113: NULL
                    114: 
                    115: -- Iteration 3 --
                    116: 
                    117: Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
                    118: NULL
                    119: 
                    120: -- Iteration 4 --
                    121: 
                    122: Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
                    123: NULL
                    124: 
                    125: -- Iteration 5 --
                    126: 
                    127: Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
                    128: NULL
                    129: 
                    130: -- Iteration 6 --
                    131: 
                    132: Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
                    133: NULL
                    134: 
                    135: -- Iteration 7 --
                    136: 
                    137: Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
                    138: NULL
                    139: 
                    140: -- Iteration 8 --
                    141: 
                    142: Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
                    143: NULL
                    144: 
                    145: -- Iteration 9 --
                    146: 
                    147: Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
                    148: NULL
                    149: 
                    150: -- Iteration 10 --
                    151: 
                    152: Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
                    153: NULL
                    154: 
                    155: -- Iteration 11 --
                    156: 
                    157: Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
                    158: NULL
                    159: 
                    160: -- Iteration 12 --
                    161: 
                    162: Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
                    163: NULL
                    164: 
                    165: -- Iteration 13 --
                    166: 
                    167: Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
                    168: NULL
                    169: 
                    170: -- Iteration 14 --
                    171: 
                    172: Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
                    173: NULL
                    174: 
                    175: -- Iteration 15 --
                    176: 
                    177: Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
                    178: NULL
                    179: 
                    180: -- Iteration 16 --
                    181: 
                    182: Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
                    183: NULL
                    184: 
                    185: -- Iteration 17 --
                    186: 
                    187: Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
                    188: NULL
                    189: 
                    190: -- Iteration 18 --
                    191: 
                    192: Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
                    193: NULL
                    194: 
                    195: -- Iteration 19 --
                    196: 
                    197: Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
                    198: NULL
                    199: 
                    200: -- Iteration 20 --
                    201: 
                    202: Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
                    203: NULL
                    204: 
                    205: -- Iteration 21 --
                    206: 
                    207: Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
                    208: NULL
                    209: 
                    210: -- Iteration 22 --
                    211: 
                    212: Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
                    213: NULL
                    214: 
                    215: -- Iteration 23 --
                    216: 
                    217: Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
                    218: NULL
                    219: 
                    220: -- Iteration 24 --
                    221: 
                    222: Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
                    223: NULL
                    224: 
                    225: -- Iteration 25 --
                    226: 
                    227: Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
                    228: NULL
                    229: 
                    230: -- Iteration 26 --
                    231: 
                    232: Warning: array_diff_assoc(): Argument #1 is not an array in %s on line %d
                    233: NULL
                    234: Done

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