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