From 041cf62b1da4907c230718f14a55466ee24e93db Mon Sep 17 00:00:00 2001 From: David Monllao Date: Tue, 15 Oct 2013 18:08:31 +0800 Subject: [PATCH] MDL-42362 behat: Passing options to modules generators --- lib/tests/behat/behat_data_generators.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/tests/behat/behat_data_generators.php b/lib/tests/behat/behat_data_generators.php index 007ce54435f..0a5b39007a7 100644 --- a/lib/tests/behat/behat_data_generators.php +++ b/lib/tests/behat/behat_data_generators.php @@ -224,14 +224,24 @@ class behat_data_generators extends behat_base { * @return void */ protected function process_activity($data) { + global $DB; // The the_following_exists() method checks that the field exists. $activityname = $data['activity']; unset($data['activity']); + // We split $data in the activity $record and the course module $options. + $cmoptions = array(); + $cmcolumns = $DB->get_columns('course_modules'); + foreach ($cmcolumns as $key => $value) { + if (isset($data[$key])) { + $cmoptions[$key] = $data[$key]; + } + } + // Custom exception. try { - $this->datagenerator->create_module($activityname, $data); + $this->datagenerator->create_module($activityname, $data, $cmoptions); } 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');