From e195cb39059f5339248f58fbbdcd9bb38ba4271a Mon Sep 17 00:00:00 2001 From: Kim Jared Lucas Date: Tue, 20 Jan 2026 10:37:23 +0800 Subject: [PATCH] MDL-87092 tool_uploaduser: suspend enrolments via CSV upload --- .../behat/suspend_user_enrolment.feature | 41 +++++++++++++++++++ lib/tests/fixtures/QA_user_enrol.txt | 3 ++ lib/tests/fixtures/QA_user_suspend.txt | 3 ++ 3 files changed, 47 insertions(+) create mode 100644 admin/tool/uploaduser/tests/behat/suspend_user_enrolment.feature create mode 100644 lib/tests/fixtures/QA_user_enrol.txt create mode 100644 lib/tests/fixtures/QA_user_suspend.txt diff --git a/admin/tool/uploaduser/tests/behat/suspend_user_enrolment.feature b/admin/tool/uploaduser/tests/behat/suspend_user_enrolment.feature new file mode 100644 index 00000000000..cdbdef176b4 --- /dev/null +++ b/admin/tool/uploaduser/tests/behat/suspend_user_enrolment.feature @@ -0,0 +1,41 @@ +@tool @tool_uploaduser @_file_upload +Feature: Admin can suspend user course enrolment via CSV upload + In order to manage enrolments in bulk + As an administrator + I need to be able to enrol and suspend users using CSV upload + + Background: + Given the following "courses" exist: + | fullname | shortname | + | Course 1 | C1 | + | Course 2 | C2 | + | Course 3 | C3 | + + @javascript + Scenario: Admin uploads enrol and suspend CSVs and verifies enrolment status + Given I log in as "admin" + And I navigate to "Users > Accounts > Upload users" in site administration + When I upload "lib/tests/fixtures/QA_user_enrol.txt" file to "File" filemanager + And I press "Upload users" + And I press "Upload users" + And I press "Continue" + And I upload "lib/tests/fixtures/QA_user_suspend.txt" file to "File" filemanager + And I press "Upload users" + And I set the field "Upload type" to "Update existing users only" + And I press "Upload users" + And I press "Continue" + And I am on the "Course 1" "enrolled users" page + Then the following should exist in the "participants" table: + | First name | Status | + | Learner One | Active | + | Learner Two | Active | + And I am on the "Course 2" "enrolled users" page + And the following should exist in the "participants" table: + | First name | Status | + | Learner One | Active | + | Learner Two | Suspended | + And I am on the "Course 3" "enrolled users" page + And the following should exist in the "participants" table: + | First name | Status | + | Learner One | Suspended | + | Learner Two | Active | diff --git a/lib/tests/fixtures/QA_user_enrol.txt b/lib/tests/fixtures/QA_user_enrol.txt new file mode 100644 index 00000000000..a33aead4857 --- /dev/null +++ b/lib/tests/fixtures/QA_user_enrol.txt @@ -0,0 +1,3 @@ +username,firstname,lastname,email,course1,role1,course2,role2,course3,role3 +learner1,Learner,One,learner1@example.com,C1,student,C2,student,C3,student +learner2,Learner,Two,learner2@example.com,C1,student,C2,student,C3,student diff --git a/lib/tests/fixtures/QA_user_suspend.txt b/lib/tests/fixtures/QA_user_suspend.txt new file mode 100644 index 00000000000..dadc2fb3960 --- /dev/null +++ b/lib/tests/fixtures/QA_user_suspend.txt @@ -0,0 +1,3 @@ +username,course1,role1,enrolstatus1,course2,role2,enrolstatus2,course3,role3,enrolstatus3 +learner1,C1,student,0,C2,student,0,C3,student,1 +learner2,C1,student,0,C2,student,1,C3,student,0