Fix (hopefully) the Travis tests using https for localhost
[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->_runtests();
159     }
160
161     function testHttpsProxy()
162     {
163         if(!function_exists('curl_init'))
164         {
165             $this->fail('CURL missing: cannot test https functionality');
166             return;
167         }
168         else if ($this->args['PROXYSERVER'] == '')
169         {
170             $this->fail('PROXY definition missing: cannot test proxy w. http 1.1');
171             return;
172         }
173         $this->client->server = $this->args['HTTPSSERVER'];
174         $this->method = 'https';
175         $this->client->method = 'https';
176         $this->client->setProxy($this->args['PROXYSERVER'], $this->args['PROXYPORT']);
177         $this->client->path = $this->args['HTTPSURI'];
178         $this->client->setSSLVerifyPeer( !$this->args['HTTPSIGNOREPEER'] );
179         $this->client->setSSLVerifyHost($this->args['HTTPSVERIFYHOST'] );
180         $this->_runtests();
181     }
182
183     function testUTF8Responses()
184     {
185         //$this->client->path = strpos($URI, '?') === null ? $URI.'?RESPONSE_ENCODING=UTF-8' : $URI.'&RESPONSE_ENCODING=UTF-8';
186         $this->client->path = $this->args['URI'].'?RESPONSE_ENCODING=UTF-8';
187         $this->_runtests();
188     }
189
190     function testUTF8Requests()
191     {
192         $this->client->request_charset_encoding = 'UTF-8';
193         $this->_runtests();
194     }
195
196     function testISOResponses()
197     {
198         //$this->client->path = strpos($URI, '?') === null ? $URI.'?RESPONSE_ENCODING=UTF-8' : $URI.'&RESPONSE_ENCODING=UTF-8';
199         $this->client->path = $this->args['URI'].'?RESPONSE_ENCODING=ISO-8859-1';
200         $this->_runtests();
201     }
202
203     function testISORequests()
204     {
205         $this->client->request_charset_encoding = 'ISO-8859-1';
206         $this->_runtests();
207     }
208 }