protected function set_up()
{
$this->args = argParser::getArgs();
- if ($this->args['DEBUG'] == 1)
+ // hide parsing errors unless in debug mode
+ if ($this->args['DEBUG'] < 1)
ob_start();
}
protected function tear_down()
{
- if ($this->args['DEBUG'] != 1)
+ if ($this->args['DEBUG'] >= 1)
return;
$out = ob_get_clean();
$status = $this->getStatus();
--- /dev/null
+<?php
+
+include_once __DIR__ . '/PolyfillTestCase.php';
+
+use PhpXmlRpc\Helper\Charset;
+use PhpXmlRpc\Helper\Http;
+use PhpXmlRpc\Helper\XMLParser;
+
+class LoggerTest extends PhpXmlRpc_PolyfillTestCase
+{
+ protected $debugBuffer = '';
+ protected $errorBuffer = '';
+
+ protected function set_up()
+ {
+ $this->debugBuffer = '';
+ $this->errorBuffer = '';
+ }
+
+ public function testCharsetAltLogger()
+ {
+ $ch = Charset::instance();
+ $l = $ch->getLogger();
+ Charset::setLogger($this);
+
+ // silence the mbstring warning
+ $ch->encodeEntities('hello world', 'UTF-8', 'NOT-A-CHARSET');
+ $this->assertStringContainsString("via mbstring: failed", $this->errorBuffer);
+
+ Charset::setLogger($l);
+ }
+
+ public function testHttpAltLogger()
+ {
+ $l = Http::getLogger();
+ Http::setLogger($this);
+
+ $h = new Http();
+ $s = "HTTP/1.0 200 OK\r\n" .
+ "Content-Type: unknown\r\n" .
+ "\r\n" .
+ "body";
+ $h->parseResponseHeaders($s, false, 1);
+ $this->assertStringContainsString("HEADER: content-type: unknown", $this->debugBuffer);
+ Http::setLogger($l);
+ }
+
+ public function testXPAltLogger()
+ {
+ $xp = new XMLParser();
+ $l = $xp->getLogger();
+ XMLParser::setLogger($this);
+
+ $xp->parse('<?xml version="1.0" ?><methodResponse><params><param><value><boolean> 1 </boolean></value></param></params></methodResponse>');
+ $this->assertStringContainsString("invalid data received in BOOLEAN value", $this->errorBuffer);
+
+ XMLParser::setLogger($l);
+ }
+
+ // logger API
+
+ public function debugMessage($message, $encoding = null)
+ {
+ $this->debugBuffer .= $message;
+ }
+
+ public function errorLog($message)
+ {
+ $this->errorBuffer .= $message;
+ }
+}
protected function set_up()
{
$this->args = argParser::getArgs();
+ // hide parsing errors unless in debug mode
if ($this->args['DEBUG'] == 1)
ob_start();
}
$this->client = new xmlrpc_client('/NOTEXIST.php', $this->args['HTTPSERVER'], 80);
$this->client->setDebug($this->args['DEBUG']);
- if ($this->args['DEBUG'] == 1)
+ // in debug mode, the client will be very verbose. Avoid showing its output unless there are errors
+ if ($this->args['DEBUG'] >= 1)
ob_start();
}
protected function tear_down()
{
- if ($this->args['DEBUG'] != 1)
+ if ($this->args['DEBUG'] < 1)
return;
$out = ob_get_clean();
$status = $this->getStatus();
$this->coverageScriptUrl = 'http://' . $this->args['HTTPSERVER'] . preg_replace('|/tests/index\.php(\?.*)?|', '/tests/phpunit_coverage.php', $this->args['HTTPURI']);
- if ($this->args['DEBUG'] == 1)
+ // in debug mode, the client will be very verbose. Avoid showing its output unless there are errors
+ if ($this->args['DEBUG'] >= 1)
ob_start();
}
protected function tear_down()
{
- if ($this->args['DEBUG'] != 1)
+ if ($this->args['DEBUG'] < 1)
return;
$out = ob_get_clean();
$status = $this->getStatus();
$this->args = argParser::getArgs();
// assumes HTTPURI to be in the form /tests/index.php?etc...
- $this->baseUrl = $this->args['HTTPSERVER'] . preg_replace('|\?.+|', '', $this->args['HTTPURI']);
+ $this->baseUrl = 'http://' . $this->args['HTTPSERVER'] . preg_replace('|\?.+|', '', $this->args['HTTPURI']);
$this->coverageScriptUrl = 'http://' . $this->args['HTTPSERVER'] . preg_replace('|/tests/index\.php(\?.*)?|', '/tests/phpunit_coverage.php', $this->args['HTTPURI']);
}
if ($this->collectCodeCoverageInformation) {
$client->setCookie('PHPUNIT_SELENIUM_TEST_ID', $this->testId);
}
- $client->setAcceptedCompression(false);
- $client->setDebug($this->args['DEBUG']);
+ // let's just assume that the client works fine for these tests, and avoid polluting output
+ //$client->setAcceptedCompression(false);
+ //$client->setDebug($this->args['DEBUG']);
return $client;
}
}