MDL-66378 behat: Fix use of before/after selectors

This commit is contained in:
Andrew Nicols 2019-08-16 08:50:33 +08:00
parent 989f380089
commit 221bfed37b
3 changed files with 20 additions and 12 deletions

View file

@ -102,7 +102,7 @@ class core_question_generator extends component_generator_base {
* @param array|stdClass $overrides any fields that should be different from the base example.
*/
public function update_question($question, $which = null, $overrides = null) {
global $CFG;
global $CFG, $DB;
require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
$qtype = $question->qtype;
@ -113,7 +113,16 @@ class core_question_generator extends component_generator_base {
$fromform = (object) $this->datagenerator->combine_defaults_and_record(
(array) $fromform, $overrides);
return question_bank::get_qtype($qtype)->save_question($question, $fromform);
$question = question_bank::get_qtype($qtype)->save_question($question, $fromform);
if ($overrides && array_key_exists('createdby', $overrides)) {
// Manually update the createdby because questiontypebase forces current user and some tests require a
// specific user.
$question->createdby = $overrides['createdby'];
$DB->update_record('question', $question);
}
return $question;
}
/**