MDL-60738 webservice: Clean theme and lang properly

Sometimes the "theme" and "lang" fields in the user and course tables
in the database are set to incorrect values (uninstalled or
non-existent themes and language packs).
This makes Web Services functions to fail because the WS server
validate the returned data using the validate_param function that clean
parameters.
This commit is contained in:
Juan Leyva
2017-11-20 09:38:03 +01:00
parent 665c3ac59c
commit e84e1bbff3
8 changed files with 60 additions and 13 deletions
+6 -4
View File
@@ -720,14 +720,16 @@ class core_userliblib_testcase extends advanced_testcase {
* calling user_get_user_details() function.
*/
public function test_user_get_user_details_missing_fields() {
global $CFG;
$this->resetAfterTest(true);
$this->setAdminUser(); // We need capabilities to view the data.
$user = self::getDataGenerator()->create_user([
'auth' => 'auth_something',
'confirmed' => '0',
'idnumber' => 'someidnumber',
'lang' => 'en_ar',
'theme' => 'mytheme',
'lang' => 'en',
'theme' => $CFG->theme,
'timezone' => '50',
'mailformat' => '0',
]);
@@ -737,8 +739,8 @@ class core_userliblib_testcase extends advanced_testcase {
self::assertSame('auth_something', $got['auth']);
self::assertSame('0', $got['confirmed']);
self::assertSame('someidnumber', $got['idnumber']);
self::assertSame('en_ar', $got['lang']);
self::assertSame('mytheme', $got['theme']);
self::assertSame('en', $got['lang']);
self::assertSame($CFG->theme, $got['theme']);
self::assertSame('50', $got['timezone']);
self::assertSame('0', $got['mailformat']);
}