1--TEST-- 2Test hebrevc() function : usage variations - test values for $hebrew_text argument 3--FILE-- 4<?php 5 6/* Prototype : string hebrevc ( 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 hebrevc() 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 71// loop through with each element of the $texts array to test hebrevc() function 72$count = 1; 73 74foreach($texts as $hebrew_text) { 75 echo "-- Iteration $count --\n"; 76 var_dump( hebrevc($hebrew_text) ); 77 $count ++; 78} 79 80fclose($file_handle); //closing the file handle 81 82?> 83===DONE=== 84--EXPECTF-- 85*** Testing hebrevc() function: with unexpected inputs for 'hebrew_text' argument *** 86-- Iteration 1 -- 87string(1) "0" 88-- Iteration 2 -- 89string(1) "1" 90-- Iteration 3 -- 91string(3) "255" 92-- Iteration 4 -- 93string(3) "256" 94-- Iteration 5 -- 95string(10) "2147483647" 96-- Iteration 6 -- 97string(11) "-2147483648" 98-- Iteration 7 -- 99string(4) "10.5" 100-- Iteration 8 -- 101string(5) "-20.5" 102-- Iteration 9 -- 103string(10) "1012345.67" 104-- Iteration 10 -- 105 106Warning: hebrevc() expects parameter 1 to be string, array given in %s on line %d 107NULL 108-- Iteration 11 -- 109 110Warning: hebrevc() expects parameter 1 to be string, array given in %s on line %d 111NULL 112-- Iteration 12 -- 113 114Warning: hebrevc() expects parameter 1 to be string, array given in %s on line %d 115NULL 116-- Iteration 13 -- 117string(1) "1" 118-- Iteration 14 -- 119bool(false) 120-- Iteration 15 -- 121string(1) "1" 122-- Iteration 16 -- 123bool(false) 124-- Iteration 17 -- 125bool(false) 126-- Iteration 18 -- 127bool(false) 128-- Iteration 19 -- 129string(13) "sample object" 130-- Iteration 20 -- 131 132Warning: hebrevc() expects parameter 1 to be string, resource given in %s on line %d 133NULL 134-- Iteration 21 -- 135bool(false) 136-- Iteration 22 -- 137bool(false) 138===DONE=== 139