Skip to content

Commit

Permalink
MDL-75148 mod_data: Implement preset behat generator
Browse files Browse the repository at this point in the history
  • Loading branch information
sarjona committed Aug 1, 2022
1 parent 13264c7 commit ad0595b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions mod/data/tests/generator/behat_mod_data_generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ protected function get_creatable_entities(): array {
'required' => ['database', 'name'],
'switchids' => ['database' => 'databaseid'],
],
'presets' => [
'singular' => 'preset',
'datagenerator' => 'preset',
'required' => ['database', 'name'],
'switchids' => ['database' => 'databaseid'],
],
];
}

Expand Down Expand Up @@ -124,6 +130,19 @@ public function process_template(array $data): void {
}
}

/**
* 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.
*
Expand Down

0 comments on commit ad0595b

Please sign in to comment.