X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=tests%2F1ParsingBugsTest.php;h=6a6a3f99a492c33407d215c74c69e4b0fc052023;hb=4bc0f6904a12381079bec46ad648f6170f07d449;hp=33915cab1c0a019f7bd23b8aa3892f7b7fa4b4e4;hpb=98ff9c3b600d0a98a8febe836acdfe4f67e91f53;p=plcapi.git diff --git a/tests/1ParsingBugsTest.php b/tests/1ParsingBugsTest.php index 33915ca..6a6a3f9 100644 --- a/tests/1ParsingBugsTest.php +++ b/tests/1ParsingBugsTest.php @@ -7,6 +7,34 @@ include_once __DIR__ . '/../lib/xmlrpcs.inc'; class ParsingBugsTests extends PHPUnit_Framework_TestCase { + public $args = array(); + + protected function setUp() + { + $this->args = argParser::getArgs(); + 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 newMsg($methodName, $params = array()) + { + $msg = new xmlrpcmsg($methodName, $params); + $msg->setDebug($this->args['DEBUG']); + return $msg; + } + public function testMinusOneString() { $v = new xmlrpcval('-1'); @@ -32,7 +60,7 @@ class ParsingBugsTests extends PHPUnit_Framework_TestCase $v = array($str => new xmlrpcval(1)); $r = new xmlrpcresp(new xmlrpcval($v, 'struct')); $r = $r->serialize(); - $m = new xmlrpcmsg('dummy'); + $m = $this->newMsg('dummy'); $r = $m->parseResponse($r); $v = $r->value(); $this->assertEquals($v->structmemexists($str), true); @@ -62,7 +90,7 @@ class ParsingBugsTests extends PHPUnit_Framework_TestCase '); - $m = new xmlrpcmsg('dummy'); + $m = $this->newMsg('dummy'); $r = $m->parseResponse($response); $v = $r->faultString(); $this->assertEquals(chr(224) . chr(252) . chr(232) . chr(224) . chr(252) . chr(232), $v); @@ -70,7 +98,7 @@ class ParsingBugsTests extends PHPUnit_Framework_TestCase public function testValidNumbers() { - $m = new xmlrpcmsg('dummy'); + $m = $this->newMsg('dummy'); $fp = ' @@ -193,8 +221,7 @@ class ParsingBugsTests extends PHPUnit_Framework_TestCase public function testBrokenResponses() { - $m = new xmlrpcmsg('dummy'); - //$m->debug = 1; + $m = $this->newMsg('dummy'); // omitting the 'params' tag: no more tolerated by the lib... $f = ' @@ -226,7 +253,7 @@ class ParsingBugsTests extends PHPUnit_Framework_TestCase public function testBuggyHttp() { - $s = new xmlrpcmsg('dummy'); + $s = $this->newMsg('dummy'); $f = 'HTTP/1.1 100 Welcome to the jungle HTTP/1.0 200 OK @@ -253,7 +280,7 @@ and there they were.postid7414222newMsg('dummy'); $f = '