X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=test%2Ftestsuite.php;h=90c5844fc1421f1f84755e93e0c0a886380af1ee;hb=05102eb7d8c0faad30ae3719e2045c1af72b9e9d;hp=08b7d9134cf40e6a5a3e4e27f818a7c4674afc41;hpb=26ac91603dc5dab166667622bbc5e7de6d585f3c;p=plcapi.git diff --git a/test/testsuite.php b/test/testsuite.php index 08b7d91..90c5844 100644 --- a/test/testsuite.php +++ b/test/testsuite.php @@ -1,5 +1,4 @@ 1) { - $this->client=&new xmlrpc_client($URI, $server[0], $server[1]); + $this->client=new xmlrpc_client($URI, $server[0], $server[1]); } else { - $this->client=&new xmlrpc_client($URI, $LOCALSERVER); + $this->client=new xmlrpc_client($URI, $LOCALSERVER); } if($DEBUG) { @@ -100,7 +100,7 @@ "a simple CR here".chr(13). "a simple LF here".chr(10). "and then LFCR".chr(10).chr(13). - "last but not least weird names: Günter, Elène, and an xml comment closing tag: -->"; + "last but not least weird names: G�nter, El�ne, and an xml comment closing tag: -->"; $f=new xmlrpcmsg('examples.stringecho', array( new xmlrpcval($sendstring, 'string') )); @@ -221,6 +221,20 @@ And turned it into nylon'; } } + function testDateTime() + { + $time = time(); + $t1 = new xmlrpcval($time, 'dateTime.iso8601'); + $t2 = new xmlrpcval(iso8601_encode($time), 'dateTime.iso8601'); + $this->assertEquals($t1->serialize(), $t2->serialize()); + if (class_exists('DateTime')) + { + $datetime = new DateTime(); + $t3 = new xmlrpcval($datetime->setTimestamp($time), 'dateTime.iso8601'); + $this->assertEquals($t1->serialize(), $t3->serialize()); + } + } + function testCountEntities() { $sendstring = "h'fd>onc>>l>>rw&bpu>q>esend($f, $GLOBALS['xmlrpcerr']['server_error']); + $this->client->path = $URI.'?EXCEPTION_HANDLING=1'; + $v = $this->send($f, 1); + $this->client->path = $URI.'?EXCEPTION_HANDLING=2'; + $v = $this->send($f, $GLOBALS['xmlrpcerr']['invalid_return']); + } + function testZeroParams() { $f = new xmlrpcmsg('system.listMethods'); @@ -527,7 +554,7 @@ And turned it into nylon'; 'c4' => array('value' => 'c4', 'expires' => time()+60*60*24*30, 'path' => '/'), 'c5' => array('value' => 'c5', 'expires' => time()+60*60*24*30, 'path' => '/', 'domain' => 'localhost'), ); - $cookiesval =& php_xmlrpc_encode($cookies); + $cookiesval = php_xmlrpc_encode($cookies); $f=new xmlrpcmsg('examples.setcookies',array($cookiesval)); $r=$this->send($f, 0, true); if($r) @@ -602,7 +629,7 @@ And turned it into nylon'; global $failed_tests; foreach(get_class_methods('LocalhostTests') as $meth) { - if(strpos($meth, 'test') === 0 && $meth != 'testHttps') + if(strpos($meth, 'test') === 0 && $meth != 'testHttps' && $meth != 'testCatchExceptions') { if (!isset($failed_tests[$meth])) $this->$meth(); @@ -804,13 +831,13 @@ And turned it into nylon'; } function testUnicodeInMemberName(){ - $v = array('Günter, Elène' => new xmlrpcval(1)); + $v = array('G�nter, El�ne' => new xmlrpcval(1)); $r = new xmlrpcresp(new xmlrpcval($v, 'struct')); $r = $r->serialize(); $m = new xmlrpcmsg('dummy'); $r = $m->parseResponse($r); $v = $r->value(); - $this->assertEquals($v->structmemexists('Günter, Elène'), true); + $this->assertEquals($v->structmemexists('G�nter, El�ne'), true); } function testUnicodeInErrorString() @@ -820,7 +847,7 @@ And turned it into nylon'; - + @@ -831,7 +858,7 @@ And turned it into nylon'; faultString -àüèàüè +���àüè @@ -840,7 +867,7 @@ And turned it into nylon'; $m=new xmlrpcmsg('dummy'); $r=$m->parseResponse($response); $v=$r->faultString(); - $this->assertEquals('àüèàüè', $v); + $this->assertEquals('������', $v); } function testValidNumbers() @@ -1164,11 +1191,11 @@ and there they were.postid7414222serialize()); $this->assertEquals($v1, $v2); - $r1 =& new xmlrpcresp($v1); + $r1 = new xmlrpcresp($v1); $r2 = php_xmlrpc_decode_xml($r1->serialize()); $r2->serialize(); // needed to set internal member payload $this->assertEquals($r1, $r2); - $m1 =& new xmlrpcmsg('hello dolly', array($v1)); + $m1 = new xmlrpcmsg('hello dolly', array($v1)); $m2 = php_xmlrpc_decode_xml($m1->serialize()); $m2->serialize(); // needed to set internal member payload $this->assertEquals($m1, $m2); @@ -1188,19 +1215,19 @@ and there they were.postid7414222userid311127 -dateCreated20011126T09:17:52content'.utf8_encode('àüèàüè').'postid7414222 +dateCreated20011126T09:17:52content'.utf8_encode('������').'postid7414222 '; $r = $s->parseResponse($f, false, 'phpvals'); $v = $r->value(); $v = $v['content']; - $this->assertEquals("àüèàüè", $v); + $this->assertEquals("������", $v); $f = 'userid311127 -dateCreated20011126T09:17:52content'.utf8_encode('àüèàüè').'postid7414222 +dateCreated20011126T09:17:52content'.utf8_encode('������').'postid7414222 '; $r = $s->parseResponse($f, false, 'phpvals'); $v = $r->value(); $v = $v['content']; - $this->assertEquals("àüèàüè", $v); + $this->assertEquals("������", $v); } function testUTF8IntString() @@ -1240,6 +1267,21 @@ $f = 'parseresponse($s); $v = $r->value(); $this->assertequals('null', $v->scalartyp()); + // test with the apache version: EX:NIL + $GLOBALS['xmlrpc_null_apache_encoding'] = true; + // serialization + $v = new xmlrpcval('hello', 'null'); + $s = $v->serialize(); + $this->assertequals(1, preg_match( '##', $s )); + // deserialization + $r = new xmlrpcresp($v); + $s = $r->serialize(); + $r = $m->parseresponse($s); + $v = $r->value(); + $this->assertequals('null', $v->scalartyp()); + $GLOBALS['xmlrpc_null_extension'] = false; + $r = $m->parseresponse($s); + $this->assertequals(2, $r->faultCode()); } function TestLocale() @@ -1307,7 +1349,7 @@ $f = 'assertEquals(8, $r->faultCode()); // now test a successful connection - $server = split(':', $LOCALSERVER); + $server = explode(':', $LOCALSERVER); if(count($server) > 1) { $this->client->port = $server[1]; @@ -1316,8 +1358,8 @@ $f = 'client->path = $URI; $r = $this->client->send($f, 5, 'http11'); - $r = $r->value(); - $this->assertEquals('hello', $r->scalarVal()); + $ro = $r->value(); + $this->assertEquals('hello', $ro->scalarVal()); } } @@ -1329,11 +1371,13 @@ $f = 'addTest(new LocalhostTests('testBoolean')); $suite->addTest(new LocalhostTests('testCountEntities')); $suite->addTest(new LocalhostTests('testBase64')); + $suite->addTest(new LocalhostTests('testDateTime')); $suite->addTest(new LocalhostTests('testServerMulticall')); $suite->addTest(new LocalhostTests('testClientMulticall1')); $suite->addTest(new LocalhostTests('testClientMulticall2')); $suite->addTest(new LocalhostTests('testClientMulticall3')); $suite->addTest(new LocalhostTests('testCatchWarnings')); + $suite->addTest(new LocalhostTests('testCatchExceptions')); $suite->addTest(new LocalhostTests('testZeroParams')); $suite->addTest(new LocalhostTests('testCodeInjectionServerSide')); $suite->addTest(new LocalhostTests('testAutoRegisteredFunction')); @@ -1409,6 +1453,7 @@ $f = 'Using lib version: $xmlrpcVersion on PHP version: ".phpversion()."\n"; echo '

Running '.$suite->testCount().' tests (some of which are multiple) against servers: http://'.htmlspecialchars($LOCALSERVER.$URI).' and https://'.htmlspecialchars($HTTPSSERVER.$HTTPSURI)."\n ...

\n"; flush(); + @ob_flush(); } else { @@ -1470,4 +1515,4 @@ Proxy Server: \n\n"; } -?> +?> \ No newline at end of file