X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=tests%2F3LocalhostTest.php;h=118f10b722f71947ea5288376a593e69ba12b79c;hb=ac735cf96eb914759f7e7595630857254b599783;hp=9d848ab2aea9e4ab0078fe2268a9b1804f98efd4;hpb=70ee98a9c00c79621db919e79082762ace00fe70;p=plcapi.git
diff --git a/tests/3LocalhostTest.php b/tests/3LocalhostTest.php
index 9d848ab..118f10b 100644
--- a/tests/3LocalhostTest.php
+++ b/tests/3LocalhostTest.php
@@ -194,6 +194,34 @@ class LocalhostTest extends PHPUnit_Framework_TestCase
return;
}
$sendString = 'κόÏμε'; // Greek word 'kosme'. NB: NOT a valid ISO8859 string!
+ $str = '
+
+ examples.stringecho
+
+
+ '.$sendString.'
+
+
+';
+
+ PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding = 'UTF-8';
+ // we have to set the encoding declaration either in the http header or xml prolog, as mb_detect_encoding
+ // (used on the server side) will fail recognizing these 2 charsets
+ $v = $this->send(mb_convert_encoding(str_replace('_ENC_', 'UCS-4', $str), 'UCS-4', 'UTF-8'));
+ $this->assertEquals($sendString, $v->scalarval());
+ $v = $this->send(mb_convert_encoding(str_replace('_ENC_', 'UTF-16', $str), 'UTF-16', 'UTF-8'));
+ $this->assertEquals($sendString, $v->scalarval());
+ PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding = 'ISO-8859-1';
+ }
+
+ public function testExoticCharsetsRequests2()
+ {
+ // note that we should disable this call also when mbstring is missing server-side
+ if (!function_exists('mb_convert_encoding')) {
+ $this->markTestSkipped('Miss mbstring extension to test exotic charsets');
+ return;
+ }
+ $sendString = 'å®å®¤å¥ç¾æµ'; // No idea what this means :-) NB: NOT a valid ISO8859 string!
$str = '
examples.stringecho
@@ -204,10 +232,37 @@ class LocalhostTest extends PHPUnit_Framework_TestCase
';
- // these calls will have no charset declaration in either http headers or xml prolog
- $v = $this->send(mb_convert_encoding($str, 'UCS-4', 'UTF-8'));
+ PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding = 'UTF-8';
+ // no encoding declaration either in the http header or xml prolog, let mb_detect_encoding
+ // (used on the server side) sort it out
+ $this->client->path = $this->args['URI'].'?DETECT_ENCODINGS[]=EUC-JP&DETECT_ENCODINGS[]=UTF-8';
+ $v = $this->send(mb_convert_encoding($str, 'EUC-JP', 'UTF-8'));
$this->assertEquals($sendString, $v->scalarval());
- $v = $this->send(mb_convert_encoding($str, 'UTF-16', 'UTF-8'));
+ PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding = 'ISO-8859-1';
+ }
+
+ public function testExoticCharsetsRequests3()
+ {
+ // note that we should disable this call also when mbstring is missing server-side
+ if (!function_exists('mb_convert_encoding')) {
+ $this->markTestSkipped('Miss mbstring extension to test exotic charsets');
+ return;
+ }
+ $sendString = utf8_decode('élève');
+ $str = '
+
+ examples.stringecho
+
+
+ '.$sendString.'
+
+
+';
+
+ // no encoding declaration either in the http header or xml prolog, let mb_detect_encoding
+ // (used on the server side) sort it out
+ $this->client->path = $this->args['URI'].'?DETECT_ENCODINGS[]=ISO-8859-1&DETECT_ENCODINGS[]=UTF-8';
+ $v = $this->send($str);
$this->assertEquals($sendString, $v->scalarval());
}
@@ -356,7 +411,7 @@ And turned it into nylon';
$got = '';
$expected = '37210';
$expect_array = array('ctLeftAngleBrackets', 'ctRightAngleBrackets', 'ctAmpersands', 'ctApostrophes', 'ctQuotes');
- while (list(, $val) = each($expect_array)) {
+ foreach($expect_array as $val) {
$b = $v->structmem($val);
$got .= $b->me['int'];
}