$this->assertTrue($actionevent->is_actionable());
}
+ public function test_label_core_calendar_provide_event_action_as_non_user() {
+ global $CFG;
+
+ // Create the activity.
+ $course = $this->getDataGenerator()->create_course();
+ $label = $this->getDataGenerator()->create_module('label', array('course' => $course->id));
+
+ // Create a calendar event.
+ $event = $this->create_action_event($course->id, $label->id,
+ \core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
+
+ // Now log out.
+ $CFG->forcelogin = true; // We don't want to be logged in as guest, as guest users might still have some capabilities.
+ $this->setUser();
+
+ // Create an action factory.
+ $factory = new \core_calendar\action_factory();
+
+ // Decorate action event.
+ $actionevent = mod_label_core_calendar_provide_event_action($event, $factory);
+
+ // Confirm the event is not shown at all.
+ $this->assertNull($actionevent);
+ }
+
+ public function test_label_core_calendar_provide_event_action_in_hidden_section() {
+ // Create the activity.
+ $course = $this->getDataGenerator()->create_course();
+ $label = $this->getDataGenerator()->create_module('label', array('course' => $course->id));
+
+ // Create a student.
+ $student = $this->getDataGenerator()->create_and_enrol($course, 'student');
+
+ // Create a calendar event.
+ $event = $this->create_action_event($course->id, $label->id,
+ \core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
+
+ // Set sections 0 as hidden.
+ set_section_visible($course->id, 0, 0);
+
+ // Create an action factory.
+ $factory = new \core_calendar\action_factory();
+
+ // Decorate action event for the student.
+ $actionevent = mod_label_core_calendar_provide_event_action($event, $factory, $student->id);
+
+ // Confirm the event is not shown at all.
+ $this->assertNull($actionevent);
+ }
+
public function test_label_core_calendar_provide_event_action_for_user() {
+ global $CFG;
+
// Create the activity.
$course = $this->getDataGenerator()->create_course();
$label = $this->getDataGenerator()->create_module('label', array('course' => $course->id));
\core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED);
// Now, log out.
+ $CFG->forcelogin = true; // We don't want to be logged in as guest, as guest users might still have some capabilities.
$this->setUser();
// Create an action factory.