From 33c67b74aa897a562e0e864313201696cbc7b849 Mon Sep 17 00:00:00 2001 From: Andrew Hancox Date: Fri, 24 Nov 2017 15:29:23 +0000 Subject: [PATCH] MDL-60801 tool_uploaduser: Fix issue with defaults being ignored --- admin/tool/uploaduser/index.php | 2 +- .../tests/behat/upload_users.feature | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/admin/tool/uploaduser/index.php b/admin/tool/uploaduser/index.php index d11332b23a4..496b52dd1ac 100644 --- a/admin/tool/uploaduser/index.php +++ b/admin/tool/uploaduser/index.php @@ -358,7 +358,7 @@ if ($formdata = $mform2->is_cancelled()) { // add default values for remaining fields $formdefaults = array(); - if ($updatetype != UU_UPDATE_FILEOVERRIDE && $updatetype != UU_UPDATE_NOCHANGES) { + if (!$existinguser || ($updatetype != UU_UPDATE_FILEOVERRIDE && $updatetype != UU_UPDATE_NOCHANGES)) { foreach ($STD_FIELDS as $field) { if (isset($user->$field)) { continue; diff --git a/admin/tool/uploaduser/tests/behat/upload_users.feature b/admin/tool/uploaduser/tests/behat/upload_users.feature index e217cf13765..1ee26f45ca2 100644 --- a/admin/tool/uploaduser/tests/behat/upload_users.feature +++ b/admin/tool/uploaduser/tests/behat/upload_users.feature @@ -38,6 +38,31 @@ Feature: Upload users And I set the field "groups" to "Section 1 (1)" And the "members" select box should contain "Tom Jones" + @javascript + Scenario: Upload users enrolling them on courses and groups applying defaults + Given the following "courses" exist: + | fullname | shortname | category | + | Maths | math102 | 0 | + And the following "groups" exist: + | name | course | idnumber | + | Section 1 | math102 | S1 | + | Section 3 | math102 | S3 | + And I log in as "admin" + And I navigate to "Upload users" node in "Site administration > Users > Accounts" + When I upload "lib/tests/fixtures/upload_users.csv" file to "File" filemanager + And I press "Upload users" + And I set the following fields to these values: + | City/town | Brighton | + | Department | Purchasing | + And I press "Upload users" + And I press "Continue" + And I navigate to "Users > Accounts > Browse list of users" in site administration + And I should see "Tom Jones" + And I follow "Tom Jones" + And I follow "Edit profile" + And the field "City/town" matches value "Brighton" + And the field "Department" matches value "Purchasing" + @javascript Scenario: Upload users with custom profile fields # Create user profile field.