Skip to content

Commit

Permalink
Merge pull request #536 from jrchamp/fix/moodle-cs-testcases
Browse files Browse the repository at this point in the history
tests: set void as return type
  • Loading branch information
jrchamp authored Oct 26, 2023
2 parents c7dba43 + e9eb43b commit 2bfad61
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 47 deletions.
20 changes: 10 additions & 10 deletions tests/advanced_passcode_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static function setUpBeforeClass(): void {
* Tests that a default password of 6 numbers is created when settings are null.
* @covers ::zoom_create_default_passcode
*/
public function test_settings_default() {
public function test_settings_default(): void {
$this->zoomdata = (object) webservice::DEFAULT_MEETING_PASSWORD_REQUIREMENT;

$passcode = zoom_create_default_passcode($this->zoomdata);
Expand All @@ -77,7 +77,7 @@ public function test_settings_default() {
* Tests that a password has the given minimum length.
* @covers ::zoom_create_default_passcode
*/
public function test_settings_length() {
public function test_settings_length(): void {
$data = [
'length' => 8,
'have_letter' => false,
Expand All @@ -95,7 +95,7 @@ public function test_settings_length() {
* Tests that a password is all numbers when the setting is specified.
* @covers ::zoom_create_default_passcode
*/
public function test_settings_only_numeric() {
public function test_settings_only_numeric(): void {
$data = [
'length' => 10,
'have_letter' => false,
Expand All @@ -114,7 +114,7 @@ public function test_settings_only_numeric() {
* Tests that a password has a letter when the setting is specified.
* @covers ::zoom_create_default_passcode
*/
public function test_settings_letter() {
public function test_settings_letter(): void {
$data = [
'length' => null,
'have_letter' => true,
Expand All @@ -133,7 +133,7 @@ public function test_settings_letter() {
* Tests that a password has uppercase and lowercase letters when the setting is specified.
* @covers ::zoom_create_default_passcode
*/
public function test_settings_upper_and_lower_letters() {
public function test_settings_upper_and_lower_letters(): void {
$data = [
'length' => null,
'have_letter' => true,
Expand All @@ -153,7 +153,7 @@ public function test_settings_upper_and_lower_letters() {
* Tests that a password has a special character when the setting is specified.
* @covers ::zoom_create_default_passcode
*/
public function test_settings_special_character() {
public function test_settings_special_character(): void {
$data = [
'length' => null,
'have_letter' => null,
Expand All @@ -172,7 +172,7 @@ public function test_settings_special_character() {
* Tests that a password has correct length, a letter, and a special character when setting is specified.
* @covers ::zoom_create_default_passcode
*/
public function test_settings_all() {
public function test_settings_all(): void {
$data = [
'length' => 7,
'have_letter' => true,
Expand All @@ -192,7 +192,7 @@ public function test_settings_all() {
* Tests that the password description is correct when all settings are present.
* @covers ::zoom_create_passcode_description
*/
public function test_pasword_description_all() {
public function test_pasword_description_all(): void {
$data = [
'length' => 9,
'have_letter' => true,
Expand All @@ -215,7 +215,7 @@ public function test_pasword_description_all() {
* Tests that the password description is correct when the only numeric option is present.
* @covers ::zoom_create_passcode_description
*/
public function test_pasword_description_only_numeric() {
public function test_pasword_description_only_numeric(): void {
$data = [
'length' => 8,
'have_letter' => false,
Expand All @@ -237,7 +237,7 @@ public function test_pasword_description_only_numeric() {
* Tests that the password description is correct when the default settings are present.
* @covers ::zoom_create_passcode_description
*/
public function test_pasword_description_default() {
public function test_pasword_description_default(): void {
$this->zoomdata = (object) webservice::DEFAULT_MEETING_PASSWORD_REQUIREMENT;

$description = zoom_create_passcode_description($this->zoomdata);
Expand Down
2 changes: 1 addition & 1 deletion tests/error_handling_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function setUp(): void {
* @covers ::zoom_is_meeting_gone_error
* @covers ::zoom_is_user_not_found_error
*/
public function test_correct_error_recognition() {
public function test_correct_error_recognition(): void {
// Check meeting not found behavior.
$this->assertTrue(zoom_is_meeting_gone_error($this->meetingnotfoundexception));
$this->assertTrue(zoom_is_meeting_gone_error($this->usernotfoundexception));
Expand Down
10 changes: 5 additions & 5 deletions tests/get_meeting_reports_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function setUp(): void {
/**
* Make sure that format_participant() filters bad data from Zoom.
*/
public function test_format_participant_filtering() {
public function test_format_participant_filtering(): void {
// Sometimes Zoom has a # instead of comma in the name.
$this->zoomdata->name = 'SMITH# JOE';
$participant = $this->meetingtask->format_participant($this->zoomdata, 1, [], []);
Expand All @@ -95,7 +95,7 @@ public function test_format_participant_filtering() {
/**
* Make sure that format_participant() can match Moodle users.
*/
public function test_format_participant_matching() {
public function test_format_participant_matching(): void {
global $DB;
return;

Expand Down Expand Up @@ -186,7 +186,7 @@ public function test_format_participant_matching() {
* Make sure that format_participant() can match Moodle users more
* aggressively on name.
*/
public function test_format_participant_name_matching() {
public function test_format_participant_name_matching(): void {
// Enroll a bunch of users. Note: names were generated by
// https://www.behindthename.com/random/ and any similarity to anyone
// real or ficitional is concidence and not intentional.
Expand Down Expand Up @@ -252,7 +252,7 @@ public function test_format_participant_name_matching() {
* Tests that we can handle when the Zoom API sometimes returns invalid
* userids in the report/meeting/participants call.
*/
public function test_invalid_userids() {
public function test_invalid_userids(): void {
global $DB, $SITE;

// Make sure we start with nothing.
Expand Down Expand Up @@ -342,7 +342,7 @@ public function test_invalid_userids() {
* Tests that normalize_meeting() can handle different meeting records from
* Dashboard API versus the Report API.
*/
public function test_normalize_meeting() {
public function test_normalize_meeting(): void {
$dashboardmeeting = [
'uuid' => 'sfsdfsdfc6122222d',
'id' => 1000000,
Expand Down
6 changes: 3 additions & 3 deletions tests/mod_zoom_grade_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function setUp(): void {
* Tests that Zoom grades can be added and updated in the gradebook.
* @covers ::zoom_grade_item_update
*/
public function test_grade_added() {
public function test_grade_added(): void {
$params['course'] = $this->course->id;
$params['grade'] = 100;

Expand Down Expand Up @@ -109,7 +109,7 @@ public function test_grade_added() {
* Tests that the Zoom grade type cannot be changed to NONE if grades are already inputted.
* @covers ::zoom_grade_item_update
*/
public function test_grade_type_not_none() {
public function test_grade_type_not_none(): void {
$params['course'] = $this->course->id;
$params['grade'] = 100;

Expand Down Expand Up @@ -140,7 +140,7 @@ public function test_grade_type_not_none() {
* Tests that the Zoom grades can be deleted.
* @covers ::zoom_grade_item_delete
*/
public function test_grade_delete() {
public function test_grade_delete(): void {
$params['course'] = $this->course->id;
$params['grade'] = 100;

Expand Down
26 changes: 13 additions & 13 deletions tests/mod_zoom_invitation_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected function setUp(): void {
/**
* Test zoom invitation display message for user with all capabilities.
*/
public function test_display_message_when_user_has_all_capabilities() {
public function test_display_message_when_user_has_all_capabilities(): void {
$this->resetAfterTest();
$this->setAdminUser();
$course = $this->getDataGenerator()->create_course();
Expand Down Expand Up @@ -112,7 +112,7 @@ public function test_display_message_when_user_has_all_capabilities() {
/**
* Test zoom invitation display message for user with only the mod/zoom:viewjoinurl capability.
*/
public function test_display_message_when_user_has_viewjoinurl_capability() {
public function test_display_message_when_user_has_viewjoinurl_capability(): void {
$this->resetAfterTest();
$this->setAdminUser();
$user = $this->getDataGenerator()->create_user();
Expand Down Expand Up @@ -140,7 +140,7 @@ public function test_display_message_when_user_has_viewjoinurl_capability() {
/**
* Test zoom invitation display message for user with only the mod/zoom:viewdialin capability.
*/
public function test_display_message_when_user_has_viewdialin_capability() {
public function test_display_message_when_user_has_viewdialin_capability(): void {
$this->resetAfterTest();
$this->setAdminUser();
$user = $this->getDataGenerator()->create_user();
Expand Down Expand Up @@ -197,7 +197,7 @@ public function test_display_message_when_user_has_viewdialin_capability() {
/**
* Test zoom invitation display message for user has no capabilities.
*/
public function test_display_message_when_user_has_no_capabilities() {
public function test_display_message_when_user_has_no_capabilities(): void {
$this->resetAfterTest();
$this->setAdminUser();
$user = $this->getDataGenerator()->create_user();
Expand All @@ -218,7 +218,7 @@ public function test_display_message_when_user_has_no_capabilities() {
/**
* Test message if regex pattern is intentionally set to empty for an element.
*/
public function test_display_message_when_a_regex_pattern_is_empty() {
public function test_display_message_when_a_regex_pattern_is_empty(): void {
global $PAGE;
$this->resetAfterTest();
$this->setAdminUser();
Expand All @@ -239,7 +239,7 @@ public function test_display_message_when_a_regex_pattern_is_empty() {
/**
* Test debug message if regex pattern is not valid for an element.
*/
public function test_display_message_when_a_regex_pattern_is_invalid() {
public function test_display_message_when_a_regex_pattern_is_invalid(): void {
global $PAGE;
$this->resetAfterTest();
$this->setAdminUser();
Expand All @@ -260,7 +260,7 @@ public function test_display_message_when_a_regex_pattern_is_invalid() {
/**
* Test debug message if no match is found using regex pattern for an element.
*/
public function test_display_message_when_a_regex_pattern_is_finds_no_match() {
public function test_display_message_when_a_regex_pattern_is_finds_no_match(): void {
$this->resetAfterTest();
$this->setAdminUser();
set_config('invitation_joinurl', '/nomatch/mi', 'zoom');
Expand All @@ -278,7 +278,7 @@ public function test_display_message_when_a_regex_pattern_is_finds_no_match() {
/**
* Test removing the invite sentence from the zoom meeting message.
*/
public function test_display_message_has_invite_removed_if_setting_enabled() {
public function test_display_message_has_invite_removed_if_setting_enabled(): void {
$this->resetAfterTest();
$this->setAdminUser();
set_config('invitationremoveinvite', '1', 'zoom');
Expand Down Expand Up @@ -336,7 +336,7 @@ public function test_display_message_has_invite_removed_if_setting_enabled() {
/**
* Test not removing the invite sentence from the zoom meeting message.
*/
public function test_display_message_does_not_have_invite_removed_if_setting_disabled() {
public function test_display_message_does_not_have_invite_removed_if_setting_disabled(): void {
$this->resetAfterTest();
$this->setAdminUser();
set_config('invitationremoveinvite', '0', 'zoom');
Expand Down Expand Up @@ -396,7 +396,7 @@ public function test_display_message_does_not_have_invite_removed_if_setting_dis
/**
* Test removing the iCal link from the zoom meeting message.
*/
public function test_display_message_has_icallink_removed_if_setting_enabled() {
public function test_display_message_has_icallink_removed_if_setting_enabled(): void {
$this->resetAfterTest();
$this->setAdminUser();
set_config('invitationremoveicallink', '1', 'zoom');
Expand Down Expand Up @@ -569,7 +569,7 @@ public function test_display_message_has_icallink_removed_if_setting_enabled() {
/**
* Test not removing the iCal link from the zoom meeting message.
*/
public function test_display_message_does_not_have_icallink_removed_if_setting_disabled() {
public function test_display_message_does_not_have_icallink_removed_if_setting_disabled(): void {
$this->resetAfterTest();
$this->setAdminUser();
set_config('invitationremoveicallink', '0', 'zoom');
Expand Down Expand Up @@ -738,7 +738,7 @@ public function test_display_message_does_not_have_icallink_removed_if_setting_d
/**
* Test get_display_string returns null without throwing an error if the invitation string provided is null.
*/
public function test_display_message_when_instantiated_with_null_zoom_meeting_invitation() {
public function test_display_message_when_instantiated_with_null_zoom_meeting_invitation(): void {
$this->resetAfterTest();
$this->setAdminUser();
$course = $this->getDataGenerator()->create_course();
Expand All @@ -750,7 +750,7 @@ public function test_display_message_when_instantiated_with_null_zoom_meeting_in
/**
* Test display message is returned in full regardless of capabilities if regex patterns are disabled.
*/
public function test_display_message_when_user_has_no_capabilities_with_regex_disabled() {
public function test_display_message_when_user_has_no_capabilities_with_regex_disabled(): void {
set_config('invitationregexenabled', 0, 'zoom');
$this->resetAfterTest();
$this->setAdminUser();
Expand Down
16 changes: 8 additions & 8 deletions tests/mod_zoom_webservice_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function get_info() {
/**
* Tests that uuid are encoded properly for use in web service calls.
*/
public function test_encode_uuid() {
public function test_encode_uuid(): void {
$service = zoom_webservice();

// If uuid includes / or // it needs to be double encoded.
Expand All @@ -103,7 +103,7 @@ public function test_encode_uuid() {
/**
* Tests whether the meeting not found errors are properly parsed.
*/
public function test_meeting_not_found_exception() {
public function test_meeting_not_found_exception(): void {
$mockservice = $this->getMockBuilder('\mod_zoom\webservice')
->setMethods(['make_curl_call', 'get_curl_object', 'get_access_token'])
->getMock();
Expand Down Expand Up @@ -135,7 +135,7 @@ public function test_meeting_not_found_exception() {
/**
* Tests whether user not found errors are properly parsed.
*/
public function test_user_not_found_exception() {
public function test_user_not_found_exception(): void {
$mockservice = $this->getMockBuilder('\mod_zoom\webservice')
->setMethods(['make_curl_call', 'get_curl_object', 'get_access_token'])
->getMock();
Expand Down Expand Up @@ -168,7 +168,7 @@ public function test_user_not_found_exception() {
/**
* Tests whether invalid user errors are parsed properly
*/
public function test_invalid_user_exception() {
public function test_invalid_user_exception(): void {
$invalidmockcurl = new class {
// @codingStandardsIgnoreStart
/**
Expand Down Expand Up @@ -229,7 +229,7 @@ public function get_info() {
* Tests whether the retry on a 429 works properly when the Retry-After header
* is in the curl response to specify the time that the retry should be sent.
*/
public function test_retry_with_header() {
public function test_retry_with_header(): void {
$retrywithheadermockcurl = new class {
public $numgetinfocalls = 0;
// @codingStandardsIgnoreStart
Expand Down Expand Up @@ -308,7 +308,7 @@ public function getResponse() {
* Tests whether the retry on a 429 response works when the Retry-After
* header is not sent in the curl response.
*/
public function test_retry_without_header() {
public function test_retry_without_header(): void {
$retrynoheadermockcurl = new class {
public $numgetinfocalls = 0;
// @codingStandardsIgnoreStart
Expand Down Expand Up @@ -376,7 +376,7 @@ public function getResponse() {
/**
* Tests that we throw error if we tried more than max retries.
*/
public function test_retry_exception() {
public function test_retry_exception(): void {
$retryfailuremockcurl = new class {
public $urlpath = null;
// @codingStandardsIgnoreStart
Expand Down Expand Up @@ -463,7 +463,7 @@ public function getResponse() {
/**
* Tests that we are waiting 1 minute for QPS rate limit types.
*/
public function test_retryqps_exception() {
public function test_retryqps_exception(): void {
$retryqpsmockcurl = new class {
public $urlpath = null;
// @codingStandardsIgnoreStart
Expand Down
Loading

0 comments on commit 2bfad61

Please sign in to comment.