- release 1.0.0RC1
[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 echo "Done\n";
38 ?>
39 --EXPECTF--
40 %sTEST
41 1: HttpRuntimeException
42 2: HttpInvalidParamException
43 3: HttpHeaderException
44 4: HttpMalformedHeadersException
45 5: HttpRequestMethodException
46 6: HttpMessageTypeException
47 7: HttpEncodingException
48 8: HttpRequestException
49 9: HttpRequestPoolException
50 10: HttpSocketException
51 11: HttpResponseException
52 12: HttpUrlException
53 Done