docs
[plcapi.git] / tests / 1ParsingBugsTest.php
index 1e4b040..3fa7b8e 100644 (file)
@@ -7,28 +7,32 @@ include_once __DIR__ . '/../lib/xmlrpcs.inc';
 
 include_once __DIR__ . '/parse_args.php';
 
+include_once __DIR__ . '/PolyfillTestCase.php';
+
+use PHPUnit\Runner\BaseTestRunner;
+
 /**
  * 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;
         $out = ob_get_clean();
         $status = $this->getStatus();
-        if ($status == PHPUnit_Runner_BaseTestRunner::STATUS_ERROR
-            || $status == PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE) {
+        if ($status == BaseTestRunner::STATUS_ERROR
+            || $status == BaseTestRunner::STATUS_FAILURE) {
             echo $out;
         }
     }
@@ -76,8 +80,7 @@ class ParsingBugsTests extends PHPUnit_Framework_TestCase
         $response = utf8_encode(
             '<?xml version="1.0"?>
 <!-- $Id -->
-<!-- found by G. giunta, covers what happens when lib receives
-  UTF8 chars in response text and comments -->
+<!-- found by G. Giunta, covers what happens when lib receives UTF8 chars in response text and comments -->
 <!-- ' . chr(224) . chr(252) . chr(232) . '&#224;&#252;&#232; -->
 <methodResponse>
 <fault>
@@ -160,7 +163,7 @@ class ParsingBugsTests extends PHPUnit_Framework_TestCase
     public function testI8()
     {
         if (PHP_INT_SIZE == 4 ) {
-            $this->markTestSkipped('did not find a locale which sets decimal separator to comma');
+            $this->markTestSkipped('Can not test i8 as php is compiled in 32 bit mode');
             return;
         }
 
@@ -618,12 +621,12 @@ and there they were.</value></member><member><name>postid</name><value>7414222</
 
         foreach($v1 as $key => $val)
         {
-            $this->assertContains($key, $out);
+            $this->assertArrayHasKey($key, $out);
             $expected = $out[$key];
-            if (gettype($expected['value']) == 'array') {
+            if (gettype($expected) == 'array') {
                 $this->assertequals('array', gettype($val));
             } else {
-                $this->assertequals($expected['value'], $val);
+                $this->assertequals($expected, $val);
             }
         }
 
@@ -639,4 +642,22 @@ and there they were.</value></member><member><name>postid</name><value>7414222</
             $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']);
+    }
 }