mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 04:30:15 +01:00
Merge branch 'MDL-70126' of git://github.com/paulholden/moodle
This commit is contained in:
commit
c3086f74fb
@ -81,7 +81,7 @@ class core_tag_tag {
|
||||
*/
|
||||
protected function __construct($record) {
|
||||
if (empty($record->id)) {
|
||||
throw new coding_exeption("Record must contain at least field 'id'");
|
||||
throw new coding_exception("Record must contain at least field 'id'");
|
||||
}
|
||||
$this->record = $record;
|
||||
}
|
||||
@ -753,7 +753,7 @@ class core_tag_tag {
|
||||
public static function set_item_tags($component, $itemtype, $itemid, context $context, $tagnames, $tiuserid = 0) {
|
||||
if ($itemtype === 'tag') {
|
||||
if ($tiuserid) {
|
||||
throw new coding_exeption('Related tags can not have tag instance userid');
|
||||
throw new coding_exception('Related tags can not have tag instance userid');
|
||||
}
|
||||
debugging('You can not use set_item_tags() for tagging a tag, please use set_related_tags()', DEBUG_DEVELOPER);
|
||||
static::get($itemid, '*', MUST_EXIST)->set_related_tags($tagnames);
|
||||
|
@ -275,6 +275,17 @@ class core_tag_taglib_testcase extends advanced_testcase {
|
||||
$this->assertEquals(0, $instancecount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that setting a list of tags for "tag" item type throws exception if userid specified
|
||||
*/
|
||||
public function test_set_item_tags_with_invalid_userid(): void {
|
||||
$user = $this->getDataGenerator()->create_user();
|
||||
|
||||
$this->expectException(coding_exception::class);
|
||||
$this->expectExceptionMessage('Related tags can not have tag instance userid');
|
||||
core_tag_tag::set_item_tags('core', 'tag', 1, context_system::instance(), ['all', 'night', 'long'], $user->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares environment for testing tag correlations
|
||||
* @return core_tag_tag[] list of used tags
|
||||
|
Loading…
x
Reference in New Issue
Block a user