From c85140350b96942405c1a3c13270eaebddf7bf49 Mon Sep 17 00:00:00 2001 From: Rex Lorenzo Date: Wed, 18 Feb 2015 12:58:55 -0800 Subject: [PATCH] MDL-46665 core_user: Add 'idnumber' field to user filter --- user/filters/lib.php | 3 +- user/tests/behat/filter_idnumber.feature | 64 ++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 user/tests/behat/filter_idnumber.feature diff --git a/user/filters/lib.php b/user/filters/lib.php index c26dc328af7..2d6c04a0cff 100644 --- a/user/filters/lib.php +++ b/user/filters/lib.php @@ -66,7 +66,7 @@ class user_filtering { $fieldnames = array('realname' => 0, 'lastname' => 1, 'firstname' => 1, 'username' => 1, 'email' => 1, 'city' => 1, 'country' => 1, 'confirmed' => 1, 'suspended' => 1, 'profile' => 1, 'courserole' => 1, 'systemrole' => 1, 'cohort' => 1, 'firstaccess' => 1, 'lastaccess' => 1, 'neveraccessed' => 1, 'timemodified' => 1, - 'nevermodified' => 1, 'auth' => 1, 'mnethostid' => 1); + 'nevermodified' => 1, 'auth' => 1, 'mnethostid' => 1, 'idnumber' => 1); } $this->_fields = array(); @@ -149,6 +149,7 @@ class user_filtering { case 'timemodified': return new user_filter_date('timemodified', get_string('lastmodified'), $advanced, 'timemodified'); case 'nevermodified': return new user_filter_checkbox('nevermodified', get_string('nevermodified', 'filters'), $advanced, array('timemodified', 'timecreated'), array('timemodified_sck', 'timemodified_eck')); case 'cohort': return new user_filter_cohort($advanced); + case 'idnumber': return new user_filter_text('idnumber', get_string('idnumber'), $advanced, 'idnumber'); case 'auth': $plugins = core_component::get_plugin_list('auth'); $choices = array(); diff --git a/user/tests/behat/filter_idnumber.feature b/user/tests/behat/filter_idnumber.feature new file mode 100644 index 00000000000..db8e4f50f83 --- /dev/null +++ b/user/tests/behat/filter_idnumber.feature @@ -0,0 +1,64 @@ +@core @core_user +Feature: Filter users by idnumber + As a system administrator + I need to be able to filter users by their ID number + So that I can quickly find users based on an external key. + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | idnumber | + | teacher1 | Teacher | 1 | teacher@asd.com | 0000002 | + | student1 | Student1 | 1 | student1@asd.com | 0000003 | + | student2 | Student2 | 1 | student2@asd.com | 2000000 | + | student3 | Student3 | 1 | student3@asd.com | 3000000 | + And I log in as "admin" + And I expand "Site administration" node + # Front page settings also has a "Users" node. + And I expand "Users" node + And I expand "Users" node + And I expand "Accounts" node + When I follow "Browse list of users" + + @javascript + Scenario: Filtering id numbers - with case "is empty" + # We should see see admin on the user list, the following e-mail is admin's e-mail. + Then I should see "moodle@moodlemoodle.com" in the "users" "table" + And I should see "Teacher" in the "users" "table" + And I should see "Student1" in the "users" "table" + And I should see "Student2" in the "users" "table" + And I should see "Student3" in the "users" "table" + And I follow "Show more..." + And I set the field "id_idnumber_op" to "is empty" + When I press "Add filter" + # We should see admin on the user list, the following e-mail is admin's e-mail. + Then I should see "moodle@moodlemoodle.com" in the "users" "table" + And I should not see "Teacher" in the "users" "table" + And I should not see "Student1" in the "users" "table" + And I should not see "Student2" in the "users" "table" + And I should not see "Student3" in the "users" "table" + + @javascript + Scenario Outline: Filtering id numbers - with all other cases + # We should see see admin on the user list, the following e-mail is admin's e-mail. + Then I should see "moodle@moodlemoodle.com" in the "users" "table" + And I should see "Teacher" in the "users" "table" + And I should see "Student1" in the "users" "table" + And I should see "Student2" in the "users" "table" + And I should see "Student3" in the "users" "table" + And I follow "Show more..." + And I set the field "id_idnumber_op" to "" + And I set the field "idnumber" to "" + When I press "Add filter" + Then I should "moodle@moodlemoodle.com" in the "users" "table" + And I should "Teacher" in the "users" "table" + And I should "Student1" in the "users" "table" + And I should "Student2" in the "users" "table" + And I should "Student3" in the "users" "table" + +Examples: + | Category | Argument | Admin's Visibility | Teacher's Vis | S1's Vis | S2's Vis | S3's Vis | + | contains | 0 | not see | see | see | see | see | + | doesn't contain | 2 | see | not see | see | not see | see | + | is equal to | 2000000 | not see | not see | not see | see | not see | + | starts with | 0 | not see | see | see | not see | not see | + | ends with | 0 | not see | not see | not see | see | see | \ No newline at end of file