public function test_set_nested_categories()
 {
     global $DB;
     // Setup fixture.
     $topcat = $this->getDataGenerator()->create_category();
     $topcatdbrecord = $DB->get_record('course_categories', array('id' => $topcat->id));
     $subcat = $this->getDataGenerator()->create_category(array('parent' => $topcat->id));
     $subcatdbrecord = $DB->get_record('course_categories', array('id' => $subcat->id));
     // Exercise SUT.
     $this->testpage->set_category_by_id($subcat->id);
     // Validated.
     $categories = $this->testpage->categories;
     $this->assertCount(2, $categories);
     $this->assertEquals($topcatdbrecord, array_pop($categories));
     $this->assertEquals($subcatdbrecord, array_pop($categories));
 }