DemoFilesTest   A
last analyzed

Complexity

Total Complexity 16

Size/Duplication

Total Lines 112
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 1
Metric Value
eloc 41
c 3
b 0
f 1
dl 0
loc 112
rs 10
wmc 16

14 Methods

Rating   Name   Duplication   Size   Complexity  
A testWhich() 0 3 1
A testCodegen() 0 3 1
A testLoggerInjection() 0 3 1
A testWrap() 0 3 1
A testIntrospect() 0 3 1
A testDiscussServer() 0 26 2
A testWindowsCharset() 0 3 1
A testAgeSort() 0 3 1
A testProxy() 0 3 1
A testVardemo() 0 3 1
A testProxyServer() 0 6 1
A testParallel() 0 3 1
A testGetStateName() 0 4 1
A testCodegenServer() 0 14 2
1
<?php
2
3
include_once __DIR__ . '/WebTestCase.php';
4
5
use PhpXmlRpc\Request;
6
use PhpXmlRpc\Value;
7
8
/**
9
 * Tests for php files in the 'demo' directory.
10
 *
11
 * @todo add execution of perl and python demos via usage of 'exec'
12
 */
13
class DemoFilesTest extends PhpXmlRpc_WebTestCase
14
{
15
    public function testVardemo()
16
    {
17
        $page = $this->request('?demo=vardemo.php');
0 ignored issues
show
Unused Code introduced by
The assignment to $page is dead and can be removed.
Loading history...
18
    }
19
20
    // *** client ***
21
22
    public function testAgeSort()
23
    {
24
        $page = $this->request('?demo=client/agesort.php');
0 ignored issues
show
Unused Code introduced by
The assignment to $page is dead and can be removed.
Loading history...
25
    }
26
27
    public function testCodegen()
28
    {
29
        $page = $this->request('?demo=client/codegen.php');
0 ignored issues
show
Unused Code introduced by
The assignment to $page is dead and can be removed.
Loading history...
30
    }
31
32
    public function testGetStateName()
33
    {
34
        $page = $this->request('?demo=client/getstatename.php');
0 ignored issues
show
Unused Code introduced by
The assignment to $page is dead and can be removed.
Loading history...
35
        $page = $this->request('?demo=client/getstatename.php', 'POST', array('stateno' => '1'));
0 ignored issues
show
Bug introduced by
array('stateno' => '1') of type array<string,string> is incompatible with the type string expected by parameter $payload of PhpXmlRpc_WebTestCase::request(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

35
        $page = $this->request('?demo=client/getstatename.php', 'POST', /** @scrutinizer ignore-type */ array('stateno' => '1'));
Loading history...
36
    }
37
38
    public function testLoggerInjection()
39
    {
40
        $page = $this->request('?demo=client/loggerinjection.php');
0 ignored issues
show
Unused Code introduced by
The assignment to $page is dead and can be removed.
Loading history...
41
    }
42
43
    public function testIntrospect()
44
    {
45
        $page = $this->request('?demo=client/introspect.php');
0 ignored issues
show
Unused Code introduced by
The assignment to $page is dead and can be removed.
Loading history...
46
    }
47
48
    public function testParallel()
49
    {
50
        $page = $this->request('?demo=client/parallel.php');
0 ignored issues
show
Unused Code introduced by
The assignment to $page is dead and can be removed.
Loading history...
51
    }
52
53
    public function testProxy()
54
    {
55
        $page = $this->request('?demo=client/proxy.php', 'GET', null, true);
0 ignored issues
show
Unused Code introduced by
The assignment to $page is dead and can be removed.
Loading history...
56
    }
57
58
    public function testWhich()
59
    {
60
        $page = $this->request('?demo=client/which.php');
0 ignored issues
show
Unused Code introduced by
The assignment to $page is dead and can be removed.
Loading history...
61
    }
62
63
    public function testWindowsCharset()
64
    {
65
        $page = $this->request('?demo=client/windowscharset.php');
0 ignored issues
show
Unused Code introduced by
The assignment to $page is dead and can be removed.
Loading history...
66
    }
67
68
    public function testWrap()
69
    {
70
        $page = $this->request('?demo=client/wrap.php');
0 ignored issues
show
Unused Code introduced by
The assignment to $page is dead and can be removed.
Loading history...
71
    }
72
73
    // *** servers ***
74
75
    public function testCodegenServer()
76
    {
77
        if (!extension_loaded('sqlite3')) {
78
            $this->markTestSkipped('PHP extension sqlite3 is required for this test');
79
        }
80
81
        $page = $this->request('?demo=server/codegen.php&generate=1');
82
        $this->assertStringContainsString('Code generated', $page);
0 ignored issues
show
Bug introduced by
It seems like $page can also be of type true; however, parameter $haystack of PHPUnit\Framework\Assert...tStringContainsString() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

82
        $this->assertStringContainsString('Code generated', /** @scrutinizer ignore-type */ $page);
Loading history...
83
84
        $c = $this->newClient('?demo=server/codegen.php');
85
        $r = $c->send(new Request('CommentManager.getComments', array(
86
            new Value('aCommentId')
87
        )));
88
        $this->assertEquals(0, $r->faultCode());
89
    }
90
91
    public function testDiscussServer()
92
    {
93
        if (!extension_loaded('sqlite3')) {
94
            $this->markTestSkipped('PHP extension sqlite3 is required for this test');
95
        }
96
97
        $page = $this->request('?demo=server/discuss.php');
98
        $this->assertStringContainsString('<name>faultCode</name>', $page);
0 ignored issues
show
Bug introduced by
It seems like $page can also be of type true; however, parameter $haystack of PHPUnit\Framework\Assert...tStringContainsString() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

98
        $this->assertStringContainsString('<name>faultCode</name>', /** @scrutinizer ignore-type */ $page);
Loading history...
99
        $this->assertRegexp('#<int>10(5|3)</int>#', $page);
0 ignored issues
show
Bug introduced by
It seems like $page can also be of type true; however, parameter $string of PHPUnit\Framework\Assert::assertRegExp() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

99
        $this->assertRegexp('#<int>10(5|3)</int>#', /** @scrutinizer ignore-type */ $page);
Loading history...
100
101
        $c = $this->newClient('?demo=server/discuss.php');
102
103
        $r = $c->send(new Request('discuss.addComment', array(
104
            new Value('aCommentId'),
105
            new Value('aCommentUser'),
106
            new Value('a Comment')
107
        )));
108
        $this->assertEquals(0, $r->faultCode());
109
        $this->assertGreaterThanOrEqual(1, $r->value()->scalarval());
110
111
        $r = $c->send(new Request('discuss.getComments', array(
112
            new Value('aCommentId')
113
        )));
114
        $this->assertEquals(0, $r->faultCode());
115
        $this->assertEquals(0, $r->faultCode());
116
        $this->assertGreaterThanOrEqual(1, count($r->value()));
0 ignored issues
show
Bug introduced by
It seems like $r->value() can also be of type string; however, parameter $value of count() does only seem to accept Countable|array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

116
        $this->assertGreaterThanOrEqual(1, count(/** @scrutinizer ignore-type */ $r->value()));
Loading history...
117
    }
118
119
    public function testProxyServer()
120
    {
121
        /// @todo add a couple of proper xmlrpc calls, too
122
        $page = $this->request('?demo=server/proxy.php');
123
        $this->assertStringContainsString('<name>faultCode</name>', $page);
0 ignored issues
show
Bug introduced by
It seems like $page can also be of type true; however, parameter $haystack of PHPUnit\Framework\Assert...tStringContainsString() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

123
        $this->assertStringContainsString('<name>faultCode</name>', /** @scrutinizer ignore-type */ $page);
Loading history...
124
        $this->assertRegexp('#<int>10(5|3)</int>#', $page);
0 ignored issues
show
Bug introduced by
It seems like $page can also be of type true; however, parameter $string of PHPUnit\Framework\Assert::assertRegExp() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

124
        $this->assertRegexp('#<int>10(5|3)</int>#', /** @scrutinizer ignore-type */ $page);
Loading history...
125
    }
126
}
127