Skip to content

Commit

Permalink
MDL-81482 Questions: Fix questionlib_test PHPUnit tests
Browse files Browse the repository at this point in the history
AnupamaSarjoshi committed Apr 9, 2024
1 parent c9fe574 commit cec3a64
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/tests/questionlib_test.php
Original file line number Diff line number Diff line change
@@ -2019,9 +2019,11 @@ public function test_question_categorylist(): void {
// Create a category tree.
/** @var \core_question_generator $questiongenerator */
$questiongenerator = $this->getDataGenerator()->get_plugin_generator('core_question');
$context = \context_system::instance();
// Create a Course.
$course = $this->getDataGenerator()->create_course();
$coursecontext = \context_course::instance($course->id);

$top = question_get_top_category($context->id, true);
$top = question_get_top_category($coursecontext->id, true);
$cat1 = $questiongenerator->create_question_category(['parent' => $top->id]);
$sub11 = $questiongenerator->create_question_category(['parent' => $cat1->id]);
$sub12 = $questiongenerator->create_question_category(['parent' => $cat1->id]);
@@ -2057,11 +2059,11 @@ public function test_question_categorylist_bad_data(): void {
$questiongenerator = $this->getDataGenerator()->get_plugin_generator('core_question');
$context = \context_system::instance();

$top = question_get_top_category($context->id, true);
$top = question_get_top_category($coursecontext->id, true);
$cat1 = $questiongenerator->create_question_category(['parent' => $top->id]);
$sub11 = $questiongenerator->create_question_category(['parent' => $cat1->id]);
$sub12 = $questiongenerator->create_question_category(['parent' => $cat1->id]);
$cat2 = $questiongenerator->create_question_category(['parent' => $top->id, 'contextid' => $coursecontext->id]);
$cat2 = $questiongenerator->create_question_category(['parent' => $top->id, 'contextid' => $context->id]);
$sub22 = $questiongenerator->create_question_category(['parent' => $cat2->id]);

// Test - returned array has keys and values the same.

0 comments on commit cec3a64

Please sign in to comment.