X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=tests%2F1ParsingBugsTest.php;h=6a6a3f99a492c33407d215c74c69e4b0fc052023;hb=4bc0f6904a12381079bec46ad648f6170f07d449;hp=db03a478021188880bf0bf372b5715d4b7a02ee7;hpb=048358caae836a0e0d6a28956acf80c84e480aa3;p=plcapi.git diff --git a/tests/1ParsingBugsTest.php b/tests/1ParsingBugsTest.php index db03a478..6a6a3f99 100644 --- a/tests/1ParsingBugsTest.php +++ b/tests/1ParsingBugsTest.php @@ -7,10 +7,50 @@ 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'); $u = new xmlrpcval('-1', 'string'); + $t = new xmlrpcval(-1, 'string'); + $this->assertEquals($u->scalarval(), $v->scalarval()); + $this->assertEquals($t->scalarval(), $v->scalarval()); + } + + /** + * This looks funny, and we might call it a bug. But we strive for 100 backwards compat... + */ + public function testMinusOneInt() + { + $v = new xmlrpcval(-1); + $u = new xmlrpcval(); $this->assertEquals($u->scalarval(), $v->scalarval()); } @@ -20,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); @@ -50,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); @@ -58,7 +98,7 @@ class ParsingBugsTests extends PHPUnit_Framework_TestCase public function testValidNumbers() { - $m = new xmlrpcmsg('dummy'); + $m = $this->newMsg('dummy'); $fp = ' @@ -181,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 = ' @@ -214,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 @@ -241,7 +280,7 @@ and there they were.postid7414222newMsg('dummy'); $f = '