MDL-58363 mod_chat: Remove calendar is_visible

Part of MDL-55611 epic.
This commit is contained in:
Andrew Nicols 2017-03-22 09:34:01 +08:00 committed by Damyon Wiese
parent 0c9dc98b44
commit 73be2a8821
2 changed files with 8 additions and 31 deletions

View File

@ -1407,19 +1407,6 @@ function chat_view($chat, $course, $cm, $context) {
$completion->set_module_viewed($cm);
}
/**
* Is the event visible?
*
* @param \core_calendar\event $event
* @return bool Returns true if the event is visible to the current user, false otherwise.
*/
function mod_chat_core_calendar_is_event_visible(\core_calendar\event $event) {
$cm = get_fast_modinfo($event->courseid)->instances['chat'][$event->instance];
$context = context_module::instance($cm->id);
return has_capability('mod/chat:view', $context);
}
/**
* Handles creating actions for events.
*

View File

@ -39,23 +39,7 @@ class mod_chat_lib_testcase extends advanced_testcase {
$this->resetAfterTest();
}
public function test_chat_core_calendar_is_event_visible_chattime_event_as_admin() {
$this->setAdminUser();
// Create a course.
$course = $this->getDataGenerator()->create_course();
// Create a chat.
$chat = $this->getDataGenerator()->create_module('chat', array('course' => $course->id));
// Create a calendar event.
$event = $this->create_action_event($course->id, $chat->id, CHAT_EVENT_TYPE_CHATTIME);
// Check that we can see the event.
$this->assertTrue(mod_chat_core_calendar_is_event_visible($event));
}
public function test_chat_core_calendar_is_event_visible_chattime_event_as_non_user() {
public function test_chat_core_calendar_provide_event_action_chattime_event_as_non_user() {
global $CFG;
$this->setAdminUser();
@ -69,12 +53,18 @@ class mod_chat_lib_testcase extends advanced_testcase {
// Create a calendar event.
$event = $this->create_action_event($course->id, $chat->id, CHAT_EVENT_TYPE_CHATTIME);
// Create an action factory.
$factory = new \core_calendar\action_factory();
// Log out the user and set force login to true.
\core\session\manager::init_empty_session();
$CFG->forcelogin = true;
// Decorate action event.
$actionevent = mod_chat_core_calendar_provide_event_action($event, $factory);
// Check that we can't see the event.
$this->assertFalse(mod_chat_core_calendar_is_event_visible($event));
$this->assertNull($actionevent);
}
public function test_chat_core_calendar_provide_event_action_chattime_event() {