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