1--TEST-- 2Test hebrev() function : usage variations - test values for $hebrew_text 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 'hebrew_text' 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 $hebrew_text 28$texts = 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 // objects 59/*19*/ new sample(), 60 61 // resource 62/*20*/ $file_handle, 63 64 // undefined variable 65/*21*/ @$undefined_var, 66 67 // unset variable 68/*22*/ @$unset_var, 69 70 // text with parentheses 71 'text with parentheses (', 72 'text with parentheses )', 73 74 // text with brackets 75 'text with bracket [', 76 'text with bracket ]', 77 78 // text with curly brackets 79 'text with curly bracket {', 80 'text with curly bracket }', 81 82 // text with backslash escape 83 'text with backslash escape \\', 84 85 // text with a slash char 86 'text with a slash char /', 87 88 // text with a greater than char 89 'text with a greater than char >', 90 91 // text with a less than char 92 'text with a less than char <' 93); 94 95// loop through with each element of the $texts array to test hebrev() function 96$count = 1; 97 98foreach($texts as $hebrew_text) { 99 echo "-- Iteration $count --\n"; 100 var_dump( hebrev($hebrew_text) ); 101 $count ++; 102} 103 104fclose($file_handle); //closing the file handle 105 106?> 107===DONE=== 108--EXPECTF-- 109*** Testing hebrev() function: with unexpected inputs for 'hebrew_text' argument *** 110-- Iteration 1 -- 111string(1) "0" 112-- Iteration 2 -- 113string(1) "1" 114-- Iteration 3 -- 115string(3) "255" 116-- Iteration 4 -- 117string(3) "256" 118-- Iteration 5 -- 119string(10) "2147483647" 120-- Iteration 6 -- 121string(11) "-2147483648" 122-- Iteration 7 -- 123string(4) "10.5" 124-- Iteration 8 -- 125string(5) "-20.5" 126-- Iteration 9 -- 127string(10) "1012345.67" 128-- Iteration 10 -- 129 130Warning: hebrev() expects parameter 1 to be string, array given in %s on line %d 131NULL 132-- Iteration 11 -- 133 134Warning: hebrev() expects parameter 1 to be string, array given in %s on line %d 135NULL 136-- Iteration 12 -- 137 138Warning: hebrev() expects parameter 1 to be string, array given in %s on line %d 139NULL 140-- Iteration 13 -- 141string(1) "1" 142-- Iteration 14 -- 143bool(false) 144-- Iteration 15 -- 145string(1) "1" 146-- Iteration 16 -- 147bool(false) 148-- Iteration 17 -- 149bool(false) 150-- Iteration 18 -- 151bool(false) 152-- Iteration 19 -- 153string(13) "sample object" 154-- Iteration 20 -- 155 156Warning: hebrev() expects parameter 1 to be string, resource given in %s on line %d 157NULL 158-- Iteration 21 -- 159bool(false) 160-- Iteration 22 -- 161bool(false) 162-- Iteration 23 -- 163string(23) ") text with parentheses" 164-- Iteration 24 -- 165string(23) "( text with parentheses" 166-- Iteration 25 -- 167string(19) "] text with bracket" 168-- Iteration 26 -- 169string(19) "[ text with bracket" 170-- Iteration 27 -- 171string(25) "} text with curly bracket" 172-- Iteration 28 -- 173string(25) "{ text with curly bracket" 174-- Iteration 29 -- 175string(28) "/ text with backslash escape" 176-- Iteration 30 -- 177string(24) "text with a slash char /" 178-- Iteration 31 -- 179string(31) "< text with a greater than char" 180-- Iteration 32 -- 181string(28) "> text with a less than char" 182===DONE=== 183