1--TEST-- 2Test get_extension_funcs() function : error conditions 3--FILE-- 4<?php 5/* Prototype : array get_extension_funcs ( string $module_name ) 6 * Description: Returns an array with the names of the functions of a module. 7 * Source code: Zend/zend_builtin_functions.c 8 * Alias to functions: 9 */ 10 11echo "*** Testing get_extension_funcs() function: with unexpected inputs for 'module_name' 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 $str 28$inputs = array ( 29 30 // integer values 31 0, 32 1, 33 255, 34 256, 35 PHP_INT_MAX, 36 -PHP_INT_MAX, 37 38 // float values 39 10.5, 40 -20.5, 41 10.1234567e10, 42 43 // array values 44 array(), 45 array(0), 46 array(1, 2), 47 48 // boolean values 49 true, 50 false, 51 TRUE, 52 FALSE, 53 54 // null values 55 NULL, 56 null, 57 58 // objects 59 new sample(), 60 61 // resource 62 $file_handle, 63 64 // undefined variable 65 @$undefined_var, 66 67 // unset variable 68 @$unset_var 69); 70 71// loop through with each element of the $inputs array to test get_extension_funcs() function 72$count = 1; 73foreach($inputs as $input) { 74 echo "-- Iteration $count --\n"; 75 var_dump( get_extension_funcs($input) ); 76 $count ++; 77} 78 79fclose($file_handle); //closing the file handle 80 81?> 82===DONE=== 83--EXPECTF-- 84*** Testing get_extension_funcs() function: with unexpected inputs for 'module_name' argument *** 85-- Iteration 1 -- 86bool(false) 87-- Iteration 2 -- 88bool(false) 89-- Iteration 3 -- 90bool(false) 91-- Iteration 4 -- 92bool(false) 93-- Iteration 5 -- 94bool(false) 95-- Iteration 6 -- 96bool(false) 97-- Iteration 7 -- 98bool(false) 99-- Iteration 8 -- 100bool(false) 101-- Iteration 9 -- 102bool(false) 103-- Iteration 10 -- 104 105Warning: get_extension_funcs() expects parameter 1 to be string, array given in %s on line %d 106NULL 107-- Iteration 11 -- 108 109Warning: get_extension_funcs() expects parameter 1 to be string, array given in %s on line %d 110NULL 111-- Iteration 12 -- 112 113Warning: get_extension_funcs() expects parameter 1 to be string, array given in %s on line %d 114NULL 115-- Iteration 13 -- 116bool(false) 117-- Iteration 14 -- 118bool(false) 119-- Iteration 15 -- 120bool(false) 121-- Iteration 16 -- 122bool(false) 123-- Iteration 17 -- 124bool(false) 125-- Iteration 18 -- 126bool(false) 127-- Iteration 19 -- 128bool(false) 129-- Iteration 20 -- 130 131Warning: get_extension_funcs() expects parameter 1 to be string, resource given in %s on line %d 132NULL 133-- Iteration 21 -- 134bool(false) 135-- Iteration 22 -- 136bool(false) 137===DONE=== 138