Remove $id$ tag now that we are on git; update copyright notice to year 2013
[plcapi.git] / test / testsuite.php
index 6c43cb9..90c5844 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-       /* $Id$ */
 
        include(getcwd().'/parse_args.php');
 
                                "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')
                        ));
@@ -460,6 +459,19 @@ And turned it into nylon';
                        }
                }
 
+           function testCatchExceptions()
+           {
+               global $URI;
+               $f = new xmlrpcmsg('examples.raiseException', array(
+                       new xmlrpcval('whatever', 'string')
+               ));
+               $v = $this->send($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');
@@ -617,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();
@@ -819,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()
@@ -835,7 +847,7 @@ And turned it into nylon';
 <!-- $Id -->
 <!-- found by G. giunta, covers what happens when lib receives
   UTF8 chars in reponse text and comments -->
-<!-- àüè&#224;&#252;&#232; -->
+<!-- ���&#224;&#252;&#232; -->
 <methodResponse>
 <fault>
 <value>
@@ -846,7 +858,7 @@ And turned it into nylon';
 </member>
 <member>
 <name>faultString</name>
-<value><string>àüè&#224;&#252;&#232;</string></value>
+<value><string>���&#224;&#252;&#232;</string></value>
 </member>
 </struct>
 </value>
@@ -855,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()
@@ -1203,19 +1215,19 @@ and there they were.</value></member><member><name>postid</name><value>7414222</
                {
                        $s = new xmlrpcmsg('dummy');
 $f = "HTTP/1.1 200 OK\r\nContent-type: text/xml; charset=UTF-8\r\n\r\n".'<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
-<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>'.utf8_encode('àüèàüè').'</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
+<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>'.utf8_encode('������').'</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
 ';
                        $r = $s->parseResponse($f, false, 'phpvals');
                        $v = $r->value();
                        $v = $v['content'];
-                       $this->assertEquals("àüèàüè", $v);
+                       $this->assertEquals("������", $v);
 $f = '<?xml version="1.0" encoding="utf-8"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
-<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>'.utf8_encode('àüèàüè').'</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
+<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>'.utf8_encode('������').'</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
 ';
                        $r = $s->parseResponse($f, false, 'phpvals');
                        $v = $r->value();
                        $v = $v['content'];
-                       $this->assertEquals("àüèàüè", $v);
+                       $this->assertEquals("������", $v);
                }
 
                function testUTF8IntString()
@@ -1365,6 +1377,7 @@ $f = '<?xml version="1.0" encoding="utf-8"?><methodResponse><params><param><valu
        $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'));