MDL-83881 question: Switch user ids in updated questions

Add switching of "modifiedby" and "createdby" usernames for user ids in
the "updated questions" behat creatable entity.
This commit is contained in:
Mark Johnson
2025-03-06 11:42:30 +00:00
parent 5670447ece
commit d5397fee96
@@ -45,7 +45,12 @@ class behat_core_question_generator extends behat_generator_base {
'singular' => 'question',
'datagenerator' => 'updated_question',
'required' => ['question', 'questioncategory'],
'switchids' => ['question' => 'id', 'questioncategory' => 'category'],
'switchids' => [
'question' => 'id',
'questioncategory' => 'category',
'modifiedbyuser' => 'modifiedby',
'createdbyuser' => 'createdby',
],
],
];
}
@@ -65,6 +70,26 @@ class behat_core_question_generator extends behat_generator_base {
return $id;
}
/**
* Look up the id of the createdby user from their username
*
* @param string $username The username for the createdby user.
* @return int The user ID.
*/
protected function get_createdbyuser_id(string $username): int {
return $this->get_user_id($username);
}
/**
* Look up the id of the modifiedby user from their username
*
* @param string $username The username for the modifiedby user.
* @return int The user ID.
*/
protected function get_modifiedbyuser_id(string $username): int {
return $this->get_user_id($username);
}
/**
* Update a question
*