Permalink
Browse files

MDL-42324 behat: New activities data generator

  • Loading branch information...
dmonllao committed Jul 16, 2013
1 parent d653929 commit 552af5abddd204483cda46b30a6fdb2ce5bda5a5
Showing with 40 additions and 0 deletions.
  1. +15 −0 admin/tool/behat/tests/behat/data_generators.feature
  2. +25 −0 lib/tests/behat/behat_data_generators.php
@@ -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 @@ protected function preprocess_user($data) {
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.

0 comments on commit 552af5a

Please sign in to comment.