Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
/**
4
 * Tests that properties of XML_RPC_Client get properly set
5
 *
6
 * Any individual tests that fail will have their name, expected result
7
 * and actual result printed out.  So seeing no output when executing
8
 * this file is a good thing.
9
 *
10
 * Can be run via CLI or a web server.
11
 *
12
 * PHP versions 4 and 5
13
 *
14
 * @category   Web Services
15
 * @package    XML_RPC
16
 * @author     Daniel Convissor <danielc@php.net>
17
 * @copyright  2005-2010 The PHP Group
18
 * @license    http://www.php.net/license/3_01.txt  PHP License
19
 * @version    SVN: $Id: protoport.php 300957 2010-07-02 23:55:00Z danielc $
20
 * @link       http://pear.php.net/package/XML_RPC
21
 * @since      File available since Release 1.2
22
 */
23
 
24
/*
25
 * If the package version number is found in the left hand
26
 * portion of the if() expression below, that means this file has
27
 * come from the PEAR installer.  Therefore, let's test the
28
 * installed version of XML_RPC which should be in the include path.
29
 *
30
 * If the version has not been substituted in the if() expression,
31
 * this file has likely come from a SVN checkout or a .tar file.
32
 * Therefore, we'll assume the tests should use the version of
33
 * XML_RPC that has come from there as well.
34
 */
35
if ('1.5.5' == '@'.'package_version'.'@') {
36
    ini_set('include_path', '../'
37
            . PATH_SEPARATOR . '.' . PATH_SEPARATOR
38
            . ini_get('include_path')
39
    );
40
}
41
require_once 'XML/RPC.php';
42
 
43
 
44
/**
45
 * Compare the test result to the expected result
46
 *
47
 * If the test fails, echo out the results.
48
 *
49
 * @param array  $expect     the array of object properties you expect
50
 *                            from the test
51
 * @param object $actual     the object results from the test
52
 * @param string $test_name  the name of the test
53
 *
54
 * @return void
55
 */
56
function compare($expect, $actual, $test_name) {
57
    $actual = get_object_vars($actual);
58
    if (count(array_diff($actual, $expect))) {
59
        echo "$test_name failed.\nExpect: ";
60
        print_r($expect);
61
        echo "Actual: ";
62
        print_r($actual);
63
        echo "\n";
64
    }
65
}
66
 
67
if (php_sapi_name() != 'cli') {
68
    echo "<pre>\n";
69
}
70
 
71
 
72
$x = array(
73
    'path' => 'thepath',
74
    'server' => 'theserver',
75
    'protocol' => 'http://',
76
    'port' => 80,
77
    'proxy' => '',
78
    'proxy_protocol' => 'http://',
79
    'proxy_port' => 8080,
80
    'proxy_user' => '',
81
    'proxy_pass' => '',
82
    'errno' => 0,
83
    'errstring' => '',
84
    'debug' => 0,
85
    'username' => '',
86
    'password' => '',
87
);
88
$c = new XML_RPC_Client('thepath', 'theserver');
89
compare($x, $c, 'defaults');
90
 
91
$x = array(
92
    'path' => 'thepath',
93
    'server' => 'theserver',
94
    'protocol' => 'http://',
95
    'port' => 80,
96
    'proxy' => '',
97
    'proxy_protocol' => 'http://',
98
    'proxy_port' => 8080,
99
    'proxy_user' => '',
100
    'proxy_pass' => '',
101
    'errno' => 0,
102
    'errstring' => '',
103
    'debug' => 0,
104
    'username' => '',
105
    'password' => '',
106
);
107
$c = new XML_RPC_Client('thepath', 'http://theserver');
108
compare($x, $c, 'defaults with http');
109
 
110
$x = array(
111
    'path' => 'thepath',
112
    'server' => 'theserver',
113
    'protocol' => 'ssl://',
114
    'port' => 443,
115
    'proxy' => '',
116
    'proxy_protocol' => 'http://',
117
    'proxy_port' => 8080,
118
    'proxy_user' => '',
119
    'proxy_pass' => '',
120
    'errno' => 0,
121
    'errstring' => '',
122
    'debug' => 0,
123
    'username' => '',
124
    'password' => '',
125
);
126
$c = new XML_RPC_Client('thepath', 'https://theserver');
127
compare($x, $c, 'defaults with https');
128
 
129
$x = array(
130
    'path' => 'thepath',
131
    'server' => 'theserver',
132
    'protocol' => 'ssl://',
133
    'port' => 443,
134
    'proxy' => '',
135
    'proxy_protocol' => 'http://',
136
    'proxy_port' => 8080,
137
    'proxy_user' => '',
138
    'proxy_pass' => '',
139
    'errno' => 0,
140
    'errstring' => '',
141
    'debug' => 0,
142
    'username' => '',
143
    'password' => '',
144
);
145
$c = new XML_RPC_Client('thepath', 'ssl://theserver');
146
compare($x, $c, 'defaults with ssl');
147
 
