mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 12:32:08 +02:00
Merge branch 'MDL-43584_master' of git://github.com/dmonllao/moodle
This commit is contained in:
commit
718f42ae68
@ -8,9 +8,9 @@ Feature: An administrator can filter user accounts by role, cohort and other pro
|
||||
Given the following "users" exists:
|
||||
| username | firstname | lastname | email | auth | confirmed |
|
||||
| user1 | User | One | one@asd.com | manual | 0 |
|
||||
| user2 | User | Two | one@asd.com | ldap | 1 |
|
||||
| user3 | User | Three | one@asd.com | manual | 1 |
|
||||
| user4 | User | Four | one@asd.com | ldap | 0 |
|
||||
| user2 | User | Two | two@asd.com | ldap | 1 |
|
||||
| user3 | User | Three | three@asd.com | manual | 1 |
|
||||
| user4 | User | Four | four@asd.com | ldap | 0 |
|
||||
And the following "cohorts" exists:
|
||||
| name | idnumber |
|
||||
| Cohort 1 | CH1 |
|
||||
@ -23,8 +23,8 @@ Feature: An administrator can filter user accounts by role, cohort and other pro
|
||||
| user2 | C1 | student |
|
||||
| user3 | C1 | student |
|
||||
And I log in as "admin"
|
||||
And I add "user2" user to "CH1" cohort
|
||||
And I add "user3" user to "CH1" cohort
|
||||
And I add "User Two (two@asd.com)" user to "CH1" cohort members
|
||||
And I add "User Three (three@asd.com)" user to "CH1" cohort members
|
||||
And I follow "Browse list of users"
|
||||
|
||||
@javascript
|
||||
|
@ -35,8 +35,8 @@ Feature: Add cohorts of users
|
||||
|
||||
@javascript
|
||||
Scenario: Add users to a cohort selecting them from the system users list
|
||||
When I add "user1" user to "333" cohort
|
||||
And I add "user2" user to "333" cohort
|
||||
When I add "First User (first@user.com)" user to "333" cohort members
|
||||
And I add "Second User (second@user.com)" user to "333" cohort members
|
||||
Then I should see "2" in the "#cohorts" "css_element"
|
||||
And I follow "Assign"
|
||||
And the "Current users" select box should contain "First User (first@user.com)"
|
||||
|
@ -40,39 +40,49 @@ use Behat\Behat\Context\Step\Given as Given;
|
||||
class behat_cohort extends behat_base {
|
||||
|
||||
/**
|
||||
* Adds the user to the specified cohort.
|
||||
* Adds the user to the specified cohort. The user should be specified like "Firstname Lastname (user@email.com)".
|
||||
*
|
||||
* @Given /^I add "(?P<user_username_string>(?:[^"]|\\")*)" user to "(?P<cohort_idnumber_string>(?:[^"]|\\")*)" cohort$/
|
||||
* @param string $username
|
||||
* @Given /^I add "(?P<user_fullname_string>(?:[^"]|\\")*)" user to "(?P<cohort_idnumber_string>(?:[^"]|\\")*)" cohort members$/
|
||||
* @param string $user
|
||||
* @param string $cohortidnumber
|
||||
*/
|
||||
public function i_add_user_to_cohort($username, $cohortidnumber) {
|
||||
global $DB;
|
||||
|
||||
// The user was created by the data generator, executed by the same PHP process that is
|
||||
// running this step, not by any Selenium action.
|
||||
$userid = $DB->get_field('user', 'id', array('username' => $username));
|
||||
public function i_add_user_to_cohort_members($user, $cohortidnumber) {
|
||||
|
||||
$steps = array(
|
||||
new Given('I click on "' . get_string('assign', 'cohort') . '" "link" in the "' . $this->escape($cohortidnumber) . '" "table_row"'),
|
||||
new Given('I select "' . $userid . '" from "' . get_string('potusers', 'cohort') . '"'),
|
||||
new Given('I select "' . $this->escape($user) . '" from "' . get_string('potusers', 'cohort') . '"'),
|
||||
new Given('I press "' . get_string('add') . '"'),
|
||||
new Given('I press "' . get_string('backtocohorts', 'cohort') . '"')
|
||||
);
|
||||
|
||||
// If we are not in the cohorts management we should move there before anything else.
|
||||
if (!$this->getSession()->getPage()->find('css', 'input#cohort_search_q')) {
|
||||
$steps = array_merge(
|
||||
array(
|
||||
new Given('I am on homepage'),
|
||||
new Given('I collapse "' . get_string('frontpagesettings', 'admin') . '" node'),
|
||||
new Given('I expand "' . get_string('administrationsite') . '" node'),
|
||||
new Given('I expand "' . get_string('users', 'admin') . '" node'),
|
||||
new Given('I expand "' . get_string('accounts', 'admin') . '" node'),
|
||||
new Given('I follow "' . get_string('cohorts', 'cohort') . '"')
|
||||
),
|
||||
$steps
|
||||
);
|
||||
|
||||
// With JS enabled we should expand a few tree nodes.
|
||||
if ($this->running_javascript()) {
|
||||
$steps = array_merge(
|
||||
array(
|
||||
new Given('I am on homepage'),
|
||||
new Given('I collapse "' . get_string('frontpagesettings', 'admin') . '" node'),
|
||||
new Given('I expand "' . get_string('administrationsite') . '" node'),
|
||||
new Given('I expand "' . get_string('users', 'admin') . '" node'),
|
||||
new Given('I expand "' . get_string('accounts', 'admin') . '" node'),
|
||||
new Given('I follow "' . get_string('cohorts', 'cohort') . '"')
|
||||
),
|
||||
$steps
|
||||
);
|
||||
|
||||
} else {
|
||||
// JS disabled.
|
||||
$steps = array_merge(
|
||||
array(
|
||||
new Given('I am on homepage'),
|
||||
new Given('I follow "' . get_string('administrationsite') . '" node'),
|
||||
new Given('I follow "' . get_string('cohorts', 'cohort') . '"')
|
||||
),
|
||||
$steps
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $steps;
|
||||
|
@ -40,18 +40,16 @@ use Behat\Mink\Exception\ElementNotFoundException as ElementNotFoundException;
|
||||
class behat_groups extends behat_base {
|
||||
|
||||
/**
|
||||
* Add the specified user to the group. You should be in the groups page when running this step.
|
||||
* Add the specified user to the group. You should be in the groups page when running this step. The user should be specified like "Firstname Lastname (user@email.com)".
|
||||
*
|
||||
* @Given /^I add "(?P<username_string>(?:[^"]|\\")*)" user to "(?P<group_name_string>(?:[^"]|\\")*)" group$/
|
||||
* @Given /^I add "(?P<user_fullname_string>(?:[^"]|\\")*)" user to "(?P<group_name_string>(?:[^"]|\\")*)" group members$/
|
||||
* @throws ElementNotFoundException Thrown by behat_base::find
|
||||
* @param string $username
|
||||
* @param string $groupname
|
||||
*/
|
||||
public function i_add_user_to_group($username, $groupname) {
|
||||
global $DB;
|
||||
public function i_add_user_to_group_members($userfullname, $groupname) {
|
||||
|
||||
$user = $DB->get_record('user', array('username' => $username));
|
||||
$userfullname = $this->getSession()->getSelectorsHandler()->xpathLiteral(fullname($user));
|
||||
$userfullname = $this->getSession()->getSelectorsHandler()->xpathLiteral($userfullname);
|
||||
|
||||
// Using a xpath liternal to avoid problems with quotes and double quotes.
|
||||
$groupname = $this->getSession()->getSelectorsHandler()->xpathLiteral($groupname);
|
||||
|
@ -35,10 +35,10 @@ Feature: Organize students into groups
|
||||
And I fill the moodle form with:
|
||||
| Group name | Group 2 |
|
||||
And I press "Save changes"
|
||||
When I add "student0" user to "Group 1" group
|
||||
And I add "student1" user to "Group 1" group
|
||||
And I add "student2" user to "Group 2" group
|
||||
And I add "student3" user to "Group 2" group
|
||||
When I add "Student 0 (student0@asd.com)" user to "Group 1" group members
|
||||
And I add "Student 1 (student1@asd.com)" user to "Group 1" group members
|
||||
And I add "Student 2 (student2@asd.com)" user to "Group 2" group members
|
||||
And I add "Student 3 (student3@asd.com)" user to "Group 2" group members
|
||||
Then I select "Group 1 (2)" from "groups"
|
||||
And the "members" select box should contain "Student 0"
|
||||
And the "members" select box should contain "Student 1"
|
||||
|
@ -60,16 +60,7 @@ class behat_deprecated extends behat_base {
|
||||
'" in the "' . $this->escape($tablerowtext) . '" "table_row"';
|
||||
$this->deprecated_message($alternative);
|
||||
|
||||
// The table row container.
|
||||
$nocontainerexception = new ElementNotFoundException($this->getSession(), '"' . $tablerowtext . '" row text ');
|
||||
$tablerowtext = $this->getSession()->getSelectorsHandler()->xpathLiteral($tablerowtext);
|
||||
$rownode = $this->find('xpath', "//tr[contains(., $tablerowtext)]", $nocontainerexception);
|
||||
|
||||
// Looking for the element DOM node inside the specified row.
|
||||
list($selector, $locator) = $this->transform_selector($selectortype, $element);
|
||||
$elementnode = $this->find($selector, $locator, false, $rownode);
|
||||
$this->ensure_element_is_visible($elementnode);
|
||||
$elementnode->click();
|
||||
return new Given($alternative);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -233,6 +224,84 @@ class behat_deprecated extends behat_base {
|
||||
return array(new Given($alternative));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a message to the specified user from the logged user.
|
||||
*
|
||||
* @deprecated since 2.7
|
||||
* @todo MDL-42862 This will be deleted in Moodle 2.9
|
||||
* @see behat_message::i_send_message_to_user()
|
||||
*
|
||||
* @Given /^I send "(?P<message_contents_string>(?:[^"]|\\")*)" message to "(?P<username_string>(?:[^"]|\\")*)"$/
|
||||
* @throws ElementNotFoundException
|
||||
* @param string $messagecontent
|
||||
* @param string $tousername
|
||||
*/
|
||||
public function i_send_message_to_user($messagecontent, $tousername) {
|
||||
|
||||
global $DB;
|
||||
|
||||
// Runs by CLI, same PHP process that created the user.
|
||||
$touser = $DB->get_record('user', array('username' => $tousername));
|
||||
if (!$touser) {
|
||||
throw new ElementNotFoundException($this->getSession(), '"' . $tousername . '" ');
|
||||
}
|
||||
$tofullname = fullname($touser);
|
||||
|
||||
$alternative = 'I send "' . $this->escape($messagecontent) . '" message to "' . $tofullname . '" user';
|
||||
$this->deprecated_message($alternative);
|
||||
return new Given($alternative);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the user to the specified cohort.
|
||||
*
|
||||
* @deprecated since 2.7
|
||||
* @todo MDL-42862 This will be deleted in Moodle 2.9
|
||||
* @see behat_cohort::i_add_user_to_cohort_members()
|
||||
*
|
||||
* @Given /^I add "(?P<user_username_string>(?:[^"]|\\")*)" user to "(?P<cohort_idnumber_string>(?:[^"]|\\")*)" cohort$/
|
||||
* @param string $username
|
||||
* @param string $cohortidnumber
|
||||
*/
|
||||
public function i_add_user_to_cohort($username, $cohortidnumber) {
|
||||
global $DB;
|
||||
|
||||
// The user was created by the data generator, executed by the same PHP process that is
|
||||
// running this step, not by any Selenium action.
|
||||
$user = $DB->get_record('user', array('username' => $username));
|
||||
$userlocator = $user->firstname . ' ' . $user->lastname . ' (' . $user->email . ')';
|
||||
|
||||
$alternative = 'I add "' . $this->escape($userlocator) .
|
||||
'" user to "' . $this->escape($cohortidnumber) . '" cohort members';
|
||||
$this->deprecated_message($alternative);
|
||||
|
||||
return new Given($alternative);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the specified user to the group. You should be in the groups page when running this step.
|
||||
*
|
||||
* @deprecated since 2.7
|
||||
* @todo MDL-42862 This will be deleted in Moodle 2.9
|
||||
* @see behat_groups::i_add_user_to_group_members()
|
||||
*
|
||||
* @Given /^I add "(?P<username_string>(?:[^"]|\\")*)" user to "(?P<group_name_string>(?:[^"]|\\")*)" group$/
|
||||
* @param string $username
|
||||
* @param string $groupname
|
||||
*/
|
||||
public function i_add_user_to_group($username, $groupname) {
|
||||
global $DB;
|
||||
|
||||
$user = $DB->get_record('user', array('username' => $username));
|
||||
$userfullname = fullname($user);
|
||||
|
||||
$alternative = 'I add "' . $this->escape($userfullname) .
|
||||
'" user to "' . $this->escape($groupname) . '" group members';
|
||||
$this->deprecated_message($alternative);
|
||||
|
||||
return new Given($alternative);
|
||||
}
|
||||
|
||||
/**
|
||||
* Throws an exception if $CFG->behat_usedeprecated is not allowed.
|
||||
*
|
||||
|
@ -41,23 +41,13 @@ use Behat\Behat\Context\Step\Given as Given,
|
||||
class behat_message extends behat_base {
|
||||
|
||||
/**
|
||||
* Sends a message to the specified user from the logged user.
|
||||
* Sends a message to the specified user from the logged user. The user full name should contain the first and last names.
|
||||
*
|
||||
* @Given /^I send "(?P<message_contents_string>(?:[^"]|\\")*)" message to "(?P<username_string>(?:[^"]|\\")*)"$/
|
||||
* @throws ElementNotFoundException
|
||||
* @Given /^I send "(?P<message_contents_string>(?:[^"]|\\")*)" message to "(?P<user_full_name_string>(?:[^"]|\\")*)" user$/
|
||||
* @param string $messagecontent
|
||||
* @param string $tousername
|
||||
* @param string $userfullname
|
||||
*/
|
||||
public function i_send_message_to_user($messagecontent, $tousername) {
|
||||
|
||||
global $DB;
|
||||
|
||||
// Runs by CLI, same PHP process that created the user.
|
||||
$touser = $DB->get_record('user', array('username' => $tousername));
|
||||
if (!$touser) {
|
||||
throw new ElementNotFoundException($this->getSession(), '"' . $tousername . '" ');
|
||||
}
|
||||
$tofullname = fullname($touser);
|
||||
public function i_send_message_to_user($messagecontent, $userfullname) {
|
||||
|
||||
$steps = array();
|
||||
$steps[] = new Given('I am on homepage');
|
||||
@ -67,9 +57,9 @@ class behat_message extends behat_base {
|
||||
}
|
||||
|
||||
$steps[] = new Given('I follow "' . get_string('messages', 'message') . '"');
|
||||
$steps[] = new Given('I fill in "' . get_string('searchcombined', 'message') . '" with "' . $this->escape($tofullname) . '"');
|
||||
$steps[] = new Given('I fill in "' . get_string('searchcombined', 'message') . '" with "' . $this->escape($userfullname) . '"');
|
||||
$steps[] = new Given('I press "' . get_string('searchcombined', 'message') . '"');
|
||||
$steps[] = new Given('I follow "' . $this->escape(get_string('sendmessageto', 'message', $tofullname)) . '"');
|
||||
$steps[] = new Given('I follow "' . $this->escape(get_string('sendmessageto', 'message', $userfullname)) . '"');
|
||||
$steps[] = new Given('I fill in "id_message" with "' . $this->escape($messagecontent) . '"');
|
||||
$steps[] = new Given('I press "' . get_string('sendmessage', 'message') . '"');
|
||||
|
||||
|
@ -10,16 +10,16 @@ Feature: Message history displays correctly
|
||||
| user1 | User | One | one@asd.com |
|
||||
| user2 | User | Two | two@asd.com |
|
||||
And I log in as "user1"
|
||||
And I send "Message 1 from user1 to user2" message to "user2"
|
||||
And I send "Message 2 from user1 to user2" message to "user2"
|
||||
And I send "Message 3 from user1 to user2" message to "user2"
|
||||
And I send "Message 4 from user1 to user2" message to "user2"
|
||||
And I send "Message 5 from user1 to user2" message to "user2"
|
||||
And I send "Message 6 from user1 to user2" message to "user2"
|
||||
And I send "Message 7 from user1 to user2" message to "user2"
|
||||
And I send "Message 8 from user1 to user2" message to "user2"
|
||||
And I send "Message 9 from user1 to user2" message to "user2"
|
||||
And I send "Message 10 from user1 to user2" message to "user2"
|
||||
And I send "Message 1 from user1 to user2" message to "User Two" user
|
||||
And I send "Message 2 from user1 to user2" message to "User Two" user
|
||||
And I send "Message 3 from user1 to user2" message to "User Two" user
|
||||
And I send "Message 4 from user1 to user2" message to "User Two" user
|
||||
And I send "Message 5 from user1 to user2" message to "User Two" user
|
||||
And I send "Message 6 from user1 to user2" message to "User Two" user
|
||||
And I send "Message 7 from user1 to user2" message to "User Two" user
|
||||
And I send "Message 8 from user1 to user2" message to "User Two" user
|
||||
And I send "Message 9 from user1 to user2" message to "User Two" user
|
||||
And I send "Message 10 from user1 to user2" message to "User Two" user
|
||||
|
||||
Scenario: View sent messages
|
||||
When I expand "My profile" node
|
||||
|
@ -10,8 +10,8 @@ Feature: Manage contacts
|
||||
| user1 | User | One | one@asd.com |
|
||||
| user2 | User | Two | two@asd.com |
|
||||
And I log in as "user1"
|
||||
And I send "Message 1 from user1 to user2" message to "user2"
|
||||
And I send "Message 2 from user1 to user2" message to "user2"
|
||||
And I send "Message 1 from user1 to user2" message to "User Two" user
|
||||
And I send "Message 2 from user1 to user2" message to "User Two" user
|
||||
And I expand "My profile" node
|
||||
And I click on "Messages" "link" in the "Navigation" "block"
|
||||
And I fill in "Search people and messages" with "User Two"
|
||||
|
@ -10,7 +10,7 @@ Feature: Users can search their message history
|
||||
| user1 | User | One | one@asd.com |
|
||||
| user2 | User | Two | two@asd.com |
|
||||
And I log in as "user1"
|
||||
When I send "Give me your biscuits" message to "user2"
|
||||
When I send "Give me your biscuits" message to "User Two" user
|
||||
And I expand "My profile" node
|
||||
And I click on "Messages" "link" in the "Navigation" "block"
|
||||
And I fill in "Search people and messages" with "your biscuits"
|
||||
|
@ -50,8 +50,8 @@ Feature: Group assignment submissions
|
||||
And I press "Save changes"
|
||||
And I expand "Users" node
|
||||
And I follow "Groups"
|
||||
And I add "student0" user to "Group 1" group
|
||||
And I add "student1" user to "Group 1" group
|
||||
And I add "Student 0 (student0@asd.com)" user to "Group 1" group members
|
||||
And I add "Student 1 (student1@asd.com)" user to "Group 1" group members
|
||||
And I follow "Course 1"
|
||||
And I follow "Test assignment name"
|
||||
And I follow "View/grade all submissions"
|
||||
|
Loading…
x
Reference in New Issue
Block a user