MDL-42324 behat: New activities data generator
This commit is contained in:
committed by
David Monllao
parent
d653929fde
commit
552af5abdd
@@ -107,6 +107,21 @@ Feature: Set up contextual data for tests
|
||||
And I follow "Course 1"
|
||||
And I should see "Turn editing on"
|
||||
|
||||
Scenario: Add modules
|
||||
Given the following "courses" exists:
|
||||
| fullname | shortname |
|
||||
| Course 1 | C1 |
|
||||
And the following "activities" exists:
|
||||
| activity | name | intro | course | idnumber |
|
||||
| assign | Test assignment name | Test assignment description | C1 | assign1 |
|
||||
| data | Test database name | Test database description | C1 | data1 |
|
||||
When I log in as "admin"
|
||||
And I follow "Course 1"
|
||||
Then I should see "Test assignment name"
|
||||
And I should see "Test database name"
|
||||
And I follow "Test assignment name"
|
||||
And I should see "Test assignment description"
|
||||
|
||||
@javascript
|
||||
Scenario: Add relations between users and groups
|
||||
Given the following "users" exists:
|
||||
|
||||
@@ -103,6 +103,11 @@ class behat_data_generators extends behat_base {
|
||||
'required' => array('user', 'role', 'contextlevel', 'reference'),
|
||||
'switchids' => array('user' => 'userid', 'role' => 'roleid')
|
||||
),
|
||||
'activities' => array(
|
||||
'datagenerator' => 'activity',
|
||||
'required' => array('activity', 'idnumber', 'course'),
|
||||
'switchids' => array('course' => 'course')
|
||||
),
|
||||
'group members' => array(
|
||||
'datagenerator' => 'group_member',
|
||||
'required' => array('user', 'group'),
|
||||
@@ -203,6 +208,26 @@ class behat_data_generators extends behat_base {
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapter to modules generator
|
||||
* @throws Exception Custom exception for test writers
|
||||
* @param array $data
|
||||
* @return void
|
||||
*/
|
||||
protected function process_activity($data) {
|
||||
|
||||
// The the_following_exists() method checks that the field exists.
|
||||
$activityname = $data['activity'];
|
||||
unset($data['activity']);
|
||||
|
||||
// Custom exception.
|
||||
try {
|
||||
$this->datagenerator->create_module($activityname, $data);
|
||||
} catch (coding_exception $e) {
|
||||
throw new Exception('\'' . $activityname . '\' activity can not be added using this step,' .
|
||||
' use the step \'I add a "ACTIVITY_OR_RESOURCE_NAME_STRING" to section "SECTION_NUMBER"\' instead');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapter to enrol_user() data generator.
|
||||
|
||||
Reference in New Issue
Block a user