7
7
8
8
use PHPUnit \Framework \Attributes \Test ;
9
9
10
- class bundledLibsTest extends PHPUnit \Framework \TestCase
11
- {
12
- #[Test]
13
- public function test_serendipity_xml_rpc_message ()
14
- {
10
+ class bundledLibsTest extends PHPUnit \Framework \TestCase {
11
+ var $ message = null ;
12
+
13
+ protected function setUp (): void {
15
14
$ args = array (
16
15
new XML_RPC_Value (
17
16
'testA ' ,
@@ -22,12 +21,16 @@ public function test_serendipity_xml_rpc_message()
22
21
'string '
23
22
)
24
23
);
25
- $ message = new XML_RPC_Message (
24
+ $ this -> $ message = new XML_RPC_Message (
26
25
'weblogUpdates.ping ' ,
27
26
$ args
28
27
);
29
- $ message ->createPayload ();
30
-
28
+ $ this ->$ message ->createPayload ();
29
+ }
30
+
31
+ #[Test]
32
+ public function test_serendipity_xml_rpc_message ()
33
+ {
31
34
$ expected = "<?xml version= \"1.0 \" encoding= \"UTF-8 \"?> \r
32
35
<methodCall> \r
33
36
<methodName>weblogUpdates.ping</methodName> \r
@@ -41,27 +44,12 @@ public function test_serendipity_xml_rpc_message()
41
44
</params> \r
42
45
</methodCall> \r
43
46
" ;
44
- $ this ->assertEquals ($ expected , $ message ->payload );
47
+ $ this ->assertEquals ($ expected , $ this -> $ message ->payload );
45
48
}
46
49
47
50
#[Test]
48
51
public function test_serendipity_xml_rpc_response_valid ()
49
52
{
50
- $ args = array (
51
- new XML_RPC_Value (
52
- 'testA ' ,
53
- 'string '
54
- ),
55
- new XML_RPC_Value (
56
- 'testB ' ,
57
- 'string '
58
- )
59
- );
60
- $ message = new XML_RPC_Message (
61
- 'weblogUpdates.ping ' ,
62
- $ args
63
- );
64
- $ message ->createPayload ();
65
53
$ example_response = "<methodResponse>
66
54
<params>
67
55
<param>
@@ -70,8 +58,16 @@ public function test_serendipity_xml_rpc_response_valid()
70
58
</params>
71
59
</methodResponse> " ;
72
60
73
- $ xmlrpc_result = $ message ->parseResponse ($ example_response );
61
+ $ xmlrpc_result = $ this -> $ message ->parseResponse ($ example_response );
74
62
$ this ->assertEquals ($ example_response , $ xmlrpc_result ->serialize ());
75
63
}
64
+ #[Test]
65
+ public function test_serendipity_xml_rpc_response_invalid ()
66
+ {
67
+ $ example_response = "some non-xml response " ;
68
+
69
+ $ xmlrpc_result = $ this ->$ message ->parseResponse ($ example_response );
70
+ $ this ->assertEquals (2 , $ xmlrpc_result ->faultCode ());
71
+ }
76
72
77
73
}
0 commit comments