Code Duplication    Length = 12-35 lines in 5 locations

tests/1ParsingBugsTest.php 5 locations

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