148
 
149
$x = array(
150
    'path' => 'thepath',
151
    'server' => 'theserver',
152
    'protocol' => 'http://',
153
    'port' => 65,
154
    'proxy' => '',
155
    'proxy_protocol' => 'http://',
156
    'proxy_port' => 8080,
157
    'proxy_user' => '',
158
    'proxy_pass' => '',
159
    'errno' => 0,
160
    'errstring' => '',
161
    'debug' => 0,
162
    'username' => '',
163
    'password' => '',
164
);
165
$c = new XML_RPC_Client('thepath', 'theserver', 65);
166
compare($x, $c, 'port 65');
167
 
168
$x = array(
169
    'path' => 'thepath',
170
    'server' => 'theserver',
171
    'protocol' => 'http://',
172
    'port' => 65,
173
    'proxy' => '',
174
    'proxy_protocol' => 'http://',
175
    'proxy_port' => 8080,
176
    'proxy_user' => '',
177
    'proxy_pass' => '',
178
    'errno' => 0,
179
    'errstring' => '',
180
    'debug' => 0,
181
    'username' => '',
182
    'password' => '',
183
);
184
$c = new XML_RPC_Client('thepath', 'http://theserver', 65);
185
compare($x, $c, 'port 65 with http');
186
 
187
$x = array(
188
    'path' => 'thepath',
189
    'server' => 'theserver',
190
    'protocol' => 'ssl://',
191
    'port' => 65,
192
    'proxy' => '',
193
    'proxy_protocol' => 'http://',
194
    'proxy_port' => 8080,
195
    'proxy_user' => '',
196
    'proxy_pass' => '',
197
    'errno' => 0,
198
    'errstring' => '',
199
    'debug' => 0,
200
    'username' => '',
201
    'password' => '',
202
);
203
$c = new XML_RPC_Client('thepath', 'https://theserver', 65);
204
compare($x, $c, 'port 65 with https');
205
 
206
$x = array(
207
    'path' => 'thepath',
208
    'server' => 'theserver',
209
    'protocol' => 'ssl://',
210
    'port' => 65,
211
    'proxy' => '',
212
    'proxy_protocol' => 'http://',
213
    'proxy_port' => 8080,
214
    'proxy_user' => '',
215
    'proxy_pass' => '',
216
    'errno' => 0,
217
    'errstring' => '',
218
    'debug' => 0,
219
    'username' => '',
220
    'password' => '',
221
);
222
$c = new XML_RPC_Client('thepath', 'ssl://theserver', 65);
223
compare($x, $c, 'port 65 with ssl');
224
 
225
 
226
$x = array(
227
    'path' => 'thepath',
228
    'server' => 'theserver',
229
    'protocol' => 'http://',
230
    'port' => 80,
231
    'proxy' => 'theproxy',
232
    'proxy_protocol' => 'http://',
233
    'proxy_port' => 8080,
234
    'proxy_user' => '',
235
    'proxy_pass' => '',
236
    'errno' => 0,
237
    'errstring' => '',
238
    'debug' => 0,
239
    'username' => '',
240
    'password' => '',
241
);
242
$c = new XML_RPC_Client('thepath', 'theserver', 0,
243
                        'theproxy');
244
compare($x, $c, 'defaults proxy');
245
 
246
$x = array(
247
    'path' => 'thepath',
248
    'server' => 'theserver',
249
    'protocol' => 'http://',
250
    'port' => 80,
251
    'proxy' => 'theproxy',
252
    'proxy_protocol' => 'http://',
253
    'proxy_port' => 8080,
254
    'proxy_user' => '',
255
    'proxy_pass' => '',
256
    'errno' => 0,
257
    'errstring' => '',
258
    'debug' => 0,
259
    'username' => '',
260
    'password' => '',
261
);
262
$c = new XML_RPC_Client('thepath', 'http://theserver', 0,
263
                        'http://theproxy');
264
compare($x, $c, 'defaults with http proxy');
265
 
266
$x = array(
267
    'path' => 'thepath',
268
    'server' => 'theserver',
269
    'protocol' => 'ssl://',
270
    'port' => 443,
271
    'proxy' => 'theproxy',
272
    'proxy_protocol' => 'ssl://',
273
    'proxy_port' => 443,
274
    'proxy_user' => '',
275
    'proxy_pass' => '',
276
    'errno' => 0,
277
    'errstring' => '',
278
    'debug' => 0,
279
    'username' => '',
280
    'password' => '',
281
);
282
$c = new XML_RPC_Client('thepath', 'https://theserver', 0,
283
                        'https://theproxy');
284
compare($x, $c, 'defaults with https proxy');
285
 
