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