Skip to content

Commit ea57c64

Browse files
committed
reorganize http tests; avoid double execution of legacy loader test; test comments and cleanups
1 parent eeac552 commit ea57c64

11 files changed

Lines changed: 272 additions & 251 deletions

.github/workflows/ci.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,6 @@ jobs:
116116
fi
117117
fi
118118
119-
- name: test legacy php classes loader
120-
run: 'php ./tests/legacy_loader_test.php'
121-
122119
# @todo would it be useful to run a 2nd test with composer --prefer-lowest? After all the only dependencies we have are testing tools
123120

124121
- name: test python demo files

tests/01CharsetTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ public function testLatin15()
101101
{
102102
if (!function_exists('mb_convert_encoding')) {
103103
$this->markTestSkipped('Miss mbstring extension to test exotic charsets');
104-
return;
105104
}
106105

107106
// euro symbol in ISO-8859-15

tests/02ValueTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ public function testLatin15InternalEncoding()
219219
{
220220
if (!function_exists('mb_convert_encoding')) {
221221
$this->markTestSkipped('Miss mbstring extension to test exotic charsets');
222-
return;
223222
}
224223

225224
$string = chr(164);

tests/04ParsingTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ public function testI8()
103103
{
104104
if (PHP_INT_SIZE == 4 ) {
105105
$this->markTestSkipped('Can not test i8 as php is compiled in 32 bit mode');
106-
return;
107106
}
108107

109108
$m = $this->newRequest('dummy');

tests/06EncoderTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ public function testLatin15InternalEncoding()
6060
{
6161
if (!function_exists('mb_convert_encoding')) {
6262
$this->markTestSkipped('Miss mbstring extension to test exotic charsets');
63-
return;
6463
}
6564

6665
$string = chr(164);

tests/07ClientTest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
include_once __DIR__ . '/ServerAwareTestCase.php';
44

55
/**
6-
* Tests involving the Client class (and mostly no server).
6+
* Tests involving the Client class features (and mostly no server).
7+
* @todo review: are there any tests which belong to the ServerTest class?
78
*/
89
class ClientTest extends PhpXmlRpc_ServerAwareTestCase
910
{
@@ -40,6 +41,7 @@ public function test404Interop()
4041
\PhpXmlRpc\PhpXmlRpc::useInteropFaults();
4142
$r = $this->client->send($m, $this->timeout);
4243
$this->assertEquals(-32300, $r->faultCode());
44+
/// @todo reset this via tear_down
4345
\PhpXmlRpc\PhpXmlRpc::$xmlrpcerr = $orig;
4446
}
4547

@@ -75,9 +77,8 @@ public function testCurlKAErr()
7577
{
7678
if (!function_exists('curl_init')) {
7779
$this->markTestSkipped('CURL missing: cannot test curl keepalive errors');
78-
79-
return;
8080
}
81+
8182
$m = new xmlrpcmsg('examples.stringecho', array(
8283
new xmlrpcval('hello', 'string'),
8384
));
@@ -116,7 +117,8 @@ public function testCustomHeaders($curlOpt)
116117
$this->assertArrayHasKey('X-Pxr-Test', $ro->scalarVal(), "Testing with curl mode: $curlOpt");
117118
}
118119

119-
public function testgetUrl()
120+
/// @todo add more permutations, eg. check that PHP_URL_SCHEME is ok with http10, http11, h2 etc...
121+
public function testGetUrl()
120122
{
121123
$m = $this->client->getUrl(PHP_URL_SCHEME);
122124
$this->assertEquals($m, $this->client->method);

tests/08ServerTest.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,13 @@ public function set_up()
5252
{
5353
parent::set_up();
5454

55+
// these 2 values are injected into the client when calling `send`, and are modified by some tests - reset them
5556
$this->timeout = 10;
57+
$this->method = 'http';
5658

5759
$this->client = $this->getClient();
60+
61+
/// @todo replace with setOption when dropping the BC layer
5862
$this->client->request_compression = $this->request_compression;
5963
$this->client->accepted_compression = $this->accepted_compression;
6064
}
@@ -75,6 +79,7 @@ public function tear_down()
7579
*/
7680
protected function send($msg, $errorCode = 0, $returnResponse = false)
7781
{
82+
/// @todo move to injecting timeout and method into `getClient`, use the non-legacy API calling convention
7883
$r = $this->client->send($msg, $this->timeout, $this->method);
7984
// for multicall, return directly array of responses
8085
if (is_array($r)) {
@@ -160,8 +165,8 @@ public function testExoticCharsetsRequests()
160165
// note that we should disable this call also when mbstring is missing server-side
161166
if (!function_exists('mb_convert_encoding')) {
162167
$this->markTestSkipped('Miss mbstring extension to test exotic charsets');
163-
return;
164168
}
169+
165170
$sendString = 'κόσμε'; // Greek word 'kosme'
166171
$str = '<?xml version="1.0" encoding="_ENC_"?>
167172
<methodCall>
@@ -192,8 +197,8 @@ public function testExoticCharsetsRequests2()
192197
// note that we should disable this call also when mbstring is missing server-side
193198
if (!function_exists('mb_convert_encoding')) {
194199
$this->markTestSkipped('Miss mbstring extension to test exotic charsets');
195-
return;
196200
}
201+
197202
$sendString = '安室奈美恵'; // Japanese name "Namie Amuro"
198203
$str = '<?xml version="1.0"?>
199204
<methodCall>
@@ -219,8 +224,8 @@ public function testExoticCharsetsRequests3()
219224
// note that we should disable this call also when mbstring is missing server-side
220225
if (!function_exists('mb_convert_encoding')) {
221226
$this->markTestSkipped('Miss mbstring extension to test exotic charsets');
222-
return;
223227
}
228+
224229
// the warning suppression is due to utf8_decode being deprecated in php 8.2
225230
$sendString = @utf8_decode('élève');
226231
$str = '<?xml version="1.0"?>
@@ -635,7 +640,6 @@ public function testCatchErrors()
635640
if (version_compare(PHP_VERSION, '7.0.0', '<'))
636641
{
637642
$this->markTestSkipped('Cannot test php Error on php < 7.0');
638-
return;
639643
}
640644

641645
// these test for the different server error catching modes

0 commit comments

Comments
 (0)