286
$x = array(
287
    'path' => 'thepath',
288
    'server' => 'theserver',
289
    'protocol' => 'ssl://',
290
    'port' => 443,
291
    'proxy' => 'theproxy',
292
    'proxy_protocol' => 'ssl://',
293
    'proxy_port' => 443,
294
    'proxy_user' => '',
295
    'proxy_pass' => '',
296
    'errno' => 0,
297
    'errstring' => '',
298
    'debug' => 0,
299
    'username' => '',
300
    'password' => '',
301
);
302
$c = new XML_RPC_Client('thepath', 'ssl://theserver', 0,
303
                        'ssl://theproxy');
304
compare($x, $c, 'defaults with ssl proxy');
305
 
306
 
307
$x = array(
308
    'path' => 'thepath',
309
    'server' => 'theserver',
310
    'protocol' => 'http://',
311
    'port' => 65,
312
    'proxy' => 'theproxy',
313
    'proxy_protocol' => 'http://',
314
    'proxy_port' => 6565,
315
    'proxy_user' => '',
316
    'proxy_pass' => '',
317
    'errno' => 0,
318
    'errstring' => '',
319
    'debug' => 0,
320
    'username' => '',
321
    'password' => '',
322
);
323
$c = new XML_RPC_Client('thepath', 'theserver', 65,
324
                        'theproxy', 6565);
325
compare($x, $c, 'port 65 proxy 6565');
326
 
327
$x = array(
328
    'path' => 'thepath',
329
    'server' => 'theserver',
330
    'protocol' => 'http://',
331
    'port' => 65,
332
    'proxy' => 'theproxy',
333
    'proxy_protocol' => 'http://',
334
    'proxy_port' => 6565,
335
    'proxy_user' => '',
336
    'proxy_pass' => '',
337
    'errno' => 0,
338
    'errstring' => '',
339
    'debug' => 0,
340
    'username' => '',
341
    'password' => '',
342
);
343
$c = new XML_RPC_Client('thepath', 'http://theserver', 65,
344
                        'http://theproxy', 6565);
345
compare($x, $c, 'port 65 with http proxy 6565');
346
 
347
$x = array(
348
    'path' => 'thepath',
349
    'server' => 'theserver',
350
    'protocol' => 'ssl://',
351
    'port' => 65,
352
    'proxy' => 'theproxy',
353
    'proxy_protocol' => 'ssl://',
354
    'proxy_port' => 6565,
355
    'proxy_user' => '',
356
    'proxy_pass' => '',
357
    'errno' => 0,
358
    'errstring' => '',
359
    'debug' => 0,
360
    'username' => '',
361
    'password' => '',
362
);
363
$c = new XML_RPC_Client('thepath', 'https://theserver', 65,
364
                        'https://theproxy', 6565);
365
compare($x, $c, 'port 65 with https proxy 6565');
366
 
367
$x = array(
368
    'path' => 'thepath',
369
    'server' => 'theserver',
370
    'protocol' => 'ssl://',
371
    'port' => 65,
372
    'proxy' => 'theproxy',
373
    'proxy_protocol' => 'ssl://',
374
    'proxy_port' => 6565,
375
    'proxy_user' => '',
376
    'proxy_pass' => '',
377
    'errno' => 0,
378
    'errstring' => '',
379
    'debug' => 0,
380
    'username' => '',
381
    'password' => '',
382
);
383
$c = new XML_RPC_Client('thepath', 'ssl://theserver', 65,
384
                        'ssl://theproxy', 6565);
385
compare($x, $c, 'port 65 with ssl proxy 6565');
386
 
387
 
388
$x = array(
389
    'path' => 'thepath',
390
    'server' => 'theserver',
391
    'protocol' => 'ssl://',
392
    'port' => 443,
393
    'proxy' => 'theproxy',
394
    'proxy_protocol' => 'ssl://',
395
    'proxy_port' => 443,
396
    'proxy_user' => '',
397
    'proxy_pass' => '',
398
    'errno' => 0,
399
    'errstring' => '',
400
    'debug' => 0,
401
    'username' => '',
402
    'password' => '',
403
);
404
$c = new XML_RPC_Client('thepath', 'theserver', 443,
405
                        'theproxy', 443);
406
compare($x, $c, 'port 443 no protocol and proxy port 443 no protocol');
407
 
408
$x = array(
409
    'path' => 'thepath',
410
    'server' => 'theserver',
411
    'protocol' => 'http://',
412
    'port' => 80,
413
    'proxy' => 'theproxy',
414
    'proxy_protocol' => 'ssl://',
415
    'proxy_port' => 6565,
416
    'proxy_user' => '',
417
    'proxy_pass' => '',
418
    'errno' => 0,
419
    'errstring' => '',
420
    'debug' => 0,
421
    'username' => '',
422
    'password' => '',
423
);
424
$c = new XML_RPC_Client('thepath', 'theserver', 0,
425
                        'ssl://theproxy', 6565);
426
compare($x, $c, 'port 443 no protocol and proxy port 443 no protocol');
427
 
428
echo "\nIf no other output was produced, these tests passed.\n";