Code Duplication    Length = 26-26 lines in 2 locations

tests/1ParsingBugsTest.php 2 locations

@@ 446-471 (lines=26) @@
443
        \PhpXmlRpc\PhpXmlRpc::importGlobals();
444
    }
445
446
    public function testUTF8Response()
447
    {
448
        $string = chr(224) . chr(252) . chr(232);
449
450
        $s = $this->newMsg('dummy');
451
        $f = "HTTP/1.1 200 OK\r\nContent-type: text/xml; charset=UTF-8\r\n\r\n" . '<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
452
<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . utf8_encode($string) . '</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
453
';
454
        $r = $s->parseResponse($f, false, 'phpvals');
455
        $v = $r->value();
456
        $v = $v['content'];
457
        $this->assertEquals($string, $v);
458
459
        $f = '<?xml version="1.0" encoding="UTF-8"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
460
<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . utf8_encode($string) . '</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
461
';
462
        $r = $s->parseResponse($f, false, 'phpvals');
463
        $v = $r->value();
464
        $v = $v['content'];
465
        $this->assertEquals($string, $v);
466
467
        $r = php_xmlrpc_decode_xml($f);
468
        $v = $r->value();
469
        $v = $v->structmem('content')->scalarval();
470
        $this->assertEquals($string, $v);
471
    }
472
473
    public function testLatin1Response()
474
    {
@@ 473-498 (lines=26) @@
470
        $this->assertEquals($string, $v);
471
    }
472
473
    public function testLatin1Response()
474
    {
475
        $string = chr(224) . chr(252) . chr(232);
476
477
        $s = $this->newMsg('dummy');
478
        $f = "HTTP/1.1 200 OK\r\nContent-type: text/xml; charset=ISO-8859-1\r\n\r\n" . '<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
479
<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . $string . '</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
480
';
481
        $r = $s->parseResponse($f, false, 'phpvals');
482
        $v = $r->value();
483
        $v = $v['content'];
484
        $this->assertEquals($string, $v);
485
486
        $f = '<?xml version="1.0" encoding="ISO-8859-1"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
487
<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . $string . '</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
488
';
489
        $r = $s->parseResponse($f, false, 'phpvals');
490
        $v = $r->value();
491
        $v = $v['content'];
492
        $this->assertEquals($string, $v);
493
494
        $r = php_xmlrpc_decode_xml($f);
495
        $v = $r->value();
496
        $v = $v->structmem('content')->scalarval();
497
        $this->assertEquals($string, $v);
498
    }
499
500
    public function testUTF8IntString()
501
    {