- xmlrpcs.inc: add a new member var in server class to allow fine-tuning of the encod...
[plcapi.git] / test / testsuite.php
index 5784be4..2873698 100644 (file)
@@ -222,6 +222,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>e<v&gxs<ytjzkami<";
@@ -1241,6 +1255,21 @@ $f = '<?xml version="1.0" encoding="utf-8"?><methodResponse><params><param><valu
                        $r = $m->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( '#<value><ex:nil/></value>#', $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()
@@ -1330,6 +1359,7 @@ $f = '<?xml version="1.0" encoding="utf-8"?><methodResponse><params><param><valu
        $suite->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'));