1--TEST-- 2Test curl_version() function : usage variations - test values for $ascii argument 3--SKIPIF-- 4<?php 5if (!extension_loaded("curl")) { 6 echo "skip - curl extension not available in this build"; 7} 8if (!getenv('PHP_CURL_HTTP_REMOTE_SERVER')) { 9 echo "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; 10} 11?> 12--FILE-- 13<?php 14 15/* Prototype : array curl_version ([ int $age ] ) 16 * Description: Returns information about the cURL version. 17 * Source code: ext/curl/interface.c 18*/ 19 20echo "*** Testing curl_version() function: with unexpected inputs for 'age' argument ***\n"; 21 22//get an unset variable 23$unset_var = 'string_val'; 24unset($unset_var); 25 26//defining a class 27class sample { 28 public function __toString() { 29 return "sample object"; 30 } 31} 32 33//getting the resource 34$file_handle = fopen(__FILE__, "r"); 35 36// array with different values for $input 37$inputs = array ( 38 39 // integer values 40 0, 41 1, 42 255, 43 256, 44 PHP_INT_MAX, 45 -PHP_INT_MAX, 46 47 // float values 48 10.5, 49 -20.5, 50 10.1234567e10, 51 52 // array values 53 array(), 54 array(0), 55 array(1, 2), 56 57 //string values 58 "ABC", 59 'abc', 60 "2abc", 61 62 // boolean values 63 true, 64 false, 65 TRUE, 66 FALSE, 67 68 // null values 69 NULL, 70 null, 71 72 // objects 73 new sample(), 74 75 // resource 76 $file_handle, 77 78 // undefined variable 79 @$undefined_var, 80 81 // unset variable 82 @$unset_var 83); 84 85// loop through with each element of the $inputs array to test curl_version() function 86$count = 1; 87foreach($inputs as $input) { 88 echo "-- Iteration $count --\n"; 89 var_dump( is_array(curl_version($input)) ); 90 $count ++; 91} 92 93fclose($file_handle); //closing the file handle 94 95?> 96===Done=== 97--EXPECTF-- 98*** Testing curl_version() function: with unexpected inputs for 'age' argument *** 99-- Iteration 1 -- 100bool(true) 101-- Iteration 2 -- 102bool(true) 103-- Iteration 3 -- 104bool(true) 105-- Iteration 4 -- 106bool(true) 107-- Iteration 5 -- 108bool(true) 109-- Iteration 6 -- 110bool(true) 111-- Iteration 7 -- 112bool(true) 113-- Iteration 8 -- 114bool(true) 115-- Iteration 9 -- 116bool(true) 117-- Iteration 10 -- 118 119Warning: curl_version() expects parameter 1 to be long, array given in %s on line %d 120bool(false) 121-- Iteration 11 -- 122 123Warning: curl_version() expects parameter 1 to be long, array given in %s on line %d 124bool(false) 125-- Iteration 12 -- 126 127Warning: curl_version() expects parameter 1 to be long, array given in %s on line %d 128bool(false) 129-- Iteration 13 -- 130 131Warning: curl_version() expects parameter 1 to be long, string given in %s on line %d 132bool(false) 133-- Iteration 14 -- 134 135Warning: curl_version() expects parameter 1 to be long, string given in %s on line %d 136bool(false) 137-- Iteration 15 -- 138 139Notice: A non well formed numeric value encountered in %s on line %d 140bool(true) 141-- Iteration 16 -- 142bool(true) 143-- Iteration 17 -- 144bool(true) 145-- Iteration 18 -- 146bool(true) 147-- Iteration 19 -- 148bool(true) 149-- Iteration 20 -- 150bool(true) 151-- Iteration 21 -- 152bool(true) 153-- Iteration 22 -- 154 155Warning: curl_version() expects parameter 1 to be long, object given in %s on line %d 156bool(false) 157-- Iteration 23 -- 158 159Warning: curl_version() expects parameter 1 to be long, resource given in %s on line %d 160bool(false) 161-- Iteration 24 -- 162bool(true) 163-- Iteration 25 -- 164bool(true) 165===Done=== 166