--- /dev/null
+--TEST--\r
+Test curl_version() function : error conditions\r
+--SKIPIF--\r
+<?php \r
+if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) {\r
+ die('skip - curl extension not available in this build'); \r
+}\r
+?>\r
+--FILE--\r
+<?php\r
+\r
+/* Prototype : array curl_version ([ int $age ] )\r
+ * Description: Returns information about the cURL version.\r
+ * Source code: ext/curl/interface.c\r
+*/\r
+\r
+echo "*** Testing curl_version() : error conditions ***\n";\r
+\r
+echo "\n-- Testing curl_version() function with more than expected no. of arguments --\n";\r
+$extra_arg = 10;\r
+var_dump( curl_version(1, $extra_arg) );\r
+\r
+?>\r
+===Done===\r
+--EXPECTF--\r
+*** Testing curl_version() : error conditions ***\r
+\r
+-- Testing curl_version() function with more than expected no. of arguments --\r
+\r
+Warning: curl_version() expects at most 1 parameter, 2 given in %s on line %d\r
+NULL\r
+===Done===\r
--- /dev/null
+--TEST--\r
+Test curl_version() function : usage variations - test values for $ascii argument\r
+--SKIPIF--\r
+<?php \r
+if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) {\r
+ die('skip - curl extension not available in this build'); \r
+}\r
+?>\r
+--FILE--\r
+<?php\r
+\r
+/* Prototype : array curl_version ([ int $age ] )\r
+ * Description: Returns information about the cURL version.\r
+ * Source code: ext/curl/interface.c\r
+*/\r
+\r
+echo "*** Testing curl_version() function: with unexpected inputs for 'age' argument ***\n";\r
+\r
+//get an unset variable\r
+$unset_var = 'string_val';\r
+unset($unset_var);\r
+\r
+//defining a class\r
+class sample {\r
+ public function __toString() {\r
+ return "sample object";\r
+ } \r
+}\r
+\r
+//getting the resource\r
+$file_handle = fopen(__FILE__, "r");\r
+\r
+// array with different values for $input\r
+$inputs = array (\r
+\r
+ // integer values\r
+ 0,\r
+ 1,\r
+ 255,\r
+ 256,\r
+ PHP_INT_MAX,\r
+ -PHP_INT_MAX,\r
+\r
+ // float values\r
+ 10.5,\r
+ -20.5,\r
+ 10.1234567e10,\r
+\r
+ // array values\r
+ array(),\r
+ array(0),\r
+ array(1, 2),\r
+ \r
+ //string values\r
+ "ABC",\r
+ 'abc',\r
+ "2abc",\r
+\r
+ // boolean values\r
+ true,\r
+ false,\r
+ TRUE,\r
+ FALSE,\r
+\r
+ // null values\r
+ NULL,\r
+ null,\r
+\r
+ // objects\r
+ new sample(),\r
+\r
+ // resource\r
+ $file_handle,\r
+\r
+ // undefined variable\r
+ @$undefined_var,\r
+\r
+ // unset variable\r
+ @$unset_var\r
+);\r
+\r
+// loop through with each element of the $inputs array to test curl_version() function\r
+$count = 1;\r
+foreach($inputs as $input) {\r
+ echo "-- Iteration $count --\n";\r
+ var_dump( is_array(curl_version($input)) );\r
+ $count ++;\r
+}\r
+\r
+fclose($file_handle); //closing the file handle\r
+\r
+?>\r
+===Done===\r
+--EXPECTF--\r
+*** Testing curl_version() function: with unexpected inputs for 'age' argument ***\r
+-- Iteration 1 --\r
+bool(true)\r
+-- Iteration 2 --\r
+bool(true)\r
+-- Iteration 3 --\r
+bool(true)\r
+-- Iteration 4 --\r
+bool(true)\r
+-- Iteration 5 --\r
+bool(true)\r
+-- Iteration 6 --\r
+bool(true)\r
+-- Iteration 7 --\r
+bool(true)\r
+-- Iteration 8 --\r
+bool(true)\r
+-- Iteration 9 --\r
+bool(true)\r
+-- Iteration 10 --\r
+\r
+Warning: curl_version() expects parameter 1 to be long, array given in %s on line %d\r
+bool(false)\r
+-- Iteration 11 --\r
+\r
+Warning: curl_version() expects parameter 1 to be long, array given in %s on line %d\r
+bool(false)\r
+-- Iteration 12 --\r
+\r
+Warning: curl_version() expects parameter 1 to be long, array given in %s on line %d\r
+bool(false)\r
+-- Iteration 13 --\r
+\r
+Warning: curl_version() expects parameter 1 to be long, string given in %s on line %d\r
+bool(false)\r
+-- Iteration 14 --\r
+\r
+Warning: curl_version() expects parameter 1 to be long, string given in %s on line %d\r
+bool(false)\r
+-- Iteration 15 --\r
+\r
+Notice: A non well formed numeric value encountered in %s on line %d\r
+bool(true)\r
+-- Iteration 16 --\r
+bool(true)\r
+-- Iteration 17 --\r
+bool(true)\r
+-- Iteration 18 --\r
+bool(true)\r
+-- Iteration 19 --\r
+bool(true)\r
+-- Iteration 20 --\r
+bool(true)\r
+-- Iteration 21 --\r
+bool(true)\r
+-- Iteration 22 --\r
+\r
+Warning: curl_version() expects parameter 1 to be long, object given in %s on line %d\r
+bool(false)\r
+-- Iteration 23 --\r
+\r
+Warning: curl_version() expects parameter 1 to be long, resource given in %s on line %d\r
+bool(false)\r
+-- Iteration 24 --\r
+bool(true)\r
+-- Iteration 25 --\r
+bool(true)\r
+===Done===\r