X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=tests%2F1ParsingBugsTest.php;h=09d8b2f4105f9766a15d19684c0ec73c8dd63db8;hb=9d4b72a3d2eac50750399d22102bcecb6ad17202;hp=8ed214bdaf77ff99a47efc8cd2a71c113dd9bf30;hpb=58c58d4953465ea14af366ddc2afc8d901715461;p=plcapi.git diff --git a/tests/1ParsingBugsTest.php b/tests/1ParsingBugsTest.php index 8ed214b..09d8b2f 100644 --- a/tests/1ParsingBugsTest.php +++ b/tests/1ParsingBugsTest.php @@ -5,21 +5,25 @@ include_once __DIR__ . '/../lib/xmlrpc.inc'; include_once __DIR__ . '/../lib/xmlrpcs.inc'; +include_once __DIR__ . '/parse_args.php'; + +include_once __DIR__ . '/PolyfillTestCase.php'; + /** * Tests involving parsing of xml and handling of xmlrpc values */ -class ParsingBugsTests extends PHPUnit_Framework_TestCase +class ParsingBugsTests extends PhpXmlRpc_PolyfillTestCase { public $args = array(); - protected function setUp() + protected function set_up() { $this->args = argParser::getArgs(); if ($this->args['DEBUG'] == 1) ob_start(); } - protected function tearDown() + protected function tear_down() { if ($this->args['DEBUG'] != 1) return; @@ -74,8 +78,7 @@ class ParsingBugsTests extends PHPUnit_Framework_TestCase $response = utf8_encode( ' - + @@ -114,14 +117,18 @@ class ParsingBugsTests extends PHPUnit_Framework_TestCase 01 -float1 -01.10 - - integer2 +1 +integer3 +1 + + +float1 +01.10 + + float2 +1.10 @@ -137,15 +144,48 @@ class ParsingBugsTests extends PHPUnit_Framework_TestCase $r = $m->parseResponse($fp); $v = $r->value(); $s = $v->structmem('integer1'); - $t = $v->structmem('float1'); - $u = $v->structmem('integer2'); - $w = $v->structmem('float2'); - $x = $v->structmem('float3'); + $t = $v->structmem('integer2'); + $u = $v->structmem('integer3'); + $x = $v->structmem('float1'); + $y = $v->structmem('float2'); + $z = $v->structmem('float3'); $this->assertEquals(1, $s->scalarval()); - $this->assertEquals(1.1, $t->scalarval()); + $this->assertEquals(1, $t->scalarval()); $this->assertEquals(1, $u->scalarval()); - $this->assertEquals(1.1, $w->scalarval()); - $this->assertEquals(-110.0, $x->scalarval()); + + $this->assertEquals(1.1, $x->scalarval()); + $this->assertEquals(1.1, $y->scalarval()); + $this->assertEquals(-110.0, $z->scalarval()); + } + + public function testI8() + { + if (PHP_INT_SIZE == 4 ) { + $this->markTestSkipped('Can not test i8 as php is compiled in 32 bit mode'); + return; + } + + $m = $this->newMsg('dummy'); + $fp = + ' + + + + + + +integer1 +1 + + + + + +'; + $r = $m->parseResponse($fp); + $v = $r->value(); + $s = $v->structmem('integer1'); + $this->assertEquals(1, $s->scalarval()); } public function testAddScalarToStruct() @@ -552,7 +592,7 @@ and there they were.postid7414222assertequals(2, $r->faultCode()); } - public function TestLocale() + public function testLocale() { $locale = setlocale(LC_NUMERIC, 0); /// @todo on php 5.3/win setting locale to german does not seem to set decimal separator to comma... @@ -570,4 +610,52 @@ and there they were.postid7414222markTestSkipped('did not find a locale which sets decimal separator to comma'); } } + + public function testArrayAccess() + { + $v1 = new xmlrpcval(array(new xmlrpcval('one'), new xmlrpcval('two')), 'array'); + $this->assertequals(1, count($v1)); + $out = array('me' => array(), 'mytype' => 2, '_php_class' => null); + + foreach($v1 as $key => $val) + { + $this->assertArrayHasKey($key, $out); + $expected = $out[$key]; + if (gettype($expected) == 'array') { + $this->assertequals('array', gettype($val)); + } else { + $this->assertequals($expected, $val); + } + } + + $v2 = new \PhpXmlRpc\Value(array(new \PhpXmlRpc\Value('one'), new \PhpXmlRpc\Value('two')), 'array'); + $this->assertequals(2, count($v2)); + $out = array(array('key' => 0, 'value' => 'object'), array('key' => 1, 'value' => 'object')); + $i = 0; + foreach($v2 as $key => $val) + { + $expected = $out[$i]; + $this->assertequals($expected['key'], $key); + $this->assertequals($expected['value'], gettype($val)); + $i++; + } + } + + function testBigXML() + { + // nb: make sure that the serialized xml corresponding to this is > 10MB in size + $data = array(); + for ($i = 0; $i < 500000; $i++ ) { + $data[] = 'hello world'; + } + + $encoder = new \PhpXmlRpc\Encoder(); + $val = $encoder->encode($data); + $req = new \PhpXmlRpc\Request('test', array($val)); + $xml = $req->serialize(); + $parser = new \PhpXmlRpc\Helper\XMLParser(); + $parser->parse($xml); + + $this->assertequals(0, $parser->_xh['isf']); + } }