This issue relates to MDLQA-144. A student cannot use a valid group enrolment key to enrol in a course or be sorted into a pre-configured group.
This test requires a course in which self-enrolment is allowed and for which an enrolment key has been set.
1. Login as a teacher, access a course and follow the groups link in the course administration settings.
2. Create a group and set a group enrolment key.
3. Login as user1 (not yet enrolled in the course) and enrol in the course by supplying the course enrolment key.
4. Login as user2 (not yet enrolled in the course) and enrol in the course by supplying the group enrolment key.
5. Login as the teacher again, access the participants page and check that user2 is a member of the group whereas user1 is not.
Steps 1-3, 5a: pass
Step 4: fail - cannot login with valid group enrolment key
Step 5: user 1 enrols as an ungrouped student, user2 cannot enrol and is not grouped.