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