mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
MDL-75148 mod_data: Implement preset behat generator
This commit is contained in:
parent
13264c7107
commit
ad0595b4b4
@ -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.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user