1--TEST-- 2Test join() function : usage variations - unexpected values for 'pieces' argument(Bug#42789) 3--FILE-- 4<?php 5/* 6 * test join() by passing different unexpected value for pieces argument 7*/ 8 9echo "*** Testing join() : usage variations ***\n"; 10// initialize all required variables 11$glue = '::'; 12 13// get an unset variable 14$unset_var = array(1, 2); 15unset($unset_var); 16 17// get a resource variable 18$fp = fopen(__FILE__, "r"); 19 20// define a class 21class test 22{ 23 var $t = 10; 24 var $p = 10; 25 function __toString() { 26 return "testObject"; 27 } 28} 29 30// array with different values 31$values = array ( 32 // integer values 33 0, 34 1, 35 12345, 36 -2345, 37 38 // float values 39 10.5, 40 -10.5, 41 10.5e10, 42 10.6E-10, 43 .5, 44 45 // boolean values 46 true, 47 false, 48 TRUE, 49 FALSE, 50 51 // string values 52 "string", 53 'string', 54 55 // objects 56 new test(), 57 58 // empty string 59 "", 60 '', 61 62 // null values 63 NULL, 64 null, 65 66 // resource variable 67 $fp, 68 69 // undefined variable 70 @$undefined_var, 71 72 // unset variable 73 @$unset_var 74); 75 76 77// loop through each element of the array and check the working of join() 78// when $pieces argument is supplied with different values 79echo "\n--- Testing join() by supplying different values for 'pieces' argument ---\n"; 80$counter = 1; 81for($index = 0; $index < count($values); $index ++) { 82 echo "-- Iteration $counter --\n"; 83 $pieces = $values [$index]; 84 85 try { 86 var_dump(join($glue, $pieces)); 87 } catch (TypeError $e) { 88 echo $e->getMessage(), "\n"; 89 } 90 91 $counter ++; 92} 93 94// close the resources used 95fclose($fp); 96 97echo "Done\n"; 98?> 99--EXPECT-- 100*** Testing join() : usage variations *** 101 102--- Testing join() by supplying different values for 'pieces' argument --- 103-- Iteration 1 -- 104join(): Argument #2 ($array) must be of type ?array, int given 105-- Iteration 2 -- 106join(): Argument #2 ($array) must be of type ?array, int given 107-- Iteration 3 -- 108join(): Argument #2 ($array) must be of type ?array, int given 109-- Iteration 4 -- 110join(): Argument #2 ($array) must be of type ?array, int given 111-- Iteration 5 -- 112join(): Argument #2 ($array) must be of type ?array, float given 113-- Iteration 6 -- 114join(): Argument #2 ($array) must be of type ?array, float given 115-- Iteration 7 -- 116join(): Argument #2 ($array) must be of type ?array, float given 117-- Iteration 8 -- 118join(): Argument #2 ($array) must be of type ?array, float given 119-- Iteration 9 -- 120join(): Argument #2 ($array) must be of type ?array, float given 121-- Iteration 10 -- 122join(): Argument #2 ($array) must be of type ?array, true given 123-- Iteration 11 -- 124join(): Argument #2 ($array) must be of type ?array, false given 125-- Iteration 12 -- 126join(): Argument #2 ($array) must be of type ?array, true given 127-- Iteration 13 -- 128join(): Argument #2 ($array) must be of type ?array, false given 129-- Iteration 14 -- 130join(): Argument #2 ($array) must be of type ?array, string given 131-- Iteration 15 -- 132join(): Argument #2 ($array) must be of type ?array, string given 133-- Iteration 16 -- 134join(): Argument #2 ($array) must be of type ?array, test given 135-- Iteration 17 -- 136join(): Argument #2 ($array) must be of type ?array, string given 137-- Iteration 18 -- 138join(): Argument #2 ($array) must be of type ?array, string given 139-- Iteration 19 -- 140join(): If argument #1 ($separator) is of type string, argument #2 ($array) must be of type array, null given 141-- Iteration 20 -- 142join(): If argument #1 ($separator) is of type string, argument #2 ($array) must be of type array, null given 143-- Iteration 21 -- 144join(): Argument #2 ($array) must be of type ?array, resource given 145-- Iteration 22 -- 146join(): If argument #1 ($separator) is of type string, argument #2 ($array) must be of type array, null given 147-- Iteration 23 -- 148join(): If argument #1 ($separator) is of type string, argument #2 ($array) must be of type array, null given 149Done 150