From fc04366bef7ffd07d9c8cdbde3b5793974dbadd7 Mon Sep 17 00:00:00 2001 From: Jonathan Champ Date: Thu, 30 Sep 2021 18:15:56 -0400 Subject: [PATCH 1/4] phpcs: acknowledge require_login missing --- loadmeeting.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/loadmeeting.php b/loadmeeting.php index 6ecfccc6..7555d8b6 100644 --- a/loadmeeting.php +++ b/loadmeeting.php @@ -22,6 +22,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +// phpcs:ignore moodle.Files.RequireLogin.Missing require_once(dirname(dirname(__DIR__)) . '/config.php'); require_once(__DIR__ . '/locallib.php'); @@ -31,7 +32,7 @@ $context = context_module::instance($id); $PAGE->set_context($context); - // Call load meeting function. + // Call load meeting function (note: this is where require_login() happens). $meetinginfo = zoom_load_meeting($id, $context); // Redirect if available, otherwise deny access. From d03d234712b5add0c52e1760a2e9934091cbbddc Mon Sep 17 00:00:00 2001 From: Jonathan Champ Date: Thu, 30 Sep 2021 18:17:11 -0400 Subject: [PATCH 2/4] phpcs: fix long lines --- backup/moodle2/backup_zoom_stepslib.php | 14 +- mod_form.php | 24 +- tests/mod_zoom_invitation_test.php | 852 ++++++++++++++++++------ 3 files changed, 681 insertions(+), 209 deletions(-) diff --git a/backup/moodle2/backup_zoom_stepslib.php b/backup/moodle2/backup_zoom_stepslib.php index 64081d6b..8ffddbdb 100644 --- a/backup/moodle2/backup_zoom_stepslib.php +++ b/backup/moodle2/backup_zoom_stepslib.php @@ -42,13 +42,13 @@ class backup_zoom_activity_structure_step extends backup_activity_structure_step protected function define_structure() { // Define the root element describing the zoom instance. $zoom = new backup_nested_element('zoom', array('id'), array( - 'intro', 'introformat', 'grade', 'meeting_id', 'start_url', 'join_url', 'created_at', 'host_id', 'name', - 'start_time', 'timemodified', 'recurring', 'recurrence_type', 'repeat_interval', 'weekly_days', 'monthly_day', - 'monthly_week', 'monthly_week_day', 'monthly_repeat_option', 'end_times', 'end_date_time', 'end_date_option', - 'webinar', 'duration', 'timezone', 'password', 'option_jbh', 'option_start_type', 'option_host_video', - 'option_participants_video', 'option_audio', 'option_mute_upon_entry', 'option_waiting_room', 'option_authenticated_users', - 'option_encryption_type', 'exists_on_zoom', 'alternative_hosts') - ); + 'intro', 'introformat', 'grade', 'meeting_id', 'start_url', 'join_url', 'created_at', 'host_id', 'name', + 'start_time', 'timemodified', 'recurring', 'recurrence_type', 'repeat_interval', 'weekly_days', 'monthly_day', + 'monthly_week', 'monthly_week_day', 'monthly_repeat_option', 'end_times', 'end_date_time', 'end_date_option', + 'webinar', 'duration', 'timezone', 'password', 'option_jbh', 'option_start_type', 'option_host_video', + 'option_participants_video', 'option_audio', 'option_mute_upon_entry', 'option_waiting_room', + 'option_authenticated_users', 'option_encryption_type', 'exists_on_zoom', 'alternative_hosts', + )); // If we had more elements, we would build the tree here. diff --git a/mod_form.php b/mod_form.php index 22d98ba1..c6fca5af 100755 --- a/mod_form.php +++ b/mod_form.php @@ -237,7 +237,13 @@ public function definition() { $monthlyweekoptions = zoom_get_monthweek_options(); $group = []; - $group[] = $mform->createElement('radio', 'monthly_repeat_option', '', get_string('day', 'calendar'), ZOOM_MONTHLY_REPEAT_OPTION_DAY); + $group[] = $mform->createElement( + 'radio', + 'monthly_repeat_option', + '', + get_string('day', 'calendar'), + ZOOM_MONTHLY_REPEAT_OPTION_DAY + ); $group[] = $mform->createElement('select', 'monthly_day', '', $monthoptions); $group[] = $mform->createElement('static', 'month_day_text', '', get_string('month_day_text', 'zoom')); $group[] = $mform->createElement('radio', 'monthly_repeat_option', '', '', ZOOM_MONTHLY_REPEAT_OPTION_WEEK); @@ -255,9 +261,21 @@ public function definition() { $maxoptions[$i] = $i; } $group = []; - $group[] = $mform->createElement('radio', 'end_date_option', '', get_string('end_date_option_by', 'zoom'), ZOOM_END_DATE_OPTION_BY); + $group[] = $mform->createElement( + 'radio', + 'end_date_option', + '', + get_string('end_date_option_by', 'zoom'), + ZOOM_END_DATE_OPTION_BY + ); $group[] = $mform->createElement('date_selector', 'end_date_time', ''); - $group[] = $mform->createElement('radio', 'end_date_option', '', get_string('end_date_option_after', 'zoom'), ZOOM_END_DATE_OPTION_AFTER); + $group[] = $mform->createElement( + 'radio', + 'end_date_option', + '', + get_string('end_date_option_after', 'zoom'), + ZOOM_END_DATE_OPTION_AFTER + ); $group[] = $mform->createElement('select', 'end_times', '', $maxoptions); $group[] = $mform->createElement('static', 'end_times_text', '', get_string('end_date_option_occurrences', 'zoom')); $mform->addGroup($group, 'radioenddate', get_string('enddate', 'zoom'), null, false); diff --git a/tests/mod_zoom_invitation_test.php b/tests/mod_zoom_invitation_test.php index b0070cbc..515715d3 100644 --- a/tests/mod_zoom_invitation_test.php +++ b/tests/mod_zoom_invitation_test.php @@ -46,19 +46,54 @@ public function test_display_message_when_user_has_all_capabilities() { $this->setAdminUser(); $course = $this->getDataGenerator()->create_course(); $zoom = $this->getDataGenerator()->create_module('zoom', ['course' => $course]); - $message = (new \mod_zoom\invitation($this->get_mock_invitation_message_scheduledmeeting()))->get_display_string($zoom->cmid); - $expectedmessage = "Organization is inviting you to a scheduled Zoom meeting.\r\n\r\nTopic: Zoom Meeting\r\nTime: Mar 15, 2021 06:08 AM London\r\n\r\n" - . "Join Zoom Meeting\r\nhttps://us02web.zoom.us/j/12341234123?pwd=THBLWExVS0QyYnV1Z1nZTDJGYVI2QT09\r\n\r\n" - . "Meeting ID: 123 1234 1234\r\nPasscode: 123123\r\n\r\nOne tap mobile\r\n+61323452345,,12341234123#,,,,*123456# Australia\r\n" - . "+61312341234,,12341234123#,,,,*123456# Australia\r\n\r\nDial by your location\r\n +61 3 5678 5678 Australia\r\n" - . " +61 3 4567 4567 Australia\r\n +61 3 3456 3456 Australia\r\n +61 3 2345 2345 Australia\r\n" - . " +61 3 1234 1234 Australia\r\nMeeting ID: 123 1234 1234\r\nPasscode: 123456\r\n" - . "Find your local number: https://us02web.zoom.us/u/abcde12345\r\n\r\nJoin by SIP\r\n1231231231234@zoomabc.com\r\n\r\n" - . "Join by H.323\r\n162.255.37.11 (US West)\r\n162.255.36.11 (US East)\r\n115.114.131.7 (India Mumbai)\r\n" - . "115.114.115.7 (India Hyderabad)\r\n213.19.144.110 (Amsterdam Netherlands)\r\n213.244.140.110 (Germany)\r\n" - . "103.122.166.55 (Australia Sydney)\r\n103.122.167.55 (Australia Melbourne)\r\n149.137.40.110 (Singapore)\r\n" - . "64.211.144.160 (Brazil)\r\n69.174.57.160 (Canada Toronto)\r\n65.39.152.160 (Canada Vancouver)\r\n207.226.132.110 (Japan Tokyo)\r\n" - . "149.137.24.110 (Japan Osaka)\r\nMeeting ID: 966 7989 3993\r\nPasscode: 44730043"; + $message = (new \mod_zoom\invitation( + $this->get_mock_invitation_message_scheduledmeeting() + ))->get_display_string($zoom->cmid); + $expectedmessage = "Organization is inviting you to a scheduled Zoom meeting.\r\n" + . "\r\n" + . "Topic: Zoom Meeting\r\n" + . "Time: Mar 15, 2021 06:08 AM London\r\n" + . "\r\n" + . "Join Zoom Meeting\r\n" + . "https://us02web.zoom.us/j/12341234123?pwd=THBLWExVS0QyYnV1Z1nZTDJGYVI2QT09\r\n" + . "\r\n" + . "Meeting ID: 123 1234 1234\r\n" + . "Passcode: 123123\r\n" + . "\r\n" + . "One tap mobile\r\n" + . "+61323452345,,12341234123#,,,,*123456# Australia\r\n" + . "+61312341234,,12341234123#,,,,*123456# Australia\r\n" + . "\r\n" + . "Dial by your location\r\n" + . " +61 3 5678 5678 Australia\r\n" + . " +61 3 4567 4567 Australia\r\n" + . " +61 3 3456 3456 Australia\r\n" + . " +61 3 2345 2345 Australia\r\n" + . " +61 3 1234 1234 Australia\r\n" + . "Meeting ID: 123 1234 1234\r\n" + . "Passcode: 123456\r\n" + . "Find your local number: https://us02web.zoom.us/u/abcde12345\r\n" + . "\r\n" + . "Join by SIP\r\n" + . "1231231231234@zoomabc.com\r\n" + . "\r\n" + . "Join by H.323\r\n" + . "162.255.37.11 (US West)\r\n" + . "162.255.36.11 (US East)\r\n" + . "115.114.131.7 (India Mumbai)\r\n" + . "115.114.115.7 (India Hyderabad)\r\n" + . "213.19.144.110 (Amsterdam Netherlands)\r\n" + . "213.244.140.110 (Germany)\r\n" + . "103.122.166.55 (Australia Sydney)\r\n" + . "103.122.167.55 (Australia Melbourne)\r\n" + . "149.137.40.110 (Singapore)\r\n" + . "64.211.144.160 (Brazil)\r\n" + . "69.174.57.160 (Canada Toronto)\r\n" + . "65.39.152.160 (Canada Vancouver)\r\n" + . "207.226.132.110 (Japan Tokyo)\r\n" + . "149.137.24.110 (Japan Osaka)\r\n" + . "Meeting ID: 966 7989 3993\r\n" + . "Passcode: 44730043"; $this->assertEquals($expectedmessage, $message); } @@ -74,10 +109,19 @@ public function test_display_message_when_user_has_viewjoinurl_capability() { $zoom = $this->getDataGenerator()->create_module('zoom', ['course' => $course]); assign_capability('mod/zoom:viewjoinurl', CAP_ALLOW, $role, context_system::instance()->id); role_assign($role, $user->id, context_course::instance($course->id)); - $message = (new \mod_zoom\invitation($this->get_mock_invitation_message_scheduledmeeting()))->get_display_string($zoom->cmid, $user->id); - $expectedmessage = "Organization is inviting you to a scheduled Zoom meeting.\r\n\r\nTopic: Zoom Meeting\r\n" - . "Time: Mar 15, 2021 06:08 AM London\r\n\r\nJoin Zoom Meeting\r\nhttps://us02web.zoom.us/j/12341234123?pwd=THBLWExVS0QyYnV1Z1nZTDJGYVI2QT09\r\n\r\n" - . "Meeting ID: 123 1234 1234\r\nPasscode: 123123"; + $message = (new \mod_zoom\invitation( + $this->get_mock_invitation_message_scheduledmeeting() + ))->get_display_string($zoom->cmid, $user->id); + $expectedmessage = "Organization is inviting you to a scheduled Zoom meeting.\r\n" + . "\r\n" + . "Topic: Zoom Meeting\r\n" + . "Time: Mar 15, 2021 06:08 AM London\r\n" + . "\r\n" + . "Join Zoom Meeting\r\n" + . "https://us02web.zoom.us/j/12341234123?pwd=THBLWExVS0QyYnV1Z1nZTDJGYVI2QT09\r\n" + . "\r\n" + . "Meeting ID: 123 1234 1234\r\n" + . "Passcode: 123123"; $this->assertEquals($expectedmessage, $message); } @@ -93,18 +137,48 @@ public function test_display_message_when_user_has_viewdialin_capability() { $zoom = $this->getDataGenerator()->create_module('zoom', ['course' => $course]); assign_capability('mod/zoom:viewdialin', CAP_ALLOW, $role, context_system::instance()); role_assign($role, $user->id, context_course::instance($course->id)); - $message = (new \mod_zoom\invitation($this->get_mock_invitation_message_scheduledmeeting()))->get_display_string($zoom->cmid, $user->id); - $expectedmessage = "Organization is inviting you to a scheduled Zoom meeting.\r\n\r\nTopic: Zoom Meeting\r\n" - . "Time: Mar 15, 2021 06:08 AM London\r\n\r\nOne tap mobile\r\n+61323452345,,12341234123#,,,,*123456# Australia\r\n" - . "+61312341234,,12341234123#,,,,*123456# Australia\r\n\r\nDial by your location\r\n +61 3 5678 5678 Australia\r\n" - . " +61 3 4567 4567 Australia\r\n +61 3 3456 3456 Australia\r\n +61 3 2345 2345 Australia\r\n" - . " +61 3 1234 1234 Australia\r\nMeeting ID: 123 1234 1234\r\nPasscode: 123456\r\n" - . "Find your local number: https://us02web.zoom.us/u/abcde12345\r\n\r\nJoin by SIP\r\n1231231231234@zoomabc.com\r\n\r\n" - . "Join by H.323\r\n162.255.37.11 (US West)\r\n162.255.36.11 (US East)\r\n115.114.131.7 (India Mumbai)\r\n" - . "115.114.115.7 (India Hyderabad)\r\n213.19.144.110 (Amsterdam Netherlands)\r\n213.244.140.110 (Germany)\r\n" - . "103.122.166.55 (Australia Sydney)\r\n103.122.167.55 (Australia Melbourne)\r\n149.137.40.110 (Singapore)\r\n" - . "64.211.144.160 (Brazil)\r\n69.174.57.160 (Canada Toronto)\r\n65.39.152.160 (Canada Vancouver)\r\n207.226.132.110 (Japan Tokyo)\r\n" - . "149.137.24.110 (Japan Osaka)\r\nMeeting ID: 966 7989 3993\r\nPasscode: 44730043"; + $message = (new \mod_zoom\invitation( + $this->get_mock_invitation_message_scheduledmeeting() + ))->get_display_string($zoom->cmid, $user->id); + $expectedmessage = "Organization is inviting you to a scheduled Zoom meeting.\r\n" + . "\r\n" + . "Topic: Zoom Meeting\r\n" + . "Time: Mar 15, 2021 06:08 AM London\r\n" + . "\r\n" + . "One tap mobile\r\n" + . "+61323452345,,12341234123#,,,,*123456# Australia\r\n" + . "+61312341234,,12341234123#,,,,*123456# Australia\r\n" + . "\r\n" + . "Dial by your location\r\n" + . " +61 3 5678 5678 Australia\r\n" + . " +61 3 4567 4567 Australia\r\n" + . " +61 3 3456 3456 Australia\r\n" + . " +61 3 2345 2345 Australia\r\n" + . " +61 3 1234 1234 Australia\r\n" + . "Meeting ID: 123 1234 1234\r\n" + . "Passcode: 123456\r\n" + . "Find your local number: https://us02web.zoom.us/u/abcde12345\r\n" + . "\r\n" + . "Join by SIP\r\n" + . "1231231231234@zoomabc.com\r\n" + . "\r\n" + . "Join by H.323\r\n" + . "162.255.37.11 (US West)\r\n" + . "162.255.36.11 (US East)\r\n" + . "115.114.131.7 (India Mumbai)\r\n" + . "115.114.115.7 (India Hyderabad)\r\n" + . "213.19.144.110 (Amsterdam Netherlands)\r\n" + . "213.244.140.110 (Germany)\r\n" + . "103.122.166.55 (Australia Sydney)\r\n" + . "103.122.167.55 (Australia Melbourne)\r\n" + . "149.137.40.110 (Singapore)\r\n" + . "64.211.144.160 (Brazil)\r\n" + . "69.174.57.160 (Canada Toronto)\r\n" + . "65.39.152.160 (Canada Vancouver)\r\n" + . "207.226.132.110 (Japan Tokyo)\r\n" + . "149.137.24.110 (Japan Osaka)\r\n" + . "Meeting ID: 966 7989 3993\r\n" + . "Passcode: 44730043"; $this->assertEquals($expectedmessage, $message); } @@ -119,8 +193,13 @@ public function test_display_message_when_user_has_no_capabilities() { $role = $this->getDataGenerator()->create_role(); $zoom = $this->getDataGenerator()->create_module('zoom', ['course' => $course]); role_assign($role, $user->id, context_course::instance($course->id)); - $message = (new \mod_zoom\invitation($this->get_mock_invitation_message_scheduledmeeting()))->get_display_string($zoom->cmid, $user->id); - $expectedmessage = "Organization is inviting you to a scheduled Zoom meeting.\r\n\r\nTopic: Zoom Meeting\r\nTime: Mar 15, 2021 06:08 AM London"; + $message = (new \mod_zoom\invitation( + $this->get_mock_invitation_message_scheduledmeeting() + ))->get_display_string($zoom->cmid, $user->id); + $expectedmessage = "Organization is inviting you to a scheduled Zoom meeting.\r\n" + . "\r\n" + . "Topic: Zoom Meeting\r\n" + . "Time: Mar 15, 2021 06:08 AM London"; $this->assertEquals($expectedmessage, $message); } @@ -139,7 +218,9 @@ public function test_display_message_when_a_regex_pattern_is_empty() { role_assign($role, $user->id, context_course::instance($course->id)); // Set mock zoom activity URL for page as exception messages expect it. $PAGE->set_url(new moodle_url('/mod/zoom/view.php?id=123')); - $message = (new \mod_zoom\invitation($this->get_mock_invitation_message_scheduledmeeting()))->get_display_string($zoom->cmid, $user->id); + $message = (new \mod_zoom\invitation( + $this->get_mock_invitation_message_scheduledmeeting() + ))->get_display_string($zoom->cmid, $user->id); $this->assertDebuggingNotCalled(); } @@ -158,7 +239,9 @@ public function test_display_message_when_a_regex_pattern_is_invalid() { role_assign($role, $user->id, context_course::instance($course->id)); // Set mock zoom activity URL for page as exception messages expect it. $PAGE->set_url(new moodle_url('/mod/zoom/view.php?id=123')); - $message = (new \mod_zoom\invitation($this->get_mock_invitation_message_scheduledmeeting()))->get_display_string($zoom->cmid, $user->id); + $message = (new \mod_zoom\invitation( + $this->get_mock_invitation_message_scheduledmeeting() + ))->get_display_string($zoom->cmid, $user->id); $this->assertDebuggingCalled('Error in regex for zoom invitation element: "joinurl" with pattern: "~".'); } @@ -174,7 +257,9 @@ public function test_display_message_when_a_regex_pattern_is_finds_no_match() { $role = $this->getDataGenerator()->create_role(); $zoom = $this->getDataGenerator()->create_module('zoom', ['course' => $course]); role_assign($role, $user->id, context_course::instance($course->id)); - $message = (new \mod_zoom\invitation($this->get_mock_invitation_message_scheduledmeeting()))->get_display_string($zoom->cmid, $user->id); + $message = (new \mod_zoom\invitation( + $this->get_mock_invitation_message_scheduledmeeting() + ))->get_display_string($zoom->cmid, $user->id); $this->assertDebuggingCalled('No match found in zoom invitation for element: "joinurl" with pattern: "/nomatch/mi".'); } @@ -187,19 +272,52 @@ public function test_display_message_has_invite_removed_if_setting_enabled() { set_config('invitationremoveinvite', '1', 'zoom'); $course = $this->getDataGenerator()->create_course(); $zoom = $this->getDataGenerator()->create_module('zoom', ['course' => $course]); - $message = (new \mod_zoom\invitation($this->get_mock_invitation_message_scheduledmeeting()))->get_display_string($zoom->cmid); - $expectedmessage = "Topic: Zoom Meeting\r\nTime: Mar 15, 2021 06:08 AM London\r\n\r\n" - . "Join Zoom Meeting\r\nhttps://us02web.zoom.us/j/12341234123?pwd=THBLWExVS0QyYnV1Z1nZTDJGYVI2QT09\r\n\r\n" - . "Meeting ID: 123 1234 1234\r\nPasscode: 123123\r\n\r\nOne tap mobile\r\n+61323452345,,12341234123#,,,,*123456# Australia\r\n" - . "+61312341234,,12341234123#,,,,*123456# Australia\r\n\r\nDial by your location\r\n +61 3 5678 5678 Australia\r\n" - . " +61 3 4567 4567 Australia\r\n +61 3 3456 3456 Australia\r\n +61 3 2345 2345 Australia\r\n" - . " +61 3 1234 1234 Australia\r\nMeeting ID: 123 1234 1234\r\nPasscode: 123456\r\n" - . "Find your local number: https://us02web.zoom.us/u/abcde12345\r\n\r\nJoin by SIP\r\n1231231231234@zoomabc.com\r\n\r\n" - . "Join by H.323\r\n162.255.37.11 (US West)\r\n162.255.36.11 (US East)\r\n115.114.131.7 (India Mumbai)\r\n" - . "115.114.115.7 (India Hyderabad)\r\n213.19.144.110 (Amsterdam Netherlands)\r\n213.244.140.110 (Germany)\r\n" - . "103.122.166.55 (Australia Sydney)\r\n103.122.167.55 (Australia Melbourne)\r\n149.137.40.110 (Singapore)\r\n" - . "64.211.144.160 (Brazil)\r\n69.174.57.160 (Canada Toronto)\r\n65.39.152.160 (Canada Vancouver)\r\n207.226.132.110 (Japan Tokyo)\r\n" - . "149.137.24.110 (Japan Osaka)\r\nMeeting ID: 966 7989 3993\r\nPasscode: 44730043"; + $message = (new \mod_zoom\invitation( + $this->get_mock_invitation_message_scheduledmeeting() + ))->get_display_string($zoom->cmid); + $expectedmessage = "Topic: Zoom Meeting\r\n" + . "Time: Mar 15, 2021 06:08 AM London\r\n" + . "\r\n" + . "Join Zoom Meeting\r\n" + . "https://us02web.zoom.us/j/12341234123?pwd=THBLWExVS0QyYnV1Z1nZTDJGYVI2QT09\r\n" + . "\r\n" + . "Meeting ID: 123 1234 1234\r\n" + . "Passcode: 123123\r\n" + . "\r\n" + . "One tap mobile\r\n" + . "+61323452345,,12341234123#,,,,*123456# Australia\r\n" + . "+61312341234,,12341234123#,,,,*123456# Australia\r\n" + . "\r\n" + . "Dial by your location\r\n" + . " +61 3 5678 5678 Australia\r\n" + . " +61 3 4567 4567 Australia\r\n" + . " +61 3 3456 3456 Australia\r\n" + . " +61 3 2345 2345 Australia\r\n" + . " +61 3 1234 1234 Australia\r\n" + . "Meeting ID: 123 1234 1234\r\n" + . "Passcode: 123456\r\n" + . "Find your local number: https://us02web.zoom.us/u/abcde12345\r\n" + . "\r\n" + . "Join by SIP\r\n" + . "1231231231234@zoomabc.com\r\n" + . "\r\n" + . "Join by H.323\r\n" + . "162.255.37.11 (US West)\r\n" + . "162.255.36.11 (US East)\r\n" + . "115.114.131.7 (India Mumbai)\r\n" + . "115.114.115.7 (India Hyderabad)\r\n" + . "213.19.144.110 (Amsterdam Netherlands)\r\n" + . "213.244.140.110 (Germany)\r\n" + . "103.122.166.55 (Australia Sydney)\r\n" + . "103.122.167.55 (Australia Melbourne)\r\n" + . "149.137.40.110 (Singapore)\r\n" + . "64.211.144.160 (Brazil)\r\n" + . "69.174.57.160 (Canada Toronto)\r\n" + . "65.39.152.160 (Canada Vancouver)\r\n" + . "207.226.132.110 (Japan Tokyo)\r\n" + . "149.137.24.110 (Japan Osaka)\r\n" + . "Meeting ID: 966 7989 3993\r\n" + . "Passcode: 44730043"; $this->assertEquals($expectedmessage, $message); } @@ -212,19 +330,54 @@ public function test_display_message_does_not_have_invite_removed_if_setting_dis set_config('invitationremoveinvite', '0', 'zoom'); $course = $this->getDataGenerator()->create_course(); $zoom = $this->getDataGenerator()->create_module('zoom', ['course' => $course]); - $message = (new \mod_zoom\invitation($this->get_mock_invitation_message_scheduledmeeting()))->get_display_string($zoom->cmid); - $expectedmessage = "Organization is inviting you to a scheduled Zoom meeting.\r\n\r\nTopic: Zoom Meeting\r\nTime: Mar 15, 2021 06:08 AM London\r\n\r\n" - . "Join Zoom Meeting\r\nhttps://us02web.zoom.us/j/12341234123?pwd=THBLWExVS0QyYnV1Z1nZTDJGYVI2QT09\r\n\r\n" - . "Meeting ID: 123 1234 1234\r\nPasscode: 123123\r\n\r\nOne tap mobile\r\n+61323452345,,12341234123#,,,,*123456# Australia\r\n" - . "+61312341234,,12341234123#,,,,*123456# Australia\r\n\r\nDial by your location\r\n +61 3 5678 5678 Australia\r\n" - . " +61 3 4567 4567 Australia\r\n +61 3 3456 3456 Australia\r\n +61 3 2345 2345 Australia\r\n" - . " +61 3 1234 1234 Australia\r\nMeeting ID: 123 1234 1234\r\nPasscode: 123456\r\n" - . "Find your local number: https://us02web.zoom.us/u/abcde12345\r\n\r\nJoin by SIP\r\n1231231231234@zoomabc.com\r\n\r\n" - . "Join by H.323\r\n162.255.37.11 (US West)\r\n162.255.36.11 (US East)\r\n115.114.131.7 (India Mumbai)\r\n" - . "115.114.115.7 (India Hyderabad)\r\n213.19.144.110 (Amsterdam Netherlands)\r\n213.244.140.110 (Germany)\r\n" - . "103.122.166.55 (Australia Sydney)\r\n103.122.167.55 (Australia Melbourne)\r\n149.137.40.110 (Singapore)\r\n" - . "64.211.144.160 (Brazil)\r\n69.174.57.160 (Canada Toronto)\r\n65.39.152.160 (Canada Vancouver)\r\n207.226.132.110 (Japan Tokyo)\r\n" - . "149.137.24.110 (Japan Osaka)\r\nMeeting ID: 966 7989 3993\r\nPasscode: 44730043"; + $message = (new \mod_zoom\invitation( + $this->get_mock_invitation_message_scheduledmeeting() + ))->get_display_string($zoom->cmid); + $expectedmessage = "Organization is inviting you to a scheduled Zoom meeting.\r\n" + . "\r\n" + . "Topic: Zoom Meeting\r\n" + . "Time: Mar 15, 2021 06:08 AM London\r\n" + . "\r\n" + . "Join Zoom Meeting\r\n" + . "https://us02web.zoom.us/j/12341234123?pwd=THBLWExVS0QyYnV1Z1nZTDJGYVI2QT09\r\n" + . "\r\n" + . "Meeting ID: 123 1234 1234\r\n" + . "Passcode: 123123\r\n" + . "\r\n" + . "One tap mobile\r\n" + . "+61323452345,,12341234123#,,,,*123456# Australia\r\n" + . "+61312341234,,12341234123#,,,,*123456# Australia\r\n" + . "\r\n" + . "Dial by your location\r\n" + . " +61 3 5678 5678 Australia\r\n" + . " +61 3 4567 4567 Australia\r\n" + . " +61 3 3456 3456 Australia\r\n" + . " +61 3 2345 2345 Australia\r\n" + . " +61 3 1234 1234 Australia\r\n" + . "Meeting ID: 123 1234 1234\r\n" + . "Passcode: 123456\r\n" + . "Find your local number: https://us02web.zoom.us/u/abcde12345\r\n" + . "\r\n" + . "Join by SIP\r\n" + . "1231231231234@zoomabc.com\r\n" + . "\r\n" + . "Join by H.323\r\n" + . "162.255.37.11 (US West)\r\n" + . "162.255.36.11 (US East)\r\n" + . "115.114.131.7 (India Mumbai)\r\n" + . "115.114.115.7 (India Hyderabad)\r\n" + . "213.19.144.110 (Amsterdam Netherlands)\r\n" + . "213.244.140.110 (Germany)\r\n" + . "103.122.166.55 (Australia Sydney)\r\n" + . "103.122.167.55 (Australia Melbourne)\r\n" + . "149.137.40.110 (Singapore)\r\n" + . "64.211.144.160 (Brazil)\r\n" + . "69.174.57.160 (Canada Toronto)\r\n" + . "65.39.152.160 (Canada Vancouver)\r\n" + . "207.226.132.110 (Japan Tokyo)\r\n" + . "149.137.24.110 (Japan Osaka)\r\n" + . "Meeting ID: 966 7989 3993\r\n" + . "Passcode: 44730043"; $this->assertEquals($expectedmessage, $message); } @@ -239,62 +392,165 @@ public function test_display_message_has_icallink_removed_if_setting_enabled() { $zoom = $this->getDataGenerator()->create_module('zoom', ['course' => $course]); // Test a scheduled meeting. - $message = (new \mod_zoom\invitation($this->get_mock_invitation_message_scheduledmeeting()))->get_display_string($zoom->cmid); - $expectedmessage = "Organization is inviting you to a scheduled Zoom meeting.\r\n\r\n" - . "Topic: Zoom Meeting\r\nTime: Mar 15, 2021 06:08 AM London\r\n\r\n" - . "Join Zoom Meeting\r\nhttps://us02web.zoom.us/j/12341234123?pwd=THBLWExVS0QyYnV1Z1nZTDJGYVI2QT09\r\n\r\n" - . "Meeting ID: 123 1234 1234\r\nPasscode: 123123\r\n\r\nOne tap mobile\r\n+61323452345,,12341234123#,,,,*123456# Australia\r\n" - . "+61312341234,,12341234123#,,,,*123456# Australia\r\n\r\nDial by your location\r\n +61 3 5678 5678 Australia\r\n" - . " +61 3 4567 4567 Australia\r\n +61 3 3456 3456 Australia\r\n +61 3 2345 2345 Australia\r\n" - . " +61 3 1234 1234 Australia\r\nMeeting ID: 123 1234 1234\r\nPasscode: 123456\r\n" - . "Find your local number: https://us02web.zoom.us/u/abcde12345\r\n\r\nJoin by SIP\r\n1231231231234@zoomabc.com\r\n\r\n" - . "Join by H.323\r\n162.255.37.11 (US West)\r\n162.255.36.11 (US East)\r\n115.114.131.7 (India Mumbai)\r\n" - . "115.114.115.7 (India Hyderabad)\r\n213.19.144.110 (Amsterdam Netherlands)\r\n213.244.140.110 (Germany)\r\n" - . "103.122.166.55 (Australia Sydney)\r\n103.122.167.55 (Australia Melbourne)\r\n149.137.40.110 (Singapore)\r\n" - . "64.211.144.160 (Brazil)\r\n69.174.57.160 (Canada Toronto)\r\n65.39.152.160 (Canada Vancouver)\r\n207.226.132.110 (Japan Tokyo)\r\n" - . "149.137.24.110 (Japan Osaka)\r\nMeeting ID: 966 7989 3993\r\nPasscode: 44730043"; + $message = (new \mod_zoom\invitation( + $this->get_mock_invitation_message_scheduledmeeting() + ))->get_display_string($zoom->cmid); + $expectedmessage = "Organization is inviting you to a scheduled Zoom meeting.\r\n" + . "\r\n" + . "Topic: Zoom Meeting\r\n" + . "Time: Mar 15, 2021 06:08 AM London\r\n" + . "\r\n" + . "Join Zoom Meeting\r\n" + . "https://us02web.zoom.us/j/12341234123?pwd=THBLWExVS0QyYnV1Z1nZTDJGYVI2QT09\r\n" + . "\r\n" + . "Meeting ID: 123 1234 1234\r\n" + . "Passcode: 123123\r\n" + . "\r\n" + . "One tap mobile\r\n" + . "+61323452345,,12341234123#,,,,*123456# Australia\r\n" + . "+61312341234,,12341234123#,,,,*123456# Australia\r\n" + . "\r\n" + . "Dial by your location\r\n" + . " +61 3 5678 5678 Australia\r\n" + . " +61 3 4567 4567 Australia\r\n" + . " +61 3 3456 3456 Australia\r\n" + . " +61 3 2345 2345 Australia\r\n" + . " +61 3 1234 1234 Australia\r\n" + . "Meeting ID: 123 1234 1234\r\n" + . "Passcode: 123456\r\n" + . "Find your local number: https://us02web.zoom.us/u/abcde12345\r\n" + . "\r\n" + . "Join by SIP\r\n" + . "1231231231234@zoomabc.com\r\n" + . "\r\n" + . "Join by H.323\r\n" + . "162.255.37.11 (US West)\r\n" + . "162.255.36.11 (US East)\r\n" + . "115.114.131.7 (India Mumbai)\r\n" + . "115.114.115.7 (India Hyderabad)\r\n" + . "213.19.144.110 (Amsterdam Netherlands)\r\n" + . "213.244.140.110 (Germany)\r\n" + . "103.122.166.55 (Australia Sydney)\r\n" + . "103.122.167.55 (Australia Melbourne)\r\n" + . "149.137.40.110 (Singapore)\r\n" + . "64.211.144.160 (Brazil)\r\n" + . "69.174.57.160 (Canada Toronto)\r\n" + . "65.39.152.160 (Canada Vancouver)\r\n" + . "207.226.132.110 (Japan Tokyo)\r\n" + . "149.137.24.110 (Japan Osaka)\r\n" + . "Meeting ID: 966 7989 3993\r\n" + . "Passcode: 44730043"; $this->assertEquals($expectedmessage, $message); // Test a recurring meeting with no fixed time. - $message = (new \mod_zoom\invitation($this->get_mock_invitation_message_recurringnofixed()))->get_display_string($zoom->cmid); - $expectedmessage = "Organization is inviting you to a scheduled Zoom meeting.\r\n\r\n" - . "Topic: Zoom Meeting\r\nTime: This is a recurring meeting Meet anytime\r\n\r\n" - . "Join Zoom Meeting\r\nhttps://us02web.zoom.us/j/12341234123?pwd=THBLWExVS0QyYnV1Z1nZTDJGYVI2QT09\r\n\r\n" - . "Meeting ID: 123 1234 1234\r\nPasscode: 123123\r\n\r\nOne tap mobile\r\n+61323452345,,12341234123#,,,,*123456# Australia\r\n" - . "+61312341234,,12341234123#,,,,*123456# Australia\r\n\r\nDial by your location\r\n +61 3 5678 5678 Australia\r\n" - . " +61 3 4567 4567 Australia\r\n +61 3 3456 3456 Australia\r\n +61 3 2345 2345 Australia\r\n" - . " +61 3 1234 1234 Australia\r\nMeeting ID: 123 1234 1234\r\nPasscode: 123456\r\n" - . "Find your local number: https://us02web.zoom.us/u/abcde12345\r\n\r\nJoin by SIP\r\n1231231231234@zoomabc.com\r\n\r\n" - . "Join by H.323\r\n162.255.37.11 (US West)\r\n162.255.36.11 (US East)\r\n115.114.131.7 (India Mumbai)\r\n" - . "115.114.115.7 (India Hyderabad)\r\n213.19.144.110 (Amsterdam Netherlands)\r\n213.244.140.110 (Germany)\r\n" - . "103.122.166.55 (Australia Sydney)\r\n103.122.167.55 (Australia Melbourne)\r\n149.137.40.110 (Singapore)\r\n" - . "64.211.144.160 (Brazil)\r\n69.174.57.160 (Canada Toronto)\r\n65.39.152.160 (Canada Vancouver)\r\n207.226.132.110 (Japan Tokyo)\r\n" - . "149.137.24.110 (Japan Osaka)\r\nMeeting ID: 966 7989 3993\r\nPasscode: 44730043"; + $message = (new \mod_zoom\invitation( + $this->get_mock_invitation_message_recurringnofixed() + ))->get_display_string($zoom->cmid); + $expectedmessage = "Organization is inviting you to a scheduled Zoom meeting.\r\n" + . "\r\n" + . "Topic: Zoom Meeting\r\n" + . "Time: This is a recurring meeting Meet anytime\r\n" + . "\r\n" + . "Join Zoom Meeting\r\n" + . "https://us02web.zoom.us/j/12341234123?pwd=THBLWExVS0QyYnV1Z1nZTDJGYVI2QT09\r\n" + . "\r\n" + . "Meeting ID: 123 1234 1234\r\n" + . "Passcode: 123123\r\n" + . "\r\n" + . "One tap mobile\r\n" + . "+61323452345,,12341234123#,,,,*123456# Australia\r\n" + . "+61312341234,,12341234123#,,,,*123456# Australia\r\n" + . "\r\n" + . "Dial by your location\r\n" + . " +61 3 5678 5678 Australia\r\n" + . " +61 3 4567 4567 Australia\r\n" + . " +61 3 3456 3456 Australia\r\n" + . " +61 3 2345 2345 Australia\r\n" + . " +61 3 1234 1234 Australia\r\n" + . "Meeting ID: 123 1234 1234\r\n" + . "Passcode: 123456\r\n" + . "Find your local number: https://us02web.zoom.us/u/abcde12345\r\n" + . "\r\n" + . "Join by SIP\r\n" + . "1231231231234@zoomabc.com\r\n" + . "\r\n" + . "Join by H.323\r\n" + . "162.255.37.11 (US West)\r\n" + . "162.255.36.11 (US East)\r\n" + . "115.114.131.7 (India Mumbai)\r\n" + . "115.114.115.7 (India Hyderabad)\r\n" + . "213.19.144.110 (Amsterdam Netherlands)\r\n" + . "213.244.140.110 (Germany)\r\n" + . "103.122.166.55 (Australia Sydney)\r\n" + . "103.122.167.55 (Australia Melbourne)\r\n" + . "149.137.40.110 (Singapore)\r\n" + . "64.211.144.160 (Brazil)\r\n" + . "69.174.57.160 (Canada Toronto)\r\n" + . "65.39.152.160 (Canada Vancouver)\r\n" + . "207.226.132.110 (Japan Tokyo)\r\n" + . "149.137.24.110 (Japan Osaka)\r\n" + . "Meeting ID: 966 7989 3993\r\n" + . "Passcode: 44730043"; $this->assertEquals($expectedmessage, $message); // Test a recurring meeting with fixed time. $message = (new \mod_zoom\invitation($this->get_mock_invitation_message_recurringfixed()))->get_display_string($zoom->cmid); - $expectedmessage = "Organization is inviting you to a scheduled Zoom meeting.\r\n\r\n" - . "Topic: Zoom Meeting\r\nTime: Mar 15, 2021 06:08 AM London\r\n" - . " Every day, until Mar 17, 2021, 3 occurrence(s)\r\n" - . " Mar 15, 2021 06:08 AM\r\n" - . " Mar 16, 2021 06:08 AM\r\n" - . " Mar 17, 2021 06:08 AM\r\n\r\n" - . "Join Zoom Meeting\r\nhttps://us02web.zoom.us/j/12341234123?pwd=THBLWExVS0QyYnV1Z1nZTDJGYVI2QT09\r\n\r\n" - . "Meeting ID: 123 1234 1234\r\nPasscode: 123123\r\n\r\nOne tap mobile\r\n+61323452345,,12341234123#,,,,*123456# Australia\r\n" - . "+61312341234,,12341234123#,,,,*123456# Australia\r\n\r\nDial by your location\r\n +61 3 5678 5678 Australia\r\n" - . " +61 3 4567 4567 Australia\r\n +61 3 3456 3456 Australia\r\n +61 3 2345 2345 Australia\r\n" - . " +61 3 1234 1234 Australia\r\nMeeting ID: 123 1234 1234\r\nPasscode: 123456\r\n" - . "Find your local number: https://us02web.zoom.us/u/abcde12345\r\n\r\nJoin by SIP\r\n1231231231234@zoomabc.com\r\n\r\n" - . "Join by H.323\r\n162.255.37.11 (US West)\r\n162.255.36.11 (US East)\r\n115.114.131.7 (India Mumbai)\r\n" - . "115.114.115.7 (India Hyderabad)\r\n213.19.144.110 (Amsterdam Netherlands)\r\n213.244.140.110 (Germany)\r\n" - . "103.122.166.55 (Australia Sydney)\r\n103.122.167.55 (Australia Melbourne)\r\n149.137.40.110 (Singapore)\r\n" - . "64.211.144.160 (Brazil)\r\n69.174.57.160 (Canada Toronto)\r\n65.39.152.160 (Canada Vancouver)\r\n207.226.132.110 (Japan Tokyo)\r\n" - . "149.137.24.110 (Japan Osaka)\r\nMeeting ID: 966 7989 3993\r\nPasscode: 44730043"; + $expectedmessage = "Organization is inviting you to a scheduled Zoom meeting.\r\n" + . "\r\n" + . "Topic: Zoom Meeting\r\n" + . "Time: Mar 15, 2021 06:08 AM London\r\n" + . " Every day, until Mar 17, 2021, 3 occurrence(s)\r\n" + . " Mar 15, 2021 06:08 AM\r\n" + . " Mar 16, 2021 06:08 AM\r\n" + . " Mar 17, 2021 06:08 AM\r\n" + . "\r\n" + . "Join Zoom Meeting\r\n" + . "https://us02web.zoom.us/j/12341234123?pwd=THBLWExVS0QyYnV1Z1nZTDJGYVI2QT09\r\n" + . "\r\n" + . "Meeting ID: 123 1234 1234\r\n" + . "Passcode: 123123\r\n" + . "\r\n" + . "One tap mobile\r\n" + . "+61323452345,,12341234123#,,,,*123456# Australia\r\n" + . "+61312341234,,12341234123#,,,,*123456# Australia\r\n" + . "\r\n" + . "Dial by your location\r\n" + . " +61 3 5678 5678 Australia\r\n" + . " +61 3 4567 4567 Australia\r\n" + . " +61 3 3456 3456 Australia\r\n" + . " +61 3 2345 2345 Australia\r\n" + . " +61 3 1234 1234 Australia\r\n" + . "Meeting ID: 123 1234 1234\r\n" + . "Passcode: 123456\r\n" + . "Find your local number: https://us02web.zoom.us/u/abcde12345\r\n" + . "\r\n" + . "Join by SIP\r\n" + . "1231231231234@zoomabc.com\r\n" + . "\r\n" + . "Join by H.323\r\n" + . "162.255.37.11 (US West)\r\n" + . "162.255.36.11 (US East)\r\n" + . "115.114.131.7 (India Mumbai)\r\n" + . "115.114.115.7 (India Hyderabad)\r\n" + . "213.19.144.110 (Amsterdam Netherlands)\r\n" + . "213.244.140.110 (Germany)\r\n" + . "103.122.166.55 (Australia Sydney)\r\n" + . "103.122.167.55 (Australia Melbourne)\r\n" + . "149.137.40.110 (Singapore)\r\n" + . "64.211.144.160 (Brazil)\r\n" + . "69.174.57.160 (Canada Toronto)\r\n" + . "65.39.152.160 (Canada Vancouver)\r\n" + . "207.226.132.110 (Japan Tokyo)\r\n" + . "149.137.24.110 (Japan Osaka)\r\n" + . "Meeting ID: 966 7989 3993\r\n" + . "Passcode: 44730043"; $this->assertEquals($expectedmessage, $message); - // We expect that the debugging was called two times, one time for the scheduled meeting and one time for the recurring meeting with no fixed time. - $debugmessage = 'No match found in zoom invitation for element: "icallink" with pattern: "/^.+download and import the following iCalendar.+$\n.+$/mi".'; + // We expect that the debugging was called two times: + // - one time for the scheduled meeting + // - one time for the recurring meeting with no fixed time. + $debugmessage = 'No match found in zoom invitation for element: "icallink"' + . ' with pattern: "/^.+download and import the following iCalendar.+$\n.+$/mi".'; $this->assertDebuggingCalledCount(2, array($debugmessage, $debugmessage)); } @@ -309,61 +565,161 @@ public function test_display_message_does_not_have_icallink_removed_if_setting_d $zoom = $this->getDataGenerator()->create_module('zoom', ['course' => $course]); // Test a scheduled meeting. - $message = (new \mod_zoom\invitation($this->get_mock_invitation_message_scheduledmeeting()))->get_display_string($zoom->cmid); - $expectedmessage = "Organization is inviting you to a scheduled Zoom meeting.\r\n\r\n" - . "Topic: Zoom Meeting\r\nTime: Mar 15, 2021 06:08 AM London\r\n\r\n" - . "Join Zoom Meeting\r\nhttps://us02web.zoom.us/j/12341234123?pwd=THBLWExVS0QyYnV1Z1nZTDJGYVI2QT09\r\n\r\n" - . "Meeting ID: 123 1234 1234\r\nPasscode: 123123\r\n\r\nOne tap mobile\r\n+61323452345,,12341234123#,,,,*123456# Australia\r\n" - . "+61312341234,,12341234123#,,,,*123456# Australia\r\n\r\nDial by your location\r\n +61 3 5678 5678 Australia\r\n" - . " +61 3 4567 4567 Australia\r\n +61 3 3456 3456 Australia\r\n +61 3 2345 2345 Australia\r\n" - . " +61 3 1234 1234 Australia\r\nMeeting ID: 123 1234 1234\r\nPasscode: 123456\r\n" - . "Find your local number: https://us02web.zoom.us/u/abcde12345\r\n\r\nJoin by SIP\r\n1231231231234@zoomabc.com\r\n\r\n" - . "Join by H.323\r\n162.255.37.11 (US West)\r\n162.255.36.11 (US East)\r\n115.114.131.7 (India Mumbai)\r\n" - . "115.114.115.7 (India Hyderabad)\r\n213.19.144.110 (Amsterdam Netherlands)\r\n213.244.140.110 (Germany)\r\n" - . "103.122.166.55 (Australia Sydney)\r\n103.122.167.55 (Australia Melbourne)\r\n149.137.40.110 (Singapore)\r\n" - . "64.211.144.160 (Brazil)\r\n69.174.57.160 (Canada Toronto)\r\n65.39.152.160 (Canada Vancouver)\r\n207.226.132.110 (Japan Tokyo)\r\n" - . "149.137.24.110 (Japan Osaka)\r\nMeeting ID: 966 7989 3993\r\nPasscode: 44730043"; + $message = (new \mod_zoom\invitation( + $this->get_mock_invitation_message_scheduledmeeting() + ))->get_display_string($zoom->cmid); + $expectedmessage = "Organization is inviting you to a scheduled Zoom meeting.\r\n" + . "\r\n" + . "Topic: Zoom Meeting\r\n" + . "Time: Mar 15, 2021 06:08 AM London\r\n" + . "\r\n" + . "Join Zoom Meeting\r\n" + . "https://us02web.zoom.us/j/12341234123?pwd=THBLWExVS0QyYnV1Z1nZTDJGYVI2QT09\r\n" + . "\r\n" + . "Meeting ID: 123 1234 1234\r\n" + . "Passcode: 123123\r\n" + . "\r\n" + . "One tap mobile\r\n" + . "+61323452345,,12341234123#,,,,*123456# Australia\r\n" + . "+61312341234,,12341234123#,,,,*123456# Australia\r\n" + . "\r\n" + . "Dial by your location\r\n" + . " +61 3 5678 5678 Australia\r\n" + . " +61 3 4567 4567 Australia\r\n" + . " +61 3 3456 3456 Australia\r\n" + . " +61 3 2345 2345 Australia\r\n" + . " +61 3 1234 1234 Australia\r\n" + . "Meeting ID: 123 1234 1234\r\n" + . "Passcode: 123456\r\n" + . "Find your local number: https://us02web.zoom.us/u/abcde12345\r\n" + . "\r\n" + . "Join by SIP\r\n" + . "1231231231234@zoomabc.com\r\n" + . "\r\n" + . "Join by H.323\r\n" + . "162.255.37.11 (US West)\r\n" + . "162.255.36.11 (US East)\r\n" + . "115.114.131.7 (India Mumbai)\r\n" + . "115.114.115.7 (India Hyderabad)\r\n" + . "213.19.144.110 (Amsterdam Netherlands)\r\n" + . "213.244.140.110 (Germany)\r\n" + . "103.122.166.55 (Australia Sydney)\r\n" + . "103.122.167.55 (Australia Melbourne)\r\n" + . "149.137.40.110 (Singapore)\r\n" + . "64.211.144.160 (Brazil)\r\n" + . "69.174.57.160 (Canada Toronto)\r\n" + . "65.39.152.160 (Canada Vancouver)\r\n" + . "207.226.132.110 (Japan Tokyo)\r\n" + . "149.137.24.110 (Japan Osaka)\r\n" + . "Meeting ID: 966 7989 3993\r\n" + . "Passcode: 44730043"; $this->assertEquals($expectedmessage, $message); // Test a recurring meeting with no fixed time. - $message = (new \mod_zoom\invitation($this->get_mock_invitation_message_recurringnofixed()))->get_display_string($zoom->cmid); - $expectedmessage = "Organization is inviting you to a scheduled Zoom meeting.\r\n\r\n" - . "Topic: Zoom Meeting\r\nTime: This is a recurring meeting Meet anytime\r\n\r\n" - . "Join Zoom Meeting\r\nhttps://us02web.zoom.us/j/12341234123?pwd=THBLWExVS0QyYnV1Z1nZTDJGYVI2QT09\r\n\r\n" - . "Meeting ID: 123 1234 1234\r\nPasscode: 123123\r\n\r\nOne tap mobile\r\n+61323452345,,12341234123#,,,,*123456# Australia\r\n" - . "+61312341234,,12341234123#,,,,*123456# Australia\r\n\r\nDial by your location\r\n +61 3 5678 5678 Australia\r\n" - . " +61 3 4567 4567 Australia\r\n +61 3 3456 3456 Australia\r\n +61 3 2345 2345 Australia\r\n" - . " +61 3 1234 1234 Australia\r\nMeeting ID: 123 1234 1234\r\nPasscode: 123456\r\n" - . "Find your local number: https://us02web.zoom.us/u/abcde12345\r\n\r\nJoin by SIP\r\n1231231231234@zoomabc.com\r\n\r\n" - . "Join by H.323\r\n162.255.37.11 (US West)\r\n162.255.36.11 (US East)\r\n115.114.131.7 (India Mumbai)\r\n" - . "115.114.115.7 (India Hyderabad)\r\n213.19.144.110 (Amsterdam Netherlands)\r\n213.244.140.110 (Germany)\r\n" - . "103.122.166.55 (Australia Sydney)\r\n103.122.167.55 (Australia Melbourne)\r\n149.137.40.110 (Singapore)\r\n" - . "64.211.144.160 (Brazil)\r\n69.174.57.160 (Canada Toronto)\r\n65.39.152.160 (Canada Vancouver)\r\n207.226.132.110 (Japan Tokyo)\r\n" - . "149.137.24.110 (Japan Osaka)\r\nMeeting ID: 966 7989 3993\r\nPasscode: 44730043"; + $message = (new \mod_zoom\invitation( + $this->get_mock_invitation_message_recurringnofixed() + ))->get_display_string($zoom->cmid); + $expectedmessage = "Organization is inviting you to a scheduled Zoom meeting.\r\n" + . "\r\n" + . "Topic: Zoom Meeting\r\n" + . "Time: This is a recurring meeting Meet anytime\r\n" + . "\r\n" + . "Join Zoom Meeting\r\n" + . "https://us02web.zoom.us/j/12341234123?pwd=THBLWExVS0QyYnV1Z1nZTDJGYVI2QT09\r\n" + . "\r\n" + . "Meeting ID: 123 1234 1234\r\n" + . "Passcode: 123123\r\n" + . "\r\n" + . "One tap mobile\r\n" + . "+61323452345,,12341234123#,,,,*123456# Australia\r\n" + . "+61312341234,,12341234123#,,,,*123456# Australia\r\n" + . "\r\n" + . "Dial by your location\r\n" + . " +61 3 5678 5678 Australia\r\n" + . " +61 3 4567 4567 Australia\r\n" + . " +61 3 3456 3456 Australia\r\n" + . " +61 3 2345 2345 Australia\r\n" + . " +61 3 1234 1234 Australia\r\n" + . "Meeting ID: 123 1234 1234\r\n" + . "Passcode: 123456\r\n" + . "Find your local number: https://us02web.zoom.us/u/abcde12345\r\n" + . "\r\n" + . "Join by SIP\r\n" + . "1231231231234@zoomabc.com\r\n" + . "\r\n" + . "Join by H.323\r\n" + . "162.255.37.11 (US West)\r\n" + . "162.255.36.11 (US East)\r\n" + . "115.114.131.7 (India Mumbai)\r\n" + . "115.114.115.7 (India Hyderabad)\r\n" + . "213.19.144.110 (Amsterdam Netherlands)\r\n" + . "213.244.140.110 (Germany)\r\n" + . "103.122.166.55 (Australia Sydney)\r\n" + . "103.122.167.55 (Australia Melbourne)\r\n" + . "149.137.40.110 (Singapore)\r\n" + . "64.211.144.160 (Brazil)\r\n" + . "69.174.57.160 (Canada Toronto)\r\n" + . "65.39.152.160 (Canada Vancouver)\r\n" + . "207.226.132.110 (Japan Tokyo)\r\n" + . "149.137.24.110 (Japan Osaka)\r\n" + . "Meeting ID: 966 7989 3993\r\n" + . "Passcode: 44730043"; $this->assertEquals($expectedmessage, $message); // Test a recurring meeting with fixed time. $message = (new \mod_zoom\invitation($this->get_mock_invitation_message_recurringfixed()))->get_display_string($zoom->cmid); - $expectedmessage = "Organization is inviting you to a scheduled Zoom meeting.\r\n\r\n" - . "Topic: Zoom Meeting\r\nTime: Mar 15, 2021 06:08 AM London\r\n" - . " Every day, until Mar 17, 2021, 3 occurrence(s)\r\n" - . " Mar 15, 2021 06:08 AM\r\n" - . " Mar 16, 2021 06:08 AM\r\n" - . " Mar 17, 2021 06:08 AM\r\n" - . "Please download and import the following iCalendar (.ics) files to your calendar system.\r\n" - . "Zoom Meeting: https://us02web.zoom.us/meeting/u7Utd-GqqTkiEtEkvHci3z_X0W3TMjX_Avua/ics?icsToken=" - . "88tyKu-prjsiGNOXuBGCR_McAoigWerwtnpHj7d4lwnNACkAeDzOZtURBp91KOfx\r\n\r\n" - . "Join Zoom Meeting\r\nhttps://us02web.zoom.us/j/12341234123?pwd=THBLWExVS0QyYnV1Z1nZTDJGYVI2QT09\r\n\r\n" - . "Meeting ID: 123 1234 1234\r\nPasscode: 123123\r\n\r\nOne tap mobile\r\n+61323452345,,12341234123#,,,,*123456# Australia\r\n" - . "+61312341234,,12341234123#,,,,*123456# Australia\r\n\r\nDial by your location\r\n +61 3 5678 5678 Australia\r\n" - . " +61 3 4567 4567 Australia\r\n +61 3 3456 3456 Australia\r\n +61 3 2345 2345 Australia\r\n" - . " +61 3 1234 1234 Australia\r\nMeeting ID: 123 1234 1234\r\nPasscode: 123456\r\n" - . "Find your local number: https://us02web.zoom.us/u/abcde12345\r\n\r\nJoin by SIP\r\n1231231231234@zoomabc.com\r\n\r\n" - . "Join by H.323\r\n162.255.37.11 (US West)\r\n162.255.36.11 (US East)\r\n115.114.131.7 (India Mumbai)\r\n" - . "115.114.115.7 (India Hyderabad)\r\n213.19.144.110 (Amsterdam Netherlands)\r\n213.244.140.110 (Germany)\r\n" - . "103.122.166.55 (Australia Sydney)\r\n103.122.167.55 (Australia Melbourne)\r\n149.137.40.110 (Singapore)\r\n" - . "64.211.144.160 (Brazil)\r\n69.174.57.160 (Canada Toronto)\r\n65.39.152.160 (Canada Vancouver)\r\n207.226.132.110 (Japan Tokyo)\r\n" - . "149.137.24.110 (Japan Osaka)\r\nMeeting ID: 966 7989 3993\r\nPasscode: 44730043"; + $expectedmessage = "Organization is inviting you to a scheduled Zoom meeting.\r\n" + . "\r\n" + . "Topic: Zoom Meeting\r\n" + . "Time: Mar 15, 2021 06:08 AM London\r\n" + . " Every day, until Mar 17, 2021, 3 occurrence(s)\r\n" + . " Mar 15, 2021 06:08 AM\r\n" + . " Mar 16, 2021 06:08 AM\r\n" + . " Mar 17, 2021 06:08 AM\r\n" + . "Please download and import the following iCalendar (.ics) files to your calendar system.\r\n" + . "Zoom Meeting: https://us02web.zoom.us/meeting/u7Utd-GqqTkiEtEkvHci3z_X0W3TMjX_Avua/ics?icsToken=" + . "88tyKu-prjsiGNOXuBGCR_McAoigWerwtnpHj7d4lwnNACkAeDzOZtURBp91KOfx\r\n" + . "\r\n" + . "Join Zoom Meeting\r\n" + . "https://us02web.zoom.us/j/12341234123?pwd=THBLWExVS0QyYnV1Z1nZTDJGYVI2QT09\r\n" + . "\r\n" + . "Meeting ID: 123 1234 1234\r\n" + . "Passcode: 123123\r\n" + . "\r\n" + . "One tap mobile\r\n" + . "+61323452345,,12341234123#,,,,*123456# Australia\r\n" + . "+61312341234,,12341234123#,,,,*123456# Australia\r\n" + . "\r\n" + . "Dial by your location\r\n" + . " +61 3 5678 5678 Australia\r\n" + . " +61 3 4567 4567 Australia\r\n" + . " +61 3 3456 3456 Australia\r\n" + . " +61 3 2345 2345 Australia\r\n" + . " +61 3 1234 1234 Australia\r\n" + . "Meeting ID: 123 1234 1234\r\n" + . "Passcode: 123456\r\n" + . "Find your local number: https://us02web.zoom.us/u/abcde12345\r\n" + . "\r\n" + . "Join by SIP\r\n" + . "1231231231234@zoomabc.com\r\n" + . "\r\n" + . "Join by H.323\r\n" + . "162.255.37.11 (US West)\r\n" + . "162.255.36.11 (US East)\r\n" + . "115.114.131.7 (India Mumbai)\r\n" + . "115.114.115.7 (India Hyderabad)\r\n" + . "213.19.144.110 (Amsterdam Netherlands)\r\n" + . "213.244.140.110 (Germany)\r\n" + . "103.122.166.55 (Australia Sydney)\r\n" + . "103.122.167.55 (Australia Melbourne)\r\n" + . "149.137.40.110 (Singapore)\r\n" + . "64.211.144.160 (Brazil)\r\n" + . "69.174.57.160 (Canada Toronto)\r\n" + . "65.39.152.160 (Canada Vancouver)\r\n" + . "207.226.132.110 (Japan Tokyo)\r\n" + . "149.137.24.110 (Japan Osaka)\r\n" + . "Meeting ID: 966 7989 3993\r\n" + . "Passcode: 44730043"; $this->assertEquals($expectedmessage, $message); } @@ -391,7 +747,9 @@ public function test_display_message_when_user_has_no_capabilities_with_regex_di $role = $this->getDataGenerator()->create_role(); $zoom = $this->getDataGenerator()->create_module('zoom', ['course' => $course]); role_assign($role, $user->id, context_course::instance($course->id)); - $message = (new \mod_zoom\invitation($this->get_mock_invitation_message_scheduledmeeting()))->get_display_string($zoom->cmid, $user->id); + $message = (new \mod_zoom\invitation( + $this->get_mock_invitation_message_scheduledmeeting() + ))->get_display_string($zoom->cmid, $user->id); $expectedmessage = $this->get_mock_invitation_message_scheduledmeeting(); $this->assertEquals($expectedmessage, $message); } @@ -402,18 +760,50 @@ public function test_display_message_when_user_has_no_capabilities_with_regex_di * @return string */ private function get_mock_invitation_message_scheduledmeeting(): string { - return "Organization is inviting you to a scheduled Zoom meeting.\r\n\r\nTopic: Zoom Meeting\r\nTime: Mar 15, 2021 06:08 AM London\r\n\r\n" - . "Join Zoom Meeting\r\nhttps://us02web.zoom.us/j/12341234123?pwd=THBLWExVS0QyYnV1Z1nZTDJGYVI2QT09\r\n\r\n" - . "Meeting ID: 123 1234 1234\r\nPasscode: 123123\r\nOne tap mobile\r\n+61323452345,,12341234123#,,,,*123456# Australia\r\n" - . "+61312341234,,12341234123#,,,,*123456# Australia\r\n\r\nDial by your location\r\n +61 3 5678 5678 Australia\r\n" - . " +61 3 4567 4567 Australia\r\n +61 3 3456 3456 Australia\r\n +61 3 2345 2345 Australia\r\n" - . " +61 3 1234 1234 Australia\r\nMeeting ID: 123 1234 1234\r\nPasscode: 123456\r\n" - . "Find your local number: https://us02web.zoom.us/u/abcde12345\r\n\r\nJoin by SIP\r\n1231231231234@zoomabc.com\r\n\r\n" - . "Join by H.323\r\n162.255.37.11 (US West)\r\n162.255.36.11 (US East)\r\n115.114.131.7 (India Mumbai)\r\n" - . "115.114.115.7 (India Hyderabad)\r\n213.19.144.110 (Amsterdam Netherlands)\r\n213.244.140.110 (Germany)\r\n" - . "103.122.166.55 (Australia Sydney)\r\n103.122.167.55 (Australia Melbourne)\r\n149.137.40.110 (Singapore)\r\n" - . "64.211.144.160 (Brazil)\r\n69.174.57.160 (Canada Toronto)\r\n65.39.152.160 (Canada Vancouver)\r\n207.226.132.110 (Japan Tokyo)\r\n" - . "149.137.24.110 (Japan Osaka)\r\nMeeting ID: 966 7989 3993\r\nPasscode: 44730043\r"; + return "Organization is inviting you to a scheduled Zoom meeting.\r\n" + . "\r\n" + . "Topic: Zoom Meeting\r\n" + . "Time: Mar 15, 2021 06:08 AM London\r\n" + . "\r\n" + . "Join Zoom Meeting\r\n" + . "https://us02web.zoom.us/j/12341234123?pwd=THBLWExVS0QyYnV1Z1nZTDJGYVI2QT09\r\n" + . "\r\n" + . "Meeting ID: 123 1234 1234\r\n" + . "Passcode: 123123\r\n" + . "One tap mobile\r\n" + . "+61323452345,,12341234123#,,,,*123456# Australia\r\n" + . "+61312341234,,12341234123#,,,,*123456# Australia\r\n" + . "\r\n" + . "Dial by your location\r\n" + . " +61 3 5678 5678 Australia\r\n" + . " +61 3 4567 4567 Australia\r\n" + . " +61 3 3456 3456 Australia\r\n" + . " +61 3 2345 2345 Australia\r\n" + . " +61 3 1234 1234 Australia\r\n" + . "Meeting ID: 123 1234 1234\r\n" + . "Passcode: 123456\r\n" + . "Find your local number: https://us02web.zoom.us/u/abcde12345\r\n" + . "\r\n" + . "Join by SIP\r\n" + . "1231231231234@zoomabc.com\r\n" + . "\r\n" + . "Join by H.323\r\n" + . "162.255.37.11 (US West)\r\n" + . "162.255.36.11 (US East)\r\n" + . "115.114.131.7 (India Mumbai)\r\n" + . "115.114.115.7 (India Hyderabad)\r\n" + . "213.19.144.110 (Amsterdam Netherlands)\r\n" + . "213.244.140.110 (Germany)\r\n" + . "103.122.166.55 (Australia Sydney)\r\n" + . "103.122.167.55 (Australia Melbourne)\r\n" + . "149.137.40.110 (Singapore)\r\n" + . "64.211.144.160 (Brazil)\r\n" + . "69.174.57.160 (Canada Toronto)\r\n" + . "65.39.152.160 (Canada Vancouver)\r\n" + . "207.226.132.110 (Japan Tokyo)\r\n" + . "149.137.24.110 (Japan Osaka)\r\n" + . "Meeting ID: 966 7989 3993\r\n" + . "Passcode: 44730043\r"; } /** @@ -422,18 +812,50 @@ private function get_mock_invitation_message_scheduledmeeting(): string { * @return string */ private function get_mock_invitation_message_recurringnofixed(): string { - return "Organization is inviting you to a scheduled Zoom meeting.\r\n\r\nTopic: Zoom Meeting\r\nTime: This is a recurring meeting Meet anytime\r\n\r\n" - . "Join Zoom Meeting\r\nhttps://us02web.zoom.us/j/12341234123?pwd=THBLWExVS0QyYnV1Z1nZTDJGYVI2QT09\r\n\r\n" - . "Meeting ID: 123 1234 1234\r\nPasscode: 123123\r\nOne tap mobile\r\n+61323452345,,12341234123#,,,,*123456# Australia\r\n" - . "+61312341234,,12341234123#,,,,*123456# Australia\r\n\r\nDial by your location\r\n +61 3 5678 5678 Australia\r\n" - . " +61 3 4567 4567 Australia\r\n +61 3 3456 3456 Australia\r\n +61 3 2345 2345 Australia\r\n" - . " +61 3 1234 1234 Australia\r\nMeeting ID: 123 1234 1234\r\nPasscode: 123456\r\n" - . "Find your local number: https://us02web.zoom.us/u/abcde12345\r\n\r\nJoin by SIP\r\n1231231231234@zoomabc.com\r\n\r\n" - . "Join by H.323\r\n162.255.37.11 (US West)\r\n162.255.36.11 (US East)\r\n115.114.131.7 (India Mumbai)\r\n" - . "115.114.115.7 (India Hyderabad)\r\n213.19.144.110 (Amsterdam Netherlands)\r\n213.244.140.110 (Germany)\r\n" - . "103.122.166.55 (Australia Sydney)\r\n103.122.167.55 (Australia Melbourne)\r\n149.137.40.110 (Singapore)\r\n" - . "64.211.144.160 (Brazil)\r\n69.174.57.160 (Canada Toronto)\r\n65.39.152.160 (Canada Vancouver)\r\n207.226.132.110 (Japan Tokyo)\r\n" - . "149.137.24.110 (Japan Osaka)\r\nMeeting ID: 966 7989 3993\r\nPasscode: 44730043\r"; + return "Organization is inviting you to a scheduled Zoom meeting.\r\n" + . "\r\n" + . "Topic: Zoom Meeting\r\n" + . "Time: This is a recurring meeting Meet anytime\r\n" + . "\r\n" + . "Join Zoom Meeting\r\n" + . "https://us02web.zoom.us/j/12341234123?pwd=THBLWExVS0QyYnV1Z1nZTDJGYVI2QT09\r\n" + . "\r\n" + . "Meeting ID: 123 1234 1234\r\n" + . "Passcode: 123123\r\n" + . "One tap mobile\r\n" + . "+61323452345,,12341234123#,,,,*123456# Australia\r\n" + . "+61312341234,,12341234123#,,,,*123456# Australia\r\n" + . "\r\n" + . "Dial by your location\r\n" + . " +61 3 5678 5678 Australia\r\n" + . " +61 3 4567 4567 Australia\r\n" + . " +61 3 3456 3456 Australia\r\n" + . " +61 3 2345 2345 Australia\r\n" + . " +61 3 1234 1234 Australia\r\n" + . "Meeting ID: 123 1234 1234\r\n" + . "Passcode: 123456\r\n" + . "Find your local number: https://us02web.zoom.us/u/abcde12345\r\n" + . "\r\n" + . "Join by SIP\r\n" + . "1231231231234@zoomabc.com\r\n" + . "\r\n" + . "Join by H.323\r\n" + . "162.255.37.11 (US West)\r\n" + . "162.255.36.11 (US East)\r\n" + . "115.114.131.7 (India Mumbai)\r\n" + . "115.114.115.7 (India Hyderabad)\r\n" + . "213.19.144.110 (Amsterdam Netherlands)\r\n" + . "213.244.140.110 (Germany)\r\n" + . "103.122.166.55 (Australia Sydney)\r\n" + . "103.122.167.55 (Australia Melbourne)\r\n" + . "149.137.40.110 (Singapore)\r\n" + . "64.211.144.160 (Brazil)\r\n" + . "69.174.57.160 (Canada Toronto)\r\n" + . "65.39.152.160 (Canada Vancouver)\r\n" + . "207.226.132.110 (Japan Tokyo)\r\n" + . "149.137.24.110 (Japan Osaka)\r\n" + . "Meeting ID: 966 7989 3993\r\n" + . "Passcode: 44730043\r"; } /** @@ -442,24 +864,56 @@ private function get_mock_invitation_message_recurringnofixed(): string { * @return string */ private function get_mock_invitation_message_recurringfixed(): string { - return "Organization is inviting you to a scheduled Zoom meeting.\r\n\r\nTopic: Zoom Meeting\r\nTime: Mar 15, 2021 06:08 AM London\r\n" - . " Every day, until Mar 17, 2021, 3 occurrence(s)\r\n" - . " Mar 15, 2021 06:08 AM\r\n" - . " Mar 16, 2021 06:08 AM\r\n" - . " Mar 17, 2021 06:08 AM\r\n" - . "Please download and import the following iCalendar (.ics) files to your calendar system.\r\n" - . "Zoom Meeting: https://us02web.zoom.us/meeting/u7Utd-GqqTkiEtEkvHci3z_X0W3TMjX_Avua/ics?icsToken=" - . "88tyKu-prjsiGNOXuBGCR_McAoigWerwtnpHj7d4lwnNACkAeDzOZtURBp91KOfx\r\n\r\n" - . "Join Zoom Meeting\r\nhttps://us02web.zoom.us/j/12341234123?pwd=THBLWExVS0QyYnV1Z1nZTDJGYVI2QT09\r\n\r\n" - . "Meeting ID: 123 1234 1234\r\nPasscode: 123123\r\nOne tap mobile\r\n+61323452345,,12341234123#,,,,*123456# Australia\r\n" - . "+61312341234,,12341234123#,,,,*123456# Australia\r\n\r\nDial by your location\r\n +61 3 5678 5678 Australia\r\n" - . " +61 3 4567 4567 Australia\r\n +61 3 3456 3456 Australia\r\n +61 3 2345 2345 Australia\r\n" - . " +61 3 1234 1234 Australia\r\nMeeting ID: 123 1234 1234\r\nPasscode: 123456\r\n" - . "Find your local number: https://us02web.zoom.us/u/abcde12345\r\n\r\nJoin by SIP\r\n1231231231234@zoomabc.com\r\n\r\n" - . "Join by H.323\r\n162.255.37.11 (US West)\r\n162.255.36.11 (US East)\r\n115.114.131.7 (India Mumbai)\r\n" - . "115.114.115.7 (India Hyderabad)\r\n213.19.144.110 (Amsterdam Netherlands)\r\n213.244.140.110 (Germany)\r\n" - . "103.122.166.55 (Australia Sydney)\r\n103.122.167.55 (Australia Melbourne)\r\n149.137.40.110 (Singapore)\r\n" - . "64.211.144.160 (Brazil)\r\n69.174.57.160 (Canada Toronto)\r\n65.39.152.160 (Canada Vancouver)\r\n207.226.132.110 (Japan Tokyo)\r\n" - . "149.137.24.110 (Japan Osaka)\r\nMeeting ID: 966 7989 3993\r\nPasscode: 44730043\r"; + return "Organization is inviting you to a scheduled Zoom meeting.\r\n" + . "\r\n" + . "Topic: Zoom Meeting\r\n" + . "Time: Mar 15, 2021 06:08 AM London\r\n" + . " Every day, until Mar 17, 2021, 3 occurrence(s)\r\n" + . " Mar 15, 2021 06:08 AM\r\n" + . " Mar 16, 2021 06:08 AM\r\n" + . " Mar 17, 2021 06:08 AM\r\n" + . "Please download and import the following iCalendar (.ics) files to your calendar system.\r\n" + . "Zoom Meeting: https://us02web.zoom.us/meeting/u7Utd-GqqTkiEtEkvHci3z_X0W3TMjX_Avua/ics?icsToken=" + . "88tyKu-prjsiGNOXuBGCR_McAoigWerwtnpHj7d4lwnNACkAeDzOZtURBp91KOfx\r\n" + . "\r\n" + . "Join Zoom Meeting\r\n" + . "https://us02web.zoom.us/j/12341234123?pwd=THBLWExVS0QyYnV1Z1nZTDJGYVI2QT09\r\n" + . "\r\n" + . "Meeting ID: 123 1234 1234\r\n" + . "Passcode: 123123\r\n" + . "One tap mobile\r\n" + . "+61323452345,,12341234123#,,,,*123456# Australia\r\n" + . "+61312341234,,12341234123#,,,,*123456# Australia\r\n" + . "\r\n" + . "Dial by your location\r\n" + . " +61 3 5678 5678 Australia\r\n" + . " +61 3 4567 4567 Australia\r\n" + . " +61 3 3456 3456 Australia\r\n" + . " +61 3 2345 2345 Australia\r\n" + . " +61 3 1234 1234 Australia\r\n" + . "Meeting ID: 123 1234 1234\r\n" + . "Passcode: 123456\r\n" + . "Find your local number: https://us02web.zoom.us/u/abcde12345\r\n" + . "\r\n" + . "Join by SIP\r\n" + . "1231231231234@zoomabc.com\r\n" + . "\r\n" + . "Join by H.323\r\n" + . "162.255.37.11 (US West)\r\n" + . "162.255.36.11 (US East)\r\n" + . "115.114.131.7 (India Mumbai)\r\n" + . "115.114.115.7 (India Hyderabad)\r\n" + . "213.19.144.110 (Amsterdam Netherlands)\r\n" + . "213.244.140.110 (Germany)\r\n" + . "103.122.166.55 (Australia Sydney)\r\n" + . "103.122.167.55 (Australia Melbourne)\r\n" + . "149.137.40.110 (Singapore)\r\n" + . "64.211.144.160 (Brazil)\r\n" + . "69.174.57.160 (Canada Toronto)\r\n" + . "65.39.152.160 (Canada Vancouver)\r\n" + . "207.226.132.110 (Japan Tokyo)\r\n" + . "149.137.24.110 (Japan Osaka)\r\n" + . "Meeting ID: 966 7989 3993\r\n" + . "Passcode: 44730043\r"; } } From 8dbab73a43ea49be924f5e9fb49139f8d9562bcd Mon Sep 17 00:00:00 2001 From: Jonathan Champ Date: Thu, 30 Sep 2021 18:18:43 -0400 Subject: [PATCH 3/4] phpcs: use proper function visibility --- classes/webservice.php | 78 +++++++++++++++--------------- locallib.php | 2 +- mod_form.php | 2 +- tests/mod_zoom_webservice_test.php | 38 +++++++-------- 4 files changed, 59 insertions(+), 61 deletions(-) diff --git a/classes/webservice.php b/classes/webservice.php index f5a9fb6b..a62bd89b 100644 --- a/classes/webservice.php +++ b/classes/webservice.php @@ -109,7 +109,7 @@ class mod_zoom_webservice { protected static $userslist; /** - * Number of retries we've made for _make_call + * Number of retries we've made for make_call * @var int */ protected $makecallretries = 0; @@ -153,7 +153,7 @@ public function __construct() { /** * Makes the call to curl using the specified method, url, and parameter data. - * This has been moved out of _make_call to make unit testing possible. + * This has been moved out of make_call to make unit testing possible. * * @param \curl $curl The curl object used to make the request. * @param string $method The HTTP method to use. @@ -161,7 +161,7 @@ public function __construct() { * @param array|string $data The data to attach to the call. * @return stdClass The call's result. */ - protected function _make_curl_call(&$curl, $method, $url, $data) { + protected function make_curl_call(&$curl, $method, $url, $data) { return $curl->$method($url, $data); } @@ -170,7 +170,7 @@ protected function _make_curl_call(&$curl, $method, $url, $data) { * to enable unit testing for the webservice class. * @return curl The curl object used to make the API calls */ - protected function _get_curl_object() { + protected function get_curl_object() { return new curl(); } @@ -183,7 +183,7 @@ protected function _get_curl_object() { * @return stdClass The call's result in JSON format. * @throws moodle_exception Moodle exception is thrown for curl errors. */ - protected function _make_call($path, $data = array(), $method = 'get') { + private function make_call($path, $data = array(), $method = 'get') { global $CFG; $url = $this->apiurl . $path; $method = strtolower($method); @@ -204,7 +204,7 @@ protected function _make_call($path, $data = array(), $method = 'get') { $CFG->proxyuser = ''; $CFG->proxypassword = ''; } - $curl = $this->_get_curl_object(); // Create $curl, which implicitly uses the proxy settings from $CFG. + $curl = $this->get_curl_object(); // Create $curl, which implicitly uses the proxy settings from $CFG. if (!empty($proxyhost)) { // Restore the stored global proxy settings from above. $CFG->proxyhost = $cfg->proxyhost; @@ -224,7 +224,7 @@ protected function _make_call($path, $data = array(), $method = 'get') { $curl->setHeader('Content-Type: application/json'); $data = is_array($data) ? json_encode($data) : $data; } - $response = $this->_make_curl_call($curl, $method, $url, $data); + $response = $this->make_curl_call($curl, $method, $url, $data); if ($curl->get_errno()) { throw new moodle_exception('errorwebservice', 'mod_zoom', '', $curl->error); @@ -275,7 +275,7 @@ protected function _make_call($path, $data = array(), $method = 'get') { if ($timediff > 0 && !(defined('PHPUNIT_TEST') && PHPUNIT_TEST)) { sleep($timediff); } - return $this->_make_call($path, $data, $method); + return $this->make_call($path, $data, $method); default: if ($response) { $exception = new moodle_exception('errorwebservice', 'mod_zoom', '', $response->message); @@ -294,22 +294,22 @@ protected function _make_call($path, $data = array(), $method = 'get') { /** * Makes a paginated REST call. - * Makes a call like _make_call() but specifically for GETs with paginated results. + * Makes a call like make_call() but specifically for GETs with paginated results. * * @param string $url The URL to append to the API URL * @param array|string $data The data to attach to the call. * @param string $datatoget The name of the array of the data to get. * @return array The retrieved data. - * @see _make_call() + * @see make_call() * @link https://zoom.github.io/api/#list-users */ - protected function _make_paginated_call($url, $data = array(), $datatoget) { + private function make_paginated_call($url, $data = array(), $datatoget) { $aggregatedata = array(); $data['page_size'] = ZOOM_MAX_RECORDS_PER_CALL; do { $callresult = null; $moredata = false; - $callresult = $this->_make_call($url, $data); + $callresult = $this->make_call($url, $data); if ($callresult) { $aggregatedata = array_merge($aggregatedata, $callresult->$datatoget); @@ -345,7 +345,7 @@ public function autocreate_user($user) { ); try { - $this->_make_call($url, $data, 'post'); + $this->make_call($url, $data, 'post'); } catch (moodle_exception $error) { // If the user already exists, the error will contain 'User already in the account'. if (strpos($error->getMessage(), 'User already in the account') === true) { @@ -366,7 +366,7 @@ public function autocreate_user($user) { */ public function list_users() { if (empty(self::$userslist)) { - self::$userslist = $this->_make_paginated_call('users', null, 'users'); + self::$userslist = $this->make_paginated_call('users', null, 'users'); } return self::$userslist; } @@ -378,7 +378,7 @@ public function list_users() { * @see $numlicenses * @return bool Whether the paid user license limit has been reached. */ - protected function _paid_user_limit_reached() { + private function paid_user_limit_reached() { $userslist = $this->list_users(); $numusers = 0; foreach ($userslist as $user) { @@ -394,7 +394,7 @@ protected function _paid_user_limit_reached() { * * @return string|false If user is found, returns the User ID. Otherwise, returns false. */ - protected function _get_least_recently_active_paid_user_id() { + private function get_least_recently_active_paid_user_id() { $usertimes = array(); $userslist = $this->list_users(); foreach ($userslist as $user) { @@ -417,8 +417,8 @@ protected function _get_least_recently_active_paid_user_id() { * @return stdClass The call's result in JSON format. * @link https://zoom.github.io/api/#retrieve-a-users-settings */ - public function _get_user_settings($userid) { - return $this->_make_call('users/' . $userid . '/settings'); + public function get_user_settings($userid) { + return $this->make_call('users/' . $userid . '/settings'); } /** @@ -431,7 +431,7 @@ public function get_account_meeting_security_settings() { $url = 'accounts/me/settings?option=meeting_security'; $response = null; try { - $response = $this->_make_call($url); + $response = $this->make_call($url); // Set a default meeting password requirment if it is not present. if (!isset($response->meeting_security->meeting_password_requirement)) { $response->meeting_security->meeting_password_requirement = (object) DEFAULT_MEETING_PASSWORD_REQUIREMENT; @@ -455,7 +455,7 @@ public function get_user($identifier) { $url = 'users/' . $identifier; try { - $founduser = $this->_make_call($url); + $founduser = $this->make_call($url); } catch (moodle_exception $error) { if (zoom_is_user_not_found_error($error)) { return false; @@ -480,7 +480,7 @@ public function get_schedule_for_users($identifier) { $schedulerswithoutkey = []; $schedulers = []; try { - $response = $this->_make_call($url); + $response = $this->make_call($url); if (is_array($response->schedulers)) { $schedulerswithoutkey = $response->schedulers; } @@ -502,10 +502,8 @@ public function get_schedule_for_users($identifier) { * * @param stdClass $zoom The zoom meeting to format. * @return array The formatted meetings for the meeting. - * @todo Add functionality for 'alternative_hosts' => $zoom->option_alternative_hosts in $data['settings'] - * @todo Make UCLA data fields and API data fields match? */ - protected function _database_to_api($zoom) { + private function database_to_api($zoom) { global $CFG; $data = array( @@ -611,14 +609,14 @@ protected function _database_to_api($zoom) { */ public function provide_license($zoomuserid) { // Checks whether we need to recycle licenses and acts accordingly. - if ($this->recyclelicenses && $this->_make_call("users/$zoomuserid")->type == ZOOM_USER_TYPE_BASIC) { - if ($this->_paid_user_limit_reached()) { - $leastrecentlyactivepaiduserid = $this->_get_least_recently_active_paid_user_id(); + if ($this->recyclelicenses && $this->make_call("users/$zoomuserid")->type == ZOOM_USER_TYPE_BASIC) { + if ($this->paid_user_limit_reached()) { + $leastrecentlyactivepaiduserid = $this->get_least_recently_active_paid_user_id(); // Changes least_recently_active_user to a basic user so we can use their license. - $this->_make_call("users/$leastrecentlyactivepaiduserid", array('type' => ZOOM_USER_TYPE_BASIC), 'patch'); + $this->make_call("users/$leastrecentlyactivepaiduserid", array('type' => ZOOM_USER_TYPE_BASIC), 'patch'); } // Changes current user to pro so they can make a meeting. - $this->_make_call("users/$zoomuserid", array('type' => ZOOM_USER_TYPE_PRO), 'patch'); + $this->make_call("users/$zoomuserid", array('type' => ZOOM_USER_TYPE_PRO), 'patch'); } } @@ -633,7 +631,7 @@ public function create_meeting($zoom) { // Provide license if needed. $this->provide_license($zoom->host_id); $url = "users/$zoom->host_id/" . (!empty($zoom->webinar) ? 'webinars' : 'meetings'); - return $this->_make_call($url, $this->_database_to_api($zoom), 'post'); + return $this->make_call($url, $this->database_to_api($zoom), 'post'); } /** @@ -644,7 +642,7 @@ public function create_meeting($zoom) { */ public function update_meeting($zoom) { $url = ($zoom->webinar ? 'webinars/' : 'meetings/') . $zoom->meeting_id; - $this->_make_call($url, $this->_database_to_api($zoom), 'patch'); + $this->make_call($url, $this->database_to_api($zoom), 'patch'); } /** @@ -656,7 +654,7 @@ public function update_meeting($zoom) { */ public function delete_meeting($id, $webinar) { $url = ($webinar ? 'webinars/' : 'meetings/') . $id . '?schedule_for_reminder=false'; - $this->_make_call($url, null, 'delete'); + $this->make_call($url, null, 'delete'); } /** @@ -670,7 +668,7 @@ public function get_meeting_webinar_info($id, $webinar) { $url = ($webinar ? 'webinars/' : 'meetings/') . $id; $response = null; try { - $response = $this->_make_call($url); + $response = $this->make_call($url); } catch (moodle_exception $error) { throw $error; } @@ -694,7 +692,7 @@ public function get_meeting_invitation($zoom) { } $url = 'meetings/' . $zoom->meeting_id . '/invitation'; try { - $response = $this->_make_call($url); + $response = $this->make_call($url); } catch (moodle_exception $error) { debugging($error->getMessage()); return new \mod_zoom\invitation(null); @@ -714,7 +712,7 @@ public function get_meeting_invitation($zoom) { public function get_user_report($userid, $from, $to) { $url = 'report/users/' . $userid . '/meetings'; $data = array('from' => $from, 'to' => $to, 'page_size' => ZOOM_MAX_RECORDS_PER_CALL); - return $this->_make_paginated_call($url, $data, 'meetings'); + return $this->make_paginated_call($url, $data, 'meetings'); } /** @@ -728,7 +726,7 @@ public function get_user_report($userid, $from, $to) { */ public function list_meetings($userid, $webinar) { $url = 'users/' . $userid . ($webinar ? '/webinars' : '/meetings'); - $instances = $this->_make_paginated_call($url, null, ($webinar ? 'webinars' : 'meetings')); + $instances = $this->make_paginated_call($url, null, ($webinar ? 'webinars' : 'meetings')); return $instances; } @@ -740,7 +738,7 @@ public function list_meetings($userid, $webinar) { */ public function get_meeting_participants($meetinguuid, $webinar) { $meetinguuid = $this->encode_uuid($meetinguuid); - return $this->_make_paginated_call('report/' . ($webinar ? 'webinars' : 'meetings') . '/' + return $this->make_paginated_call('report/' . ($webinar ? 'webinars' : 'meetings') . '/' . $meetinguuid . '/participants', null, 'participants'); } @@ -752,7 +750,7 @@ public function get_meeting_participants($meetinguuid, $webinar) { * @return array An array of UUIDs. */ public function get_active_hosts_uuids($from, $to) { - $users = $this->_make_paginated_call('report/users', array('type' => 'active', 'from' => $from, 'to' => $to), 'users'); + $users = $this->make_paginated_call('report/users', array('type' => 'active', 'from' => $from, 'to' => $to), 'users'); $uuids = array(); foreach ($users as $user) { $uuids[] = $user->id; @@ -775,7 +773,7 @@ public function get_active_hosts_uuids($from, $to) { * @return array An array of meeting objects. */ public function get_meetings($from, $to) { - return $this->_make_paginated_call('metrics/meetings', + return $this->make_paginated_call('metrics/meetings', ['type' => 'past', 'from' => $from, 'to' => $to], 'meetings'); } @@ -794,7 +792,7 @@ public function get_meetings($from, $to) { * @return array An array of meeting objects. */ public function get_webinars($from, $to) { - return $this->_make_paginated_call('metrics/webinars', + return $this->make_paginated_call('metrics/webinars', ['type' => 'past', 'from' => $from, 'to' => $to], 'webinars'); } diff --git a/locallib.php b/locallib.php index 661b4e3f..7b27370d 100755 --- a/locallib.php +++ b/locallib.php @@ -829,7 +829,7 @@ function zoom_get_meeting_capacity(string $zoomhostid, bool $iswebinar = false) $service = new mod_zoom_webservice(); // Get the 'feature' section of the user's Zoom settings. - $userfeatures = $service->_get_user_settings($zoomhostid)->feature; + $userfeatures = $service->get_user_settings($zoomhostid)->feature; // If this is a webinar. if ($iswebinar == true) { diff --git a/mod_form.php b/mod_form.php index c6fca5af..3c3305a3 100755 --- a/mod_form.php +++ b/mod_form.php @@ -292,7 +292,7 @@ public function definition() { // If we are creating a new instance. if ($isnew) { // Check if the user has a webinar license. - $haswebinarlicense = $service->_get_user_settings($zoomuser->id)->feature->webinar; + $haswebinarlicense = $service->get_user_settings($zoomuser->id)->feature->webinar; // Only show if the admin always wants to show this widget or // if the admin wants to show this widget conditionally and the user has a valid license. diff --git a/tests/mod_zoom_webservice_test.php b/tests/mod_zoom_webservice_test.php index 009d62fc..f683be55 100644 --- a/tests/mod_zoom_webservice_test.php +++ b/tests/mod_zoom_webservice_test.php @@ -96,15 +96,15 @@ public function test_encode_uuid() { */ public function test_meeting_not_found_exception() { $mockservice = $this->getMockBuilder('\mod_zoom_webservice') - ->setMethods(array('_make_curl_call', '_get_curl_object')) + ->setMethods(array('make_curl_call', 'get_curl_object')) ->getMock(); $mockservice->expects($this->any()) - ->method('_make_curl_call') + ->method('make_curl_call') ->willReturn('{"code":3001,"message":"réunion introuvable"}'); $mockservice->expects($this->any()) - ->method('_get_curl_object') + ->method('get_curl_object') ->willReturn($this->notfoundmockcurl); $foundexception = false; @@ -123,15 +123,15 @@ public function test_meeting_not_found_exception() { */ public function test_user_not_found_exception() { $mockservice = $this->getMockBuilder('\mod_zoom_webservice') - ->setMethods(array('_make_curl_call', '_get_curl_object')) + ->setMethods(array('make_curl_call', 'get_curl_object')) ->getMock(); $mockservice->expects($this->any()) - ->method('_make_curl_call') + ->method('make_curl_call') ->willReturn('{"code":1001,"message":"n’existe pas ou n’appartient pas à ce compte"}'); $mockservice->expects($this->any()) - ->method('_get_curl_object') + ->method('get_curl_object') ->willReturn($this->notfoundmockcurl); $foundexception = false; @@ -178,15 +178,15 @@ public function get_info() { }; $mockservice = $this->getMockBuilder('\mod_zoom_webservice') - ->setMethods(array('_make_curl_call', '_get_curl_object')) + ->setMethods(array('make_curl_call', 'get_curl_object')) ->getMock(); $mockservice->expects($this->any()) - ->method('_make_curl_call') + ->method('make_curl_call') ->willReturn('{"code":1120,"message":"utilisateur invalide"}'); $mockservice->expects($this->any()) - ->method('_get_curl_object') + ->method('get_curl_object') ->willReturn($invalidmockcurl); $foundexception = false; @@ -252,17 +252,17 @@ public function getResponse() { }; $mockservice = $this->getMockBuilder('\mod_zoom_webservice') - ->setMethods(array('_make_curl_call', '_get_curl_object')) + ->setMethods(array('make_curl_call', 'get_curl_object')) ->getMock(); $mockservice->expects($this->any()) - ->method('_make_curl_call') + ->method('make_curl_call') ->willReturn('{"response":"success", "message": "", "code": 200}'); // Class retrywithheadermockcurl will give 429 retry error 3 times // before giving a 200. $mockservice->expects($this->any()) - ->method('_get_curl_object') + ->method('get_curl_object') ->willReturn($retrywithheadermockcurl); $result = $mockservice->get_user("1"); @@ -320,15 +320,15 @@ public function getResponse() { }; $mockservice = $this->getMockBuilder('\mod_zoom_webservice') - ->setMethods(array('_make_curl_call', '_get_curl_object')) + ->setMethods(array('make_curl_call', 'get_curl_object')) ->getMock(); $mockservice->expects($this->any()) - ->method('_make_curl_call') + ->method('make_curl_call') ->willReturn('{"response":"success"}'); $mockservice->expects($this->any()) - ->method('_get_curl_object') + ->method('get_curl_object') ->willReturn($retrynoheadermockcurl); $result = $mockservice->get_user("1"); @@ -398,11 +398,11 @@ public function getResponse() { }; $mockservice = $this->getMockBuilder('\mod_zoom_webservice') - ->setMethods(array('_get_curl_object')) + ->setMethods(array('get_curl_object')) ->getMock(); $mockservice->expects($this->any()) - ->method('_get_curl_object') + ->method('get_curl_object') ->willReturn($retryfailuremockcurl); $foundexception = false; @@ -476,11 +476,11 @@ public function getResponse() { }; $mockservice = $this->getMockBuilder('\mod_zoom_webservice') - ->setMethods(array('_get_curl_object')) + ->setMethods(array('get_curl_object')) ->getMock(); $mockservice->expects($this->any()) - ->method('_get_curl_object') + ->method('get_curl_object') ->willReturn($retryqpsmockcurl); $foundexception = false; From bd17903479bc8456a730741d52f8a48f0dcc2a6b Mon Sep 17 00:00:00 2001 From: Jonathan Champ Date: Thu, 30 Sep 2021 18:19:22 -0400 Subject: [PATCH 4/4] release: v4.1.2 --- README.md | 4 ++++ version.php | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f9cc48bb..e4976880 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,10 @@ server is properly synchronized with the time servers. ## Changelog +v4.1.2 + +- Make loadmeeting consistent via web and mobile (event, completion, grade, etc) #307 (thanks @nstefanski) + v4.1.1 - Fix invitation class not found exception #296 (thanks @byvamo for reporting) diff --git a/version.php b/version.php index 7c0fb7e3..3f860be5 100755 --- a/version.php +++ b/version.php @@ -25,8 +25,8 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'mod_zoom'; -$plugin->version = 2021090200; -$plugin->release = 'v4.1.1'; +$plugin->version = 2021093000; +$plugin->release = 'v4.1.2'; $plugin->requires = 2017051500.00; $plugin->maturity = MATURITY_STABLE; $plugin->cron = 0;