It seems like the $wgUser is sometimes set to group wbeditor and sometimes to sysop. When it is set to sysop testing of permissions will sometimes fail because of failed assumptions.
A typical run where this bug shows up is for group Wikibase and gives six failures in testCheckPermission and testUserCan. Other groups, or combinations of groups, will give other permission related errors.
It is available a workaround in Change Iaa705f72: "Workaround for failing tests", but any tests that manipulates the $wgUser should save previous state and restore it on exit. The tests for EditEntity seems to do this right (saved in $userGroups) but EditContentTest and subclasses seems to fail on this. When the method testCheckPermission or testUserCan is called the permission checks are triggered, and then they will fail sometimes because the user is either a sysop or wbeditor and they have different rights.
Version: unspecified
Severity: normal