The instance of this module does not exist

The instance of this module does not exist

by Miguel Zumbado -
Number of replies: 0

I'm having an issue in moodle 3.6.4

this is part of my code

the executable function

    public static function delete_grade_item($gradeitemid) {
global $USER;
global $DB;

$params = self::validate_parameters(self::delete_grade_item_parameters(),
array('gradeitemid' => $gradeitemid)
);

$context = context_system::instance();
require_capability('moodle/grade:manage', $context);

$result = array();
$failed = false;
$message = "GRADE_ITEM_DELETE_FAILED";

if (is_null($gradeitemid)) {
debugging('Missing grade item id');
$failed = true;
}

$data = array('id' => $params['gradeitemid']);

$gradeitem = new grade_item($data);

if (!$gradeitem->delete()) {
$failed = true;
}

if (!$failed) {
$message = "GRADE_ITEM_DELETE_OK";
}

$result["operationresult"] = $message;
return $result;
}
then the test

    public function test_delete_grade_item() {
global $USER, $DB;
$this->resetAfterTest(true);
$usertest = self::getDataGenerator()->create_user(['username' => 'usertest',
"email" => "test.user@soomo.com",
"firstname" => "User",
"lastname" => "Test"]);

$coursedata['id'] = '1234567';
$coursedata['fullname'] = 'Course 1: Test to get Grades Items';

// Creates a dummy course!
$course = self::getDataGenerator()->create_course($coursedata);

// Creates a dummy grade item!
$gradeitem = self::getDataGenerator()->create_grade_item(array('courseid' => $course->id,
'itemtype' => 'mod',
'itemmodule' => 'lti',
'itemname' => 'Grade Item Test 1',
'gradetype' => 1));

// Asignning capability!
$context = context_system::instance();
$this->assignUserCapability('moodle/grade:manage', $context->id);

$result = local_soomo_api_external::delete_grade_item($gradeitem->id);
$result = external_api::clean_returnvalue(local_soomo_api_external::delete_grade_item_returns(), $result);

// Check if the Grade item is deleted!
$this->assertEquals("GRADE_ITEM_DELETE_OK", $result["operationresult"]);

}
when I run the tests
vendor/bin/phpunit local_soomo_api_testcase  local/soomo_api/test/soomoapi_test.php

I get this error

1) local_soomo_api_testcase::test_delete_grade_item

This test printed output: The instance of this module does not exist


To re-run:

 vendor/bin/phpunit "local_soomo_api_testcase" /vagrant/soomo_api/test/soomoapi_test.php


this exact same code runs perfectly on moodle 3.5

Regards 

Average of ratings: -