This commit is contained in:
Andrew Nicols 2020-12-03 11:39:13 +08:00
commit 9e12342aa5

View File

@ -225,7 +225,8 @@ class core_question_backup_testcase extends advanced_testcase {
// Create a question.
$questiongenerator = $this->getDataGenerator()->get_plugin_generator('core_question');
$questioncategory = $questiongenerator->create_question_category();
$overrides = ['category' => $questioncategory->id, 'createdby' => $user->id, 'modifiedby' => $user->id];
$overrides = ['name' => 'Test question', 'category' => $questioncategory->id,
'createdby' => $user->id, 'modifiedby' => $user->id];
$question = $questiongenerator->create_question('truefalse', null, $overrides);
// Create a quiz and a questions.
@ -261,7 +262,7 @@ class core_question_backup_testcase extends advanced_testcase {
$rc->destroy();
// Test the question author.
$questions = $DB->get_records('question');
$questions = $DB->get_records('question', ['name' => 'Test question']);
$this->assertCount(1, $questions);
$question3 = array_shift($questions);
$this->assertEquals($user->id, $question3->createdby);
@ -285,7 +286,8 @@ class core_question_backup_testcase extends advanced_testcase {
// Create a question.
$questiongenerator = $this->getDataGenerator()->get_plugin_generator('core_question');
$questioncategory = $questiongenerator->create_question_category();
$overrides = ['category' => $questioncategory->id, 'createdby' => $user->id, 'modifiedby' => $user->id];
$overrides = ['name' => 'Test question', 'category' => $questioncategory->id,
'createdby' => $user->id, 'modifiedby' => $user->id];
$question = $questiongenerator->create_question('truefalse', null, $overrides);
// Create a quiz and a questions.
@ -317,7 +319,7 @@ class core_question_backup_testcase extends advanced_testcase {
$rc->destroy();
// Test the question author.
$questions = $DB->get_records('question');
$questions = $DB->get_records('question', ['name' => 'Test question']);
$this->assertCount(1, $questions);
$question = array_shift($questions);
$this->assertEquals($user->id, $question->createdby);
@ -341,7 +343,8 @@ class core_question_backup_testcase extends advanced_testcase {
// Create a question.
$questiongenerator = $this->getDataGenerator()->get_plugin_generator('core_question');
$questioncategory = $questiongenerator->create_question_category();
$overrides = ['category' => $questioncategory->id, 'createdby' => $user->id, 'modifiedby' => $user->id];
$overrides = ['name' => 'Test question', 'category' => $questioncategory->id,
'createdby' => $user->id, 'modifiedby' => $user->id];
$question = $questiongenerator->create_question('truefalse', null, $overrides);
// Create a quiz and a questions.
@ -376,7 +379,7 @@ class core_question_backup_testcase extends advanced_testcase {
$rc->destroy();
// Test the question author.
$questions = $DB->get_records('question');
$questions = $DB->get_records('question', ['name' => 'Test question']);
$this->assertCount(1, $questions);
$question = array_shift($questions);
$this->assertEquals($USER->id, $question->createdby);