1--TEST-- 2Test hebrev() function : usage variations - test values for $max_chars_per_line argument 3--FILE-- 4<?php 5 6/* Prototype : string hebrev ( string $hebrew_text [, int $max_chars_per_line ] ) 7 * Description: Convert logical Hebrew text to visual text 8 * Source code: ext/standard/string.c 9*/ 10 11echo "*** Testing hebrev() function: with unexpected inputs for 'max_chars_per_line' argument ***\n"; 12 13//get an unset variable 14$unset_var = 'string_val'; 15unset($unset_var); 16 17//defining a class 18class sample { 19 public function __toString() { 20 return "sample object"; 21 } 22} 23 24//getting the resource 25$file_handle = fopen(__FILE__, "r"); 26 27// array with different values for $max_chars_per_line 28$inputs = array ( 29 30 // integer values 31/*1*/ 0, 32 1, 33 255, 34 256, 35 2147483647, 36 -2147483648, 37 38 // float values 39/*7*/ 10.5, 40 -20.5, 41 10.1234567e5, 42 43 // array values 44/*10*/ array(), 45 array(0), 46 array(1, 2), 47 48 // boolean values 49/*13*/ true, 50 false, 51 TRUE, 52 FALSE, 53 54 // null values 55/*17*/ NULL, 56 null, 57 58 // string values 59/*19*/ "abc", 60 'abc', 61 "3abc", 62 "0abc", 63 "0x3", 64 65 // objects 66/*24*/ new sample(), 67 68 // resource 69/*25*/ $file_handle, 70 71 // undefined variable 72/*26*/ @$undefined_var, 73 74 // unset variable 75/*27*/ @$unset_var 76); 77 78// loop through with each element of the $texts array to test hebrev() function 79$count = 1; 80 81$hebrew_text = "The hebrev function converts logical Hebrew text to visual text.\nThe function tries to avoid breaking words.\n"; 82 83foreach($inputs as $max_chars_per_line) { 84 echo "-- Iteration $count --\n"; 85 var_dump( hebrev($hebrew_text, $max_chars_per_line) ); 86 $count ++; 87} 88 89fclose($file_handle); //closing the file handle 90 91?> 92===DONE=== 93--EXPECTF-- 94*** Testing hebrev() function: with unexpected inputs for 'max_chars_per_line' argument *** 95-- Iteration 1 -- 96string(109) ".The hebrev function converts logical Hebrew text to visual text 97.The function tries to avoid breaking words 98" 99-- Iteration 2 -- 100string(109) "xttel uaisv 101tot ext 102ewbrHel cagilos rtveonc 103ontincfuv reebh 104he.Ts 105rdwog inakreb 106idvoa 107tos ietrn ioctunf 108he.T 109" 110-- Iteration 3 -- 111string(109) ".The hebrev function converts logical Hebrew text to visual text 112.The function tries to avoid breaking words 113" 114-- Iteration 4 -- 115string(109) ".The hebrev function converts logical Hebrew text to visual text 116.The function tries to avoid breaking words 117" 118-- Iteration 5 -- 119string(109) ".The hebrev function converts logical Hebrew text to visual text 120.The function tries to avoid breaking words 121" 122-- Iteration 6 -- 123string(109) "txet 124lausiv 125ot 126txet 127werbeH 128lacigol 129strevnoc 130noitcnuf 131verbeh 132ehT. 133sdrow 134gnikaerb 135diova 136ot 137seirt 138noitcnuf 139ehT. 140" 141-- Iteration 7 -- 142string(109) "text 143to visual 144text 145Hebrew 146logical 147converts 148function 149hebrev 150.The 151words 152breaking 153to avoid 154tries 155function 156.The 157" 158-- Iteration 8 -- 159string(109) "txet 160lausiv 161ot 162txet 163werbeH 164lacigol 165strevnoc 166noitcnuf 167verbeh 168ehT. 169sdrow 170gnikaerb 171diova 172ot 173seirt 174noitcnuf 175ehT. 176" 177-- Iteration 9 -- 178string(109) ".The hebrev function converts logical Hebrew text to visual text 179.The function tries to avoid breaking words 180" 181-- Iteration 10 -- 182 183Warning: hebrev() expects parameter 2 to be int, array given in %s on line %d 184NULL 185-- Iteration 11 -- 186 187Warning: hebrev() expects parameter 2 to be int, array given in %s on line %d 188NULL 189-- Iteration 12 -- 190 191Warning: hebrev() expects parameter 2 to be int, array given in %s on line %d 192NULL 193-- Iteration 13 -- 194string(109) "xttel uaisv 195tot ext 196ewbrHel cagilos rtveonc 197ontincfuv reebh 198he.Ts 199rdwog inakreb 200idvoa 201tos ietrn ioctunf 202he.T 203" 204-- Iteration 14 -- 205string(109) ".The hebrev function converts logical Hebrew text to visual text 206.The function tries to avoid breaking words 207" 208-- Iteration 15 -- 209string(109) "xttel uaisv 210tot ext 211ewbrHel cagilos rtveonc 212ontincfuv reebh 213he.Ts 214rdwog inakreb 215idvoa 216tos ietrn ioctunf 217he.T 218" 219-- Iteration 16 -- 220string(109) ".The hebrev function converts logical Hebrew text to visual text 221.The function tries to avoid breaking words 222" 223-- Iteration 17 -- 224string(109) ".The hebrev function converts logical Hebrew text to visual text 225.The function tries to avoid breaking words 226" 227-- Iteration 18 -- 228string(109) ".The hebrev function converts logical Hebrew text to visual text 229.The function tries to avoid breaking words 230" 231-- Iteration 19 -- 232 233Warning: hebrev() expects parameter 2 to be int, string given in %s on line %d 234NULL 235-- Iteration 20 -- 236 237Warning: hebrev() expects parameter 2 to be int, string given in %s on line %d 238NULL 239-- Iteration 21 -- 240 241Notice: A non well formed numeric value encountered in %s on line %d 242string(109) "textual vis 243to 244textrew Heb 245icallog 246ertsconvion unctf 247brevhe 248.Therds 249wo 250kingbreaoid av 251to 252riest 253tionfuncThe . 254" 255-- Iteration 22 -- 256 257Notice: A non well formed numeric value encountered in %s on line %d 258string(109) ".The hebrev function converts logical Hebrew text to visual text 259.The function tries to avoid breaking words 260" 261-- Iteration 23 -- 262 263Notice: A non well formed numeric value encountered in %s on line %d 264string(109) ".The hebrev function converts logical Hebrew text to visual text 265.The function tries to avoid breaking words 266" 267-- Iteration 24 -- 268 269Warning: hebrev() expects parameter 2 to be int, object given in %s on line %d 270NULL 271-- Iteration 25 -- 272 273Warning: hebrev() expects parameter 2 to be int, resource given in %s on line %d 274NULL 275-- Iteration 26 -- 276string(109) ".The hebrev function converts logical Hebrew text to visual text 277.The function tries to avoid breaking words 278" 279-- Iteration 27 -- 280string(109) ".The hebrev function converts logical Hebrew text to visual text 281.The function tries to avoid breaking words 282" 283===DONE=== 284