Skip to content
Browse files

MDL-37381 core_external::get_component_strings returns wrong format v…

…alue
  • Loading branch information...
1 parent 9da506c commit c5f7628d397bef08e324e6c0517c37d890a31013 @mouneyrac mouneyrac committed Jan 8, 2013
Showing with 11 additions and 4 deletions.
  1. +5 −2 lib/external/externallib.php
  2. +6 −2 lib/external/tests/externallib_test.php
View
7 lib/external/externallib.php
@@ -236,7 +236,10 @@ public static function get_component_strings($component, $lang = null) {
$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 @@ public static function get_component_strings_returns() {
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
8 lib/external/tests/externallib_test.php
@@ -105,9 +105,13 @@ public function test_get_component_strings() {
$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']]);
}
}
}

0 comments on commit c5f7628

Please sign in to comment.
Something went wrong with that request. Please try again.