From d29be3200086c1aadf403d7d65f75f02c364a9cf Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Thu, 31 Aug 2017 12:32:03 +0800 Subject: [PATCH] MDL-59801 users: Behat fixes Firstly - the list of roles to filter needs to be a combination of the assignable roles and the existing roles in the course. Secondly - the auto-complete behat step needs to search for entire strings, not substrings. --- lib/tests/behat/behat_forms.php | 2 +- user/renderer.php | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/tests/behat/behat_forms.php b/lib/tests/behat/behat_forms.php index 9b5d2c74cb2..582602f7c4b 100644 --- a/lib/tests/behat/behat_forms.php +++ b/lib/tests/behat/behat_forms.php @@ -532,7 +532,7 @@ class behat_forms extends behat_base { * @param string $item */ public function i_click_on_item_in_the_autocomplete_list($item) { - $xpathtarget = "//ul[@class='form-autocomplete-suggestions']//*[contains(.,'" . $item . "')]"; + $xpathtarget = "//ul[@class='form-autocomplete-suggestions']//*[contains(concat('|', string(.), '|'),'|" . $item . "|')]"; $this->execute('behat_general::i_click_on', [$xpathtarget, 'xpath_element']); diff --git a/user/renderer.php b/user/renderer.php index aa824da7547..b7986d4dafe 100644 --- a/user/renderer.php +++ b/user/renderer.php @@ -282,11 +282,9 @@ class core_user_renderer extends plugin_renderer_base { // Filter options for role. $roleseditable = has_capability('moodle/role:assign', $context); - $roles = []; + $roles = role_fix_names(get_profile_roles($context), $context, ROLENAME_ALIAS, true); if ($roleseditable) { - $roles = get_assignable_roles($context, ROLENAME_ALIAS); - } else { - $roles = role_fix_names(get_profile_roles($context), $context, ROLENAME_ALIAS, true); + $roles += get_assignable_roles($context, ROLENAME_ALIAS); } $criteria = get_string('role'); $roleoptions = [];