diff --git a/lib/behat/classes/behat_core_generator.php b/lib/behat/classes/behat_core_generator.php index 7f900ae3ade..c39bf93099a 100644 --- a/lib/behat/classes/behat_core_generator.php +++ b/lib/behat/classes/behat_core_generator.php @@ -120,7 +120,7 @@ class behat_core_generator extends behat_generator_base { 'activities' => [ 'singular' => 'activity', 'datagenerator' => 'activity', - 'required' => ['activity', 'idnumber', 'course'], + 'required' => ['activity', 'course'], 'switchids' => ['course' => 'course', 'gradecategory' => 'gradecat', 'grouping' => 'groupingid'], ], 'blocks' => [ @@ -389,6 +389,17 @@ class behat_core_generator extends behat_generator_base { } } + if (!array_key_exists('idnumber', $data)) { + $data['idnumber'] = $data['name']; + if (strlen($data['name']) > 100) { + throw new Exception( + "Activity '{$activityname}' cannot be used as the default idnumber. " . + "The idnumber has a max length of 100 chars. " . + "Please manually specify an idnumber." + ); + } + } + // We split $data in the activity $record and the course module $options. $cmoptions = array(); $cmcolumns = $DB->get_columns('course_modules');