Passed
Push — master ( 8ff19d...02b7f4 )
by Gaetano
05:49
created

MessagesTest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
dl 0
loc 30
rs 10
c 1
b 0
f 0
wmc 7

3 Methods

Rating   Name   Duplication   Size   Complexity  
A tear_down() 0 9 4
A set_up() 0 6 2
A testSerializePHPValResponse() 0 6 1
1
<?php
2
3
include_once __DIR__ . '/../lib/xmlrpc.inc';
4
include_once __DIR__ . '/../lib/xmlrpcs.inc';
5
6
include_once __DIR__ . '/parse_args.php';
7
8
include_once __DIR__ . '/PolyfillTestCase.php';
9
10
use PHPUnit\Runner\BaseTestRunner;
11
12
/**
13
 * Tests involving Requests and Responses, except for the parsing part
14
 */
15
class MessagesTest extends PhpXmlRpc_PolyfillTestCase
16
{
17
    public $args = array();
18
19
    protected function set_up()
20
    {
21
        $this->args = argParser::getArgs();
22
        // hide parsing errors unless in debug mode
23
        if ($this->args['DEBUG'] == 1)
24
            ob_start();
25
    }
26
27
    protected function tear_down()
28
    {
29
        if ($this->args['DEBUG'] != 1)
30
            return;
31
        $out = ob_get_clean();
32
        $status = $this->getStatus();
33
        if ($status == BaseTestRunner::STATUS_ERROR
34
            || $status == BaseTestRunner::STATUS_FAILURE) {
35
            echo $out;
36
        }
37
    }
38
39
    public function testSerializePHPValResponse()
40
    {
41
        $r = new \PhpXmlRpc\Response(array('hello' => 'world'), 0, '', 'phpvals');
42
        $v = $r->serialize();
43
        $this->assertStringContainsString('<member><name>hello</name>', $v);
44
        $this->assertStringContainsString('<value><string>world</string></value>', $v);
45
    }
46
}
47