Annotation of embedaddon/php/ext/standard/tests/array/array_intersect_assoc_variation1.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Test array_intersect_assoc() function : usage variations - unexpected values for 'arr1' argument(Bug#43196)
        !             3: --FILE--
        !             4: <?php
        !             5: /* Prototype  : array array_intersect_assoc(array $arr1, array $arr2 [, array $...])
        !             6:  * Description: Returns the entries of arr1 that have values which are present in all the other arguments.
        !             7:  * Keys are used to do more restrictive check
        !             8:  * Source code: ext/standard/array.c
        !             9: */
        !            10: 
        !            11: /*
        !            12: * Testing array_intersect_assoc() function by passing values to $arr1 argument other than arrays
        !            13: * and see that function emits proper warning messages wherever expected.
        !            14: * The $arr2 argument passed is a fixed array.
        !            15: */
        !            16: 
        !            17: echo "*** Testing array_intersect_assoc() : Passing non-array values to \$arr1 argument ***\n";
        !            18: 
        !            19: // array to be passsed to $arr2 as default argument
        !            20: $arr2 = array(1, 2);
        !            21: 
        !            22: // additional array to be passed for intersection
        !            23: $arr3 = array(1, 2, "one" => 1, "two" => 2); 
        !            24: 
        !            25: // get an unset variable
        !            26: $unset_var = 10;
        !            27: unset ($unset_var);
        !            28: 
        !            29: // get a class
        !            30: class classA
        !            31: {
        !            32:   public function __toString() {
        !            33:     return "Class A object";
        !            34:   }
        !            35: }
        !            36: 
        !            37: // heredoc string
        !            38: $heredoc = <<<EOT
        !            39: hello world
        !            40: EOT;
        !            41: 
        !            42: // get a resource variable
        !            43: $fp = fopen(__FILE__, "r");
        !            44: 
        !            45: // unexpected values to be passed to $arr1 argument
        !            46: $arrays = array(
        !            47: 
        !            48:        // int data
        !            49: /*1*/  0,
        !            50:        1,
        !            51:        12345,
        !            52:        -2345,
        !            53: 
        !            54:        // float data
        !            55: /*5*/  10.5,
        !            56:        -10.5,
        !            57:        12.3456789000e10,
        !            58:        12.3456789000E-10,
        !            59:        .5,
        !            60: 
        !            61:        // null data
        !            62: /*10*/ NULL,
        !            63:        null,
        !            64: 
        !            65:        // boolean data
        !            66: /*12*/ true,
        !            67:        false,
        !            68:        TRUE,
        !            69:        FALSE,
        !            70: 
        !            71:        // empty data
        !            72: /*16*/ "",
        !            73:        '',
        !            74:  
        !            75:        // string data
        !            76: /*18*/ "string",
        !            77:        'string',
        !            78:        $heredoc,
        !            79: 
        !            80:        // object data
        !            81: /*21*/ new classA(),
        !            82: 
        !            83:        // undefined data
        !            84: /*22*/ @$undefined_var,
        !            85: 
        !            86:        // unset data
        !            87: /*23*/ @$unset_var,
        !            88: 
        !            89:        // resource variable
        !            90: /*24*/ $fp
        !            91: );
        !            92: 
        !            93: // loop through each sub-array within $arrrays to check the behavior of array_intersect_assoc()
        !            94: $iterator = 1;
        !            95: foreach($arrays as $unexpected_value) {
        !            96:   echo "\n-- Iteration $iterator --";
        !            97:   
        !            98:   // Calling array_intersect_assoc() with default arguments
        !            99:   var_dump( array_intersect_assoc($unexpected_value, $arr2) );
        !           100: 
        !           101:   // Calling array_intersect_assoc() with more arguments
        !           102:   var_dump( array_intersect_assoc($unexpected_value, $arr2, $arr3) );
        !           103:   $iterator++;
        !           104: }
        !           105: 
        !           106: // close the file resource used
        !           107: fclose($fp);
        !           108: 
        !           109: echo "Done";
        !           110: ?>
        !           111: --EXPECTF--
        !           112: *** Testing array_intersect_assoc() : Passing non-array values to $arr1 argument ***
        !           113: 
        !           114: -- Iteration 1 --
        !           115: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           116: NULL
        !           117: 
        !           118: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           119: NULL
        !           120: 
        !           121: -- Iteration 2 --
        !           122: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           123: NULL
        !           124: 
        !           125: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           126: NULL
        !           127: 
        !           128: -- Iteration 3 --
        !           129: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           130: NULL
        !           131: 
        !           132: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           133: NULL
        !           134: 
        !           135: -- Iteration 4 --
        !           136: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           137: NULL
        !           138: 
        !           139: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           140: NULL
        !           141: 
        !           142: -- Iteration 5 --
        !           143: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           144: NULL
        !           145: 
        !           146: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           147: NULL
        !           148: 
        !           149: -- Iteration 6 --
        !           150: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           151: NULL
        !           152: 
        !           153: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           154: NULL
        !           155: 
        !           156: -- Iteration 7 --
        !           157: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           158: NULL
        !           159: 
        !           160: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           161: NULL
        !           162: 
        !           163: -- Iteration 8 --
        !           164: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           165: NULL
        !           166: 
        !           167: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           168: NULL
        !           169: 
        !           170: -- Iteration 9 --
        !           171: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           172: NULL
        !           173: 
        !           174: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           175: NULL
        !           176: 
        !           177: -- Iteration 10 --
        !           178: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           179: NULL
        !           180: 
        !           181: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           182: NULL
        !           183: 
        !           184: -- Iteration 11 --
        !           185: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           186: NULL
        !           187: 
        !           188: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           189: NULL
        !           190: 
        !           191: -- Iteration 12 --
        !           192: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           193: NULL
        !           194: 
        !           195: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           196: NULL
        !           197: 
        !           198: -- Iteration 13 --
        !           199: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           200: NULL
        !           201: 
        !           202: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           203: NULL
        !           204: 
        !           205: -- Iteration 14 --
        !           206: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           207: NULL
        !           208: 
        !           209: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           210: NULL
        !           211: 
        !           212: -- Iteration 15 --
        !           213: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           214: NULL
        !           215: 
        !           216: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           217: NULL
        !           218: 
        !           219: -- Iteration 16 --
        !           220: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           221: NULL
        !           222: 
        !           223: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           224: NULL
        !           225: 
        !           226: -- Iteration 17 --
        !           227: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           228: NULL
        !           229: 
        !           230: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           231: NULL
        !           232: 
        !           233: -- Iteration 18 --
        !           234: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           235: NULL
        !           236: 
        !           237: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           238: NULL
        !           239: 
        !           240: -- Iteration 19 --
        !           241: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           242: NULL
        !           243: 
        !           244: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           245: NULL
        !           246: 
        !           247: -- Iteration 20 --
        !           248: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           249: NULL
        !           250: 
        !           251: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           252: NULL
        !           253: 
        !           254: -- Iteration 21 --
        !           255: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           256: NULL
        !           257: 
        !           258: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           259: NULL
        !           260: 
        !           261: -- Iteration 22 --
        !           262: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           263: NULL
        !           264: 
        !           265: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           266: NULL
        !           267: 
        !           268: -- Iteration 23 --
        !           269: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           270: NULL
        !           271: 
        !           272: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           273: NULL
        !           274: 
        !           275: -- Iteration 24 --
        !           276: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           277: NULL
        !           278: 
        !           279: Warning: array_intersect_assoc(): Argument #1 is not an array in %s on line %d
        !           280: NULL
        !           281: Done

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