MDL-75148 mod_data: Implement preset behat generator

This commit is contained in:
Sara Arjona 2022-07-11 18:26:23 +02:00
parent 13264c7107
commit ad0595b4b4

View File

@ -49,6 +49,12 @@ class behat_mod_data_generator extends behat_generator_base {
'required' => ['database', 'name'],
'switchids' => ['database' => 'databaseid'],
],
'presets' => [
'singular' => 'preset',
'datagenerator' => 'preset',
'required' => ['database', 'name'],
'switchids' => ['database' => 'databaseid'],
],
];
}
@ -124,6 +130,19 @@ class behat_mod_data_generator extends behat_generator_base {
}
}
/**
* Saves a preset.
*
* @param array $data Preset data.
*/
protected function process_preset(array $data): void {
global $DB;
$instance = $DB->get_record('data', ['id' => $data['databaseid']], '*', MUST_EXIST);
$this->get_data_generator()->create_preset($instance, (object) $data);
}
/**
* Get the module data generator.
*