1--TEST--
2Test exif_imagetype() function : usage variations  - different types for filename argument
3--SKIPIF--
4<?php if (!extension_loaded('exif')) print 'skip exif extension not available';?>
5--FILE--
6<?php
7
8/* Prototype  : int exif_imagetype  ( string $filename  )
9 * Description: Determine the type of an image
10 * Source code: ext/exif/exif.c
11*/
12
13echo "*** Testing exif_imagetype() : different types for filename argument ***\n";
14// initialize all required variables
15
16// get an unset variable
17$unset_var = 'string_val';
18unset($unset_var);
19
20// declaring a class
21class sample  {
22  public function __toString() {
23  return "obj'ct";
24  }
25}
26
27// Defining resource
28$file_handle = fopen(__FILE__, 'r');
29
30// array with different values
31$values =  array (
32
33  // integer values
34  0,
35  1,
36  12345,
37  -2345,
38
39  // float values
40  10.5,
41  -10.5,
42  10.1234567e10,
43  10.7654321E-10,
44  .5,
45
46  // array values
47  array(),
48  array(0),
49  array(1),
50  array(1, 2),
51  array('color' => 'red', 'item' => 'pen'),
52
53  // boolean values
54  true,
55  false,
56  TRUE,
57  FALSE,
58
59  // empty string
60  "",
61  '',
62
63  // undefined variable
64  $undefined_var,
65
66  // unset variable
67  $unset_var,
68
69  // objects
70  new sample(),
71
72  // resource
73  $file_handle,
74
75  NULL,
76  null
77);
78
79
80// loop through each element of the array and check the working of exif_imagetype()
81// when $filename is supplied with different values
82
83echo "\n--- Testing exif_imagetype() by supplying different values for 'filename' argument ---\n";
84$counter = 1;
85foreach($values as $filename) {
86  echo "-- Iteration $counter --\n";
87  var_dump( exif_imagetype($filename) );
88  $counter ++;
89}
90
91// closing the file
92fclose($file_handle);
93
94echo "Done\n";
95?>
96
97?>
98===Done===
99--EXPECTF--
100*** Testing exif_imagetype() : different types for filename argument ***
101
102Notice: Undefined variable: undefined_var in %s on line %d
103
104Notice: Undefined variable: unset_var in %s on line %d
105
106--- Testing exif_imagetype() by supplying different values for 'filename' argument ---
107-- Iteration 1 --
108
109Warning: exif_imagetype(0): failed to open stream: No such file or directory in %s on line %d
110bool(false)
111-- Iteration 2 --
112
113Warning: exif_imagetype(1): failed to open stream: No such file or directory in %s on line %d
114bool(false)
115-- Iteration 3 --
116
117Warning: exif_imagetype(12345): failed to open stream: No such file or directory in %s on line %d
118bool(false)
119-- Iteration 4 --
120
121Warning: exif_imagetype(-2345): failed to open stream: No such file or directory in %s on line %d
122bool(false)
123-- Iteration 5 --
124
125Warning: exif_imagetype(10.5): failed to open stream: No such file or directory in %s on line %d
126bool(false)
127-- Iteration 6 --
128
129Warning: exif_imagetype(-10.5): failed to open stream: No such file or directory in %s on line %d
130bool(false)
131-- Iteration 7 --
132
133Warning: exif_imagetype(101234567000): failed to open stream: No such file or directory in %s on line %d
134bool(false)
135-- Iteration 8 --
136
137Warning: exif_imagetype(1.07654321E-9): failed to open stream: No such file or directory in %s on line %d
138bool(false)
139-- Iteration 9 --
140
141Warning: exif_imagetype(0.5): failed to open stream: No such file or directory in %s on line %d
142bool(false)
143-- Iteration 10 --
144
145Warning: exif_imagetype() expects parameter 1 to be string, array given in %s on line %d
146NULL
147-- Iteration 11 --
148
149Warning: exif_imagetype() expects parameter 1 to be string, array given in %s on line %d
150NULL
151-- Iteration 12 --
152
153Warning: exif_imagetype() expects parameter 1 to be string, array given in %s on line %d
154NULL
155-- Iteration 13 --
156
157Warning: exif_imagetype() expects parameter 1 to be string, array given in %s on line %d
158NULL
159-- Iteration 14 --
160
161Warning: exif_imagetype() expects parameter 1 to be string, array given in %s on line %d
162NULL
163-- Iteration 15 --
164
165Warning: exif_imagetype(1): failed to open stream: No such file or directory in %s on line %d
166bool(false)
167-- Iteration 16 --
168
169Warning: exif_imagetype(): Filename cannot be empty in %s on line %d
170bool(false)
171-- Iteration 17 --
172
173Warning: exif_imagetype(1): failed to open stream: No such file or directory in %s on line %d
174bool(false)
175-- Iteration 18 --
176
177Warning: exif_imagetype(): Filename cannot be empty in %s on line %d
178bool(false)
179-- Iteration 19 --
180
181Warning: exif_imagetype(): Filename cannot be empty in %s on line %d
182bool(false)
183-- Iteration 20 --
184
185Warning: exif_imagetype(): Filename cannot be empty in %s on line %d
186bool(false)
187-- Iteration 21 --
188
189Warning: exif_imagetype(): Filename cannot be empty in %s on line %d
190bool(false)
191-- Iteration 22 --
192
193Warning: exif_imagetype(): Filename cannot be empty in %s on line %d
194bool(false)
195-- Iteration 23 --
196
197Warning: exif_imagetype(obj'ct): failed to open stream: No such file or directory in %s on line %d
198bool(false)
199-- Iteration 24 --
200
201Warning: exif_imagetype() expects parameter 1 to be string, resource given in %s on line %d
202NULL
203-- Iteration 25 --
204
205Warning: exif_imagetype(): Filename cannot be empty in %s on line %d
206bool(false)
207-- Iteration 26 --
208
209Warning: exif_imagetype(): Filename cannot be empty in %s on line %d
210bool(false)
211Done
212
213?>
214===Done===
215