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