mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
Merge branch 'MDL-75152' of https://github.com/paulholden/moodle
This commit is contained in:
commit
50598298ba
@ -92,6 +92,43 @@ class badges_test extends core_reportbuilder_testcase {
|
||||
}, $content));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test datasource using course/user entities that each contain tags
|
||||
*/
|
||||
public function test_datasource_course_user_tags(): void {
|
||||
$this->resetAfterTest();
|
||||
$this->setAdminUser();
|
||||
|
||||
$course = $this->getDataGenerator()->create_course(['tags' => ['horse']]);
|
||||
$user = $this->getDataGenerator()->create_user(['interests' => ['pie']]);
|
||||
|
||||
// Create course badge, issue to user.
|
||||
$badge = $this->create_badge(['name' => 'Course badge', 'type' => BADGE_TYPE_COURSE, 'courseid' => $course->id]);
|
||||
$badge->issue($user->id, true);
|
||||
|
||||
/** @var core_reportbuilder_generator $generator */
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('core_reportbuilder');
|
||||
|
||||
// Create our report.
|
||||
$report = $generator->create_report(['name' => 'Badges', 'source' => badges::class, 'default' => 0]);
|
||||
$generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'badge:name']);
|
||||
$generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'course:fullname']);
|
||||
$generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'course:tags']);
|
||||
$generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:fullname']);
|
||||
$generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:interests']);
|
||||
|
||||
$content = $this->get_custom_report_content($report->get('id'));
|
||||
|
||||
$this->assertCount(1, $content);
|
||||
$this->assertEquals([
|
||||
$badge->name,
|
||||
$course->fullname,
|
||||
'horse',
|
||||
fullname($user),
|
||||
'pie',
|
||||
], array_values($content[0]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to create a badge
|
||||
*
|
||||
|
@ -60,8 +60,8 @@ class course extends base {
|
||||
return [
|
||||
'course' => 'c',
|
||||
'context' => 'cctx',
|
||||
'tag_instance' => 'ti',
|
||||
'tag' => 't',
|
||||
'tag_instance' => 'cti',
|
||||
'tag' => 'ct',
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -59,8 +59,8 @@ class user extends base {
|
||||
return [
|
||||
'user' => 'u',
|
||||
'context' => 'uctx',
|
||||
'tag_instance' => 'ti',
|
||||
'tag' => 't',
|
||||
'tag_instance' => 'uti',
|
||||
'tag' => 'ut',
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user