Add 'php/phpxmlrpc/' from commit 'cd5dbb4a511e7a616a61187a5de1a611a9748cbd'
[plcapi.git] / php / phpxmlrpc / tests / 4LocalhostMultiTest.php
1 <?php
2
3 include_once __DIR__ . '/../lib/xmlrpc.inc';
4 include_once __DIR__ . '/../lib/xmlrpc_wrappers.inc';
5
6 include_once __DIR__ . '/parse_args.php';
7
8 include_once __DIR__ . '/3LocalhostTest.php';
9
10 /**
11  * Tests which stress http features of the library.
12  * Each of these tests iterates over (almost) all of the 'localhost' tests
13  */
14 class LocalhostMultiTest extends LocalhostTest
15 {
16     /**
17      * @todo reintroduce skipping of tests which failed when executed individually if test runs happen as separate processes
18      * @todo reintroduce skipping of tests within the loop
19      */
20     function _runtests()
21     {
22         $unsafeMethods = array('testHttps', 'testCatchExceptions', 'testUtf8Method', 'testServerComments', 'testExoticCharsetsRequests', 'testExoticCharsetsRequests2', 'testExoticCharsetsRequests3');
23         foreach(get_class_methods('LocalhostTest') as $method)
24         {
25             if(strpos($method, 'test') === 0 && !in_array($method, $unsafeMethods))
26             {
27                 if (!isset(self::$failed_tests[$method]))
28                     $this->$method();
29             }
30             /*if ($this->_failed)
31             {
32                 break;
33             }*/
34         }
35     }
36
37     function testDeflate()
38     {
39         if(!function_exists('gzdeflate'))
40         {
41             $this->markTestSkipped('Zlib missing: cannot test deflate functionality');
42             return;
43         }
44         $this->client->accepted_compression = array('deflate');
45         $this->client->request_compression = 'deflate';
46         $this->_runtests();
47     }
48
49     function testGzip()
50     {
51         if(!function_exists('gzdeflate'))
52         {
53             $this->markTestSkipped('Zlib missing: cannot test gzip functionality');
54             return;
55         }
56         $this->client->accepted_compression = array('gzip');
57         $this->client->request_compression = 'gzip';
58         $this->_runtests();
59     }
60
61     function testKeepAlives()
62     {
63         if(!function_exists('curl_init'))
64         {
65             $this->markTestSkipped('CURL missing: cannot test http 1.1');
66             return;
67         }
68         $this->method = 'http11';
69         $this->client->keepalive = true;
70         $this->_runtests();
71     }
72
73     function testProxy()
74     {
75         if ($this->args['PROXYSERVER'])
76         {
77             $this->client->setProxy($this->args['PROXYSERVER'], $this->args['PROXYPORT']);
78             $this->_runtests();
79         }
80         else
81             $this->markTestSkipped('PROXY definition missing: cannot test proxy');
82     }
83
84     function testHttp11()
85     {
86         if(!function_exists('curl_init'))
87         {
88             $this->markTestSkipped('CURL missing: cannot test http 1.1');
89             return;
90         }
91         $this->method = 'http11'; // not an error the double assignment!
92         $this->client->method = 'http11';
93         //$this->client->verifyhost = 0;
94         //$this->client->verifypeer = 0;
95         $this->client->keepalive = false;
96         $this->_runtests();
97     }
98
99     function testHttp11Gzip()
100     {
101         if(!function_exists('curl_init'))
102         {
103             $this->markTestSkipped('CURL missing: cannot test http 1.1');
104             return;
105         }
106         $this->method = 'http11'; // not an error the double assignment!
107         $this->client->method = 'http11';
108         $this->client->keepalive = false;
109         $this->client->accepted_compression = array('gzip');
110         $this->client->request_compression = 'gzip';
111         $this->_runtests();
112     }
113
114     function testHttp11Deflate()
115     {
116         if(!function_exists('curl_init'))
117         {
118             $this->markTestSkipped('CURL missing: cannot test http 1.1');
119             return;
120         }
121         $this->method = 'http11'; // not an error the double assignment!
122         $this->client->method = 'http11';
123         $this->client->keepalive = false;
124         $this->client->accepted_compression = array('deflate');
125         $this->client->request_compression = 'deflate';
126         $this->_runtests();
127     }
128
129     function testHttp11Proxy()
130     {
131         if(!function_exists('curl_init'))
132         {
133             $this->markTestSkipped('CURL missing: cannot test http 1.1 w. proxy');
134             return;
135         }
136         else if ($this->args['PROXYSERVER'] == '')
137         {
138             $this->markTestSkipped('PROXY definition missing: cannot test proxy w. http 1.1');
139             return;
140         }
141         $this->method = 'http11'; // not an error the double assignment!
142         $this->client->method = 'http11';
143         $this->client->setProxy($this->args['PROXYSERVER'], $this->args['PROXYPORT']);
144         //$this->client->verifyhost = 0;
145         //$this->client->verifypeer = 0;
146         $this->client->keepalive = false;
147         $this->_runtests();
148     }
149
150     function testHttps()
151     {
152         if(!function_exists('curl_init'))
153         {
154             $this->markTestSkipped('CURL missing: cannot test https functionality');
155             return;
156         }
157         $this->client->server = $this->args['HTTPSSERVER'];
158         $this->method = 'https';
159         $this->client->method = 'https';
160         $this->client->path = $this->args['HTTPSURI'];
161         $this->client->setSSLVerifyPeer(!$this->args['HTTPSIGNOREPEER']);
162         $this->client->setSSLVerifyHost($this->args['HTTPSVERIFYHOST']);
163         $this->client->setSSLVersion($this->args['SSLVERSION']);
164         $this->_runtests();
165     }
166
167     function testHttpsProxy()
168     {
169         if(!function_exists('curl_init'))
170         {
171             $this->markTestSkipped('CURL missing: cannot test https functionality');
172             return;
173         }
174         else if ($this->args['PROXYSERVER'] == '')
175         {
176             $this->markTestSkipped('PROXY definition missing: cannot test proxy w. http 1.1');
177             return;
178         }
179         $this->client->server = $this->args['HTTPSSERVER'];
180         $this->method = 'https';
181         $this->client->method = 'https';
182         $this->client->setProxy($this->args['PROXYSERVER'], $this->args['PROXYPORT']);
183         $this->client->path = $this->args['HTTPSURI'];
184         $this->client->setSSLVerifyPeer(!$this->args['HTTPSIGNOREPEER']);
185         $this->client->setSSLVerifyHost($this->args['HTTPSVERIFYHOST']);
186         $this->client->setSSLVersion($this->args['SSLVERSION']);
187         $this->_runtests();
188     }
189
190     function testUTF8Responses()
191     {
192         //$this->client->path = strpos($URI, '?') === null ? $URI.'?RESPONSE_ENCODING=UTF-8' : $URI.'&RESPONSE_ENCODING=UTF-8';
193         $this->client->path = $this->args['URI'].'?RESPONSE_ENCODING=UTF-8';
194         $this->_runtests();
195     }
196
197     function testUTF8Requests()
198     {
199         $this->client->request_charset_encoding = 'UTF-8';
200         $this->_runtests();
201     }
202
203     function testISOResponses()
204     {
205         //$this->client->path = strpos($URI, '?') === null ? $URI.'?RESPONSE_ENCODING=UTF-8' : $URI.'&RESPONSE_ENCODING=UTF-8';
206         $this->client->path = $this->args['URI'].'?RESPONSE_ENCODING=ISO-8859-1';
207         $this->_runtests();
208     }
209
210     function testISORequests()
211     {
212         $this->client->request_charset_encoding = 'ISO-8859-1';
213         $this->_runtests();
214     }
215 }