dml_missing_record_exception: Can not find data record in database table context.Both 2.7 and 2.8 latest.
Any ideas anyone?
Calling advanced_testcase::resetAllData() in the setUp of the events test fixed this problem whatever it was.
Which plugin?
Anyway, you should not call resetAllData yourself. Instead, you should call resetAfterTest at the start of those tests that will change the database.
(I thought that if you forget to do that, it detected and gave you an error, but clearly not.)
Before the upgrade the tests worked with resetAfterTest and mysql 5.6.12 which had a known problem with reseting table sequences. When the tests stopped working after upgrading Moodle, I upgraded mysql to 5.6.21 but that didn't help. The problem seemed like a caching issue arising from running all these tests as one script (e.g. static variables persist instead of destroyed and recreated). I tried calling accesslib_clear_all_caches_for_unit_testing but didn't help. I revised the plugin code to be able to cleanup static content on demand but that didn't help either. I can appreciate that resetAllData is somewhat an extreme measure but it's the only thing that works so far.
The problem can be narrowed down a little more. My events testcase consists of 4 tests:
The view and field tests loop over all the installed Dataform view and field subplugins respectively.
Each test begins with creating a course and a dataform activity in the course.
Without resetAllData, if I run only this test case, the first test pass and the rest fail on the above mentioned exception. The 'first' in "first test pass" is relative. As is, the view events test pass and the rest fail. If I remove the view events test, then the field events test pass and the rest fail. And so on.
So, it happens with a group of tests even within the same test case. And it is event related issue.