DemoFilesTest::testDiscussServer()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 26
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 17
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 26
rs 9.7
1
<?php
2
3
include_once __DIR__ . '/WebTestCase.php';
4
5
/**
6
 * Tests for php files in the 'demo' directory.
7
 *
8
 * @todo add execution of perl and python demos via usage of 'exec'
9
 */
10
class DemoFilesTest extends PhpXmlRpc_WebTestCase
11
{
12
    public function testVardemo()
13
    {
14
        $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...
15
    }
16
17
    // *** client ***
18
19
    public function testAgeSort()
20
    {
21
        $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...
22
    }
23
24
    public function testCodegen()
25
    {
26
        $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...
27
    }
28
29
    public function testGetStateName()
30
    {
31
        $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...
32
        $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

32
        $page = $this->request('?demo=client/getstatename.php', 'POST', /** @scrutinizer ignore-type */ array('stateno' => '1'));
Loading history...
33
    }
34
35
    public function testLoggerInjection()
36
    {
37
        $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...
38
    }
39
40
    public function testIntrospect()
41
    {
42
        $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...
43
    }
44
45
    public function testParallel()
46
    {
47
        $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...
48
    }
49
50
    public function testProxy()
51
    {
52
        $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...
53
    }
54
55
    public function testWhich()
56
    {
57
        $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...
58
    }
59
60
    public function testWindowsCharset()
61
    {
62
        $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...
63
    }
64
65
    public function testWrap()
66
    {
67
        $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...
68
    }
69
70
    // *** servers ***
71
72
    public function testCodegenServer()
73
    {
74
        if (!extension_loaded('sqlite3')) {
75
            $this->markTestSkipped('PHP extension sqlite3 is required for this test');
76
        }
77
78
        $page = $this->request('?demo=server/codegen.php');
79
        $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

79
        $this->assertStringContainsString('<name>faultCode</name>', /** @scrutinizer ignore-type */ $page);
Loading history...
80
        $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

80
        $this->assertRegexp('#<int>10(5|3)</int>#', /** @scrutinizer ignore-type */ $page);
Loading history...
81
82
        $c = $this->newClient('?demo=server/codegen.php');
83
        $r = $c->send(new \PhpXmlRpc\Request('CommentManager.getComments', array(
84
            new \PhpXmlRpc\Value('aCommentId')
85
        )));
86
        $this->assertEquals(0, $r->faultCode());
87
    }
88
89
    public function testDiscussServer()
90
    {
91
        if (!extension_loaded('sqlite3')) {
92
            $this->markTestSkipped('PHP extension sqlite3 is required for this test');
93
        }
94
95
        $page = $this->request('?demo=server/discuss.php');
96
        $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

96
        $this->assertStringContainsString('<name>faultCode</name>', /** @scrutinizer ignore-type */ $page);
Loading history...
97
        $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

97
        $this->assertRegexp('#<int>10(5|3)</int>#', /** @scrutinizer ignore-type */ $page);
Loading history...
98
99
        $c = $this->newClient('?demo=server/discuss.php');
100
101
        $r = $c->send(new \PhpXmlRpc\Request('discuss.addComment', array(
102
            new \PhpXmlRpc\Value('aCommentId'),
103
            new \PhpXmlRpc\Value('aCommentUser'),
104
            new \PhpXmlRpc\Value('a Comment')
105
        )));
106
        $this->assertEquals(0, $r->faultCode());
107
        $this->assertGreaterThanOrEqual(1, $r->value()->scalarval());
108
109
        $r = $c->send(new \PhpXmlRpc\Request('discuss.getComments', array(
110
            new \PhpXmlRpc\Value('aCommentId')
111
        )));
112
        $this->assertEquals(0, $r->faultCode());
113
        $this->assertEquals(0, $r->faultCode());
114
        $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

114
        $this->assertGreaterThanOrEqual(1, count(/** @scrutinizer ignore-type */ $r->value()));
Loading history...
115
    }
116
117
    public function testProxyServer()
118
    {
119
        /// @todo add a couple of proper xmlrpc calls, too
120
        $page = $this->request('?demo=server/proxy.php');
121
        $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

121
        $this->assertStringContainsString('<name>faultCode</name>', /** @scrutinizer ignore-type */ $page);
Loading history...
122
        $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

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