Skip to content

Commit b73d50c

Browse files
committed
more namespacing in tests
1 parent 431f952 commit b73d50c

File tree

9 files changed

+60
-25
lines changed

9 files changed

+60
-25
lines changed

tests/02ValueTest.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
include_once __DIR__ . '/LoggerAwareTestCase.php';
44

5+
use PhpXmlRpc\Encoder;
6+
use PhpXmlRpc\Helper\XMLParser;
7+
use PhpXmlRpc\Request;
8+
use PhpXmlRpc\Value;
9+
510
/**
611
* Tests involving the Value class.
712
* NB: these tests do not involve the parsing of xml into Value objects - look in 04ParsingTest for that
@@ -170,7 +175,7 @@ public function testArrayAccess()
170175
}
171176
}
172177

173-
$v2 = new \PhpXmlRpc\Value(array(new \PhpXmlRpc\Value('one'), new \PhpXmlRpc\Value('two')), 'array');
178+
$v2 = new Value(array(new Value('one'), new Value('two')), 'array');
174179
$this->assertequals(2, count($v2));
175180
$out = array(array('key' => 0, 'value' => 'object'), array('key' => 1, 'value' => 'object'));
176181
$i = 0;
@@ -182,7 +187,7 @@ public function testArrayAccess()
182187
$i++;
183188
}
184189

185-
$v3 = new \PhpXmlRpc\Value(10, 'i4');
190+
$v3 = new Value(10, 'i4');
186191
$this->assertEquals(1, count($v3));
187192
$this->assertEquals(true, isset($v3['int']));
188193
$this->assertEquals(true, isset($v3['i4']));
@@ -196,7 +201,7 @@ public function testArrayAccess()
196201
$this->assertEquals(1000, $v3['i4']);
197202
}
198203

199-
/// @todo do not use \PhpXmlRpc\Encoder for this test
204+
/// @todo do not use Encoder for this test
200205
public function testBigXML()
201206
{
202207
// nb: make sure that the serialized xml corresponding to this is > 10MB in size
@@ -205,11 +210,11 @@ public function testBigXML()
205210
$data[] = 'hello world';
206211
}
207212

208-
$encoder = new \PhpXmlRpc\Encoder();
213+
$encoder = new Encoder();
209214
$val = $encoder->encode($data);
210-
$req = new \PhpXmlRpc\Request('test', array($val));
215+
$req = new Request('test', array($val));
211216
$xml = $req->serialize();
212-
$parser = new \PhpXmlRpc\Helper\XMLParser();
217+
$parser = new XMLParser();
213218
$_xh = $parser->parse($xml);
214219

215220
$this->assertequals(0, $_xh['isf']);
@@ -222,7 +227,7 @@ public function testLatin15InternalEncoding()
222227
}
223228

224229
$string = chr(164);
225-
$v = new \PhpXmlRpc\Value($string);
230+
$v = new Value($string);
226231

227232
$originalEncoding = \PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding;
228233
\PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding = 'ISO-8859-15';

tests/03MessagesTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22

33
include_once __DIR__ . '/LoggerAwareTestCase.php';
44

5+
use PhpXmlRpc\Response;
6+
57
/**
68
* Tests involving Requests and Responses, except for the parsing part
79
*/
810
class MessagesTest extends PhpXmlRpc_LoggerAwareTestCase
911
{
1012
public function testSerializePHPValResponse()
1113
{
12-
$r = new \PhpXmlRpc\Response(array('hello' => 'world'), 0, '', 'phpvals');
14+
$r = new Response(array('hello' => 'world'), 0, '', 'phpvals');
1315
$v = $r->serialize();
1416
$this->assertStringContainsString('<member><name>hello</name>', $v);
1517
$this->assertStringContainsString('<value><string>world</string></value>', $v);

tests/04ParsingTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
include_once __DIR__ . '/LoggerAwareTestCase.php';
44

5+
use \PhpXmlRpc\Request;
6+
57
/**
68
* Tests involving xml parsing.
79
*
@@ -727,7 +729,7 @@ public function testXXE()
727729
</params>
728730
</methodResponse>
729731
';
730-
$req = new \PhpXmlRpc\Request('hi');
732+
$req = new Request('hi');
731733
$resp = $req->parseResponse($xml, true);
732734
$val = $resp->value();
733735
if (version_compare(PHP_VERSION, '5.6.0', '>=')) {

tests/05LoggerTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use PhpXmlRpc\Helper\Charset;
66
use PhpXmlRpc\Helper\Http;
77
use PhpXmlRpc\Helper\XMLParser;
8+
use PhpXmlRpc\Value;
89

910
class LoggerTest extends PhpXmlRpc_PolyfillTestCase
1011
{
@@ -69,13 +70,13 @@ public function testXPAltLogger()
6970

7071
public function testDeprecations()
7172
{
72-
$v = new \PhpXmlRpc\Value(array(), \PhpXmlRpc\Value::$xmlrpcStruct);
73+
$v = new Value(array(), Value::$xmlrpcStruct);
7374
$l = $v->getLogger();
74-
\PhpXmlRpc\Value::setLogger($this);
75+
Value::setLogger($this);
7576
\PhpXmlRpc\PhpXmlRpc::$xmlrpc_silence_deprecations = false;
7677
$c = $v->structSize();
7778
\PhpXmlRpc\PhpXmlRpc::$xmlrpc_silence_deprecations = true;
78-
\PhpXmlRpc\Value::setLogger($l);
79+
Value::setLogger($l);
7980
$this->assertStringContainsString("Method PhpXmlRpc\Value::structSize is deprecated", $this->warningBuffer);
8081
}
8182

tests/06EncoderTest.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
include_once __DIR__ . '/LoggerAwareTestCase.php';
44

5+
use PhpXmlRpc\Encoder;
6+
use PhpXmlRpc\Request;
7+
use PhpXmlRpc\Response;
8+
59
/**
610
* Tests involving automatic encoding/decoding of php values into xmlrpc values (the Encoder class).
711
*
@@ -46,11 +50,11 @@ public function testAutoCoDec()
4650
$v1 = php_xmlrpc_encode($data, array('auto_dates'));
4751
$v2 = php_xmlrpc_decode_xml($v1->serialize());
4852
$this->assertEquals($v1, $v2);
49-
$r1 = new PhpXmlRpc\Response($v1);
53+
$r1 = new Response($v1);
5054
$r2 = php_xmlrpc_decode_xml($r1->serialize());
5155
$r2->serialize(); // needed to set internal member payload
5256
$this->assertEquals($r1, $r2);
53-
$m1 = new PhpXmlRpc\Request('hello dolly', array($v1));
57+
$m1 = new Request('hello dolly', array($v1));
5458
$m2 = php_xmlrpc_decode_xml($m1->serialize());
5559
$m2->serialize(); // needed to set internal member payload
5660
$this->assertEquals($m1, $m2);
@@ -63,7 +67,7 @@ public function testLatin15InternalEncoding()
6367
}
6468

6569
$string = chr(164);
66-
$e = new \PhpXmlRpc\Encoder();
70+
$e = new Encoder();
6771

6872
$originalEncoding = \PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding;
6973
\PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding = 'ISO-8859-15';

tests/07ClientTest.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
include_once __DIR__ . '/ServerAwareTestCase.php';
44

5+
use PhpXmlRpc\Client;
6+
57
/**
68
* Tests involving the Client class features (and mostly no server).
79
* @todo review: are there any tests which belong to the ServerTest class?
@@ -50,9 +52,9 @@ public function testUnsupportedAuth()
5052
$m = new xmlrpcmsg('examples.echo', array(
5153
new xmlrpcval('hello', 'string'),
5254
));
53-
$this->client->setOption(\PhpXmlRpc\Client::OPT_USERNAME, 'user');
54-
$this->client->setOption(\PhpXmlRpc\Client::OPT_AUTH_TYPE, 2);
55-
$this->client->setOption(\PhpXmlRpc\Client::OPT_USE_CURL, \PhpXmlRpc\Client::USE_CURL_NEVER);
55+
$this->client->setOption(Client::OPT_USERNAME, 'user');
56+
$this->client->setOption(Client::OPT_AUTH_TYPE, 2);
57+
$this->client->setOption(Client::OPT_USE_CURL, Client::USE_CURL_NEVER);
5658
$r = $this->client->send($m);
5759
$this->assertEquals(\PhpXmlRpc\PhpXmlRpc::$xmlrpcerr['unsupported_option'], $r->faultCode());
5860
}
@@ -108,8 +110,8 @@ public function testCurlKAErr()
108110
*/
109111
public function testCustomHeaders($curlOpt)
110112
{
111-
$this->client->setOption(\PhpXmlRpc\Client::OPT_USE_CURL, $curlOpt);
112-
$this->client->setOption(\PhpXmlRpc\Client::OPT_EXTRA_HEADERS, array('X-PXR-Test: yes'));
113+
$this->client->setOption(Client::OPT_USE_CURL, $curlOpt);
114+
$this->client->setOption(Client::OPT_EXTRA_HEADERS, array('X-PXR-Test: yes'));
113115
$r = new \PhpXmlRpc\Request('tests.getallheaders');
114116
$r = $this->client->send($r);
115117
$this->assertEquals(0, $r->faultCode());

tests/ServerAwareTestCase.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use PHPUnit\Extensions\SeleniumCommon\RemoteCoverage;
66
use PHPUnit\Framework\TestResult;
7+
use PhpXmlRpc\Client;
78

89
abstract class PhpXmlRpc_ServerAwareTestCase extends PhpXmlRpc_LoggerAwareTestCase
910
{
@@ -110,10 +111,10 @@ protected function getClient()
110111
*/
111112
public function getAvailableUseCurlOptions()
112113
{
113-
$opts = array(array(\PhpXmlRpc\Client::USE_CURL_NEVER));
114+
$opts = array(array(Client::USE_CURL_NEVER));
114115
if (function_exists('curl_init'))
115116
{
116-
$opts[] = array(\PhpXmlRpc\Client::USE_CURL_ALWAYS);
117+
$opts[] = array(Client::USE_CURL_ALWAYS);
117118
}
118119

119120
return $opts;

tests/WebTestCase.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
include_once __DIR__ . '/ServerAwareTestCase.php';
44

5+
use PhpXmlRpc\Client;
6+
57
abstract class PhpXmlRpc_WebTestCase extends PhpXmlRpc_ServerAwareTestCase
68
{
79
/**
@@ -58,11 +60,11 @@ protected function request($path, $method = 'GET', $payload = '', $emptyPageOk =
5860
* @see also ServerTest::set_up
5961
*
6062
* @param string $path
61-
* @return \PhpXmlRpc\Client
63+
* @return Client
6264
*/
6365
protected function newClient($path)
6466
{
65-
$client = new \PhpXmlRpc\Client($this->baseUrl . $path);
67+
$client = new Client($this->baseUrl . $path);
6668
$client->setCookie('PHPUNIT_RANDOM_TEST_ID', static::$randId);
6769
if ($this->collectCodeCoverageInformation) {
6870
$client->setCookie('PHPUNIT_SELENIUM_TEST_ID', $this->testId);

tests/ci/setup/setup_php.sh

100755100644
Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,25 @@ install_shivammatur() {
106106

107107
# @todo check if this script works with all php versions from 5.6 onwards
108108
# @todo the amount of cleanup and hacks required to get shivammathur/php-ubuntu working is huge. Can we find a better installer?
109-
# It seems that https://github.com/shivammathur/php-builder might in fact be the one to use!
109+
# It seems that https://github.com/shivammathur/php-builder might in fact be the one to use...
110110
echo "Using PHP from shivammathur/php-ubuntu..."
111111

112+
###!!!
113+
# @todo this atm fails on focal/5.6, with `108.9 Reading package lists...zstd: /*stdin*\: unsupported format
114+
# 109.2 tar: Child returned status 1
115+
# 109.2 tar: Error is not recoverable: exiting now`
116+
# Try running manually install.sh and see if we can fix it
117+
#
118+
# apt-get install -y \
119+
# apt-utils \
120+
# curl \
121+
# zstd
122+
#
123+
# set +e
124+
# curl -sSL https://github.com/shivammathur/php-builder/releases/latest/download/install.sh | bash -s "${PHP_VERSION}"
125+
# set -e
126+
###!!!
127+
112128
# Some of these packages create issues on GHA ubuntu containers...
113129
if [ -z "${GITHUB_ACTIONS}" ]; then
114130
# @todo this set of packages has only been tested on Noble so far (it should work on Jammy too)

0 commit comments

Comments
 (0)