Hi. I am creating a unit test in Moodle for my plugin. I am receiving this error when running the test class:
"Warning: unexpected database modification, resetting DB state"
This error doesn't happen if I use $this->resetAfterTest(true); before each method. The problem: I need to keep the state of the database between the test methods.
Eg: One method to create the user, other method to create a course, a third method to put the user inside the course.
public function test_create_user()
{
global $DB;
//$this->resetAfterTest(true);
$user = $this->getDataGenerator()->create_user();
$this->userid = $user->id;
$this->assertEquals(1, $DB->count_records('user', ['id' => $user->id]));
}