Code Duplication    Length = 12-35 lines in 5 locations

tests/1ParsingBugsTest.php 5 locations

@@ 259-284 (lines=26) @@
256
        $this->assertEquals(2, $r->faultCode());
257
    }
258
259
    public function testBuggyHttp()
260
    {
261
        $s = $this->newMsg('dummy');
262
        $f = 'HTTP/1.1 100 Welcome to the jungle
263
264
HTTP/1.0 200 OK
265
X-Content-Marx-Brothers: Harpo
266
        Chico and Groucho
267
Content-Length: who knows?
268
269
270
271
<?xml version="1.0"?>
272
<!-- First of all, let\'s check out if the lib properly handles a commented </methodResponse> tag... -->
273
<methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
274
<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>hello world. 2 newlines follow
275
276
277
and there they were.</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
278
<script type="text\javascript">document.write(\'Hello, my name is added nag, I\\\'m happy to serve your content for free\');</script>
279
 ';
280
        $r = $s->parseResponse($f);
281
        $v = $r->value();
282
        $s = $v->structmem('content');
283
        $this->assertEquals("hello world. 2 newlines follow\n\n\nand there they were.", $s->scalarval());
284
    }
285
286
    public function testStringBug()
287
    {
@@ 286-320 (lines=35) @@
283
        $this->assertEquals("hello world. 2 newlines follow\n\n\nand there they were.", $s->scalarval());
284
    }
285
286
    public function testStringBug()
287
    {
288
        $s = $this->newMsg('dummy');
289
        $f = '<?xml version="1.0"?>
290
<!-- $Id -->
291
<!-- found by [email protected], amongst others
292
 covers what happens when there\'s character data after </string>
293
 and before </value> -->
294
<methodResponse>
295
<params>
296
<param>
297
<value>
298
<struct>
299
<member>
300
<name>success</name>
301
<value>
302
<boolean>1</boolean>
303
</value>
304
</member>
305
<member>
306
<name>sessionID</name>
307
<value>
308
<string>S300510007I</string>
309
</value>
310
</member>
311
</struct>
312
</value>
313
</param>
314
</params>
315
</methodResponse> ';
316
        $r = $s->parseResponse($f);
317
        $v = $r->value();
318
        $s = $v->structmem('sessionID');
319
        $this->assertEquals('S300510007I', $s->scalarval());
320
    }
321
322
    public function testWhiteSpace()
323
    {
@@ 322-335 (lines=14) @@
319
        $this->assertEquals('S300510007I', $s->scalarval());
320
    }
321
322
    public function testWhiteSpace()
323
    {
324
        $s = $this->newMsg('dummy');
325
        $f = '<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
326
<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>hello world. 2 newlines follow
327
328
329
and there they were.</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
330
';
331
        $r = $s->parseResponse($f);
332
        $v = $r->value();
333
        $s = $v->structmem('content');
334
        $this->assertEquals("hello world. 2 newlines follow\n\n\nand there they were.", $s->scalarval());
335
    }
336
337
    public function testDoubleDataInArrayTag()
338
    {
@@ 387-400 (lines=14) @@
384
        $this->assertEquals(2, $v);
385
    }
386
387
    public function testAutodecodeResponse()
388
    {
389
        $s = $this->newMsg('dummy');
390
        $f = '<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
391
<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>hello world. 2 newlines follow
392
393
394
and there they were.</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
395
';
396
        $r = $s->parseResponse($f, true, 'phpvals');
397
        $v = $r->value();
398
        $s = $v['content'];
399
        $this->assertEquals("hello world. 2 newlines follow\n\n\nand there they were.", $s);
400
    }
401
402
    public function testNoDecodeResponse()
403
    {
@@ 402-413 (lines=12) @@
399
        $this->assertEquals("hello world. 2 newlines follow\n\n\nand there they were.", $s);
400
    }
401
402
    public function testNoDecodeResponse()
403
    {
404
        $s = $this->newMsg('dummy');
405
        $f = '<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
406
<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>hello world. 2 newlines follow
407
408
409
and there they were.</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>';
410
        $r = $s->parseResponse($f, true, 'xml');
411
        $v = $r->value();
412
        $this->assertEquals($f, $v);
413
    }
414
415
    public function testAutoCoDec()
416
    {