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