|
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'); |
|
|
|
|
|
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
// *** client *** |
|
21
|
|
|
|
|
22
|
|
|
public function testAgeSort() |
|
23
|
|
|
{ |
|
24
|
|
|
$page = $this->request('?demo=client/agesort.php'); |
|
|
|
|
|
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
public function testCodegen() |
|
28
|
|
|
{ |
|
29
|
|
|
$page = $this->request('?demo=client/codegen.php'); |
|
|
|
|
|
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function testGetStateName() |
|
33
|
|
|
{ |
|
34
|
|
|
$page = $this->request('?demo=client/getstatename.php'); |
|
|
|
|
|
|
35
|
|
|
$page = $this->request('?demo=client/getstatename.php', 'POST', array('stateno' => '1')); |
|
|
|
|
|
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
public function testLoggerInjection() |
|
39
|
|
|
{ |
|
40
|
|
|
$page = $this->request('?demo=client/loggerinjection.php'); |
|
|
|
|
|
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function testIntrospect() |
|
44
|
|
|
{ |
|
45
|
|
|
$page = $this->request('?demo=client/introspect.php'); |
|
|
|
|
|
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function testParallel() |
|
49
|
|
|
{ |
|
50
|
|
|
$page = $this->request('?demo=client/parallel.php'); |
|
|
|
|
|
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function testProxy() |
|
54
|
|
|
{ |
|
55
|
|
|
$page = $this->request('?demo=client/proxy.php', 'GET', null, true); |
|
|
|
|
|
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function testWhich() |
|
59
|
|
|
{ |
|
60
|
|
|
$page = $this->request('?demo=client/which.php'); |
|
|
|
|
|
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function testWindowsCharset() |
|
64
|
|
|
{ |
|
65
|
|
|
$page = $this->request('?demo=client/windowscharset.php'); |
|
|
|
|
|
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
public function testWrap() |
|
69
|
|
|
{ |
|
70
|
|
|
$page = $this->request('?demo=client/wrap.php'); |
|
|
|
|
|
|
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); |
|
|
|
|
|
|
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); |
|
|
|
|
|
|
99
|
|
|
$this->assertRegexp('#<int>10(5|3)</int>#', $page); |
|
|
|
|
|
|
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())); |
|
|
|
|
|
|
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); |
|
|
|
|
|
|
124
|
|
|
$this->assertRegexp('#<int>10(5|3)</int>#', $page); |
|
|
|
|
|
|
125
|
|
|
} |
|
126
|
|
|
} |
|
127
|
|
|
|