X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=tests%2F1ParsingBugsTest.php;h=f32bd2e5e9d32379ae31ed5c2fffb5f745ecf323;hb=679eacd661962f353a809ab66e83a86233f28bcc;hp=e4a3048c08ad35bed184146b785125da24374bef;hpb=568742e1a2911037c8d164716c138aa2cce74039;p=plcapi.git diff --git a/tests/1ParsingBugsTest.php b/tests/1ParsingBugsTest.php index e4a3048..f32bd2e 100644 --- a/tests/1ParsingBugsTest.php +++ b/tests/1ParsingBugsTest.php @@ -5,15 +5,48 @@ include_once __DIR__ . '/../lib/xmlrpc.inc'; include_once __DIR__ . '/../lib/xmlrpcs.inc'; +include_once __DIR__ . '/parse_args.php'; + +/** + * Tests involving parsing of xml and handling of xmlrpc values + */ 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->assertEquals($v->scalarval(), $u->scalarval()); + $this->assertEquals($v->scalarval(), $t->scalarval()); } /** @@ -21,8 +54,8 @@ class ParsingBugsTests extends PHPUnit_Framework_TestCase */ public function testMinusOneInt() { - $v = new xmlrpcval(-1); $u = new xmlrpcval(); + $v = new xmlrpcval(-1); $this->assertEquals($u->scalarval(), $v->scalarval()); } @@ -32,10 +65,10 @@ 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); + $this->assertEquals(true, $v->structmemexists($str)); } public function testUnicodeInErrorString() @@ -62,7 +95,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 +103,7 @@ class ParsingBugsTests extends PHPUnit_Framework_TestCase public function testValidNumbers() { - $m = new xmlrpcmsg('dummy'); + $m = $this->newMsg('dummy'); $fp = ' @@ -193,8 +226,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 +258,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 +285,7 @@ and there they were.postid7414222newMsg('dummy'); $f = '