MDL-37381 core_external::get_component_strings returns wrong format value

This commit is contained in:
Jerome Mouneyrac 2013-01-08 16:23:24 +08:00
parent 9da506c2a3
commit c5f7628d39
2 changed files with 11 additions and 4 deletions

View File

@ -236,7 +236,10 @@ class core_external extends external_api {
$wsstrings = array();
$componentstrings = $stringmanager->load_component_strings($params['component'], $params['lang']);
foreach($componentstrings as $stringid => $string) {
$wsstrings[$stringid] = $string;
$wsstring = array();
$wsstring['stringid'] = $stringid;
$wsstring['string'] = $string;
$wsstrings[] = $wsstring;
}
return $wsstrings;
@ -252,7 +255,7 @@ class core_external extends external_api {
return new external_multiple_structure(
new external_single_structure(array(
'stringid' => new external_value(PARAM_STRINGID, 'string id'),
'string' => new external_value(PARAM_TEXT, 'translated string'))
'string' => new external_value(PARAM_RAW, 'translated string'))
));
}
}

View File

@ -105,9 +105,13 @@ class core_external_testcase extends externallib_advanced_testcase {
$wsstrings = $stringmanager->load_component_strings('webservice', current_language());
$componentstrings = core_external::get_component_strings('webservice');
// We need to execute the return values cleaning process to simulate the web service server.
$componentstrings = external_api::clean_returnvalue(core_external::get_component_strings_returns(), $componentstrings);
$this->assertEquals(count($componentstrings), count($wsstrings));
foreach($wsstrings as $name => $string) {
$this->assertEquals($string, $componentstrings[$name]);
foreach($componentstrings as $string) {
$this->assertEquals($string['string'], $wsstrings[$string['stringid']]);
}
}
}