Make charset-related tests more friendly to hhvm; stricter tests for demo files
[plcapi.git] / tests / 3LocalhostTest.php
index 0e34bc8..e73bf61 100644 (file)
@@ -85,13 +85,27 @@ class LocalhostTest extends PHPUnit_Framework_TestCase
         } else {
             $this->client = new xmlrpc_client($this->args['URI'], $this->args['LOCALSERVER']);
         }
-        if ($this->args['DEBUG']) {
-            $this->client->setDebug($this->args['DEBUG']);
-        }
+
+        $this->client->setDebug($this->args['DEBUG']);
         $this->client->request_compression = $this->request_compression;
         $this->client->accepted_compression = $this->accepted_compression;
 
         $this->coverageScriptUrl = 'http://' . $this->args['LOCALSERVER'] . '/' . str_replace( '/demo/server/server.php', 'tests/phpunit_coverage.php', $this->args['URI'] );
+
+        if ($this->args['DEBUG'] == 1)
+            ob_start();
+    }
+
+    protected function tearDown()
+    {
+        if ($this->args['DEBUG'] != 1)
+            return;
+        $out = ob_get_clean();
+        $status = $this->getStatus();
+        if ($status == PHPUnit_Runner_BaseTestRunner::STATUS_ERROR
+            || $status == PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE) {
+            echo $out;
+        }
     }
 
     protected function send($msg, $errrorcode = 0, $return_response = false)
@@ -107,8 +121,7 @@ class LocalhostTest extends PHPUnit_Framework_TestCase
         }
         if (is_array($errrorcode)) {
             $this->assertContains($r->faultCode(), $errrorcode, 'Error ' . $r->faultCode() . ' connecting to server: ' . $r->faultString());
-        }
-        else {
+        } else {
             $this->assertEquals($r->faultCode(), $errrorcode, 'Error ' . $r->faultCode() . ' connecting to server: ' . $r->faultString());
         }
         if (!$r->faultCode()) {
@@ -153,8 +166,8 @@ class LocalhostTest extends PHPUnit_Framework_TestCase
     public function testLatin1String()
     {
         $sendstring =
-            "last but not least weird names: G" . chr(252) . "nter, El" . chr(232) . "ne, and an xml comment closing tag: -->";
-        $f = '<?xml version="1.0" encoding="iso-8859-1"?><methodCall><methodName>examples.stringecho</methodName><params><param><value>'.
+            "last but not least weird names: G" . chr(252) . "nter, El" . chr(232) . "ne";
+        $f = '<?xml version="1.0" encoding="ISO-8859-1"?><methodCall><methodName>examples.stringecho</methodName><params><param><value>'.
             $sendstring.
             '</value></param></params></methodCall>';
         $v = $this->send($f);