MDL-63884 core: allow tests to set group pictures when creating groups

This commit is contained in:
Jake Dallimore 2018-11-06 16:41:45 +08:00
parent bebef89174
commit 19237383f3

View File

@ -542,6 +542,18 @@ EOD;
$id = groups_create_group((object)$record);
// Allow tests to set group pictures.
if (!empty($record['picturepath'])) {
require_once($CFG->dirroot . '/lib/gdlib.php');
$grouppicture = process_new_icon(\context_course::instance($record['courseid']), 'group', 'icon', $id,
$record['picturepath']);
$DB->set_field('groups', 'picture', $grouppicture, ['id' => $id]);
// Invalidate the group data as we've updated the group record.
cache_helper::invalidate_by_definition('core', 'groupdata', array(), [$record['courseid']]);
}
return $DB->get_record('groups', array('id'=>$id));
}