From 6f6eae5d673d550a295e451eda482c400da8097e Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Wed, 16 Oct 2024 12:35:48 +0100 Subject: [PATCH] MDL-83472 phpunit: add void return type to test methods. See also 01148a0816 from MDL-81522. --- ...y_of_inquiry_activities_completed_by_test.php | 8 ++++---- .../course_module_instance_list_viewed_test.php | 4 ++-- lib/tests/event/course_module_viewed_test.php | 4 ++-- .../tests/external/delete_entry_test.php | 2 +- .../tests/external/prepare_entry_test.php | 2 +- .../tests/external/update_entry_test.php | 10 +++++----- privacy/tests/userlist_collection_test.php | 16 ++++++++-------- .../tests/report_progress_helper_test.php | 4 ++-- 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/analytics/tests/community_of_inquiry_activities_completed_by_test.php b/analytics/tests/community_of_inquiry_activities_completed_by_test.php index afa8df8f258..8d16631f552 100644 --- a/analytics/tests/community_of_inquiry_activities_completed_by_test.php +++ b/analytics/tests/community_of_inquiry_activities_completed_by_test.php @@ -50,7 +50,7 @@ final class community_of_inquiry_activities_completed_by_test extends advanced_t * @param string $availabilitylevel * @return void */ - public function test_get_activities_with_availability($availabilitylevel) { + public function test_get_activities_with_availability($availabilitylevel): void { list($course, $stu1) = $this->setup_course(); @@ -113,7 +113,7 @@ final class community_of_inquiry_activities_completed_by_test extends advanced_t * * @return void */ - public function test_get_activities_with_weeks() { + public function test_get_activities_with_weeks(): void { $startdate = gmmktime('0', '0', '0', 10, 24, 2015); $record = array( @@ -156,7 +156,7 @@ final class community_of_inquiry_activities_completed_by_test extends advanced_t * * @return void */ - public function test_get_activities_by_section() { + public function test_get_activities_by_section(): void { // This makes debugging easier, sorry WA's +8 :). $this->setTimezone('UTC'); @@ -226,7 +226,7 @@ final class community_of_inquiry_activities_completed_by_test extends advanced_t * * @return void */ - public function test_get_activities_with_specific_restrictions() { + public function test_get_activities_with_specific_restrictions(): void { list($course, $stu1) = $this->setup_course(); diff --git a/lib/tests/event/course_module_instance_list_viewed_test.php b/lib/tests/event/course_module_instance_list_viewed_test.php index 0420e7a095b..4554cd02763 100644 --- a/lib/tests/event/course_module_instance_list_viewed_test.php +++ b/lib/tests/event/course_module_instance_list_viewed_test.php @@ -39,7 +39,7 @@ final class course_module_instance_list_viewed_test extends advanced_testcase { /** * Test event properties and methods. */ - public function test_event_attributes() { + public function test_event_attributes(): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -65,7 +65,7 @@ final class course_module_instance_list_viewed_test extends advanced_testcase { /** * Test custom validations of the event. */ - public function test_event_validations() { + public function test_event_validations(): void { try { \mod_unittests\event\course_module_instance_list_viewed::create(array('context' => context_system::instance())); $this->fail('Event validation should not allow course_module_instance_list_viewed event to be triggered without outside diff --git a/lib/tests/event/course_module_viewed_test.php b/lib/tests/event/course_module_viewed_test.php index 04845c1f8ab..b894b584922 100644 --- a/lib/tests/event/course_module_viewed_test.php +++ b/lib/tests/event/course_module_viewed_test.php @@ -39,7 +39,7 @@ final class course_module_viewed_test extends advanced_testcase { /** * Test event properties and methods. */ - public function test_event_attributes() { + public function test_event_attributes(): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -71,7 +71,7 @@ final class course_module_viewed_test extends advanced_testcase { /** * Test custom validations of the event. */ - public function test_event_validations() { + public function test_event_validations(): void { // Make sure objecttable and object id is always set. try { diff --git a/mod/glossary/tests/external/delete_entry_test.php b/mod/glossary/tests/external/delete_entry_test.php index c8482130e18..17fcae418af 100644 --- a/mod/glossary/tests/external/delete_entry_test.php +++ b/mod/glossary/tests/external/delete_entry_test.php @@ -39,7 +39,7 @@ final class delete_entry_test extends externallib_advanced_testcase { /** * Test the behaviour of delete_entry(). */ - public function test_delete_entry() { + public function test_delete_entry(): void { global $DB; $this->resetAfterTest(); diff --git a/mod/glossary/tests/external/prepare_entry_test.php b/mod/glossary/tests/external/prepare_entry_test.php index cccf19b9449..9bd98b1f248 100644 --- a/mod/glossary/tests/external/prepare_entry_test.php +++ b/mod/glossary/tests/external/prepare_entry_test.php @@ -39,7 +39,7 @@ final class prepare_entry_test extends externallib_advanced_testcase { /** * test_prepare_entry */ - public function test_prepare_entry() { + public function test_prepare_entry(): void { global $USER; $this->resetAfterTest(true); diff --git a/mod/glossary/tests/external/update_entry_test.php b/mod/glossary/tests/external/update_entry_test.php index ced2eadee9e..de39c5edcd3 100644 --- a/mod/glossary/tests/external/update_entry_test.php +++ b/mod/glossary/tests/external/update_entry_test.php @@ -43,7 +43,7 @@ final class update_entry_test extends externallib_advanced_testcase { /** * test_update_entry_without_optional_settings */ - public function test_update_entry_without_optional_settings() { + public function test_update_entry_without_optional_settings(): void { global $CFG, $DB; $this->resetAfterTest(true); @@ -78,7 +78,7 @@ final class update_entry_test extends externallib_advanced_testcase { /** * test_update_entry_duplicated */ - public function test_update_entry_duplicated() { + public function test_update_entry_duplicated(): void { global $CFG, $DB; $this->resetAfterTest(true); @@ -115,7 +115,7 @@ final class update_entry_test extends externallib_advanced_testcase { /** * test_update_entry_with_aliases */ - public function test_update_entry_with_aliases() { + public function test_update_entry_with_aliases(): void { global $DB; $this->resetAfterTest(true); @@ -152,7 +152,7 @@ final class update_entry_test extends externallib_advanced_testcase { /** * test_update_entry_in_categories */ - public function test_update_entry_in_categories() { + public function test_update_entry_in_categories(): void { global $DB; $this->resetAfterTest(true); @@ -193,7 +193,7 @@ final class update_entry_test extends externallib_advanced_testcase { /** * test_update_entry_with_attachments */ - public function test_update_entry_with_attachments() { + public function test_update_entry_with_attachments(): void { global $DB, $USER; $this->resetAfterTest(true); diff --git a/privacy/tests/userlist_collection_test.php b/privacy/tests/userlist_collection_test.php index fa358fdf344..e1596dc22e7 100644 --- a/privacy/tests/userlist_collection_test.php +++ b/privacy/tests/userlist_collection_test.php @@ -37,7 +37,7 @@ final class userlist_collection_test extends advanced_testcase { * * @covers ::add_userlist */ - public function test_supports_userlist() { + public function test_supports_userlist(): void { $cut = \context_system::instance(); $uut = new userlist_collection($cut); @@ -52,7 +52,7 @@ final class userlist_collection_test extends advanced_testcase { * * @covers ::add_userlist */ - public function test_supports_approved_userlist() { + public function test_supports_approved_userlist(): void { $cut = \context_system::instance(); $uut = new userlist_collection($cut); @@ -67,7 +67,7 @@ final class userlist_collection_test extends advanced_testcase { * * @covers ::get_userlist_for_component */ - public function test_get_userlist_for_component() { + public function test_get_userlist_for_component(): void { $cut = \context_system::instance(); $uut = new userlist_collection($cut); @@ -88,7 +88,7 @@ final class userlist_collection_test extends advanced_testcase { * * @covers ::get_userlist_for_component */ - public function test_get_userlist_for_component_not_found() { + public function test_get_userlist_for_component_not_found(): void { $cut = \context_system::instance(); $uut = new userlist_collection($cut); @@ -100,7 +100,7 @@ final class userlist_collection_test extends advanced_testcase { * * @covers ::add_userlist */ - public function test_duplicate_addition_throws() { + public function test_duplicate_addition_throws(): void { $cut = \context_system::instance(); $uut = new userlist_collection($cut); @@ -116,7 +116,7 @@ final class userlist_collection_test extends advanced_testcase { * * @covers ::count */ - public function test_countable() { + public function test_countable(): void { $cut = \context_system::instance(); $uut = new userlist_collection($cut); @@ -135,7 +135,7 @@ final class userlist_collection_test extends advanced_testcase { * @covers ::rewind * @covers ::valid */ - public function test_iteration() { + public function test_iteration(): void { $cut = \context_system::instance(); $uut = new userlist_collection($cut); @@ -165,7 +165,7 @@ final class userlist_collection_test extends advanced_testcase { * * @covers ::get_context */ - public function test_get_context() { + public function test_get_context(): void { $cut = \context_system::instance(); $uut = new userlist_collection($cut); diff --git a/report/progress/tests/report_progress_helper_test.php b/report/progress/tests/report_progress_helper_test.php index 790bf6028b8..9f3c5a0d35f 100644 --- a/report/progress/tests/report_progress_helper_test.php +++ b/report/progress/tests/report_progress_helper_test.php @@ -48,7 +48,7 @@ final class report_progress_helper_test extends advanced_testcase { /** * Test process_activities_by_filter_options function. */ - public function test_sort_activities() { + public function test_sort_activities(): void { $expectedactivitytypes = ['all' => 'All activities and resources', 'assign' => 'Assignments', 'quiz' => 'Quizzes']; // Generate test data. @@ -74,7 +74,7 @@ final class report_progress_helper_test extends advanced_testcase { /** * Test filtering by section. */ - public function test_filter_activities_by_section() { + public function test_filter_activities_by_section(): void { $course = $this->getDataGenerator()->create_course(array('enablecompletion' => 1)); $this->generator->create_module('quiz', ['course' => $course->id, 'name' => 'Quiz 2', 'section' => 1], ['completion' => 1]);