public function test_highlight_section() { $generator = $this->getDataGenerator(); // Create topics course $generator->create_course(['shortname' => 'testcourse', 'format' => 'topics', 'numsections' => 5], ['createsections' => true]); $this->setAdminUser(); // Highlight the section. $highlight = $this->courseservice->highlight_section('testcourse', 3, true); $this->assertTrue(isset($highlight['actionmodel'])); $this->assertTrue(isset($highlight['toc'])); $actionmodel = $highlight['actionmodel']; $toc = $highlight['toc']; $this->assertTrue($actionmodel instanceof theme_snap\renderables\course_action_section_highlight); $this->assertTrue($toc instanceof theme_snap\renderables\course_toc); // Check that action model has toggled after highlight. $this->assertEquals('snap-highlight snap-marked', $actionmodel->class); $this->assertEquals('This topic is highlighted as the current topic', $actionmodel->title); $this->assertContains('marker=0', $actionmodel->url); // Unhiglight the section. $highlight = $this->courseservice->highlight_section('testcourse', 3, false); $actionmodel = $highlight['actionmodel']; $this->assertTrue($actionmodel instanceof theme_snap\renderables\course_action_section_highlight); // Check that action model now corresponds to unhighlighted state. $this->assertEquals('snap-highlight snap-marker', $actionmodel->class); $this->assertEquals('Highlight this topic as the current topic', $actionmodel->title); $this->assertContains('marker=3', $actionmodel->url); }