43bb19041d32a10480bab698c9f2f514dc6f3985
[m6w6/ext-http] / tests / exceptions.phpt
1 --TEST--
2 exceptions
3 --SKIPIF--
4 <?php
5 include 'skip.inc';
6 checkmin(5);
7 ?>
8 --FILE--
9 <?php
10 echo "-TEST\n";
11
12 ini_set('http.only_exceptions', true);
13
14 $e = array(
15 HTTP_E_RUNTIME => 'Runtime',
16 HTTP_E_INVALID_PARAM => 'InvalidParam',
17 HTTP_E_HEADER => 'Header',
18 HTTP_E_MALFORMED_HEADERS => 'MalformedHeaders',
19 HTTP_E_REQUEST_METHOD => 'RequestMethod',
20 HTTP_E_MESSAGE_TYPE => 'MessageType',
21 HTTP_E_ENCODING => 'Encoding',
22 HTTP_E_REQUEST => 'Request',
23 HTTP_E_REQUEST_POOL => 'RequestPool',
24 HTTP_E_SOCKET => 'Socket',
25 HTTP_E_RESPONSE => 'Response',
26 HTTP_E_URL => 'Url',
27 );
28
29 foreach ($e as $i => $c) {
30 try {
31 $n = "Http{$c}Exception";
32 throw new $n;
33 } catch (HttpException $x) {
34 printf("%2d: %s\n", $i, get_class($x));
35 }
36 }
37 if (http_support(HTTP_SUPPORT_REQUESTS)) {
38 try {
39 $tmp = http_get(null);
40 } catch (HttpRequestException $x) {
41 printf("%s (%d)\n", $x->getMessage(), $x->getCode());
42 }
43 } else {
44 echo "URL using bad/illegal format or missing URL (8)\n";
45 }
46 echo "Done\n";
47 ?>
48 --EXPECTF--
49 %sTEST
50 1: HttpRuntimeException
51 2: HttpInvalidParamException
52 3: HttpHeaderException
53 4: HttpMalformedHeadersException
54 5: HttpRequestMethodException
55 6: HttpMessageTypeException
56 7: HttpEncodingException
57 8: HttpRequestException
58 9: HttpRequestPoolException
59 10: HttpSocketException
60 11: HttpResponseException
61 12: HttpUrlException
62 URL using bad/illegal format or missing URL (8)
63 Done