Skip to content

Commit 6a13906

Browse files
committed
Fix tests v10
1 parent cb54871 commit 6a13906

File tree

4 files changed

+57
-30
lines changed

4 files changed

+57
-30
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"scripts": {
2121
"test:coverage": [
2222
"@putenv XDEBUG_MODE=coverage",
23-
"phpunit --color=always --coverage-text --configuration tests/travis/sqlite.phpunit.xml"
23+
"phpunit --color=always --coverage-text --configuration tests/phpunit.xml"
2424
],
2525
"post-install-cmd": [
2626
"sed -i s/name{0}/name[0]/ vendor/mikey179/vfsstream/src/main/php/org/bovigo/vfs/vfsStream.php"

system/libraries/Xmlrpc.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,20 +1152,19 @@ public function parseResponse($fp)
11521152
// Create and Set Up XML Parser
11531153
//-------------------------------------
11541154

1155-
$parser = xml_parser_create($this->xmlrpc_defencoding);
1156-
$this->xh = array(
1157-
'isf' => 0,
1158-
'ac' => '',
1159-
'headers' => array(),
1160-
'stack' => array(),
1161-
'valuestack' => array(),
1162-
'isf_reason' => 0
1163-
);
1155+
$parser = xml_parser_create($this->xmlrpc_defencoding);
1156+
$this->xh = array(
1157+
'isf' => 0,
1158+
'ac' => '',
1159+
'headers' => array(),
1160+
'stack' => array(),
1161+
'valuestack' => array(),
1162+
'isf_reason' => 0
1163+
);
11641164

11651165
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true);
11661166
xml_set_element_handler($parser, [$this, 'open_tag'], [$this, 'closing_tag']);
11671167
xml_set_character_data_handler($parser, [$this, 'character_data']);
1168-
11691168
//xml_set_default_handler($parser, 'default_handler');
11701169

11711170
// Get headers

system/libraries/Xmlrpcs.php

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -232,21 +232,22 @@ public function parseRequest($data = '')
232232
// Set up XML Parser
233233
//-------------------------------------
234234

235-
$parser = xml_parser_create($this->xmlrpc_defencoding);
236-
$parser_object = new XML_RPC_Message('filler');
237-
238-
$parser_object->xh = array(
239-
'isf' => 0,
240-
'isf_reason' => '',
241-
'params' => array(),
242-
'stack' => array(),
243-
'valuestack' => array(),
244-
'method' => ''
245-
);
235+
$parser = xml_parser_create($this->xmlrpc_defencoding);
236+
$parser_object = new XML_RPC_Message('default_method', FALSE);
237+
238+
$parser_object->xh = array(
239+
'isf' => 0,
240+
'isf_reason' => '',
241+
'params' => array(),
242+
'stack' => array(),
243+
'valuestack' => array(),
244+
'method' => ''
245+
);
246246

247247
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true);
248-
xml_set_element_handler($parser, [$this, 'open_tag'], [$this, 'closing_tag']);
249-
xml_set_character_data_handler($parser, [$this, 'character_data']);
248+
xml_set_element_handler($parser, [$parser_object, 'open_tag'], [$parser_object, 'closing_tag']);
249+
xml_set_character_data_handler($parser, [$parser_object, 'character_data']);
250+
250251
//xml_set_default_handler($parser, 'default_handler');
251252

252253
//-------------------------------------

tests/mocks/libraries/xmlrpcs.php

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,42 @@ class Mock_Libraries_Xmlrpcs extends CI_Xmlrpcs {
99
public function serve()
1010
{
1111
$r = $this->parseRequest();
12-
13-
$payload = '<?xml version="1.0" encoding="'.$this->xmlrpc_defencoding.'"?'.'>'."\n".$this->debug_msg.$r->prepare_response();
14-
12+
13+
if (isset($r->method_name) && isset($this->config['functions'][$r->method_name])) {
14+
$callback = $this->config['functions'][$r->method_name]['function'];
15+
if (is_callable($callback)) {
16+
call_user_func($callback, $r->parameters);
17+
} else {
18+
throw new Exception('Invalid callback: ' . $callback);
19+
}
20+
}
21+
22+
$payload = '<?xml version="1.0" encoding="' . $this->xmlrpc_defencoding . '"?>' . "\n" .
23+
$this->debug_msg . $r->prepare_response();
24+
1525
$this->mock_payload = "HTTP/1.1 200 OK\r\n";
1626
$this->mock_payload .= "Content-Type: text/xml\r\n";
17-
$this->mock_payload .= 'Content-Length: '.strlen($payload)."\r\n";
18-
27+
$this->mock_payload .= 'Content-Length: ' . strlen($payload) . "\r\n";
1928
$this->mock_payload .= "\r\n";
20-
2129
$this->mock_payload .= $payload;
2230
}
31+
32+
/**
33+
* Mock XML request (example)
34+
*/
35+
public function xml_request()
36+
{
37+
// Return a mock XML request
38+
return '<?xml version="1.0"?>
39+
<methodCall>
40+
<methodName>Testmethod</methodName>
41+
<params>
42+
<param>
43+
<value>
44+
<string>Test</string>
45+
</value>
46+
</param>
47+
</params>
48+
</methodCall>';
49+
}
2350
}

0 commit comments

Comments
 (0)