Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions context/cohort/classes/observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

defined('MOODLE_INTERNAL') || die();

require_once($CFG->dirroot . '/local/metadata/context/cohort/classes/context_handler.php');

/**
* Local metadatacontext_cohort event handler.
*/
Expand Down
8 changes: 5 additions & 3 deletions context/cohort/tests/metadatacontext_cohort_event_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@ public function setUp(): void {
*/
public function test_cohortdeleted() {
global $DB, $CFG;
require_once($CFG->dirroot . '/local/metadata/context/cohort/classes/context_handler.php');

$this->resetAfterTest(true);

// Don't declare CONTEXT_COHORT as this distorts the test
$contextcohort = 9000;

// Create a custom field of textarea type.
$id1 = $this->generator->create_metadata_field(CONTEXT_COHORT, 'frogdesc', 'Description of frog');
$id1 = $this->generator->create_metadata_field($contextcohort, 'frogdesc', 'Description of frog');
$this->generator->create_metadata($id1, $this->cohort[0]->id, 'Leopard frog');
$this->generator->create_metadata($id1, $this->cohort[1]->id, 'Bullfrog');

Expand All @@ -79,4 +81,4 @@ public function test_cohortdeleted() {
$this->assertEquals(1, $DB->count_records('local_metadata'));
$this->assertEquals(0, $DB->count_records('local_metadata', ['instanceid' => $this->cohort[0]->id]));
}
}
}
2 changes: 2 additions & 0 deletions context/group/classes/observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

defined('MOODLE_INTERNAL') || die();

require_once($CFG->dirroot . '/local/metadata/context/group/classes/context_handler.php');

/**
* Local metadatacontext_group event handler.
*/
Expand Down
12 changes: 7 additions & 5 deletions context/group/tests/metadatacontext_group_event_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,18 @@ public function setUp(): void {
}

/**
* Performs unit tests for cohort deleted event.
* Performs unit tests for group deleted event.
*/
public function test_cohortdeleted() {
public function test_groupdeleted() {
global $DB, $CFG;
require_once($CFG->dirroot . '/local/metadata/context/group/classes/context_handler.php');

$this->resetAfterTest(true);

// Don't declare CONTEXT_GROUP as this distorts the test
$contextgroup = 60;

// Create a custom field of textarea type.
$id1 = $this->generator->create_metadata_field(CONTEXT_GROUP, 'frogdesc', 'Description of frog');
$id1 = $this->generator->create_metadata_field($contextgroup, 'frogdesc', 'Description of frog');
$this->generator->create_metadata($id1, $this->group[0]->id, 'Leopard frog');
$this->generator->create_metadata($id1, $this->group[1]->id, 'Bullfrog');

Expand All @@ -81,4 +83,4 @@ public function test_cohortdeleted() {
$this->assertEquals(1, $DB->count_records('local_metadata'));
$this->assertEquals(0, $DB->count_records('local_metadata', ['instanceid' => $this->group[0]->id]));
}
}
}