From c5f7628d397bef08e324e6c0517c37d890a31013 Mon Sep 17 00:00:00 2001 From: Jerome Mouneyrac Date: Tue, 8 Jan 2013 16:23:24 +0800 Subject: [PATCH] MDL-37381 core_external::get_component_strings returns wrong format value --- lib/external/externallib.php | 7 +++++-- lib/external/tests/externallib_test.php | 8 ++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/external/externallib.php b/lib/external/externallib.php index 5ba6a5e3aa6..c69681d0e4c 100644 --- a/lib/external/externallib.php +++ b/lib/external/externallib.php @@ -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')) )); } } diff --git a/lib/external/tests/externallib_test.php b/lib/external/tests/externallib_test.php index 815b97e9347..5c4b2089855 100644 --- a/lib/external/tests/externallib_test.php +++ b/lib/external/tests/externallib_test.php @@ -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']]); } } }