MDL-44620 behat: Automates MDLQA-6

- MDLQA-6: By default, a new course contains a news
forum in which only teachers can post and subscription
is forced
This commit is contained in:
David Monllao
2014-05-27 13:13:48 +07:00
parent 529d4cdbc6
commit 94ba162660
2 changed files with 69 additions and 0 deletions
@@ -0,0 +1,31 @@
@core @core_course
Feature: Managers can create courses
In order to group users and contents
As a manager
I need to create courses and set default values on them
@javascript
Scenario: Courses are created with the default forum and blocks
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@asd.com |
| student1 | Student | 1 | student1@asd.com |
And I log in as "admin"
And I create a course with:
| Course full name | Course 1 |
| Course short name | C1 |
And I enrol "Teacher 1" user as "Teacher"
And I enrol "Student 1" user as "Student"
And I log out
When I log in as "teacher1"
And I follow "Course 1"
Then "Latest news" "block" should exist
And I follow "News forum"
And "Add a new topic" "button" should exist
And "Forced subscription" "link" should not exist
And I log out
And I log in as "student1"
And I follow "Course 1"
And I follow "News forum"
And "Add a new topic" "button" should not exist
And I should see "Forced subscription" in the "Administration" "block"
+38
View File
@@ -58,4 +58,42 @@ class behat_enrol extends behat_base {
);
}
/**
* Enrols the specified user in the current course without options.
*
* This is a simple step, to set enrolment options would be better to
* create a separate step as a TableNode will be required.
*
* @Given /^I enrol "(?P<user_fullname_string>(?:[^"]|\\")*)" user as "(?P<rolename_string>(?:[^"]|\\")*)"$/
* @param string $userfullname
* @param string $rolename
* @return Given[]
*/
public function i_enrol_user_as($userfullname, $rolename) {
$steps = array(
new Given('I follow "' . get_string('enrolledusers', 'enrol') . '"'),
new Given('I press "' . get_string('enrolusers', 'enrol') . '"')
);
if ($this->running_javascript()) {
// We have a div here, not a tr.
$userliteral = $this->getSession()->getSelectorsHandler()->xpathLiteral($userfullname);
$userrowxpath = "//div[contains(concat(' ',normalize-space(@class),' '),' user ')][contains(., $userliteral)]";
$steps[] = new Given('I set the field "' . get_string('assignroles', 'role') . '" to "' . $rolename . '"');
$steps[] = new Given('I click on "' . get_string('enrol', 'enrol') . '" "button" in the "' . $userrowxpath . '" "xpath_element"');
$steps[] = new Given('I press "' . get_string('finishenrollingusers', 'enrol') . '"');
} else {
$steps[] = new Given('I set the field "' . get_string('assignrole', 'role') . '" to "' . $rolename . '"');
$steps[] = new Given('I set the field "addselect" to "' . $userfullname . '"');
$steps[] = new Given('I press "add"');
}
return $steps;
}
}