Skip to content

Commit

Permalink
MDL-70321 question backup: fix MDL-47178 unit tests
Browse files Browse the repository at this point in the history
They were failing if you had CodeRunner installed
  • Loading branch information
timhunt committed Nov 24, 2020
1 parent c8d33eb commit 32bd113
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions question/tests/backup_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ public function test_backup_question_author_retained_when_enrolled() {
// 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.
Expand Down Expand Up @@ -261,7 +262,7 @@ public function test_backup_question_author_retained_when_enrolled() {
$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);
Expand All @@ -285,7 +286,8 @@ public function test_backup_question_author_retained_when_not_enrolled() {
// 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.
Expand Down Expand Up @@ -317,7 +319,7 @@ public function test_backup_question_author_retained_when_not_enrolled() {
$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);
Expand All @@ -341,7 +343,8 @@ public function test_backup_question_author_reset() {
// 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.
Expand Down Expand Up @@ -376,7 +379,7 @@ public function test_backup_question_author_reset() {
$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);
Expand Down

0 comments on commit 32bd113

Please sign in to comment.