Passed
Push — master ( b6cd05...9f5262 )
by Gaetano
05:39
created

DemoFilesTest::testParallel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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 set_up()
13
    {
14
        $this->args = argParser::getArgs();
15
16
        // assumes HTTPURI to be in the form /tests/index.php?etc...
17
        $this->baseUrl = 'http://' . $this->args['HTTPSERVER'] . preg_replace('|\?.+|', '', $this->args['HTTPURI']);
18
        $this->coverageScriptUrl = 'http://' . $this->args['HTTPSERVER'] . preg_replace('|/tests/index\.php(\?.*)?|', '/tests/phpunit_coverage.php', $this->args['HTTPURI']);
19
    }
20
21
    public function testVardemo()
22
    {
23
        $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...
24
    }
25
26
    // *** client ***
27
28
    public function testAgeSort()
29
    {
30
        $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...
31
    }
32
33
    public function testCodegen()
34
    {
35
        $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...
36
    }
37
38
    public function testGetStateName()
39
    {
40
        $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...
41
        $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

41
        $page = $this->request('?demo=client/getstatename.php', 'POST', /** @scrutinizer ignore-type */ array('stateno' => '1'));
Loading history...
42
    }
43
44
    public function testLoggerInjection()
45
    {
46
        $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...
47
    }
48
49
    public function testIntrospect()
50
    {
51
        $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...
52
    }
53
54
    public function testParallel()
55
    {
56
        $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...
57
    }
58
59
    public function testProxy()
60
    {
61
        $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...
62
    }
63
64
    public function testWhich()
65
    {
66
        $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...
67
    }
68
69
    public function testWindowsCharset()
70
    {
71
        $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...
72
    }
73
74
    public function testWrap()
75
    {
76
        $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...
77
    }
78
79
    // *** servers ***
80
81
    public function testCodegenServer()
82
    {
83
        $page = $this->request('?demo=server/codegen.php');
84
        $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

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

85
        $this->assertRegexp('#<int>10(5|3)</int>#', /** @scrutinizer ignore-type */ $page);
Loading history...
86
87
        $c = $this->getClient('?demo=server/codegen.php');
88
        $r = $c->send(new \PhpXmlRpc\Request('CommentManager.getComments', array(
89
            new \PhpXmlRpc\Value('aCommentId')
90
        )));
91
        $this->assertEquals(0, $r->faultCode());
92
    }
93
94
    public function testDiscussServer()
95
    {
96
        $page = $this->request('?demo=server/discuss.php');
97
        $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

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

98
        $this->assertRegexp('#<int>10(5|3)</int>#', /** @scrutinizer ignore-type */ $page);
Loading history...
99
100
        $c = $this->getClient('?demo=server/discuss.php');
101
102
        $r = $c->send(new \PhpXmlRpc\Request('discuss.addComment', array(
103
            new \PhpXmlRpc\Value('aCommentId'),
104
            new \PhpXmlRpc\Value('aCommentUser'),
105
            new \PhpXmlRpc\Value('a Comment')
106
        )));
107
        $this->assertEquals(0, $r->faultCode());
108
        $this->assertGreaterThanOrEqual(1, $r->value()->scalarval());
0 ignored issues
show
Bug introduced by
The method scalarval() does not exist on integer. ( Ignorable by Annotation )

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

108
        $this->assertGreaterThanOrEqual(1, $r->value()->/** @scrutinizer ignore-call */ scalarval());

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
109
110
        $r = $c->send(new \PhpXmlRpc\Request('discuss.getComments', array(
111
            new \PhpXmlRpc\Value('aCommentId')
112
        )));
113
        $this->assertEquals(0, $r->faultCode());
114
        $this->assertEquals(0, $r->faultCode());
115
        $this->assertGreaterThanOrEqual(1, count($r->value()));
0 ignored issues
show
Bug introduced by
$r->value() of type integer is incompatible with the type Countable|array expected by parameter $value of count(). ( Ignorable by Annotation )

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

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

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

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