Code Duplication    Length = 12-35 lines in 5 locations

tests/1ParsingBugsTest.php 5 locations

@@ 297-322 (lines=26) @@
294
        $this->assertEquals(2, $r->faultCode());
295
    }
296
297
    public function testBuggyHttp()
298
    {
299
        $s = $this->newMsg('dummy');
300
        $f = 'HTTP/1.1 100 Welcome to the jungle
301
302
HTTP/1.0 200 OK
303
X-Content-Marx-Brothers: Harpo
304
        Chico and Groucho
305
Content-Length: who knows?
306
307
308
309
<?xml version="1.0"?>
310
<!-- First of all, let\'s check out if the lib properly handles a commented </methodResponse> tag... -->
311
<methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
312
<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>hello world. 2 newlines follow
313
314
315
and there they were.</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
316
<script type="text\javascript">document.write(\'Hello, my name is added nag, I\\\'m happy to serve your content for free\');</script>
317
 ';
318
        $r = $s->parseResponse($f);
319
        $v = $r->value();
320
        $s = $v->structmem('content');
321
        $this->assertEquals("hello world. 2 newlines follow\n\n\nand there they were.", $s->scalarval());
322
    }
323
324
    public function testStringBug()
325
    {
@@ 324-358 (lines=35) @@
321
        $this->assertEquals("hello world. 2 newlines follow\n\n\nand there they were.", $s->scalarval());
322
    }
323
324
    public function testStringBug()
325
    {
326
        $s = $this->newMsg('dummy');
327
        $f = '<?xml version="1.0"?>
328
<!-- $Id -->
329
<!-- found by [email protected], amongst others
330
 covers what happens when there\'s character data after </string>
331
 and before </value> -->
332
<methodResponse>
333
<params>
334
<param>
335
<value>
336
<struct>
337
<member>
338
<name>success</name>
339
<value>
340
<boolean>1</boolean>
341
</value>
342
</member>
343
<member>
344
<name>sessionID</name>
345
<value>
346
<string>S300510007I</string>
347
</value>
348
</member>
349
</struct>
350
</value>
351
</param>
352
</params>
353
</methodResponse> ';
354
        $r = $s->parseResponse($f);
355
        $v = $r->value();
356
        $s = $v->structmem('sessionID');
357
        $this->assertEquals('S300510007I', $s->scalarval());
358
    }
359
360
    public function testWhiteSpace()
361
    {
@@ 360-373 (lines=14) @@
357
        $this->assertEquals('S300510007I', $s->scalarval());
358
    }
359
360
    public function testWhiteSpace()
361
    {
362
        $s = $this->newMsg('dummy');
363
        $f = '<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
364
<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>hello world. 2 newlines follow
365
366
367
and there they were.</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
368
';
369
        $r = $s->parseResponse($f);
370
        $v = $r->value();
371
        $s = $v->structmem('content');
372
        $this->assertEquals("hello world. 2 newlines follow\n\n\nand there they were.", $s->scalarval());
373
    }
374
375
    public function testDoubleDataInArrayTag()
376
    {
@@ 425-438 (lines=14) @@
422
        $this->assertEquals(2, $v);
423
    }
424
425
    public function testAutodecodeResponse()
426
    {
427
        $s = $this->newMsg('dummy');
428
        $f = '<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
429
<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>hello world. 2 newlines follow
430
431
432
and there they were.</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
433
';
434
        $r = $s->parseResponse($f, true, 'phpvals');
435
        $v = $r->value();
436
        $s = $v['content'];
437
        $this->assertEquals("hello world. 2 newlines follow\n\n\nand there they were.", $s);
438
    }
439
440
    public function testNoDecodeResponse()
441
    {
@@ 440-451 (lines=12) @@
437
        $this->assertEquals("hello world. 2 newlines follow\n\n\nand there they were.", $s);
438
    }
439
440
    public function testNoDecodeResponse()
441
    {
442
        $s = $this->newMsg('dummy');
443
        $f = '<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
444
<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>hello world. 2 newlines follow
445
446
447
and there they were.</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>';
448
        $r = $s->parseResponse($f, true, 'xml');
449
        $v = $r->value();
450
        $this->assertEquals($f, $v);
451
    }
452
453
    public function testAutoCoDec()
454
    {