Test data represents numbers as numbers but Moodle DB returns them as strings
See https://github.com/xAPI-vle/moodle-logstore_xapi/pull/388 for an example.
All of our test data has numbers in the json as numbers, however when pulling the data from the Moodle database the numbers come in as strings. This causes the issue where an event may pass tests when expecting a number, but then throw errors relating to the wrong type being expected in real life.
The issue is in the test repository: https://github.com/xAPI-vle/moodle-logstore_xapi/blob/master/src/transformer/repos/TestRepository.php#L43
if ($record->$key === $value) {
I think should be:
if ($record->$key === intval($value)) {
While we're in there, there seem to be logic issues around multiple query parameters. The Moodle function will only return matches where all the query parameters match, however it looks to me that the test repo will return records where ANY of the query parameters match:
foreach ($query as $key => $value) {
if ($record->$key === $value) {
$matchingrecords[] = (object) $record;
}
}
Interesting, I think you might be right with both of those. I believe when I started making the test data I used numbers instead of strings because I was creating the test data as I saw it from snapshots of the database for particular events.