diff --git a/admin/presets/tests/privacy/privacy_provider_test.php b/admin/presets/tests/privacy/privacy_provider_test.php index fb2bfbdc9c0..534f90ca38d 100644 --- a/admin/presets/tests/privacy/privacy_provider_test.php +++ b/admin/presets/tests/privacy/privacy_provider_test.php @@ -36,7 +36,7 @@ class privacy_provider_test extends provider_testcase { * Test for provider::get_metadata(). * @covers ::get_metadata */ - public function test_get_metadata() { + public function test_get_metadata(): void { $collection = new collection('core_adminpresets'); $newcollection = provider::get_metadata($collection); $itemcollection = $newcollection->get_collection(); @@ -49,7 +49,7 @@ class privacy_provider_test extends provider_testcase { * Test for provider::get_contexts_for_userid() doesn't return any context. * @covers ::get_contexts_for_userid */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { global $USER; $this->resetAfterTest(); @@ -67,7 +67,7 @@ class privacy_provider_test extends provider_testcase { * Test for provider::get_users_in_context() doesn't return any user. * @covers ::get_users_in_context */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { global $USER; $this->resetAfterTest(); @@ -88,7 +88,7 @@ class privacy_provider_test extends provider_testcase { * Test for provider::export_user_data(). * @covers ::export_user_data */ - public function test_export_user_data() { + public function test_export_user_data(): void { global $USER; $this->resetAfterTest(); @@ -121,7 +121,7 @@ class privacy_provider_test extends provider_testcase { * Test for provider::delete_data_for_all_users_in_context(). * @covers ::delete_data_for_all_users_in_context */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB, $USER; $this->resetAfterTest(); @@ -146,7 +146,7 @@ class privacy_provider_test extends provider_testcase { * Test for provider::delete_data_for_user(). * @covers ::delete_data_for_user */ - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB, $USER; $this->resetAfterTest(); diff --git a/admin/roles/tests/preset_test.php b/admin/roles/tests/preset_test.php index 370a3e2de80..bc18626b12f 100644 --- a/admin/roles/tests/preset_test.php +++ b/admin/roles/tests/preset_test.php @@ -27,7 +27,7 @@ use core_role_preset; * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class preset_test extends \advanced_testcase { - public function test_xml() { + public function test_xml(): void { global $DB; $roles = $DB->get_records('role'); @@ -81,7 +81,7 @@ class preset_test extends \advanced_testcase { * Tests covered method. * @covers \core_role_preset::parse_preset */ - public function test_mixed_levels() { + public function test_mixed_levels(): void { // The problem here is that we cannot guarantee plugin contexts // have unique short names, so we have to also support level numbers. $xml = file_get_contents(__DIR__ . '/fixtures/mixed_levels.xml'); diff --git a/admin/roles/tests/privacy/provider_test.php b/admin/roles/tests/privacy/provider_test.php index 4846ac74b5e..e1c851151b0 100644 --- a/admin/roles/tests/privacy/provider_test.php +++ b/admin/roles/tests/privacy/provider_test.php @@ -45,7 +45,7 @@ class provider_test extends provider_testcase { * Test to check export_user_preferences. * returns user preferences data. */ - public function test_export_user_preferences() { + public function test_export_user_preferences(): void { $this->resetAfterTest(); $this->setAdminUser(); $user = $this->getDataGenerator()->create_user(); @@ -64,7 +64,7 @@ class provider_test extends provider_testcase { /** * Check all contexts are returned if there is any user data for this user. */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { global $DB; $this->resetAfterTest(); @@ -114,7 +114,7 @@ class provider_test extends provider_testcase { /** * Test that user data is exported correctly. */ - public function test_export_user_data() { + public function test_export_user_data(): void { global $DB; $this->resetAfterTest(); @@ -243,7 +243,7 @@ class provider_test extends provider_testcase { /** * Test for provider::delete_data_for_all_users_in_context(). */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; $this->resetAfterTest(); @@ -329,7 +329,7 @@ class provider_test extends provider_testcase { /** * Test for provider::delete_data_for_user(). */ - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; $this->resetAfterTest(); @@ -387,7 +387,7 @@ class provider_test extends provider_testcase { /** * Export for a user with a key against a script where no instance is specified. */ - public function test_export_user_role_to_cohort() { + public function test_export_user_role_to_cohort(): void { global $DB; $this->resetAfterTest(); @@ -443,7 +443,7 @@ class provider_test extends provider_testcase { /** * Test for provider::delete_user_role_to_cohort(). */ - public function test_delete_user_role_to_cohort() { + public function test_delete_user_role_to_cohort(): void { global $DB; $this->resetAfterTest(); @@ -478,7 +478,7 @@ class provider_test extends provider_testcase { /** * Test that only users within a course context are fetched. */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { global $DB; $this->resetAfterTest(); @@ -599,7 +599,7 @@ class provider_test extends provider_testcase { /** * Test that data for users in approved userlist is deleted. */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { global $DB; $this->resetAfterTest(); diff --git a/admin/tool/admin_presets/tests/event/preset_deleted_test.php b/admin/tool/admin_presets/tests/event/preset_deleted_test.php index 0f4a4928a98..050513821d1 100644 --- a/admin/tool/admin_presets/tests/event/preset_deleted_test.php +++ b/admin/tool/admin_presets/tests/event/preset_deleted_test.php @@ -30,7 +30,7 @@ class preset_deleted_test extends \advanced_testcase { /** * Test preset_deleted event. */ - public function test_preset_deleted_event() { + public function test_preset_deleted_event(): void { $this->resetAfterTest(); $this->setAdminUser(); diff --git a/admin/tool/admin_presets/tests/event/preset_downloaded_test.php b/admin/tool/admin_presets/tests/event/preset_downloaded_test.php index dba509b7897..290f8e703df 100644 --- a/admin/tool/admin_presets/tests/event/preset_downloaded_test.php +++ b/admin/tool/admin_presets/tests/event/preset_downloaded_test.php @@ -30,7 +30,7 @@ class preset_downloaded_test extends \advanced_testcase { /** * Test preset_downloaded event. */ - public function test_preset_downloaded_event() { + public function test_preset_downloaded_event(): void { $this->resetAfterTest(); $this->setAdminUser(); diff --git a/admin/tool/admin_presets/tests/event/preset_exported_test.php b/admin/tool/admin_presets/tests/event/preset_exported_test.php index 2f3d8e9d6db..b488e62b934 100644 --- a/admin/tool/admin_presets/tests/event/preset_exported_test.php +++ b/admin/tool/admin_presets/tests/event/preset_exported_test.php @@ -30,7 +30,7 @@ class preset_exported_test extends \advanced_testcase { /** * Test preset_exported event. */ - public function test_preset_exported_event() { + public function test_preset_exported_event(): void { $this->resetAfterTest(); $this->setAdminUser(); diff --git a/admin/tool/admin_presets/tests/event/preset_imported_test.php b/admin/tool/admin_presets/tests/event/preset_imported_test.php index 6d290895e57..68622255804 100644 --- a/admin/tool/admin_presets/tests/event/preset_imported_test.php +++ b/admin/tool/admin_presets/tests/event/preset_imported_test.php @@ -30,7 +30,7 @@ class preset_imported_test extends \advanced_testcase { /** * Test preset_imported event. */ - public function test_preset_imported_event() { + public function test_preset_imported_event(): void { $this->resetAfterTest(); $this->setAdminUser(); diff --git a/admin/tool/admin_presets/tests/event/preset_loaded_test.php b/admin/tool/admin_presets/tests/event/preset_loaded_test.php index 455e3beb790..e0181967614 100644 --- a/admin/tool/admin_presets/tests/event/preset_loaded_test.php +++ b/admin/tool/admin_presets/tests/event/preset_loaded_test.php @@ -30,7 +30,7 @@ class preset_loaded_test extends \advanced_testcase { /** * Test preset_loaded event. */ - public function test_preset_loaded_event() { + public function test_preset_loaded_event(): void { $this->resetAfterTest(); $this->setAdminUser(); diff --git a/admin/tool/admin_presets/tests/event/preset_previewed_test.php b/admin/tool/admin_presets/tests/event/preset_previewed_test.php index 2a27ca117eb..f80903523c5 100644 --- a/admin/tool/admin_presets/tests/event/preset_previewed_test.php +++ b/admin/tool/admin_presets/tests/event/preset_previewed_test.php @@ -30,7 +30,7 @@ class preset_previewed_test extends \advanced_testcase { /** * Test preset_previewed event. */ - public function test_preset_previewed_event() { + public function test_preset_previewed_event(): void { $this->resetAfterTest(); $this->setAdminUser(); diff --git a/admin/tool/admin_presets/tests/event/preset_reverted_test.php b/admin/tool/admin_presets/tests/event/preset_reverted_test.php index 9dfe8d9f377..665236b9ff8 100644 --- a/admin/tool/admin_presets/tests/event/preset_reverted_test.php +++ b/admin/tool/admin_presets/tests/event/preset_reverted_test.php @@ -30,7 +30,7 @@ class preset_reverted_test extends \advanced_testcase { /** * Test preset_reverted event. */ - public function test_preset_reverted_event() { + public function test_preset_reverted_event(): void { $this->resetAfterTest(); $this->setAdminUser(); diff --git a/admin/tool/admin_presets/tests/event/presets_listed_test.php b/admin/tool/admin_presets/tests/event/presets_listed_test.php index 5fe3c8429fa..74d8beb66b5 100644 --- a/admin/tool/admin_presets/tests/event/presets_listed_test.php +++ b/admin/tool/admin_presets/tests/event/presets_listed_test.php @@ -30,7 +30,7 @@ class presets_listed_test extends \advanced_testcase { /** * Test presets_listed event. */ - public function test_presets_listed_event() { + public function test_presets_listed_event(): void { $this->resetAfterTest(); $this->setAdminUser(); diff --git a/admin/tool/analytics/tests/external/external_test.php b/admin/tool/analytics/tests/external/external_test.php index fd1fc45e0dc..20cad3573c3 100644 --- a/admin/tool/analytics/tests/external/external_test.php +++ b/admin/tool/analytics/tests/external/external_test.php @@ -50,7 +50,7 @@ class external_test extends externallib_advanced_testcase { /** * test_potential_contexts description */ - public function test_potential_contexts() { + public function test_potential_contexts(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -71,7 +71,7 @@ class external_test extends externallib_advanced_testcase { /** * test_potential_contexts description */ - public function test_potential_contexts_no_manager() { + public function test_potential_contexts_no_manager(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); diff --git a/admin/tool/behat/tests/behat_form_text_test.php b/admin/tool/behat/tests/behat_form_text_test.php index 0823cbac758..a57906959ae 100644 --- a/admin/tool/behat/tests/behat_form_text_test.php +++ b/admin/tool/behat/tests/behat_form_text_test.php @@ -70,7 +70,7 @@ class behat_form_text_test extends \basic_testcase { * @param mixed $expectation value to be checked. * @dataProvider provider_test_set_get_value() */ - public function test_set_get_value($value, $expectation) { + public function test_set_get_value($value, $expectation): void { $session = $this->createMock(Session::class); $node = $this->createMock(NodeElement::class); $node->method('getValue')->willReturn($value); @@ -115,7 +115,7 @@ class behat_form_text_test extends \basic_testcase { * @param bool $result expected return status of the function. * @dataProvider provider_test_matches() */ - public function test_matches($decsep, $value, $match, $result) { + public function test_matches($decsep, $value, $match, $result): void { global $CFG; // Switch of string manager to avoid having to (slow) customise the lang file. diff --git a/admin/tool/brickfield/tests/accessibility_test.php b/admin/tool/brickfield/tests/accessibility_test.php index 21cb64d8f5e..61ebad2072a 100644 --- a/admin/tool/brickfield/tests/accessibility_test.php +++ b/admin/tool/brickfield/tests/accessibility_test.php @@ -35,7 +35,7 @@ class accessibility_test extends \advanced_testcase { * @throws \dml_exception * @throws \moodle_exception */ - public function test_get_title() { + public function test_get_title(): void { $this->resetAfterTest(); $object = new accessibility(); $filter = new filter(); @@ -57,7 +57,7 @@ class accessibility_test extends \advanced_testcase { * * @throws \dml_exception */ - public function test_check_ids() { + public function test_check_ids(): void { $this->resetAfterTest(); $object = new accessibility(); @@ -74,7 +74,7 @@ class accessibility_test extends \advanced_testcase { * * @throws \dml_exception */ - public function test_get_translations() { + public function test_get_translations(): void { $this->resetAfterTest(); $object = new accessibility(); @@ -90,7 +90,7 @@ class accessibility_test extends \advanced_testcase { * * @throws \dml_exception */ - public function test_get_category_courseids() { + public function test_get_category_courseids(): void { $this->resetAfterTest(); $object = new accessibility(); $category = $this->getDataGenerator()->create_category(); diff --git a/admin/tool/brickfield/tests/area_test.php b/admin/tool/brickfield/tests/area_test.php index 6e88895c10a..f3b2d4b8084 100644 --- a/admin/tool/brickfield/tests/area_test.php +++ b/admin/tool/brickfield/tests/area_test.php @@ -32,7 +32,7 @@ class area_test extends area_test_base { /** * Test for the area assign intro */ - public function test_assign() { + public function test_assign(): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); $assign1 = $this->getDataGenerator()->create_module('assign', array( @@ -87,7 +87,7 @@ class area_test extends area_test_base { /** * Test for the area questiontext */ - public function test_questiontext() { + public function test_questiontext(): void { $this->resetAfterTest(); /** @var \core_question_generator $generator */ $generator = $this->getDataGenerator()->get_plugin_generator('core_question'); @@ -147,7 +147,7 @@ class area_test extends area_test_base { /** * test for the area questionanswers */ - public function test_questionanswers() { + public function test_questionanswers(): void { global $DB; $this->resetAfterTest(); @@ -191,7 +191,7 @@ class area_test extends area_test_base { /** * Test for the areas choice intro and choice options */ - public function test_choice() { + public function test_choice(): void { global $DB; $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); diff --git a/admin/tool/brickfield/tests/filters_test.php b/admin/tool/brickfield/tests/filters_test.php index edb5cde5b33..61d8b7584ef 100644 --- a/admin/tool/brickfield/tests/filters_test.php +++ b/admin/tool/brickfield/tests/filters_test.php @@ -27,7 +27,7 @@ use tool_brickfield\local\tool\filter; * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class filters_test extends \advanced_testcase { - public function test_constructor() { + public function test_constructor(): void { $this->resetAfterTest(); // Variables. @@ -56,7 +56,7 @@ class filters_test extends \advanced_testcase { $this->assertEquals($object->url, $url); } - public function test_get_course_sql() { + public function test_get_course_sql(): void { $this->resetAfterTest(); $object = new filter(); @@ -73,7 +73,7 @@ class filters_test extends \advanced_testcase { } - public function test_validate_filters() { + public function test_validate_filters(): void { $this->resetAfterTest(); // Variables. $courseid = 0; @@ -102,7 +102,7 @@ class filters_test extends \advanced_testcase { $this->assertFalse($output); } - public function test_has_course_filters() { + public function test_has_course_filters(): void { $this->resetAfterTest(); $object = new filter(); @@ -114,7 +114,7 @@ class filters_test extends \advanced_testcase { $this->assertTrue($output); } - public function test_has_capability_in_context() { + public function test_has_capability_in_context(): void { global $DB; $this->resetAfterTest(); @@ -151,7 +151,7 @@ class filters_test extends \advanced_testcase { $this->assertTrue($output); } - public function test_get_errormessage() { + public function test_get_errormessage(): void { $this->resetAfterTest(); // Variables. $courseid = 0; diff --git a/admin/tool/brickfield/tests/local/areas/core_question/questionanswers_test.php b/admin/tool/brickfield/tests/local/areas/core_question/questionanswers_test.php index 30d7c842384..54564cbce26 100644 --- a/admin/tool/brickfield/tests/local/areas/core_question/questionanswers_test.php +++ b/admin/tool/brickfield/tests/local/areas/core_question/questionanswers_test.php @@ -36,7 +36,7 @@ class questionanswers_test extends \advanced_testcase { /** * Test find course areas. */ - public function test_find_course_areas() { + public function test_find_course_areas(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -122,7 +122,7 @@ class questionanswers_test extends \advanced_testcase { /** * Test find relevant areas. */ - public function test_find_relevant_areas() { + public function test_find_relevant_areas(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -153,7 +153,7 @@ class questionanswers_test extends \advanced_testcase { /** * Test find system areas. */ - public function test_find_system_areas() { + public function test_find_system_areas(): void { $this->resetAfterTest(); $this->setAdminUser(); diff --git a/admin/tool/brickfield/tests/local/areas/core_question/questiontext_test.php b/admin/tool/brickfield/tests/local/areas/core_question/questiontext_test.php index 4e90f2f932d..8fe63b0d25f 100644 --- a/admin/tool/brickfield/tests/local/areas/core_question/questiontext_test.php +++ b/admin/tool/brickfield/tests/local/areas/core_question/questiontext_test.php @@ -42,7 +42,7 @@ class questiontext_test extends area_test_base { /** * Test find course areas. */ - public function test_find_course_areas() { + public function test_find_course_areas(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -126,7 +126,7 @@ class questiontext_test extends area_test_base { /** * Test find relevant areas. */ - public function test_find_relevant_areas() { + public function test_find_relevant_areas(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -156,7 +156,7 @@ class questiontext_test extends area_test_base { /** * Test find system areas. */ - public function test_find_system_areas() { + public function test_find_system_areas(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -197,7 +197,7 @@ class questiontext_test extends area_test_base { * * @covers ::get_course_and_category */ - public function test_get_course_and_category() { + public function test_get_course_and_category(): void { $this->resetAfterTest(); $this->setAdminUser(); diff --git a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/a_links_dont_open_new_window_test.php b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/a_links_dont_open_new_window_test.php index 2902dd9a6e1..fbc26d49486 100644 --- a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/a_links_dont_open_new_window_test.php +++ b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/a_links_dont_open_new_window_test.php @@ -103,7 +103,7 @@ EOD; /** * Test for links opening a new tab or window */ - public function test_check() { + public function test_check(): void { $results = $this->get_checker_results($this->htmlfail); $this->assertTrue($results[0]->element->tagName == 'a'); diff --git a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/a_must_contain_text_test.php b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/a_must_contain_text_test.php index 840258a47b5..86dab4958b3 100644 --- a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/a_must_contain_text_test.php +++ b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/a_must_contain_text_test.php @@ -64,7 +64,7 @@ EOD; /** * Test for anchor tags containing text */ - public function test_check() { + public function test_check(): void { $results = $this->get_checker_results($this->htmlfail); $this->assertTrue($results[0]->element->tagName == 'a'); diff --git a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/a_suspicious_link_text_test.php b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/a_suspicious_link_text_test.php index 61e55df229f..ac2d004d379 100644 --- a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/a_suspicious_link_text_test.php +++ b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/a_suspicious_link_text_test.php @@ -90,7 +90,7 @@ EOD; /** * Test for anchor tags not containing susplicious link text */ - public function test_check() { + public function test_check(): void { $results = $this->get_checker_results($this->htmlpass); $this->assertEmpty($results); diff --git a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/area_dont_open_new_window_test.php b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/area_dont_open_new_window_test.php index 119acc2d7de..73b314f8d9a 100644 --- a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/area_dont_open_new_window_test.php +++ b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/area_dont_open_new_window_test.php @@ -103,7 +103,7 @@ EOD; /** * Test Area tags opening new window without warning */ - public function test_check() { + public function test_check(): void { $results = $this->get_checker_results($this->htmlfail); $this->assertTrue($results[0]->element->tagName == 'area'); diff --git a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/area_has_alt_value_test.php b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/area_has_alt_value_test.php index 216b24e6d89..a3849e54b4a 100644 --- a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/area_has_alt_value_test.php +++ b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/area_has_alt_value_test.php @@ -64,7 +64,7 @@ EOD; /** * Test for area tags containing an alt value */ - public function test_check() { + public function test_check(): void { $results = $this->get_checker_results($this->htmlfail); $this->assertTrue($results[0]->element->tagName == 'area'); diff --git a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/basefont_is_not_used_test.php b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/basefont_is_not_used_test.php index e1bca45514f..9b4662d7ab6 100644 --- a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/basefont_is_not_used_test.php +++ b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/basefont_is_not_used_test.php @@ -64,7 +64,7 @@ EOD; /** * Test for basefont tags being used */ - public function test_check() { + public function test_check(): void { $results = $this->get_checker_results($this->htmlfail); $this->assertTrue($results[0]->element->tagName == 'basefont'); diff --git a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/blink_is_not_used_test.php b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/blink_is_not_used_test.php index 66a4ce965ac..40020c39e33 100644 --- a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/blink_is_not_used_test.php +++ b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/blink_is_not_used_test.php @@ -64,7 +64,7 @@ EOD; /** * Test for blink tags being used */ - public function test_check() { + public function test_check(): void { $results = $this->get_checker_results($this->htmlfail); $this->assertTrue($results[0]->element->tagName == 'blink'); diff --git a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/bold_is_not_used_test.php b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/bold_is_not_used_test.php index a99978976b5..276eb83b038 100644 --- a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/bold_is_not_used_test.php +++ b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/bold_is_not_used_test.php @@ -65,7 +65,7 @@ EOD; /** * Test for b tags being used */ - public function test_check() { + public function test_check(): void { $results = $this->get_checker_results($this->htmlfail); $this->assertTrue($results[0]->element->tagName == 'b'); $this->assertTrue($results[1]->element->tagName == 'b'); diff --git a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/content_too_long_test.php b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/content_too_long_test.php index a5a6702b1d1..60ece956c38 100644 --- a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/content_too_long_test.php +++ b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/content_too_long_test.php @@ -124,7 +124,7 @@ EOD; /** * Test for checking the length of the content */ - public function test_check() { + public function test_check(): void { $results = $this->get_checker_results($this->htmlfail); $this->assertTrue($results[0]->message == '

Word Count: 578

'); diff --git a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/css_text_has_contrast_test.php b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/css_text_has_contrast_test.php index f19f09bb147..1654094e4b9 100644 --- a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/css_text_has_contrast_test.php +++ b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/css_text_has_contrast_test.php @@ -229,7 +229,7 @@ EOD; /** * Test for the area assign intro */ - public function test_check() { + public function test_check(): void { $results = $this->get_checker_results($this->htmlfail1); $this->assertTrue($results[0]->element->tagName == 'p'); @@ -255,7 +255,7 @@ EOD; /** * Test with valid colour names. */ - public function test_check_for_namedcolours() { + public function test_check_for_namedcolours(): void { $results = $this->get_checker_results($this->namecolours); $this->assertTrue($results[0]->element->tagName == 'p'); } @@ -263,7 +263,7 @@ EOD; /** * Test with invalid colour names. */ - public function test_check_for_invalidcolours() { + public function test_check_for_invalidcolours(): void { $results = $this->get_checker_results($this->invalidcolours); $this->assertTrue($results[0]->element->tagName == 'p'); } @@ -271,7 +271,7 @@ EOD; /** * Test with invalid colour numeric values. */ - public function test_check_for_invalidvalues() { + public function test_check_for_invalidvalues(): void { $results = $this->get_checker_results($this->invalidvalue); $this->assertTrue($results[0]->element->tagName == 'p'); } @@ -279,7 +279,7 @@ EOD; /** * Test with empty colour values. */ - public function test_check_for_emptyvalues() { + public function test_check_for_emptyvalues(): void { $results = $this->get_checker_results($this->emptyvalue); $this->assertEmpty($results); } @@ -287,7 +287,7 @@ EOD; /** * Test for text px18 with insufficient contrast of 4.49. */ - public function test_check_for_px18_fail() { + public function test_check_for_px18_fail(): void { $results = $this->get_checker_results($this->px18); $this->assertTrue($results[0]->element->tagName == 'p'); } @@ -295,7 +295,7 @@ EOD; /** * Test for text px19 bold with sufficient contrast of 4.49. */ - public function test_check_for_px19bold_pass() { + public function test_check_for_px19bold_pass(): void { $results = $this->get_checker_results($this->px19bold); $this->assertEmpty($results); } @@ -303,7 +303,7 @@ EOD; /** * Test for text px18 with sufficient contrast of 4.81. */ - public function test_check_for_px18_pass() { + public function test_check_for_px18_pass(): void { $results = $this->get_checker_results($this->px18pass); $this->assertEmpty($results); } @@ -311,7 +311,7 @@ EOD; /** * Test for medium (12pt) text with insufficient contrast of 4.49. */ - public function test_check_for_medium_fail() { + public function test_check_for_medium_fail(): void { $results = $this->get_checker_results($this->mediumfail); $this->assertTrue($results[0]->element->tagName == 'p'); } @@ -319,7 +319,7 @@ EOD; /** * Test for medium (12pt) text with sufficient contrast of 4.81. */ - public function test_check_for_medium_pass() { + public function test_check_for_medium_pass(): void { $results = $this->get_checker_results($this->mediumpass); $this->assertEmpty($results); } @@ -327,7 +327,7 @@ EOD; /** * Test for larger (14pt) text with insufficient contrast of 2.94. */ - public function test_check_for_larger_fail() { + public function test_check_for_larger_fail(): void { $results = $this->get_checker_results($this->largerfail); $this->assertTrue($results[0]->element->tagName == 'p'); } @@ -335,7 +335,7 @@ EOD; /** * Test for larger (14pt) text with insufficient contrast of 3.02. */ - public function test_check_for_larger_pass() { + public function test_check_for_larger_pass(): void { $results = $this->get_checker_results($this->largerpass); $this->assertTrue($results[0]->element->tagName == 'p'); } @@ -343,7 +343,7 @@ EOD; /** * Test for larger (14pt) bold text with sufficient contrast of 3.02. */ - public function test_check_for_largerbold_pass() { + public function test_check_for_largerbold_pass(): void { $results = $this->get_checker_results($this->largerboldpass); $this->assertEmpty($results); } diff --git a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/embed_has_associated_no_embed_test.php b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/embed_has_associated_no_embed_test.php index 64e283f91d1..bc8fe750e56 100644 --- a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/embed_has_associated_no_embed_test.php +++ b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/embed_has_associated_no_embed_test.php @@ -81,7 +81,7 @@ EOD; /** * Test for noembed child tags */ - public function test_check() { + public function test_check(): void { $results = $this->get_checker_results($this->htmlfail); $this->assertTrue($results[0]->element->tagName == 'embed'); diff --git a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/header_h3_test.php b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/header_h3_test.php index 2941ebe595c..d52c20d4b57 100644 --- a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/header_h3_test.php +++ b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/header_h3_test.php @@ -122,7 +122,7 @@ EOD; /** * Test the header following an h3 must be h1, h2, h3 or h4. */ - public function test_check() { + public function test_check(): void { $results = $this->get_checker_results($this->htmlfail1); $this->assertTrue($results[0]->element->tagName == 'h5'); diff --git a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/headers_have_text_test.php b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/headers_have_text_test.php index 43b55534f77..8d973832286 100644 --- a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/headers_have_text_test.php +++ b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/headers_have_text_test.php @@ -76,7 +76,7 @@ EOD; /** * Test for headers not containing text */ - public function test_check() { + public function test_check(): void { $results = $this->get_checker_results($this->htmlfail); $this->assertTrue($results[0]->element->tagName == 'h2'); diff --git a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/i_is_not_used_test.php b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/i_is_not_used_test.php index 29bea3ea8be..a5a6cebb5b1 100644 --- a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/i_is_not_used_test.php +++ b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/i_is_not_used_test.php @@ -64,7 +64,7 @@ EOD; /** * Test for i tags being used */ - public function test_check() { + public function test_check(): void { $results = $this->get_checker_results($this->htmlfail); $this->assertTrue($results[0]->element->tagName == 'i'); diff --git a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/img_alt_is_different_test.php b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/img_alt_is_different_test.php index c9c420bc8d5..1a811528414 100644 --- a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/img_alt_is_different_test.php +++ b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/img_alt_is_different_test.php @@ -64,7 +64,7 @@ EOD; /** * Test for img alt attributes matching the src attribute */ - public function test_check() { + public function test_check(): void { $results = $this->get_checker_results($this->htmlfail); $this->assertTrue($results[0]->element->tagName == 'img'); diff --git a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/img_alt_is_too_long_test.php b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/img_alt_is_too_long_test.php index c5ab718e4d7..86c1704ce13 100644 --- a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/img_alt_is_too_long_test.php +++ b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/img_alt_is_too_long_test.php @@ -68,7 +68,7 @@ EOD; /** * Test for image alt attributes being too long */ - public function test_check() { + public function test_check(): void { $results = $this->get_checker_results($this->htmlfail); $this->assertTrue($results[0]->element->tagName == 'img'); diff --git a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/img_alt_not_empty_in_anchor_test.php b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/img_alt_not_empty_in_anchor_test.php index ecfeb860d9b..cf629bfaaab 100644 --- a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/img_alt_not_empty_in_anchor_test.php +++ b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/img_alt_not_empty_in_anchor_test.php @@ -63,7 +63,7 @@ EOD; /** * Test for >Anchor tags containing a nested img tag, must not have an empty alt attribute */ - public function test_check() { + public function test_check(): void { $results = $this->get_checker_results($this->htmlfail); $this->assertTrue($results[0]->element->tagName == 'img'); diff --git a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/img_alt_not_place_holder_test.php b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/img_alt_not_place_holder_test.php index 85fd7f5a0c2..421b1ba5f54 100644 --- a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/img_alt_not_place_holder_test.php +++ b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/img_alt_not_place_holder_test.php @@ -133,7 +133,7 @@ EOD; /** * Test for the each en string specified in $strings - line 43 in imgAltNotPlaceHolder. */ - public function test_failcheck() { + public function test_failcheck(): void { $results = $this->get_checker_results($this->htmlfail1); $this->assertTrue($results[0]->element->tagName == 'img'); @@ -156,7 +156,7 @@ EOD; /** * Test with alt that was not specified in the $strings array. */ - public function test_passcheck1() { + public function test_passcheck1(): void { $results = $this->get_checker_results($this->htmlpass1); $this->assertEmpty($results); } diff --git a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/img_has_alt_test.php b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/img_has_alt_test.php index 14d9941f6d9..54aeb62eb64 100644 --- a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/img_has_alt_test.php +++ b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/img_has_alt_test.php @@ -76,7 +76,7 @@ EOD; /** * Test for missing image alt text. */ - public function test_check_fail() { + public function test_check_fail(): void { $results = $this->get_checker_results($this->htmlfail1); $this->assertTrue($results[0]->element->tagName == 'img'); @@ -87,7 +87,7 @@ EOD; /** * Test for present image alt text. */ - public function test_check_pass() { + public function test_check_pass(): void { $results = $this->get_checker_results($this->htmlpass); $this->assertTrue(count($results) == 0); } diff --git a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/img_with_map_has_use_map_test.php b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/img_with_map_has_use_map_test.php index 991742a627c..554113ae47e 100644 --- a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/img_with_map_has_use_map_test.php +++ b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/img_with_map_has_use_map_test.php @@ -66,7 +66,7 @@ EOD; /** * Test for usemap attribute. */ - public function test_check_fail() { + public function test_check_fail(): void { $results = $this->get_checker_results($this->htmlfail); $this->assertTrue($results[0]->element->tagName == 'img'); } @@ -74,7 +74,7 @@ EOD; /** * Test for ismap attribute. */ - public function test_check_pass() { + public function test_check_pass(): void { $results = $this->get_checker_results($this->htmlpass); $this->assertEmpty($results); } diff --git a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/legend_text_not_empty_test.php b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/legend_text_not_empty_test.php index 76a631f2fbc..d3cce9a7835 100644 --- a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/legend_text_not_empty_test.php +++ b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/legend_text_not_empty_test.php @@ -76,7 +76,7 @@ EOD; /** * Test for if legend is empty or only has white spaces. */ - public function test_check_fail() { + public function test_check_fail(): void { $results = $this->get_checker_results($this->htmlfail1); $this->assertTrue($results[0]->element->tagName == 'legend'); @@ -87,7 +87,7 @@ EOD; /** * Test for if legend has text. */ - public function test_check_pass() { + public function test_check_pass(): void { $results = $this->get_checker_results($this->htmlpass); $this->assertEmpty($results); } diff --git a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/no_headings_test.php b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/no_headings_test.php index 3730b03e22a..dcfa737a26c 100644 --- a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/no_headings_test.php +++ b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/no_headings_test.php @@ -254,7 +254,7 @@ EOD; /** * Test for if heading exists where doc length is above 1800 */ - public function test_check_fail() { + public function test_check_fail(): void { $results = $this->get_checker_results($this->htmlfail); $this->assertNotEmpty($results); @@ -263,7 +263,7 @@ EOD; /** * Test for if marquee does not exist. */ - public function test_check_pass() { + public function test_check_pass(): void { $results = $this->get_checker_results($this->htmlpass1); $this->assertEmpty($results); diff --git a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/object_must_have_embed_test.php b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/object_must_have_embed_test.php index f560f92aecf..e40afbdc9b3 100644 --- a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/object_must_have_embed_test.php +++ b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/object_must_have_embed_test.php @@ -66,7 +66,7 @@ EOD; /** * Test for missing embed element within object element. */ - public function test_check_fail() { + public function test_check_fail(): void { $results = $this->get_checker_results($this->htmlfail); $this->assertTrue($results[0]->element->tagName == 'object'); } @@ -74,7 +74,7 @@ EOD; /** * Test for present embed element within object element. */ - public function test_check_pass() { + public function test_check_pass(): void { $results = $this->get_checker_results($this->htmlpass); $this->assertEmpty($results); } diff --git a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/object_must_have_title_test.php b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/object_must_have_title_test.php index 7235169afdd..015f5e66723 100644 --- a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/object_must_have_title_test.php +++ b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/object_must_have_title_test.php @@ -63,7 +63,7 @@ EOD; /** * Test for missing title attribute within object element. */ - public function test_check_fail() { + public function test_check_fail(): void { $results = $this->get_checker_results($this->htmlfail); $this->assertTrue($results[0]->element->tagName == 'object'); } @@ -71,7 +71,7 @@ EOD; /** * Test for present title attribute within object element. */ - public function test_check_pass() { + public function test_check_pass(): void { $results = $this->get_checker_results($this->htmlpass); $this->assertEmpty($results); } diff --git a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/object_must_have_valid_title_test.php b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/object_must_have_valid_title_test.php index 17498863a0d..f3e8d5ba74f 100644 --- a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/object_must_have_valid_title_test.php +++ b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/object_must_have_valid_title_test.php @@ -129,7 +129,7 @@ EOD; /** * Test that embed element within object element. */ - public function test_check_fail() { + public function test_check_fail(): void { $results = $this->get_checker_results($this->htmlfail); $this->assertTrue($results[0]->element->tagName == 'object'); } @@ -137,7 +137,7 @@ EOD; /** * Test for embed element within object element. */ - public function test_check_pass() { + public function test_check_pass(): void { $results = $this->get_checker_results($this->htmlpass1); $this->assertEmpty($results); diff --git a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/strike_is_not_used_test.php b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/strike_is_not_used_test.php index 2d89dbc5d89..c2a604ba55a 100644 --- a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/strike_is_not_used_test.php +++ b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/strike_is_not_used_test.php @@ -77,7 +77,7 @@ EOD; /** * Test for b tags being used */ - public function test_check() { + public function test_check(): void { $results = $this->get_checker_results($this->htmlfail); $this->assertTrue($results[0]->element->tagName == 'strike'); diff --git a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/table_data_should_have_th_test.php b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/table_data_should_have_th_test.php index ba703684ff8..e682efbcb95 100644 --- a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/table_data_should_have_th_test.php +++ b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/table_data_should_have_th_test.php @@ -117,7 +117,7 @@ EOD; /** * Test that th does not exist */ - public function test_check_fail() { + public function test_check_fail(): void { $results = $this->get_checker_results($this->htmlfail1); $this->assertTrue($results[0]->element->tagName == 'table'); @@ -128,7 +128,7 @@ EOD; /** * Test that th does exist */ - public function test_check_pass() { + public function test_check_pass(): void { $results = $this->get_checker_results($this->htmlpass1); $this->assertEmpty($results); diff --git a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/table_summary_does_not_duplicate_caption_test.php b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/table_summary_does_not_duplicate_caption_test.php index 03df83ff36a..00decd9859a 100644 --- a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/table_summary_does_not_duplicate_caption_test.php +++ b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/table_summary_does_not_duplicate_caption_test.php @@ -67,7 +67,7 @@ EOD; /** * Test that caption and summary are equal */ - public function test_check_fail() { + public function test_check_fail(): void { $results = $this->get_checker_results($this->htmlfail); $this->assertTrue($results[0]->element->tagName == 'table'); } @@ -75,7 +75,7 @@ EOD; /** * Test that caption and summary are not equal */ - public function test_check_pass() { + public function test_check_pass(): void { $results = $this->get_checker_results($this->htmlpass); $this->assertEmpty($results); } diff --git a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/table_td_should_not_merge_test.php b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/table_td_should_not_merge_test.php index 11c7b087040..1c5ab71239f 100644 --- a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/table_td_should_not_merge_test.php +++ b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/table_td_should_not_merge_test.php @@ -125,7 +125,7 @@ EOD; /** * Test for rowspan and colspan */ - public function test_check_fail() { + public function test_check_fail(): void { $results = $this->get_checker_results($this->htmlfail1); $this->assertNotEmpty($results); @@ -136,7 +136,7 @@ EOD; /** * Test for rowspan and colspan */ - public function test_check_pass() { + public function test_check_pass(): void { $results = $this->get_checker_results($this->htmlpass); $this->assertEmpty($results); } diff --git a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/table_th_should_have_scope_test.php b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/table_th_should_have_scope_test.php index 709fb4edef0..c2baabed77e 100644 --- a/admin/tool/brickfield/tests/local/htmlchecker/common/checks/table_th_should_have_scope_test.php +++ b/admin/tool/brickfield/tests/local/htmlchecker/common/checks/table_th_should_have_scope_test.php @@ -163,7 +163,7 @@ EOD; /** * Test that th has scope that is equal to col or row */ - public function test_check_fail() { + public function test_check_fail(): void { $results = $this->get_checker_results($this->htmlfail1); $this->assertEquals(2, count($results)); $this->assertTrue($results[0]->element->tagName == 'th'); @@ -177,7 +177,7 @@ EOD; /** * Test that th has scope but != col || row. Test that th has no scope */ - public function test_check_pass() { + public function test_check_pass(): void { $results = $this->get_checker_results($this->htmlpass1); $this->assertEmpty($results); diff --git a/admin/tool/brickfield/tests/local/tool/activityresults_test.php b/admin/tool/brickfield/tests/local/tool/activityresults_test.php index badaf54fd45..478f9fcbf5d 100644 --- a/admin/tool/brickfield/tests/local/tool/activityresults_test.php +++ b/admin/tool/brickfield/tests/local/tool/activityresults_test.php @@ -26,7 +26,7 @@ namespace tool_brickfield\local\tool; */ class activityresults_test extends \advanced_testcase { - public function test_toolname() { + public function test_toolname(): void { $this->resetAfterTest(); $object = new activityresults(); @@ -34,7 +34,7 @@ class activityresults_test extends \advanced_testcase { $this->assertEquals($output, 'Activity breakdown summary'); } - public function test_toolshortname() { + public function test_toolshortname(): void { $this->resetAfterTest(); $object = new activityresults(); @@ -42,7 +42,7 @@ class activityresults_test extends \advanced_testcase { $this->assertEquals($output, 'Activity breakdown'); } - public function test_pluginname() { + public function test_pluginname(): void { $this->resetAfterTest(); $object = new activityresults(); @@ -50,7 +50,7 @@ class activityresults_test extends \advanced_testcase { $this->assertEquals($output, 'activityresults'); } - public function test_get_output() { + public function test_get_output(): void { $this->resetAfterTest(); $category = $this->getDataGenerator()->create_category(); diff --git a/admin/tool/brickfield/tests/local/tool/checktyperesults_test.php b/admin/tool/brickfield/tests/local/tool/checktyperesults_test.php index e79bab3eafa..f281b85e0b1 100644 --- a/admin/tool/brickfield/tests/local/tool/checktyperesults_test.php +++ b/admin/tool/brickfield/tests/local/tool/checktyperesults_test.php @@ -26,7 +26,7 @@ namespace tool_brickfield\local\tool; */ class checktyperesults_test extends \advanced_testcase { - public function test_toolname() { + public function test_toolname(): void { $this->resetAfterTest(); $object = new checktyperesults(); @@ -34,7 +34,7 @@ class checktyperesults_test extends \advanced_testcase { $this->assertEquals($output, 'Content types summary'); } - public function test_toolshortname() { + public function test_toolshortname(): void { $this->resetAfterTest(); $object = new checktyperesults(); @@ -42,7 +42,7 @@ class checktyperesults_test extends \advanced_testcase { $this->assertEquals($output, 'Content types'); } - public function test_pluginname() { + public function test_pluginname(): void { $this->resetAfterTest(); $object = new checktyperesults(); @@ -50,7 +50,7 @@ class checktyperesults_test extends \advanced_testcase { $this->assertEquals($output, 'checktyperesults'); } - public function test_get_output() { + public function test_get_output(): void { $this->resetAfterTest(); $category = $this->getDataGenerator()->create_category(); diff --git a/admin/tool/brickfield/tests/local/tool/errors_test.php b/admin/tool/brickfield/tests/local/tool/errors_test.php index dd78e10facc..2e1a702f03d 100644 --- a/admin/tool/brickfield/tests/local/tool/errors_test.php +++ b/admin/tool/brickfield/tests/local/tool/errors_test.php @@ -26,7 +26,7 @@ namespace tool_brickfield\local\tool; */ class errors_test extends \advanced_testcase { - public function test_toolname() { + public function test_toolname(): void { $this->resetAfterTest(); $object = new errors(); @@ -34,7 +34,7 @@ class errors_test extends \advanced_testcase { $this->assertEquals($output, 'Error list summary'); } - public function test_toolshortname() { + public function test_toolshortname(): void { $this->resetAfterTest(); $object = new errors(); @@ -42,7 +42,7 @@ class errors_test extends \advanced_testcase { $this->assertEquals($output, 'Error list'); } - public function test_pluginname() { + public function test_pluginname(): void { $this->resetAfterTest(); $object = new errors(); @@ -50,7 +50,7 @@ class errors_test extends \advanced_testcase { $this->assertEquals($output, 'errors'); } - public function test_get_output() { + public function test_get_output(): void { $this->resetAfterTest(); $category = $this->getDataGenerator()->create_category(); diff --git a/admin/tool/brickfield/tests/local/tool/printable_test.php b/admin/tool/brickfield/tests/local/tool/printable_test.php index ca8300b7cc0..06bc14dfd9f 100644 --- a/admin/tool/brickfield/tests/local/tool/printable_test.php +++ b/admin/tool/brickfield/tests/local/tool/printable_test.php @@ -29,7 +29,7 @@ class printable_test extends \advanced_testcase { /** * Test tool name. */ - public function test_toolname() { + public function test_toolname(): void { $this->resetAfterTest(); $object = new printable(); @@ -40,7 +40,7 @@ class printable_test extends \advanced_testcase { /** * Test tool short name. */ - public function test_toolshortname() { + public function test_toolshortname(): void { $this->resetAfterTest(); $object = new printable(); @@ -51,7 +51,7 @@ class printable_test extends \advanced_testcase { /** * Test plugin name. */ - public function test_pluginname() { + public function test_pluginname(): void { $this->resetAfterTest(); $object = new printable(); @@ -77,7 +77,7 @@ class printable_test extends \advanced_testcase { /** * Test get output. */ - public function test_get_output() { + public function test_get_output(): void { $this->resetAfterTest(); $category = $this->getDataGenerator()->create_category(); diff --git a/admin/tool/brickfield/tests/manager_test.php b/admin/tool/brickfield/tests/manager_test.php index 9e01f9ddeb6..768e5d93c60 100644 --- a/admin/tool/brickfield/tests/manager_test.php +++ b/admin/tool/brickfield/tests/manager_test.php @@ -28,7 +28,7 @@ class manager_test extends \advanced_testcase { /** * Tests for the function manager::get_all_areas() */ - public function test_get_areas() { + public function test_get_areas(): void { $this->resetAfterTest(); $areas = manager::get_all_areas(); $areaclassnames = array_map('get_class', $areas); diff --git a/admin/tool/brickfield/tests/registration_test.php b/admin/tool/brickfield/tests/registration_test.php index 6015eba03bf..b2f736dc74a 100644 --- a/admin/tool/brickfield/tests/registration_test.php +++ b/admin/tool/brickfield/tests/registration_test.php @@ -40,7 +40,7 @@ class registration_test extends \advanced_testcase { * Tests the state of the registration system when first installed. * @throws \dml_exception */ - public function test_initial_state() { + public function test_initial_state(): void { $this->resetAfterTest(); $regobj = new mock_registration(); @@ -56,7 +56,7 @@ class registration_test extends \advanced_testcase { * Test the various states for setting registration keys. * @throws \dml_exception */ - public function test_set_keys_for_registration() { + public function test_set_keys_for_registration(): void { $this->resetAfterTest(); $regobj = new mock_registration(); @@ -79,7 +79,7 @@ class registration_test extends \advanced_testcase { * Test the validation system through its several states. * @throws \dml_exception */ - public function test_validation() { + public function test_validation(): void { $this->resetAfterTest(); $regobj = new mock_registration(); @@ -112,7 +112,7 @@ class registration_test extends \advanced_testcase { * Tests the system after validation grace periods expire. * @throws \dml_exception */ - public function test_validation_time_expiry() { + public function test_validation_time_expiry(): void { $this->resetAfterTest(); $regobj = new mock_registration(); @@ -149,7 +149,7 @@ class registration_test extends \advanced_testcase { * Tests the system after summary data time periods expire. * @throws \dml_exception */ - public function test_summary_time_expiry() { + public function test_summary_time_expiry(): void { $this->resetAfterTest(); $regobj = new mock_registration(); diff --git a/admin/tool/brickfield/tests/scheduler_test.php b/admin/tool/brickfield/tests/scheduler_test.php index 07fc7d6dc22..702157f7789 100644 --- a/admin/tool/brickfield/tests/scheduler_test.php +++ b/admin/tool/brickfield/tests/scheduler_test.php @@ -26,7 +26,7 @@ namespace tool_brickfield; */ class scheduler_test extends \advanced_testcase { - public function test_request_analysis() { + public function test_request_analysis(): void { $this->resetAfterTest(); // I believe there is a bug where the code won't work with the default constructor values. @@ -48,7 +48,7 @@ class scheduler_test extends \advanced_testcase { } - public function test_mark_analyzed() { + public function test_mark_analyzed(): void { $this->resetAfterTest(); $object = new scheduler(); $output = $object->mark_analyzed(); @@ -59,7 +59,7 @@ class scheduler_test extends \advanced_testcase { $this->assertTrue($output); } - public function test_create_schedule() { + public function test_create_schedule(): void { global $DB; $this->resetAfterTest(); @@ -76,7 +76,7 @@ class scheduler_test extends \advanced_testcase { $this->assertEquals($record->instanceid, 1); } - public function test_delete_schedule() { + public function test_delete_schedule(): void { global $DB; // Call create_record() to insert a record into the table. @@ -95,7 +95,7 @@ class scheduler_test extends \advanced_testcase { $this->assertFalse($record); } - public function test_is_in_schedule() { + public function test_is_in_schedule(): void { $this->resetAfterTest(); // This should assert to false as no record has been inserted. @@ -109,7 +109,7 @@ class scheduler_test extends \advanced_testcase { $this->assertTrue($output); } - public function test_is_scheduled() { + public function test_is_scheduled(): void { $this->resetAfterTest(); // This should assert to false as no record has been inserted. @@ -129,7 +129,7 @@ class scheduler_test extends \advanced_testcase { $this->assertTrue($output); } - public function test_is_submitted() { + public function test_is_submitted(): void { $this->resetAfterTest(); // This should assert to false as no record has been inserted. @@ -149,7 +149,7 @@ class scheduler_test extends \advanced_testcase { $this->assertTrue($output); } - public function test_is_analyzed() { + public function test_is_analyzed(): void { $this->resetAfterTest(); // This should assert to false as no record has been inserted. @@ -170,14 +170,14 @@ class scheduler_test extends \advanced_testcase { } // Can't test because it's a protected function. - public function test_standard_search_params() { + public function test_standard_search_params(): void { } // Can't test because it's a protected function. - public function test_get_contextid() { + public function test_get_contextid(): void { } - public function test_get_datarecord() { + public function test_get_datarecord(): void { $this->resetAfterTest(); $object = new scheduler(); @@ -200,11 +200,11 @@ class scheduler_test extends \advanced_testcase { } // No return statement. - public function test_process_scheduled_requests() { + public function test_process_scheduled_requests(): void { } - public function test_initialize_schedule() { + public function test_initialize_schedule(): void { global $DB; $this->resetAfterTest(); @@ -219,14 +219,14 @@ class scheduler_test extends \advanced_testcase { $this->assertEquals($record->contextlevel, 20); } - public function test_request_course_analysis() { + public function test_request_course_analysis(): void { $this->resetAfterTest(); $output = scheduler::request_course_analysis(1); $this->assertTrue($output); } - public function test_create_course_schedule() { + public function test_create_course_schedule(): void { global $DB; $this->resetAfterTest(); @@ -237,7 +237,7 @@ class scheduler_test extends \advanced_testcase { } - public function test_delete_course_schedule() { + public function test_delete_course_schedule(): void { global $DB; $this->resetAfterTest(); @@ -251,7 +251,7 @@ class scheduler_test extends \advanced_testcase { $this->assertFalse($record); } - public function test_is_course_in_schedule() { + public function test_is_course_in_schedule(): void { $this->resetAfterTest(); // This should assert to false as no record has been inserted. @@ -264,7 +264,7 @@ class scheduler_test extends \advanced_testcase { $this->assertTrue($output); } - public function test_is_course_scheduled() { + public function test_is_course_scheduled(): void { $this->resetAfterTest(); // This should assert to false as no record has been inserted. @@ -283,7 +283,7 @@ class scheduler_test extends \advanced_testcase { $this->assertTrue($output); } - public function test_is_course_analyzed() { + public function test_is_course_analyzed(): void { $this->resetAfterTest(); $object = new scheduler(10, 1); diff --git a/admin/tool/brickfield/tests/tool_test.php b/admin/tool/brickfield/tests/tool_test.php index 1b23a062e70..ed3e64ca033 100644 --- a/admin/tool/brickfield/tests/tool_test.php +++ b/admin/tool/brickfield/tests/tool_test.php @@ -58,7 +58,7 @@ w==" alt="This is a bus." />'; EOF; - public function test_build_all_accessibilitytools() { + public function test_build_all_accessibilitytools(): void { $tools = tool::build_all_accessibilitytools(); $this->assertEquals($tools['errors']::toolshortname(), 'Error list'); @@ -68,14 +68,14 @@ EOF; $this->assertEquals($tools['advanced']::toolshortname(), 'Advanced'); } - public function test_data_is_valid() { + public function test_data_is_valid(): void { $object = $this->getMockForAbstractClass(tool::class); $object->set_filter(new filter()); $output = $object->data_is_valid(); $this->assertFalse($output); } - public function test_can_access() { + public function test_can_access(): void { $this->resetAfterTest(); $category = $this->getDataGenerator()->create_category(); $filter = new filter(1, $category->id, 'tab', 3, 4); @@ -86,14 +86,14 @@ EOF; $this->assertFalse($output); } - public function test_get_error_message() { + public function test_get_error_message(): void { $tool = $this->getMockForAbstractClass(tool::class); $output = $tool->get_error_message(); $this->assertEquals($output, ''); } - public function test_get_module_label() { + public function test_get_module_label(): void { $output = tool::get_module_label('core_course'); $this->assertEquals($output, 'Course'); @@ -101,7 +101,7 @@ EOF; $this->assertEquals($output, 'Book'); } - public function test_toplevel_arguments() { + public function test_toplevel_arguments(): void { $this->resetAfterTest(); $category = $this->getDataGenerator()->create_category(); $filter = new filter(1, $category->id, 'tab', 3, 4); @@ -154,14 +154,14 @@ EOF; * @param string $content * @param bool $expectation */ - public function test_base64_img_detected(string $content, bool $expectation) { + public function test_base64_img_detected(string $content, bool $expectation): void { $this->assertEquals( $expectation, tool::base64_img_detected($content) ); } - public function test_truncate_base64() { + public function test_truncate_base64(): void { $truncated = tool::truncate_base64($this->base64img); $this->assertStringContainsString('resetAfterTest(); diff --git a/admin/tool/cohortroles/tests/api_test.php b/admin/tool/cohortroles/tests/api_test.php index 04d412e6c63..e25f5394b07 100644 --- a/admin/tool/cohortroles/tests/api_test.php +++ b/admin/tool/cohortroles/tests/api_test.php @@ -53,7 +53,7 @@ class api_test extends \advanced_testcase { cohort_add_member($this->cohort->id, $this->userassignover->id); } - public function test_create_cohort_role_assignment_without_permission() { + public function test_create_cohort_role_assignment_without_permission(): void { $this->setUser($this->userassignto); $params = (object) array( 'userid' => $this->userassignto->id, @@ -64,7 +64,7 @@ class api_test extends \advanced_testcase { api::create_cohort_role_assignment($params); } - public function test_create_cohort_role_assignment_with_invalid_data() { + public function test_create_cohort_role_assignment_with_invalid_data(): void { $this->setAdminUser(); $params = (object) array( 'userid' => $this->userassignto->id, @@ -75,7 +75,7 @@ class api_test extends \advanced_testcase { api::create_cohort_role_assignment($params); } - public function test_create_cohort_role_assignment() { + public function test_create_cohort_role_assignment(): void { $this->setAdminUser(); $params = (object) array( 'userid' => $this->userassignto->id, @@ -89,7 +89,7 @@ class api_test extends \advanced_testcase { $this->assertEquals($result->get('cohortid'), $this->cohort->id); } - public function test_delete_cohort_role_assignment_without_permission() { + public function test_delete_cohort_role_assignment_without_permission(): void { $this->setAdminUser(); $params = (object) array( 'userid' => $this->userassignto->id, @@ -102,7 +102,7 @@ class api_test extends \advanced_testcase { api::delete_cohort_role_assignment($result->get('id')); } - public function test_delete_cohort_role_assignment_with_invalid_data() { + public function test_delete_cohort_role_assignment_with_invalid_data(): void { $this->setAdminUser(); $params = (object) array( 'userid' => $this->userassignto->id, @@ -114,7 +114,7 @@ class api_test extends \advanced_testcase { api::delete_cohort_role_assignment($result->get('id') + 1); } - public function test_delete_cohort_role_assignment() { + public function test_delete_cohort_role_assignment(): void { $this->setAdminUser(); // Create a cohort role assigment. $params = (object) [ @@ -151,7 +151,7 @@ class api_test extends \advanced_testcase { /** * Test case verifying that syncing won't remove role assignments if they are valid for another cohort role assignment. */ - public function test_delete_cohort_role_assignment_cohorts_having_same_members() { + public function test_delete_cohort_role_assignment_cohorts_having_same_members(): void { $this->setAdminUser(); // Create 2 cohorts, with a 1 user (user1) present in both, @@ -203,7 +203,7 @@ class api_test extends \advanced_testcase { $this->assertContains($user2->id, $removedusers); } - public function test_list_cohort_role_assignments() { + public function test_list_cohort_role_assignments(): void { $this->setAdminUser(); $params = (object) array( 'userid' => $this->userassignto->id, @@ -217,7 +217,7 @@ class api_test extends \advanced_testcase { $this->assertEquals($list[0], $result); } - public function test_count_cohort_role_assignments() { + public function test_count_cohort_role_assignments(): void { $this->setAdminUser(); $params = (object) array( 'userid' => $this->userassignto->id, @@ -230,7 +230,7 @@ class api_test extends \advanced_testcase { $this->assertEquals($count, 1); } - public function test_sync_all_cohort_roles() { + public function test_sync_all_cohort_roles(): void { $this->setAdminUser(); $params = (object) array( 'userid' => $this->userassignto->id, diff --git a/admin/tool/cohortroles/tests/privacy/provider_test.php b/admin/tool/cohortroles/tests/privacy/provider_test.php index ab7fdfa7a75..18fa5f041cd 100644 --- a/admin/tool/cohortroles/tests/privacy/provider_test.php +++ b/admin/tool/cohortroles/tests/privacy/provider_test.php @@ -51,7 +51,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::get_contexts_for_userid(). */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { global $DB; // Test setup. @@ -94,7 +94,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::export_user_data(). */ - public function test_export_user_data() { + public function test_export_user_data(): void { // Test setup. $user = $this->getDataGenerator()->create_user(); $this->setUser($user); @@ -144,7 +144,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::delete_data_for_all_users_in_context(). */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; // Test setup. @@ -203,7 +203,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::delete_data_for_user(). */ - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; // Test setup. @@ -251,7 +251,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test that only users within a course context are fetched. */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { $component = 'tool_cohortroles'; // Create a user. @@ -293,7 +293,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test that data for users in approved userlist is deleted. */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { $component = 'tool_cohortroles'; // Create user1. diff --git a/admin/tool/dataprivacy/tests/api_test.php b/admin/tool/dataprivacy/tests/api_test.php index 74e227f8eef..ee44389e967 100644 --- a/admin/tool/dataprivacy/tests/api_test.php +++ b/admin/tool/dataprivacy/tests/api_test.php @@ -37,7 +37,7 @@ class api_test extends \advanced_testcase { * Ensure that the check_can_manage_data_registry function fails cap testing when a user without capabilities is * tested with the default context. */ - public function test_check_can_manage_data_registry_admin() { + public function test_check_can_manage_data_registry_admin(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -49,7 +49,7 @@ class api_test extends \advanced_testcase { * Ensure that the check_can_manage_data_registry function fails cap testing when a user without capabilities is * tested with the default context. */ - public function test_check_can_manage_data_registry_without_cap_default() { + public function test_check_can_manage_data_registry_without_cap_default(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); @@ -63,7 +63,7 @@ class api_test extends \advanced_testcase { * Ensure that the check_can_manage_data_registry function fails cap testing when a user without capabilities is * tested with the default context. */ - public function test_check_can_manage_data_registry_without_cap_system() { + public function test_check_can_manage_data_registry_without_cap_system(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); @@ -77,7 +77,7 @@ class api_test extends \advanced_testcase { * Ensure that the check_can_manage_data_registry function fails cap testing when a user without capabilities is * tested with the default context. */ - public function test_check_can_manage_data_registry_without_cap_own_user() { + public function test_check_can_manage_data_registry_without_cap_own_user(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); @@ -90,7 +90,7 @@ class api_test extends \advanced_testcase { /** * Test for api::update_request_status(). */ - public function test_update_request_status() { + public function test_update_request_status(): void { $this->resetAfterTest(); $generator = new testing_data_generator(); @@ -138,7 +138,7 @@ class api_test extends \advanced_testcase { /** * Test for api::get_site_dpos() when there are no users with the DPO role. */ - public function test_get_site_dpos_no_dpos() { + public function test_get_site_dpos_no_dpos(): void { $this->resetAfterTest(); $admin = get_admin(); @@ -152,7 +152,7 @@ class api_test extends \advanced_testcase { /** * Test for api::get_site_dpos() when there are no users with the DPO role. */ - public function test_get_site_dpos() { + public function test_get_site_dpos(): void { global $DB; $this->resetAfterTest(); @@ -189,7 +189,7 @@ class api_test extends \advanced_testcase { /** * Test for \tool_dataprivacy\api::get_assigned_privacy_officer_roles(). */ - public function test_get_assigned_privacy_officer_roles() { + public function test_get_assigned_privacy_officer_roles(): void { global $DB; $this->resetAfterTest(); @@ -232,7 +232,7 @@ class api_test extends \advanced_testcase { /** * Test for api::approve_data_request(). */ - public function test_approve_data_request() { + public function test_approve_data_request(): void { global $DB; $this->resetAfterTest(); @@ -276,7 +276,7 @@ class api_test extends \advanced_testcase { /** * Test for api::approve_data_request() when allow filtering of exports by course. */ - public function test_approve_data_request_with_allow_filtering() { + public function test_approve_data_request_with_allow_filtering(): void { global $DB; $this->resetAfterTest(); set_config('allowfiltering', 1, 'tool_dataprivacy'); @@ -325,7 +325,7 @@ class api_test extends \advanced_testcase { /** * Test for api::approve_data_request() when called by a user who doesn't have the DPO role. */ - public function test_approve_data_request_non_dpo_user() { + public function test_approve_data_request_non_dpo_user(): void { $this->resetAfterTest(); $generator = new testing_data_generator(); @@ -347,7 +347,7 @@ class api_test extends \advanced_testcase { /** * Test for api::add_request_contexts_with_status(). */ - public function test_add_request_contexts_with_status() { + public function test_add_request_contexts_with_status(): void { global $DB; $this->resetAfterTest(); set_config('allowfiltering', 1, 'tool_dataprivacy'); @@ -385,7 +385,7 @@ class api_test extends \advanced_testcase { /** * Test that deletion requests for the primary admin are rejected */ - public function test_reject_data_deletion_request_primary_admin() { + public function test_reject_data_deletion_request_primary_admin(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -408,7 +408,7 @@ class api_test extends \advanced_testcase { /** * Test for api::can_contact_dpo() */ - public function test_can_contact_dpo() { + public function test_can_contact_dpo(): void { $this->resetAfterTest(); // Default ('contactdataprotectionofficer' is disabled by default). @@ -426,7 +426,7 @@ class api_test extends \advanced_testcase { /** * Test for api::can_manage_data_requests() */ - public function test_can_manage_data_requests() { + public function test_can_manage_data_requests(): void { global $DB; $this->resetAfterTest(); @@ -471,7 +471,7 @@ class api_test extends \advanced_testcase { * Test that a user who has no capability to make any data requests for children cannot create data requests for any * other user. */ - public function test_can_create_data_request_for_user_no() { + public function test_can_create_data_request_for_user_no(): void { $this->resetAfterTest(); $parent = $this->getDataGenerator()->create_user(); @@ -485,7 +485,7 @@ class api_test extends \advanced_testcase { * Test that a user who has the capability to make any data requests for one other user cannot create data requests * for any other user. */ - public function test_can_create_data_request_for_user_some() { + public function test_can_create_data_request_for_user_some(): void { $this->resetAfterTest(); $parent = $this->getDataGenerator()->create_user(); @@ -505,7 +505,7 @@ class api_test extends \advanced_testcase { * Test that a user who has the capability to make any data requests for one other user cannot create data requests * for any other user. */ - public function test_can_create_data_request_for_user_own_child() { + public function test_can_create_data_request_for_user_own_child(): void { $this->resetAfterTest(); $parent = $this->getDataGenerator()->create_user(); @@ -524,7 +524,7 @@ class api_test extends \advanced_testcase { * Test that a user who has no capability to make any data requests for children cannot create data requests for any * other user. */ - public function test_require_can_create_data_request_for_user_no() { + public function test_require_can_create_data_request_for_user_no(): void { $this->resetAfterTest(); $parent = $this->getDataGenerator()->create_user(); @@ -539,7 +539,7 @@ class api_test extends \advanced_testcase { * Test that a user who has the capability to make any data requests for one other user cannot create data requests * for any other user. */ - public function test_require_can_create_data_request_for_user_some() { + public function test_require_can_create_data_request_for_user_some(): void { $this->resetAfterTest(); $parent = $this->getDataGenerator()->create_user(); @@ -560,7 +560,7 @@ class api_test extends \advanced_testcase { * Test that a user who has the capability to make any data requests for one other user cannot create data requests * for any other user. */ - public function test_require_can_create_data_request_for_user_own_child() { + public function test_require_can_create_data_request_for_user_own_child(): void { $this->resetAfterTest(); $parent = $this->getDataGenerator()->create_user(); @@ -578,7 +578,7 @@ class api_test extends \advanced_testcase { /** * Test for api::can_download_data_request_for_user() */ - public function test_can_download_data_request_for_user() { + public function test_can_download_data_request_for_user(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator(); @@ -700,7 +700,7 @@ class api_test extends \advanced_testcase { $expectedstatus, $expectedtaskcount, $allowfiltering, - ) { + ): void { global $USER; $this->resetAfterTest(); @@ -751,7 +751,7 @@ class api_test extends \advanced_testcase { /** * Test for api::create_data_request() made by a parent. */ - public function test_create_data_request_by_parent() { + public function test_create_data_request_by_parent(): void { global $DB; $this->resetAfterTest(); @@ -786,7 +786,7 @@ class api_test extends \advanced_testcase { /** * Test for api::deny_data_request() */ - public function test_deny_data_request() { + public function test_deny_data_request(): void { $this->resetAfterTest(); $generator = new testing_data_generator(); @@ -841,7 +841,7 @@ class api_test extends \advanced_testcase { * @param boolean $fetchall Whether to fetch all records. * @param int[] $statuses Status filters. */ - public function test_get_data_requests($usertype, $fetchall, $statuses) { + public function test_get_data_requests($usertype, $fetchall, $statuses): void { $this->resetAfterTest(); $generator = new testing_data_generator(); @@ -952,7 +952,7 @@ class api_test extends \advanced_testcase { /** * Test for api::get_approved_contextlist_collection_for_request. */ - public function test_get_approved_contextlist_collection_for_request() { + public function test_get_approved_contextlist_collection_for_request(): void { $this->resetAfterTest(); set_config('allowfiltering', 1, 'tool_dataprivacy'); $this->setAdminUser(); @@ -1021,7 +1021,7 @@ class api_test extends \advanced_testcase { * @param int $status The request status. * @param bool $expected The expected result. */ - public function test_has_ongoing_request($status, $expected) { + public function test_has_ongoing_request($status, $expected): void { $this->resetAfterTest(); $generator = new testing_data_generator(); @@ -1045,7 +1045,7 @@ class api_test extends \advanced_testcase { * @param int $status The request status * @param bool $expected The expected result */ - public function test_is_active($status, $expected) { + public function test_is_active($status, $expected): void { // Check if this request is ongoing. $result = api::is_active($status); $this->assertEquals($expected, $result); @@ -1054,7 +1054,7 @@ class api_test extends \advanced_testcase { /** * Test for api::is_site_dpo() */ - public function test_is_site_dpo() { + public function test_is_site_dpo(): void { global $DB; $this->resetAfterTest(); @@ -1108,7 +1108,7 @@ class api_test extends \advanced_testcase { * @param string $typestringid The request lang string identifier * @param string $comments The requestor's message to the DPO. */ - public function test_notify_dpo($byadmin, $type, $typestringid, $comments) { + public function test_notify_dpo($byadmin, $type, $typestringid, $comments): void { $this->resetAfterTest(); $generator = new testing_data_generator(); @@ -1150,7 +1150,7 @@ class api_test extends \advanced_testcase { * * @return null */ - public function test_purpose_crud() { + public function test_purpose_crud(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -1192,7 +1192,7 @@ class api_test extends \advanced_testcase { * * @return null */ - public function test_category_crud() { + public function test_category_crud(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -1230,7 +1230,7 @@ class api_test extends \advanced_testcase { * * @return null */ - public function test_context_instances() { + public function test_context_instances(): void { global $DB; $this->resetAfterTest(); @@ -1266,7 +1266,7 @@ class api_test extends \advanced_testcase { * * @return null */ - public function test_contextlevel() { + public function test_contextlevel(): void { global $DB; $this->resetAfterTest(); @@ -1302,7 +1302,7 @@ class api_test extends \advanced_testcase { * * @return null */ - public function test_effective_contextlevel_defaults() { + public function test_effective_contextlevel_defaults(): void { $this->setAdminUser(); $this->resetAfterTest(); @@ -1340,7 +1340,7 @@ class api_test extends \advanced_testcase { /** * Ensure that when nothing is configured, all values return false. */ - public function test_get_effective_contextlevel_unset() { + public function test_get_effective_contextlevel_unset(): void { // Before setup, get_effective_contextlevel_purpose will return false. $this->assertFalse(api::get_effective_contextlevel_category(CONTEXT_SYSTEM)); $this->assertFalse(api::get_effective_contextlevel_purpose(CONTEXT_SYSTEM)); @@ -1352,7 +1352,7 @@ class api_test extends \advanced_testcase { /** * Ensure that when nothing is configured, all values return false. */ - public function test_get_effective_context_unset() { + public function test_get_effective_context_unset(): void { // Before setup, get_effective_contextlevel_purpose will return false. $this->assertFalse(api::get_effective_context_category(\context_system::instance())); $this->assertFalse(api::get_effective_context_purpose(\context_system::instance())); @@ -1364,7 +1364,7 @@ class api_test extends \advanced_testcase { * @dataProvider invalid_effective_contextlevel_provider * @param int $contextlevel */ - public function test_set_contextlevel_invalid_contextlevels($contextlevel) { + public function test_set_contextlevel_invalid_contextlevels($contextlevel): void { $this->expectException(\coding_exception::class); api::set_contextlevel((object) [ @@ -1376,7 +1376,7 @@ class api_test extends \advanced_testcase { /** * Test effective contextlevel return. */ - public function test_effective_contextlevel() { + public function test_effective_contextlevel(): void { $this->resetAfterTest(); // Set the initial purpose and category. @@ -1424,7 +1424,7 @@ class api_test extends \advanced_testcase { * @dataProvider invalid_effective_contextlevel_provider * @param int $contextlevel */ - public function test_effective_contextlevel_invalid_contextlevels($contextlevel) { + public function test_effective_contextlevel_invalid_contextlevels($contextlevel): void { $this->resetAfterTest(); $purpose1 = api::create_purpose((object)['name' => 'p1', 'retentionperiod' => 'PT1H', 'lawfulbases' => 'gdpr_art_6_1_a']); @@ -1454,7 +1454,7 @@ class api_test extends \advanced_testcase { /** * Ensure that context inheritance works up the context tree. */ - public function test_effective_context_inheritance() { + public function test_effective_context_inheritance(): void { $this->resetAfterTest(); $systemdata = $this->create_and_set_purpose_for_contextlevel('PT1S', CONTEXT_SYSTEM); @@ -1734,7 +1734,7 @@ class api_test extends \advanced_testcase { * Although it should not be possible to set hard INHERIT values at this level, there may be legacy data which still * contains this. */ - public function test_effective_context_inheritance_explicitly_set() { + public function test_effective_context_inheritance_explicitly_set(): void { $this->resetAfterTest(); $systemdata = $this->create_and_set_purpose_for_contextlevel('PT1S', CONTEXT_SYSTEM); @@ -1861,7 +1861,7 @@ class api_test extends \advanced_testcase { /** * Test that delete requests do not filter out protected purpose contexts if the the site is properly configured. */ - public function test_get_approved_contextlist_collection_for_collection_delete_course_no_site_config() { + public function test_get_approved_contextlist_collection_for_collection_delete_course_no_site_config(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); @@ -1903,7 +1903,7 @@ class api_test extends \advanced_testcase { /** * Test that delete requests do not filter out protected purpose contexts if they are already expired. */ - public function test_get_approved_contextlist_collection_for_collection_delete_course_expired_protected() { + public function test_get_approved_contextlist_collection_for_collection_delete_course_expired_protected(): void { $this->resetAfterTest(); $purposes = $this->setup_basics('PT1H', 'PT1H', 'PT1H'); @@ -1936,7 +1936,7 @@ class api_test extends \advanced_testcase { /** * Test that delete requests does filter out protected purpose contexts which are not expired. */ - public function test_get_approved_contextlist_collection_for_collection_delete_course_unexpired_protected() { + public function test_get_approved_contextlist_collection_for_collection_delete_course_unexpired_protected(): void { $this->resetAfterTest(); $purposes = $this->setup_basics('PT1H', 'PT1H', 'P1Y'); @@ -1969,7 +1969,7 @@ class api_test extends \advanced_testcase { /** * Test that delete requests do not filter out unexpired contexts if they are not protected. */ - public function test_get_approved_contextlist_collection_for_collection_delete_course_unexpired_unprotected() { + public function test_get_approved_contextlist_collection_for_collection_delete_course_unexpired_unprotected(): void { $this->resetAfterTest(); $purposes = $this->setup_basics('PT1H', 'PT1H', 'P1Y'); @@ -2040,7 +2040,7 @@ class api_test extends \advanced_testcase { * @param bool $foractivity Whether to set defaults for an activity. * @param bool $override Whether to override instances. */ - public function test_set_context_defaults($contextlevel, $inheritcategory, $inheritpurpose, $foractivity, $override) { + public function test_set_context_defaults($contextlevel, $inheritcategory, $inheritpurpose, $foractivity, $override): void { $this->resetAfterTest(); $generator = $this->getDataGenerator(); @@ -2224,7 +2224,7 @@ class api_test extends \advanced_testcase { /** * Ensure that the find_ongoing_request_types_for_users only returns requests which are active. */ - public function test_find_ongoing_request_types_for_users() { + public function test_find_ongoing_request_types_for_users(): void { $this->resetAfterTest(); // Create users and their requests:. @@ -2360,7 +2360,7 @@ class api_test extends \advanced_testcase { * * @throws coding_exception */ - public function test_can_create_data_deletion_request_for_self_no() { + public function test_can_create_data_deletion_request_for_self_no(): void { $this->resetAfterTest(); $userid = $this->getDataGenerator()->create_user()->id; $roleid = $this->getDataGenerator()->create_role(); @@ -2373,7 +2373,7 @@ class api_test extends \advanced_testcase { /** * Test primary admin cannot create data deletion request for themselves */ - public function test_can_create_data_deletion_request_for_self_primary_admin() { + public function test_can_create_data_deletion_request_for_self_primary_admin(): void { $this->resetAfterTest(); $this->setAdminUser(); $this->assertFalse(api::can_create_data_deletion_request_for_self()); @@ -2382,7 +2382,7 @@ class api_test extends \advanced_testcase { /** * Test secondary admin can create data deletion request for themselves */ - public function test_can_create_data_deletion_request_for_self_secondary_admin() { + public function test_can_create_data_deletion_request_for_self_secondary_admin(): void { $this->resetAfterTest(); $admin1 = $this->getDataGenerator()->create_user(); @@ -2403,7 +2403,7 @@ class api_test extends \advanced_testcase { * * @throws coding_exception */ - public function test_can_create_data_deletion_request_for_self_yes() { + public function test_can_create_data_deletion_request_for_self_yes(): void { $this->resetAfterTest(); $userid = $this->getDataGenerator()->create_user()->id; $this->setUser($userid); @@ -2417,7 +2417,7 @@ class api_test extends \advanced_testcase { * @throws coding_exception * @throws dml_exception */ - public function test_can_create_data_deletion_request_for_other_no() { + public function test_can_create_data_deletion_request_for_other_no(): void { $this->resetAfterTest(); $userid = $this->getDataGenerator()->create_user()->id; $this->setUser($userid); @@ -2430,7 +2430,7 @@ class api_test extends \advanced_testcase { * * @throws coding_exception */ - public function test_can_create_data_deletion_request_for_other_yes() { + public function test_can_create_data_deletion_request_for_other_yes(): void { $this->resetAfterTest(); $userid = $this->getDataGenerator()->create_user()->id; $roleid = $this->getDataGenerator()->create_role(); @@ -2448,7 +2448,7 @@ class api_test extends \advanced_testcase { * @throws coding_exception * @throws dml_exception */ - public function test_can_create_data_deletion_request_for_children() { + public function test_can_create_data_deletion_request_for_children(): void { $this->resetAfterTest(); $parent = $this->getDataGenerator()->create_user(); @@ -2490,7 +2490,7 @@ class api_test extends \advanced_testcase { * @dataProvider queue_data_request_task_provider * @param bool $withuserid */ - public function test_queue_data_request_task(bool $withuserid) { + public function test_queue_data_request_task(bool $withuserid): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -2546,7 +2546,7 @@ class api_test extends \advanced_testcase { * @param bool $value The setting's value. * @param bool $expected The expected result. */ - public function test_is_automatic_request_approval_on($setting, $type, $value, $expected) { + public function test_is_automatic_request_approval_on($setting, $type, $value, $expected): void { $this->resetAfterTest(); if ($value !== null) { @@ -2713,7 +2713,7 @@ class api_test extends \advanced_testcase { /** * Test api validate_create_data_request. */ - public function test_validate_create_data_request() { + public function test_validate_create_data_request(): void { $this->resetAfterTest(); $systemcontext = \context_system::instance(); diff --git a/admin/tool/dataprivacy/tests/data_registry_test.php b/admin/tool/dataprivacy/tests/data_registry_test.php index cc234cb134d..bc3283b54ce 100644 --- a/admin/tool/dataprivacy/tests/data_registry_test.php +++ b/admin/tool/dataprivacy/tests/data_registry_test.php @@ -30,7 +30,7 @@ class data_registry_test extends \advanced_testcase { * * This test is not great because we only test a limited set of values. This is a fault of the underlying API. */ - public function test_get_effective_context_value_invalid_element() { + public function test_get_effective_context_value_invalid_element(): void { $this->expectException(\coding_exception::class); data_registry::get_effective_context_value(\context_system::instance(), 'invalid'); } @@ -40,7 +40,7 @@ class data_registry_test extends \advanced_testcase { * * This test is not great because we only test a limited set of values. This is a fault of the underlying API. */ - public function test_get_effective_contextlevel_value_invalid_element() { + public function test_get_effective_contextlevel_value_invalid_element(): void { $this->expectException(\coding_exception::class); data_registry::get_effective_contextlevel_value(\context_system::instance(), 'invalid'); } diff --git a/admin/tool/dataprivacy/tests/data_request_test.php b/admin/tool/dataprivacy/tests/data_request_test.php index d23403f48de..ddd1127ba18 100644 --- a/admin/tool/dataprivacy/tests/data_request_test.php +++ b/admin/tool/dataprivacy/tests/data_request_test.php @@ -93,7 +93,7 @@ class data_request_test extends data_privacy_testcase { * @param bool $resettable * @param bool $active */ - public function test_pseudo_states_export(int $status, bool $resettable, bool $active) { + public function test_pseudo_states_export(int $status, bool $resettable, bool $active): void { $uut = new \tool_dataprivacy\data_request(); $uut->set('status', $status); $uut->set('type', api::DATAREQUEST_TYPE_EXPORT); @@ -110,7 +110,7 @@ class data_request_test extends data_privacy_testcase { * @param bool $resettable * @param bool $active */ - public function test_pseudo_states_delete(int $status, bool $resettable, bool $active) { + public function test_pseudo_states_delete(int $status, bool $resettable, bool $active): void { $uut = new \tool_dataprivacy\data_request(); $uut->set('status', $status); $uut->set('type', api::DATAREQUEST_TYPE_DELETE); @@ -125,7 +125,7 @@ class data_request_test extends data_privacy_testcase { * @dataProvider status_state_provider * @param int $status */ - public function test_can_reset_others($status) { + public function test_can_reset_others($status): void { $uut = new \tool_dataprivacy\data_request(); $uut->set('status', $status); $uut->set('type', api::DATAREQUEST_TYPE_OTHERS); @@ -155,7 +155,7 @@ class data_request_test extends data_privacy_testcase { * @dataProvider non_resettable_provider * @param int $status */ - public function test_non_resubmit_request($status) { + public function test_non_resubmit_request($status): void { $uut = new \tool_dataprivacy\data_request(); $uut->set('status', $status); @@ -168,7 +168,7 @@ class data_request_test extends data_privacy_testcase { /** * Ensure that a rejected request can be reset. */ - public function test_resubmit_request() { + public function test_resubmit_request(): void { $this->resetAfterTest(); $uut = new \tool_dataprivacy\data_request(); @@ -192,7 +192,7 @@ class data_request_test extends data_privacy_testcase { /** * Ensure that an active request can be reset. */ - public function test_resubmit_active_request() { + public function test_resubmit_active_request(): void { $this->resetAfterTest(); $uut = new \tool_dataprivacy\data_request(); diff --git a/admin/tool/dataprivacy/tests/expired_contexts_test.php b/admin/tool/dataprivacy/tests/expired_contexts_test.php index ae50fbf2510..4b8680c4d7a 100644 --- a/admin/tool/dataprivacy/tests/expired_contexts_test.php +++ b/admin/tool/dataprivacy/tests/expired_contexts_test.php @@ -90,7 +90,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Ensure that a user with no lastaccess is not flagged for deletion. */ - public function test_flag_not_setup() { + public function test_flag_not_setup(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); @@ -111,7 +111,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Ensure that a user with no lastaccess is not flagged for deletion. */ - public function test_flag_user_no_lastaccess() { + public function test_flag_user_no_lastaccess(): void { $this->resetAfterTest(); $this->setup_basics('PT1H', 'PT1H', 'PT1H'); @@ -134,7 +134,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Ensure that a user with a recent lastaccess is not flagged for deletion. */ - public function test_flag_user_recent_lastaccess() { + public function test_flag_user_recent_lastaccess(): void { $this->resetAfterTest(); $this->setup_basics('PT1H', 'PT1H', 'PT1H'); @@ -157,7 +157,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Ensure that a user with a lastaccess in the past is flagged for deletion. */ - public function test_flag_user_past_lastaccess() { + public function test_flag_user_past_lastaccess(): void { $this->resetAfterTest(); $this->setup_basics('PT1H', 'PT1H', 'PT1H'); @@ -181,7 +181,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Ensure that a user with a lastaccess in the past but active enrolments is not flagged for deletion. */ - public function test_flag_user_past_lastaccess_still_enrolled() { + public function test_flag_user_past_lastaccess_still_enrolled(): void { $this->resetAfterTest(); $this->setup_basics('PT1H', 'PT1H', 'PT1H'); @@ -209,7 +209,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Ensure that a user with a lastaccess in the past and no active enrolments is flagged for deletion. */ - public function test_flag_user_update_existing() { + public function test_flag_user_update_existing(): void { $this->resetAfterTest(); $this->setup_basics('PT1H', 'PT1H', 'P5Y'); @@ -241,7 +241,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Ensure that a user with a lastaccess in the past and expired enrolments. */ - public function test_flag_user_past_lastaccess_unexpired_past_enrolment() { + public function test_flag_user_past_lastaccess_unexpired_past_enrolment(): void { $this->resetAfterTest(); $this->setup_basics('PT1H', 'PT1H', 'P1Y'); @@ -269,7 +269,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Ensure that a user with a lastaccess in the past and expired enrolments. */ - public function test_flag_user_past_override_role() { + public function test_flag_user_past_override_role(): void { global $DB; $this->resetAfterTest(); @@ -303,7 +303,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Ensure that a user with a lastaccess in the past and expired enrolments. */ - public function test_flag_user_past_lastaccess_expired_enrolled() { + public function test_flag_user_past_lastaccess_expired_enrolled(): void { $this->resetAfterTest(); $this->setup_basics('PT1H', 'PT1H', 'PT1H'); @@ -332,7 +332,7 @@ class expired_contexts_test extends \advanced_testcase { * Ensure that a user with a lastaccess in the past and enrolments without a course end date are respected * correctly. */ - public function test_flag_user_past_lastaccess_missing_enddate_required() { + public function test_flag_user_past_lastaccess_missing_enddate_required(): void { $this->resetAfterTest(); $this->setup_basics('PT1H', 'PT1H', 'PT1H'); @@ -364,7 +364,7 @@ class expired_contexts_test extends \advanced_testcase { * Ensure that a user with a lastaccess in the past and enrolments without a course end date are respected * correctly when the end date is not required. */ - public function test_flag_user_past_lastaccess_missing_enddate_not_required() { + public function test_flag_user_past_lastaccess_missing_enddate_not_required(): void { $this->resetAfterTest(); $this->setup_basics('PT1H', 'PT1H', 'PT1H'); @@ -395,7 +395,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Ensure that a user with a recent lastaccess is not flagged for deletion. */ - public function test_flag_user_recent_lastaccess_existing_record() { + public function test_flag_user_recent_lastaccess_existing_record(): void { $this->resetAfterTest(); $this->setup_basics('PT1H', 'PT1H', 'PT1H'); @@ -429,7 +429,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Ensure that a user with a recent lastaccess is not flagged for deletion. */ - public function test_flag_user_retention_changed() { + public function test_flag_user_retention_changed(): void { $this->resetAfterTest(); $purposes = $this->setup_basics('PT1H', 'PT1H', 'PT1H'); @@ -469,7 +469,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Ensure that a user with a historically expired expired block record child is cleaned up. */ - public function test_flag_user_historic_block_unapproved() { + public function test_flag_user_historic_block_unapproved(): void { $this->resetAfterTest(); $this->setup_basics('PT1H', 'PT1H', 'PT1H'); @@ -506,7 +506,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Ensure that a user with a block which has a default retention period which has not expired, is still expired. */ - public function test_flag_user_historic_unexpired_child() { + public function test_flag_user_historic_unexpired_child(): void { $this->resetAfterTest(); $this->setup_basics('PT1H', 'PT1H', 'PT1H'); @@ -534,7 +534,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Ensure that a course with no end date is not flagged. */ - public function test_flag_course_no_enddate() { + public function test_flag_course_no_enddate(): void { $this->resetAfterTest(); $this->setup_basics('PT1H', 'PT1H', 'PT1H', 'PT1H'); @@ -553,7 +553,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Ensure that a course with an end date in the distant past, but a child which is unexpired is not flagged. */ - public function test_flag_course_past_enddate_future_child() { + public function test_flag_course_past_enddate_future_child(): void { $this->resetAfterTest(); $this->setup_basics('PT1H', 'PT1H', 'PT1H', 'P5Y'); @@ -575,7 +575,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Ensure that a course with an end date in the distant past is flagged. */ - public function test_flag_course_past_enddate() { + public function test_flag_course_past_enddate(): void { $this->resetAfterTest(); $this->setup_basics('PT1H', 'PT1H', 'PT1H', 'PT1H'); @@ -597,7 +597,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Ensure that a course with an end date in the distant past is flagged. */ - public function test_flag_course_past_enddate_multiple() { + public function test_flag_course_past_enddate_multiple(): void { $this->resetAfterTest(); $this->setup_basics('PT1H', 'PT1H', 'PT1H', 'PT1H'); @@ -625,7 +625,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Ensure that a course with an end date in the future is not flagged. */ - public function test_flag_course_future_enddate() { + public function test_flag_course_future_enddate(): void { $this->resetAfterTest(); $this->setup_basics('PT1H', 'PT1H', 'PT1H', 'PT1H'); @@ -644,7 +644,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Ensure that a course with an end date in the future is not flagged. */ - public function test_flag_course_recent_unexpired_enddate() { + public function test_flag_course_recent_unexpired_enddate(): void { $this->resetAfterTest(); $this->setup_basics('PT1H', 'PT1H', 'PT1H', 'PT1H'); @@ -662,7 +662,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Ensure that a course with an end date in the distant past is flagged, taking into account any purpose override */ - public function test_flag_course_past_enddate_with_override_unexpired_role() { + public function test_flag_course_past_enddate_with_override_unexpired_role(): void { global $DB; $this->resetAfterTest(); @@ -701,7 +701,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Ensure that a course with an end date in the distant past is flagged, and any expired role is ignored. */ - public function test_flag_course_past_enddate_with_override_expired_role() { + public function test_flag_course_past_enddate_with_override_expired_role(): void { global $DB; $this->resetAfterTest(); @@ -740,7 +740,7 @@ class expired_contexts_test extends \advanced_testcase { * Ensure that where a course has explicitly expired one role, but that role is explicitly not expired in a child * context, does not have the parent context role expired. */ - public function test_flag_course_override_expiredwith_override_unexpired_on_child() { + public function test_flag_course_override_expiredwith_override_unexpired_on_child(): void { global $DB; $this->resetAfterTest(); @@ -809,7 +809,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Ensure that a user context previously flagged as approved is not removed if the user has any unexpired roles. */ - public function test_process_user_context_with_override_unexpired_role() { + public function test_process_user_context_with_override_unexpired_role(): void { global $DB; $this->resetAfterTest(); @@ -1228,7 +1228,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Ensure that a site not setup will not process anything. */ - public function test_process_not_setup() { + public function test_process_not_setup(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(['lastaccess' => time() - YEARSECS]); @@ -1265,7 +1265,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Ensure that a user with no lastaccess is not flagged for deletion. */ - public function test_process_none_approved() { + public function test_process_none_approved(): void { $this->resetAfterTest(); $this->setup_basics('PT1H', 'PT1H', 'PT1H', 'PT1H'); @@ -1304,7 +1304,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Ensure that a user with no lastaccess is not flagged for deletion. */ - public function test_process_no_context() { + public function test_process_no_context(): void { $this->resetAfterTest(); $this->setup_basics('PT1H', 'PT1H', 'PT1H', 'PT1H'); @@ -1343,7 +1343,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Ensure that a user context previously flagged as approved is removed. */ - public function test_process_user_context() { + public function test_process_user_context(): void { $this->resetAfterTest(); $this->setup_basics('PT1H', 'PT1H', 'PT1H'); @@ -1405,7 +1405,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Ensure that a course context previously flagged as approved is removed. */ - public function test_process_course_context() { + public function test_process_course_context(): void { $this->resetAfterTest(); $this->setup_basics('PT1H', 'PT1H', 'PT1H', 'PT1H'); @@ -1450,7 +1450,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Ensure that a user context previously flagged as approved is not removed if the user then logs in. */ - public function test_process_user_context_logged_in_after_approval() { + public function test_process_user_context_logged_in_after_approval(): void { $this->resetAfterTest(); $this->setup_basics('PT1H', 'PT1H', 'PT1H'); @@ -1502,7 +1502,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Ensure that a user context previously flagged as approved is not removed if the purpose has changed. */ - public function test_process_user_context_changed_after_approved() { + public function test_process_user_context_changed_after_approved(): void { $this->resetAfterTest(); $this->setup_basics('PT1H', 'PT1H', 'PT1H'); @@ -1554,7 +1554,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Ensure that a user with a historically expired expired block record child is cleaned up. */ - public function test_process_user_historic_block_unapproved() { + public function test_process_user_historic_block_unapproved(): void { $this->resetAfterTest(); $this->setup_basics('PT1H', 'PT1H', 'PT1H'); @@ -1613,7 +1613,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Ensure that a user with a block which has a default retention period which has not expired, is still expired. */ - public function test_process_user_historic_unexpired_child() { + public function test_process_user_historic_unexpired_child(): void { $this->resetAfterTest(); $this->setup_basics('PT1H', 'PT1H', 'PT1H'); @@ -1667,7 +1667,7 @@ class expired_contexts_test extends \advanced_testcase { * Ensure that a course context previously flagged as approved for deletion which now has an unflagged child, is * updated. */ - public function test_process_course_context_updated() { + public function test_process_course_context_updated(): void { $this->resetAfterTest(); $purposes = $this->setup_basics('PT1H', 'PT1H', 'PT1H', 'PT1H'); @@ -1718,7 +1718,7 @@ class expired_contexts_test extends \advanced_testcase { * Ensure that a course context previously flagged as approved for deletion which now has an unflagged child, is * updated. */ - public function test_process_course_context_outstanding_children() { + public function test_process_course_context_outstanding_children(): void { $this->resetAfterTest(); $this->setup_basics('PT1H', 'PT1H', 'PT1H', 'PT1H'); @@ -1767,7 +1767,7 @@ class expired_contexts_test extends \advanced_testcase { * Ensure that a course context previously flagged as approved for deletion which now has an unflagged child, is * updated. */ - public function test_process_course_context_pending_children() { + public function test_process_course_context_pending_children(): void { $this->resetAfterTest(); $this->setup_basics('PT1H', 'PT1H', 'PT1H', 'PT1H'); @@ -1825,7 +1825,7 @@ class expired_contexts_test extends \advanced_testcase { * Ensure that a course context previously flagged as approved for deletion which now has an unflagged child, is * updated. */ - public function test_process_course_context_approved_children() { + public function test_process_course_context_approved_children(): void { $this->resetAfterTest(); $this->setup_basics('PT1H', 'PT1H', 'PT1H', 'PT1H'); @@ -1903,7 +1903,7 @@ class expired_contexts_test extends \advanced_testcase { * @param int $status * @param bool $expected */ - public function test_can_process_deletion($status, $expected) { + public function test_can_process_deletion($status, $expected): void { $purpose = new expired_context(0, (object) [ 'status' => $status, @@ -1942,7 +1942,7 @@ class expired_contexts_test extends \advanced_testcase { * @param int $status * @param bool $expected */ - public function test_is_complete($status, $expected) { + public function test_is_complete($status, $expected): void { $purpose = new expired_context(0, (object) [ 'status' => $status, 'contextid' => \context_system::instance()->id, @@ -1980,7 +1980,7 @@ class expired_contexts_test extends \advanced_testcase { * @param array $record * @param bool $expected */ - public function test_is_fully_expired($record, $expected) { + public function test_is_fully_expired($record, $expected): void { $purpose = new expired_context(0, (object) $record); $this->assertEquals($expected, $purpose->is_fully_expired()); @@ -2022,7 +2022,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Ensure that any orphaned records are removed once the context has been removed. */ - public function test_orphaned_records_are_cleared() { + public function test_orphaned_records_are_cleared(): void { $this->resetAfterTest(); $this->setup_basics('PT1H', 'PT1H', 'PT1H', 'PT1H'); @@ -2073,7 +2073,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Ensure that the progres tracer works as expected out of the box. */ - public function test_progress_tracer_default() { + public function test_progress_tracer_default(): void { $manager = new \tool_dataprivacy\expired_contexts_manager(); $rc = new \ReflectionClass(\tool_dataprivacy\expired_contexts_manager::class); @@ -2085,7 +2085,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Ensure that the progres tracer works as expected when given a specific traer. */ - public function test_progress_tracer_set() { + public function test_progress_tracer_set(): void { $manager = new \tool_dataprivacy\expired_contexts_manager(); $mytrace = new \null_progress_trace(); $manager->set_progress($mytrace); @@ -2164,7 +2164,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Test the is_context_expired functions when supplied with the system context. */ - public function test_is_context_expired_system() { + public function test_is_context_expired_system(): void { $this->resetAfterTest(); $this->setup_basics('PT1H', 'PT1H', 'P1D'); $user = $this->getDataGenerator()->create_user(['lastaccess' => time() - YEARSECS]); @@ -2180,7 +2180,7 @@ class expired_contexts_test extends \advanced_testcase { * Children of a user context always follow the user expiry rather than any context level defaults (e.g. at the * block level. */ - public function test_is_context_expired_user_block() { + public function test_is_context_expired_user_block(): void { $this->resetAfterTest(); $purposes = $this->setup_basics('PT1H', 'PT1H', 'P1D'); @@ -2205,7 +2205,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Test the is_context_expired functions when supplied with the front page course. */ - public function test_is_context_expired_frontpage() { + public function test_is_context_expired_frontpage(): void { $this->resetAfterTest(); $purposes = $this->setup_basics('PT1H', 'PT1H', 'P1D'); @@ -2239,7 +2239,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Test the is_context_expired functions when supplied with an expired course. */ - public function test_is_context_expired_course_expired() { + public function test_is_context_expired_course_expired(): void { $this->resetAfterTest(); $purposes = $this->setup_basics('PT1H', 'PT1H', 'P1D'); @@ -2262,7 +2262,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Test the is_context_expired functions when supplied with an unexpired course. */ - public function test_is_context_expired_course_unexpired() { + public function test_is_context_expired_course_unexpired(): void { $this->resetAfterTest(); $purposes = $this->setup_basics('PT1H', 'PT1H', 'P1D'); @@ -2291,7 +2291,7 @@ class expired_contexts_test extends \advanced_testcase { * If the course is still within the expiry period for the child context, then that child's protected flag should be * respected, even when the course may have expired. */ - public function test_is_child_context_expired_course_unexpired_with_child() { + public function test_is_child_context_expired_course_unexpired_with_child(): void { $this->resetAfterTest(); $purposes = $this->setup_basics('PT1H', 'PT1H', 'P1D', 'P1D'); @@ -2321,7 +2321,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Test the is_context_expired functions when supplied with an expired course which has role overrides. */ - public function test_is_context_expired_course_expired_override() { + public function test_is_context_expired_course_expired_override(): void { global $DB; $this->resetAfterTest(); @@ -2356,7 +2356,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Test the is_context_expired functions when supplied with an expired course which has role overrides. */ - public function test_is_context_expired_course_expired_override_parent() { + public function test_is_context_expired_course_expired_override_parent(): void { global $DB; $this->resetAfterTest(); @@ -2405,7 +2405,7 @@ class expired_contexts_test extends \advanced_testcase { * Test the is_context_expired functions when supplied with an expired course which has role overrides but the user * does not hold the role. */ - public function test_is_context_expired_course_expired_override_parent_no_role() { + public function test_is_context_expired_course_expired_override_parent_no_role(): void { global $DB; $this->resetAfterTest(); @@ -2434,7 +2434,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Test the is_context_expired functions when supplied with an unexpired course which has role overrides. */ - public function test_is_context_expired_course_expired_override_inverse() { + public function test_is_context_expired_course_expired_override_inverse(): void { global $DB; $this->resetAfterTest(); @@ -2463,7 +2463,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Test the is_context_expired functions when supplied with an unexpired course which has role overrides. */ - public function test_is_context_expired_course_expired_override_inverse_parent() { + public function test_is_context_expired_course_expired_override_inverse_parent(): void { global $DB; $this->resetAfterTest(); @@ -2496,7 +2496,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Test the is_context_expired functions when supplied with an unexpired course which has role overrides. */ - public function test_is_context_expired_course_expired_override_inverse_parent_not_assigned() { + public function test_is_context_expired_course_expired_override_inverse_parent_not_assigned(): void { global $DB; $this->resetAfterTest(); @@ -2528,7 +2528,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Ensure that context expired checks for a specific user taken into account roles. */ - public function test_is_context_expired_or_unprotected_for_user_role_mixtures_protected() { + public function test_is_context_expired_or_unprotected_for_user_role_mixtures_protected(): void { global $DB; $this->resetAfterTest(); @@ -2583,7 +2583,7 @@ class expired_contexts_test extends \advanced_testcase { /** * Ensure that context expired checks for a specific user taken into account roles when retention is inversed. */ - public function test_is_context_expired_or_unprotected_for_user_role_mixtures_protected_inverse() { + public function test_is_context_expired_or_unprotected_for_user_role_mixtures_protected_inverse(): void { global $DB; $this->resetAfterTest(); diff --git a/admin/tool/dataprivacy/tests/expired_data_requests_test.php b/admin/tool/dataprivacy/tests/expired_data_requests_test.php index 4fd6aebdd81..0259a0774fc 100644 --- a/admin/tool/dataprivacy/tests/expired_data_requests_test.php +++ b/admin/tool/dataprivacy/tests/expired_data_requests_test.php @@ -41,7 +41,7 @@ class expired_data_requests_test extends data_privacy_testcase { /** * Test finding and deleting expired data requests */ - public function test_data_request_expiry() { + public function test_data_request_expiry(): void { global $DB; $this->resetAfterTest(); \core_privacy\local\request\writer::setup_real_writer_instance(); @@ -112,7 +112,7 @@ class expired_data_requests_test extends data_privacy_testcase { * Tests for the expected request status to protect from false positive/negative, * then tests is_expired() is returning the expected response. */ - public function test_is_expired() { + public function test_is_expired(): void { $this->resetAfterTest(); \core_privacy\local\request\writer::setup_real_writer_instance(); diff --git a/admin/tool/dataprivacy/tests/external/external_test.php b/admin/tool/dataprivacy/tests/external/external_test.php index 91ecfd9ceab..c8be8c63ee5 100644 --- a/admin/tool/dataprivacy/tests/external/external_test.php +++ b/admin/tool/dataprivacy/tests/external/external_test.php @@ -48,7 +48,7 @@ class external_test extends externallib_advanced_testcase { /** * Test for external::approve_data_request() with the user not logged in. */ - public function test_approve_data_request_not_logged_in() { + public function test_approve_data_request_not_logged_in(): void { $this->resetAfterTest(); $generator = new \testing_data_generator(); @@ -69,7 +69,7 @@ class external_test extends externallib_advanced_testcase { /** * Test for external::approve_data_request() with the user not having a DPO role. */ - public function test_approve_data_request_not_dpo() { + public function test_approve_data_request_not_dpo(): void { $this->resetAfterTest(); $generator = new \testing_data_generator(); @@ -89,7 +89,7 @@ class external_test extends externallib_advanced_testcase { /** * Test for external::approve_data_request() for request that's not ready for approval */ - public function test_approve_data_request_not_waiting_for_approval() { + public function test_approve_data_request_not_waiting_for_approval(): void { $this->resetAfterTest(); $generator = new \testing_data_generator(); @@ -110,7 +110,7 @@ class external_test extends externallib_advanced_testcase { /** * Test for external::approve_data_request() */ - public function test_approve_data_request() { + public function test_approve_data_request(): void { $this->resetAfterTest(); $generator = new \testing_data_generator(); @@ -133,7 +133,7 @@ class external_test extends externallib_advanced_testcase { /** * Test for external::approve_data_request() for a non-existent request ID. */ - public function test_approve_data_request_non_existent() { + public function test_approve_data_request_non_existent(): void { $this->resetAfterTest(); // Admin as DPO. (The default when no one's assigned as a DPO in the site). @@ -151,7 +151,7 @@ class external_test extends externallib_advanced_testcase { /** * Test for external::cancel_data_request() of another user. */ - public function test_cancel_data_request_other_user() { + public function test_cancel_data_request_other_user(): void { $this->resetAfterTest(); $generator = new \testing_data_generator(); @@ -177,7 +177,7 @@ class external_test extends externallib_advanced_testcase { /** * Test cancellation of a request where you are the requester of another user's data. */ - public function test_cancel_data_request_other_user_as_requester() { + public function test_cancel_data_request_other_user_as_requester(): void { $this->resetAfterTest(); $generator = new \testing_data_generator(); @@ -204,7 +204,7 @@ class external_test extends externallib_advanced_testcase { /** * Test cancellation of a request where you are the requester of another user's data. */ - public function test_cancel_data_request_requester_lost_permissions() { + public function test_cancel_data_request_requester_lost_permissions(): void { $this->resetAfterTest(); $generator = new \testing_data_generator(); @@ -233,7 +233,7 @@ class external_test extends externallib_advanced_testcase { /** * Test cancellation of a request where you are the requester of another user's data. */ - public function test_cancel_data_request_other_user_as_child() { + public function test_cancel_data_request_other_user_as_child(): void { $this->resetAfterTest(); $generator = new \testing_data_generator(); @@ -260,7 +260,7 @@ class external_test extends externallib_advanced_testcase { /** * Test for external::cancel_data_request() */ - public function test_cancel_data_request() { + public function test_cancel_data_request(): void { $this->resetAfterTest(); $generator = new \testing_data_generator(); @@ -283,7 +283,7 @@ class external_test extends externallib_advanced_testcase { /** * Test contact DPO. */ - public function test_contact_dpo() { + public function test_contact_dpo(): void { $this->resetAfterTest(); $generator = new \testing_data_generator(); @@ -300,7 +300,7 @@ class external_test extends externallib_advanced_testcase { /** * Test contact DPO with message containing invalid input. */ - public function test_contact_dpo_with_nasty_input() { + public function test_contact_dpo_with_nasty_input(): void { $this->resetAfterTest(); $generator = new \testing_data_generator(); @@ -314,7 +314,7 @@ class external_test extends externallib_advanced_testcase { /** * Test for external::deny_data_request() with the user not logged in. */ - public function test_deny_data_request_not_logged_in() { + public function test_deny_data_request_not_logged_in(): void { $this->resetAfterTest(); $generator = new \testing_data_generator(); @@ -334,7 +334,7 @@ class external_test extends externallib_advanced_testcase { /** * Test for external::deny_data_request() with the user not having a DPO role. */ - public function test_deny_data_request_not_dpo() { + public function test_deny_data_request_not_dpo(): void { $this->resetAfterTest(); $generator = new \testing_data_generator(); @@ -353,7 +353,7 @@ class external_test extends externallib_advanced_testcase { /** * Test for external::deny_data_request() for request that's not ready for approval */ - public function test_deny_data_request_not_waiting_for_approval() { + public function test_deny_data_request_not_waiting_for_approval(): void { $this->resetAfterTest(); $generator = new \testing_data_generator(); @@ -373,7 +373,7 @@ class external_test extends externallib_advanced_testcase { /** * Test for external::deny_data_request() */ - public function test_deny_data_request() { + public function test_deny_data_request(): void { $this->resetAfterTest(); $generator = new \testing_data_generator(); @@ -395,7 +395,7 @@ class external_test extends externallib_advanced_testcase { /** * Test for external::deny_data_request() for a non-existent request ID. */ - public function test_deny_data_request_non_existent() { + public function test_deny_data_request_non_existent(): void { $this->resetAfterTest(); // Admin as DPO. (The default when no one's assigned as a DPO in the site). @@ -412,7 +412,7 @@ class external_test extends externallib_advanced_testcase { /** * Test for external::get_data_request() with the user not logged in. */ - public function test_get_data_request_not_logged_in() { + public function test_get_data_request_not_logged_in(): void { $this->resetAfterTest(); $generator = new \testing_data_generator(); @@ -430,7 +430,7 @@ class external_test extends externallib_advanced_testcase { /** * Test for external::get_data_request() with the user not having a DPO role. */ - public function test_get_data_request_not_dpo() { + public function test_get_data_request_not_dpo(): void { $this->resetAfterTest(); $generator = new \testing_data_generator(); @@ -450,7 +450,7 @@ class external_test extends externallib_advanced_testcase { /** * Test for external::get_data_request() */ - public function test_get_data_request() { + public function test_get_data_request(): void { $this->resetAfterTest(); $generator = new \testing_data_generator(); @@ -475,7 +475,7 @@ class external_test extends externallib_advanced_testcase { /** * Test for external::get_data_request() for a non-existent request ID. */ - public function test_get_data_request_non_existent() { + public function test_get_data_request_non_existent(): void { $this->resetAfterTest(); // Admin as DPO. (The default when no one's assigned as a DPO in the site). @@ -488,7 +488,7 @@ class external_test extends externallib_advanced_testcase { * Test for \tool_dataprivacy\external::set_context_defaults() * when called by a user that doesn't have the manage registry capability. */ - public function test_set_context_defaults_no_capability() { + public function test_set_context_defaults_no_capability(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator(); @@ -508,7 +508,7 @@ class external_test extends externallib_advanced_testcase { * @param bool $modulelevel Whether defaults are to be applied on the module context level or for an activity only. * @param bool $override Whether to override instances. */ - public function test_set_context_defaults($modulelevel, $override) { + public function test_set_context_defaults($modulelevel, $override): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -567,7 +567,7 @@ class external_test extends externallib_advanced_testcase { * Test for \tool_dataprivacy\external::get_category_options() * when called by a user that doesn't have the manage registry capability. */ - public function test_get_category_options_no_capability() { + public function test_get_category_options_no_capability(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); @@ -596,7 +596,7 @@ class external_test extends externallib_advanced_testcase { * @param bool $includeinherit Whether "Inherit" would be included to the options. * @param bool $includenotset Whether "Not set" would be included to the options. */ - public function test_get_category_options($includeinherit, $includenotset) { + public function test_get_category_options($includeinherit, $includenotset): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -642,7 +642,7 @@ class external_test extends externallib_advanced_testcase { * Test for \tool_dataprivacy\external::get_purpose_options() * when called by a user that doesn't have the manage registry capability. */ - public function test_get_purpose_options_no_capability() { + public function test_get_purpose_options_no_capability(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator(); $user = $generator->create_user(); @@ -658,7 +658,7 @@ class external_test extends externallib_advanced_testcase { * @param bool $includeinherit Whether "Inherit" would be included to the options. * @param bool $includenotset Whether "Not set" would be included to the options. */ - public function test_get_purpose_options($includeinherit, $includenotset) { + public function test_get_purpose_options($includeinherit, $includenotset): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -726,7 +726,7 @@ class external_test extends externallib_advanced_testcase { * @param bool $inheritpurpose Whether the purpose would be set to "Inherit". * @param bool $nodefaults Whether to fetch only activities that don't have defaults. */ - public function test_get_activity_options($inheritcategory, $inheritpurpose, $nodefaults) { + public function test_get_activity_options($inheritcategory, $inheritpurpose, $nodefaults): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -774,7 +774,7 @@ class external_test extends externallib_advanced_testcase { /** * Test for external::bulk_approve_data_requests(). */ - public function test_bulk_approve_data_requests() { + public function test_bulk_approve_data_requests(): void { $this->resetAfterTest(); // Create delete data requests. @@ -802,7 +802,7 @@ class external_test extends externallib_advanced_testcase { /** * Test for external::bulk_approve_data_requests() for a non-existent request ID. */ - public function test_bulk_approve_data_requests_non_existent() { + public function test_bulk_approve_data_requests_non_existent(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -820,7 +820,7 @@ class external_test extends externallib_advanced_testcase { /** * Test for external::bulk_deny_data_requests() for a user without permission to deny requests. */ - public function test_bulk_approve_data_requests_no_permission() { + public function test_bulk_approve_data_requests_no_permission(): void { $this->resetAfterTest(); // Create delete data requests. @@ -849,7 +849,7 @@ class external_test extends externallib_advanced_testcase { /** * Test for external::bulk_deny_data_requests() for a user without permission to deny requests. */ - public function test_bulk_approve_data_requests_own_request() { + public function test_bulk_approve_data_requests_own_request(): void { $this->resetAfterTest(); // Create delete data requests. @@ -877,7 +877,7 @@ class external_test extends externallib_advanced_testcase { /** * Test for external::bulk_deny_data_requests(). */ - public function test_bulk_deny_data_requests() { + public function test_bulk_deny_data_requests(): void { $this->resetAfterTest(); // Create delete data requests. @@ -905,7 +905,7 @@ class external_test extends externallib_advanced_testcase { /** * Test for external::bulk_deny_data_requests() for a non-existent request ID. */ - public function test_bulk_deny_data_requests_non_existent() { + public function test_bulk_deny_data_requests_non_existent(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -922,7 +922,7 @@ class external_test extends externallib_advanced_testcase { /** * Test for external::bulk_deny_data_requests() for a user without permission to deny requests. */ - public function test_bulk_deny_data_requests_no_permission() { + public function test_bulk_deny_data_requests_no_permission(): void { $this->resetAfterTest(); // Create delete data requests. @@ -951,7 +951,7 @@ class external_test extends externallib_advanced_testcase { /** * Test for external::bulk_deny_data_requests() for a user cannot approve their own request. */ - public function test_bulk_deny_data_requests_own_request() { + public function test_bulk_deny_data_requests_own_request(): void { $this->resetAfterTest(); // Create delete data requests. @@ -986,7 +986,7 @@ class external_test extends externallib_advanced_testcase { * @throws required_capability_exception * @throws restricted_context_exception */ - public function test_get_users_using_using_non_identity() { + public function test_get_users_using_using_non_identity(): void { $this->resetAfterTest(); $context = \context_system::instance(); $requester = $this->getDataGenerator()->create_user(); @@ -1021,7 +1021,7 @@ class external_test extends externallib_advanced_testcase { * @throws required_capability_exception * @throws restricted_context_exception */ - public function test_get_users_using_identity_without_permission() { + public function test_get_users_using_identity_without_permission(): void { global $CFG; $this->resetAfterTest(); @@ -1053,7 +1053,7 @@ class external_test extends externallib_advanced_testcase { * @throws required_capability_exception * @throws restricted_context_exception */ - public function test_get_users_using_field_not_in_identity() { + public function test_get_users_using_field_not_in_identity(): void { $this->resetAfterTest(); $context = \context_system::instance(); @@ -1082,7 +1082,7 @@ class external_test extends externallib_advanced_testcase { * @throws required_capability_exception * @throws restricted_context_exception */ - public function test_get_users() { + public function test_get_users(): void { global $CFG; $this->resetAfterTest(); $CFG->showuseridentity = 'institution'; @@ -1118,7 +1118,7 @@ class external_test extends externallib_advanced_testcase { /** * Test for external::get_access_information(). */ - public function test_get_access_information() { + public function test_get_access_information(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -1145,7 +1145,7 @@ class external_test extends externallib_advanced_testcase { /** * Test for external::create_data_request() */ - public function test_create_data_request() { + public function test_create_data_request(): void { $this->resetAfterTest(); $systemcontext = \context_system::instance(); @@ -1200,7 +1200,7 @@ class external_test extends externallib_advanced_testcase { /** * Test for external::create_data_request() when no dpo available. */ - public function test_create_data_request_no_dpo() { + public function test_create_data_request_no_dpo(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); @@ -1214,7 +1214,7 @@ class external_test extends externallib_advanced_testcase { /** * Test for external::create_data_request() with missing permission. */ - public function test_create_data_request_no_permission() { + public function test_create_data_request_no_permission(): void { $this->resetAfterTest(); // Enable contact DPO. @@ -1231,7 +1231,7 @@ class external_test extends externallib_advanced_testcase { /** * Test for external::create_data_request() with invalid request type. */ - public function test_create_data_request_invalid_type() { + public function test_create_data_request_invalid_type(): void { $this->resetAfterTest(); // Enable contact DPO. @@ -1248,7 +1248,7 @@ class external_test extends externallib_advanced_testcase { /** * Test for external::get_data_requests(). */ - public function test_get_data_requests() { + public function test_get_data_requests(): void { global $DB; $this->resetAfterTest(); @@ -1355,7 +1355,7 @@ class external_test extends externallib_advanced_testcase { /** * Test for external::get_data_requests() invalid user id. */ - public function test_get_data_requests_invalid_userid() { + public function test_get_data_requests_invalid_userid(): void { $this->resetAfterTest(); $this->setAdminUser(); diff --git a/admin/tool/dataprivacy/tests/external/submit_selected_courses_form_test.php b/admin/tool/dataprivacy/tests/external/submit_selected_courses_form_test.php index 06d21dd596b..970919aee73 100644 --- a/admin/tool/dataprivacy/tests/external/submit_selected_courses_form_test.php +++ b/admin/tool/dataprivacy/tests/external/submit_selected_courses_form_test.php @@ -43,7 +43,7 @@ class submit_selected_courses_form_test extends \externallib_advanced_testcase { /** * Test for submit_selected_courses_form(). */ - public function test_submit_selected_courses_form() { + public function test_submit_selected_courses_form(): void { global $DB; $this->resetAfterTest(); diff --git a/admin/tool/dataprivacy/tests/filtered_userlist_test.php b/admin/tool/dataprivacy/tests/filtered_userlist_test.php index 4146e0ec784..f54114cd9d9 100644 --- a/admin/tool/dataprivacy/tests/filtered_userlist_test.php +++ b/admin/tool/dataprivacy/tests/filtered_userlist_test.php @@ -33,7 +33,7 @@ class filtered_userlist_test extends \advanced_testcase { * @param array $unexpired The set of userids considered as unexpired. * @param array $expected The expected values. */ - public function test_apply_expired_contexts_filters(array $initial, array $expired, array $unexpired, array $expected) { + public function test_apply_expired_contexts_filters(array $initial, array $expired, array $unexpired, array $expected): void { $userlist = $this->getMockBuilder(\tool_dataprivacy\filtered_userlist::class) ->disableOriginalConstructor() ->onlyMethods([]) diff --git a/admin/tool/dataprivacy/tests/manager_observer_test.php b/admin/tool/dataprivacy/tests/manager_observer_test.php index de898abf7d0..7296eb181d1 100644 --- a/admin/tool/dataprivacy/tests/manager_observer_test.php +++ b/admin/tool/dataprivacy/tests/manager_observer_test.php @@ -65,7 +65,7 @@ class manager_observer_test extends data_privacy_testcase { /** * Ensure that when no user is configured as DPO, the message is sent to admin instead. */ - public function test_handle_component_failure_no_dpo() { + public function test_handle_component_failure_no_dpo(): void { $this->resetAfterTest(); // Create another user who is not a DPO or admin. diff --git a/admin/tool/dataprivacy/tests/metadata_registry_test.php b/admin/tool/dataprivacy/tests/metadata_registry_test.php index 2288507e745..cb9abb070de 100644 --- a/admin/tool/dataprivacy/tests/metadata_registry_test.php +++ b/admin/tool/dataprivacy/tests/metadata_registry_test.php @@ -47,7 +47,7 @@ class metadata_registry_test extends \advanced_testcase { /** * Test that we can fetch metadata about users for the whole system and that it matches the system count. */ - public function test_get_registry_metadata_count() { + public function test_get_registry_metadata_count(): void { $data = $this->get_meta_data(); $plugintypes = \core_component::get_plugin_types(); @@ -71,7 +71,7 @@ class metadata_registry_test extends \advanced_testcase { /** * Check that the expected null provider information is returned. */ - public function test_get_registry_metadata_null_provider_details() { + public function test_get_registry_metadata_null_provider_details(): void { $data = $this->get_meta_data(); // Check details of core privacy (a null privder) are correct. @@ -83,7 +83,7 @@ class metadata_registry_test extends \advanced_testcase { /** * Check that the expected privacy provider information is returned. */ - public function test_get_registry_metadata_provider_details() { + public function test_get_registry_metadata_provider_details(): void { $data = $this->get_meta_data(); // Check details of core rating (a normal provider) are correct. diff --git a/admin/tool/dataprivacy/tests/privacy/provider_test.php b/admin/tool/dataprivacy/tests/privacy/provider_test.php index 97397816505..34164fd1b58 100644 --- a/admin/tool/dataprivacy/tests/privacy/provider_test.php +++ b/admin/tool/dataprivacy/tests/privacy/provider_test.php @@ -46,7 +46,7 @@ class provider_test extends provider_testcase { * * @return void */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); @@ -65,7 +65,7 @@ class provider_test extends provider_testcase { * * @return void */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); @@ -82,7 +82,7 @@ class provider_test extends provider_testcase { * * @return void */ - public function test_get_users_in_context_non_user_context() { + public function test_get_users_in_context_non_user_context(): void { $context = \context_system::instance(); $userlist = new userlist($context, 'tool_dataprivacy'); @@ -96,7 +96,7 @@ class provider_test extends provider_testcase { * * @return void */ - public function test_export_user_data() { + public function test_export_user_data(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); @@ -152,7 +152,7 @@ class provider_test extends provider_testcase { * * @return void */ - public function test_export_user_preferences() { + public function test_export_user_preferences(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); diff --git a/admin/tool/dataprivacy/tests/task/task_test.php b/admin/tool/dataprivacy/tests/task/task_test.php index 87e82d103d5..d43dbbdf63d 100644 --- a/admin/tool/dataprivacy/tests/task/task_test.php +++ b/admin/tool/dataprivacy/tests/task/task_test.php @@ -45,7 +45,7 @@ class task_test extends \data_privacy_testcase { * is created when there are not any existing data requests * for that particular user. */ - public function test_delete_existing_deleted_users_task_no_previous_requests() { + public function test_delete_existing_deleted_users_task_no_previous_requests(): void { global $DB; $this->resetAfterTest(); @@ -74,7 +74,7 @@ class task_test extends \data_privacy_testcase { * Ensure that a delete data request for pre-existing deleted users * is not being created when automatic creation of delete data requests is disabled. */ - public function test_delete_existing_deleted_users_task_automatic_creation_disabled() { + public function test_delete_existing_deleted_users_task_automatic_creation_disabled(): void { global $DB; $this->resetAfterTest(); @@ -104,7 +104,7 @@ class task_test extends \data_privacy_testcase { * is created when there are existing non-delete data requests * for that particular user. */ - public function test_delete_existing_deleted_users_task_existing_export_data_requests() { + public function test_delete_existing_deleted_users_task_existing_export_data_requests(): void { global $DB; $this->resetAfterTest(); @@ -139,7 +139,7 @@ class task_test extends \data_privacy_testcase { * is not created when there are existing ongoing delete data requests * for that particular user. */ - public function test_delete_existing_deleted_users_task_existing_ongoing_delete_data_requests() { + public function test_delete_existing_deleted_users_task_existing_ongoing_delete_data_requests(): void { global $DB; $this->resetAfterTest(); @@ -179,7 +179,7 @@ class task_test extends \data_privacy_testcase { * is not created when there are existing finished delete data requests * for that particular user. */ - public function test_delete_existing_deleted_users_task_existing_finished_delete_data_requests() { + public function test_delete_existing_deleted_users_task_existing_finished_delete_data_requests(): void { global $DB; $this->resetAfterTest(); diff --git a/admin/tool/dataprivacy/tests/user_deleted_observer_test.php b/admin/tool/dataprivacy/tests/user_deleted_observer_test.php index f5839891c47..fc5e5008029 100644 --- a/admin/tool/dataprivacy/tests/user_deleted_observer_test.php +++ b/admin/tool/dataprivacy/tests/user_deleted_observer_test.php @@ -30,7 +30,7 @@ class user_deleted_observer_test extends \advanced_testcase { /** * Ensure that a delete data request is created upon user deletion. */ - public function test_create_delete_data_request() { + public function test_create_delete_data_request(): void { $this->resetAfterTest(); // Enable automatic creation of delete data requests. @@ -50,7 +50,7 @@ class user_deleted_observer_test extends \advanced_testcase { * Ensure that a delete data request is not created upon user deletion if automatic creation of * delete data requests is disabled. */ - public function test_create_delete_data_request_automatic_creation_disabled() { + public function test_create_delete_data_request_automatic_creation_disabled(): void { $this->resetAfterTest(); // Disable automatic creation of delete data requests. @@ -70,7 +70,7 @@ class user_deleted_observer_test extends \advanced_testcase { * Ensure that a delete data request is being created upon user deletion * if an ongoing export data request (or any other except delete data request) for that user already exists. */ - public function test_create_delete_data_request_export_data_request_preexists() { + public function test_create_delete_data_request_export_data_request_preexists(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -96,7 +96,7 @@ class user_deleted_observer_test extends \advanced_testcase { * Ensure that a delete data request is not being created upon user deletion * if an ongoing delete data request for that user already exists. */ - public function test_create_delete_data_request_ongoing_delete_data_request_preexists() { + public function test_create_delete_data_request_ongoing_delete_data_request_preexists(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -121,7 +121,7 @@ class user_deleted_observer_test extends \advanced_testcase { * Ensure that a delete data request is being created upon user deletion * if a finished delete data request (excluding complete) for that user already exists. */ - public function test_create_delete_data_request_canceled_delete_data_request_preexists() { + public function test_create_delete_data_request_canceled_delete_data_request_preexists(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -151,7 +151,7 @@ class user_deleted_observer_test extends \advanced_testcase { * Ensure that a delete data request is being created upon user deletion * if a completed delete data request for that user already exists. */ - public function test_create_delete_data_request_completed_delete_data_request_preexists() { + public function test_create_delete_data_request_completed_delete_data_request_preexists(): void { $this->resetAfterTest(); $this->setAdminUser(); diff --git a/admin/tool/filetypes/tests/tool_filetypes_test.php b/admin/tool/filetypes/tests/tool_filetypes_test.php index 348757f63cd..1f846aa1fb7 100644 --- a/admin/tool/filetypes/tests/tool_filetypes_test.php +++ b/admin/tool/filetypes/tests/tool_filetypes_test.php @@ -30,7 +30,7 @@ class tool_filetypes_test extends advanced_testcase { * * @covers ::is_extension_invalid */ - public function test_is_extension_invalid() { + public function test_is_extension_invalid(): void { // The pdf file extension already exists in default moodle minetypes. $this->assertTrue(utils::is_extension_invalid('pdf')); @@ -52,7 +52,7 @@ class tool_filetypes_test extends advanced_testcase { * * @covers ::is_defaulticon_allowed */ - public function test_is_defaulticon_allowed() { + public function test_is_defaulticon_allowed(): void { // You ARE allowed to set a default icon for a MIME type that hasn't // been used yet. $this->assertTrue(utils::is_defaulticon_allowed('application/x-frog')); @@ -71,7 +71,7 @@ class tool_filetypes_test extends advanced_testcase { * * @covers ::get_icons_from_path */ - public function test_get_icons_from_path() { + public function test_get_icons_from_path(): void { // Get icons from the fixtures folder. $icons = utils::get_icons_from_path(__DIR__ . '/fixtures'); @@ -86,7 +86,7 @@ class tool_filetypes_test extends advanced_testcase { * * @covers ::get_file_icons */ - public function test_get_file_icons() { + public function test_get_file_icons(): void { $icons = utils::get_file_icons(); $filetypes = core_filetypes::get_types(); diff --git a/admin/tool/generator/tests/maketestcourse_test.php b/admin/tool/generator/tests/maketestcourse_test.php index 6960dd2c294..a257a42262c 100644 --- a/admin/tool/generator/tests/maketestcourse_test.php +++ b/admin/tool/generator/tests/maketestcourse_test.php @@ -137,7 +137,7 @@ class maketestcourse_test extends \advanced_testcase { /** * Creates an small test course with fixed data set and checks the used sections and users. */ - public function test_fixed_data_set() { + public function test_fixed_data_set(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -178,7 +178,7 @@ class maketestcourse_test extends \advanced_testcase { /** * Creates a small test course specifying a maximum size and checks the generated files size is limited. */ - public function test_filesize_limit() { + public function test_filesize_limit(): void { $this->resetAfterTest(); $this->setAdminUser(); diff --git a/admin/tool/generator/tests/maketestsite_test.php b/admin/tool/generator/tests/maketestsite_test.php index e345b16eeee..499bc2a54e4 100644 --- a/admin/tool/generator/tests/maketestsite_test.php +++ b/admin/tool/generator/tests/maketestsite_test.php @@ -40,7 +40,7 @@ class maketestsite_test extends \advanced_testcase { /** * Checks that site courses shortnames are properly generated. */ - public function test_shortnames_generation() { + public function test_shortnames_generation(): void { $this->resetAfterTest(); $this->setAdminUser(); diff --git a/admin/tool/httpsreplace/tests/httpsreplace_test.php b/admin/tool/httpsreplace/tests/httpsreplace_test.php index dcf3c221d2d..bd4b0e4e72c 100644 --- a/admin/tool/httpsreplace/tests/httpsreplace_test.php +++ b/admin/tool/httpsreplace/tests/httpsreplace_test.php @@ -138,7 +138,7 @@ class httpsreplace_test extends \advanced_testcase { * @param string $expectedcontent What content we are expecting afterwards. * @dataProvider upgrade_http_links_provider */ - public function test_upgrade_http_links($content, $ouputregex, $expectedcontent) { + public function test_upgrade_http_links($content, $ouputregex, $expectedcontent): void { global $DB; $this->resetAfterTest(); @@ -212,7 +212,7 @@ class httpsreplace_test extends \advanced_testcase { * @param string $expectedcount Number of urls from that domain that we expect to be replaced. * @dataProvider http_link_stats_provider */ - public function test_http_link_stats($content, $domain, $expectedcount) { + public function test_http_link_stats($content, $domain, $expectedcount): void { $this->resetAfterTest(); $finder = new tool_httpreplace_url_finder_mock(); @@ -230,7 +230,7 @@ class httpsreplace_test extends \advanced_testcase { /** * Test links and text are not changed */ - public function test_links_and_text() { + public function test_links_and_text(): void { global $DB; $this->resetAfterTest(); @@ -261,7 +261,7 @@ class httpsreplace_test extends \advanced_testcase { /** * If we have an http wwwroot then we shouldn't report it. */ - public function test_httpwwwroot() { + public function test_httpwwwroot(): void { global $DB, $CFG; $this->resetAfterTest(); @@ -286,7 +286,7 @@ class httpsreplace_test extends \advanced_testcase { /** * Test that links in excluded tables are not replaced */ - public function test_upgrade_http_links_excluded_tables() { + public function test_upgrade_http_links_excluded_tables(): void { $this->resetAfterTest(); set_config('test_upgrade_http_links', ''); @@ -306,7 +306,7 @@ class httpsreplace_test extends \advanced_testcase { /** * Test renamed domains */ - public function test_renames() { + public function test_renames(): void { global $DB, $CFG; $this->resetAfterTest(); $this->expectOutputRegex('/UPDATE/'); @@ -339,7 +339,7 @@ class httpsreplace_test extends \advanced_testcase { /** * When there are many different pieces of contents from the same site, we should only run replace once */ - public function test_multiple() { + public function test_multiple(): void { global $DB; $this->resetAfterTest(); $original1 = ''; @@ -376,7 +376,7 @@ class httpsreplace_test extends \advanced_testcase { /** * Test the tool when the column name is a reserved word in SQL (in this case 'where') */ - public function test_reserved_words() { + public function test_reserved_words(): void { global $DB; $this->resetAfterTest(); diff --git a/admin/tool/installaddon/tests/installer_test.php b/admin/tool/installaddon/tests/installer_test.php index 38d900669a4..ff98bfbf25f 100644 --- a/admin/tool/installaddon/tests/installer_test.php +++ b/admin/tool/installaddon/tests/installer_test.php @@ -35,7 +35,7 @@ require_once(__DIR__.'/fixtures/testable_installer.php'); */ class installer_test extends \advanced_testcase { - public function test_get_addons_repository_url() { + public function test_get_addons_repository_url(): void { $installer = testable_tool_installaddon_installer::instance(); $url = $installer->get_addons_repository_url(); $query = parse_url($url, PHP_URL_QUERY); @@ -49,7 +49,7 @@ class installer_test extends \advanced_testcase { $this->assertSame("2.5'; DROP TABLE mdl_user; --", $site['majorversion']); } - public function test_decode_remote_request() { + public function test_decode_remote_request(): void { $installer = testable_tool_installaddon_installer::instance(); $request = base64_encode(json_encode(array( @@ -107,7 +107,7 @@ class installer_test extends \advanced_testcase { $this->assertSame(false, $installer->testable_decode_remote_request($request)); } - public function test_detect_plugin_component() { + public function test_detect_plugin_component(): void { global $CFG; $installer = tool_installaddon_installer::instance(); @@ -119,7 +119,7 @@ class installer_test extends \advanced_testcase { $this->assertFalse($installer->detect_plugin_component($zipfile)); } - public function test_detect_plugin_component_from_versionphp() { + public function test_detect_plugin_component_from_versionphp(): void { global $CFG; $installer = testable_tool_installaddon_installer::instance(); @@ -136,7 +136,7 @@ $plugin->version = 2014121300; $this->assertFalse($installer->testable_detect_plugin_component_from_versionphp($versionphp)); } - public function test_make_installfromzip_storage() { + public function test_make_installfromzip_storage(): void { $installer = testable_tool_installaddon_installer::instance(); // Check we get writable directory. diff --git a/admin/tool/langimport/tests/event/events_test.php b/admin/tool/langimport/tests/event/events_test.php index e08d5d32c91..2f87dd0d29e 100644 --- a/admin/tool/langimport/tests/event/events_test.php +++ b/admin/tool/langimport/tests/event/events_test.php @@ -41,7 +41,7 @@ class events_test extends \advanced_testcase { $this->resetAfterTest(); } - public function test_langpack_updated() { + public function test_langpack_updated(): void { global $CFG; $event = \tool_langimport\event\langpack_updated::event_with_langcode($CFG->lang); @@ -56,14 +56,14 @@ class events_test extends \advanced_testcase { $this->assertEquals(\context_system::instance(), $event->get_context()); } - public function test_langpack_updated_validation() { + public function test_langpack_updated_validation(): void { $this->expectException('coding_exception'); $this->expectExceptionMessage("The 'langcode' value must be set to a valid language code"); \tool_langimport\event\langpack_updated::event_with_langcode('broken langcode'); } - public function test_langpack_installed() { + public function test_langpack_installed(): void { $event = \tool_langimport\event\langpack_imported::event_with_langcode('fr'); // Trigger and capture the event. @@ -76,14 +76,14 @@ class events_test extends \advanced_testcase { $this->assertEquals(\context_system::instance(), $event->get_context()); } - public function test_langpack_installed_validation() { + public function test_langpack_installed_validation(): void { $this->expectException('coding_exception'); $this->expectExceptionMessage("The 'langcode' value must be set to a valid language code"); \tool_langimport\event\langpack_imported::event_with_langcode('broken langcode'); } - public function test_langpack_removed() { + public function test_langpack_removed(): void { $event = \tool_langimport\event\langpack_removed::event_with_langcode('fr'); // Trigger and capture the event. @@ -96,7 +96,7 @@ class events_test extends \advanced_testcase { $this->assertEquals(\context_system::instance(), $event->get_context()); } - public function test_langpack_removed_validation() { + public function test_langpack_removed_validation(): void { $this->expectException('coding_exception'); $this->expectExceptionMessage("The 'langcode' value must be set to a valid language code"); diff --git a/admin/tool/langimport/tests/locale_test.php b/admin/tool/langimport/tests/locale_test.php index dbe51337b75..247e6fc4013 100644 --- a/admin/tool/langimport/tests/locale_test.php +++ b/admin/tool/langimport/tests/locale_test.php @@ -32,7 +32,7 @@ class locale_test extends \advanced_testcase { * @covers ::check_locale_availability * @return void */ - public function test_check_locale_availability() { + public function test_check_locale_availability(): void { // Create a mock of set_locale() method to simulate : // - first setlocale() call which backup current locale // - second setlocale() call which try to set new 'es' locale @@ -79,7 +79,7 @@ class locale_test extends \advanced_testcase { * @param string $set locale string to be set. * @param string $ret expected results returned after setting the locale. */ - public function test_set_locale(string $set, string $ret) { + public function test_set_locale(string $set, string $ret): void { // Make set_locale() public. $loc = new locale(); $rc = new \ReflectionClass(locale::class); diff --git a/admin/tool/licensemanager/tests/helper_test.php b/admin/tool/licensemanager/tests/helper_test.php index 14c34c6a137..cf8ee961e46 100644 --- a/admin/tool/licensemanager/tests/helper_test.php +++ b/admin/tool/licensemanager/tests/helper_test.php @@ -34,7 +34,7 @@ defined('MOODLE_INTERNAL') || die(); */ class helper_test extends advanced_testcase { - public function test_convert_version_to_epoch() { + public function test_convert_version_to_epoch(): void { $version = '2020010100'; $expected = strtotime(20200101); diff --git a/admin/tool/licensemanager/tests/manager_test.php b/admin/tool/licensemanager/tests/manager_test.php index 3fdc0dcbf1a..0be8895e58a 100644 --- a/admin/tool/licensemanager/tests/manager_test.php +++ b/admin/tool/licensemanager/tests/manager_test.php @@ -41,7 +41,7 @@ class manager_test extends advanced_testcase { /** * Test editing a license. */ - public function test_edit_existing_license() { + public function test_edit_existing_license(): void { $this->resetAfterTest(); // Create initial custom license to edit. @@ -84,7 +84,7 @@ class manager_test extends advanced_testcase { $this->assertSame(date('Ymd', $formdata['version']) . '00', $actual->version); } - public function test_edit_license_not_exists() { + public function test_edit_license_not_exists(): void { $manager = new \tool_licensemanager\manager(); // We're testing a private method, so we need to setup reflector magic. @@ -104,7 +104,7 @@ class manager_test extends advanced_testcase { $method->invoke($manager, \tool_licensemanager\manager::ACTION_UPDATE, $formdata['shortname']); } - public function test_edit_license_no_shortname() { + public function test_edit_license_no_shortname(): void { $manager = new \tool_licensemanager\manager(); // We're testing a private method, so we need to setup reflector magic. @@ -126,7 +126,7 @@ class manager_test extends advanced_testcase { /** * Test creating a new license. */ - public function test_edit_create_license() { + public function test_edit_create_license(): void { $this->resetAfterTest(); $licensecount = count(license_manager::get_licenses()); @@ -166,7 +166,7 @@ class manager_test extends advanced_testcase { /** * Test changing the order of licenses. */ - public function test_change_license_order() { + public function test_change_license_order(): void { $this->resetAfterTest(); $licenseorder = array_keys(license_manager::get_licenses()); diff --git a/admin/tool/log/store/database/tests/privacy/provider_test.php b/admin/tool/log/store/database/tests/privacy/provider_test.php index 31d9f2bb328..a0edb7c4d10 100644 --- a/admin/tool/log/store/database/tests/privacy/provider_test.php +++ b/admin/tool/log/store/database/tests/privacy/provider_test.php @@ -95,7 +95,7 @@ class provider_test extends provider_testcase { } } - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { $admin = \core_user::get_user(2); $u1 = $this->getDataGenerator()->create_user(); $u2 = $this->getDataGenerator()->create_user(); @@ -155,7 +155,7 @@ class provider_test extends provider_testcase { /** * Check that user IDs are returned for a given context. */ - public function test_add_userids_for_context() { + public function test_add_userids_for_context(): void { $admin = \core_user::get_user(2); $u1 = $this->getDataGenerator()->create_user(); $u2 = $this->getDataGenerator()->create_user(); @@ -201,7 +201,7 @@ class provider_test extends provider_testcase { $this->assertEmpty(array_diff($expectedresult, $userids)); } - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; $u1 = $this->getDataGenerator()->create_user(); $u2 = $this->getDataGenerator()->create_user(); @@ -242,7 +242,7 @@ class provider_test extends provider_testcase { $this->assertEquals(2, $DB->count_records('logstore_standard_log', ['userid' => $u2->id])); } - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; $u1 = $this->getDataGenerator()->create_user(); $u2 = $this->getDataGenerator()->create_user(); @@ -286,7 +286,7 @@ class provider_test extends provider_testcase { /** * Check that data is removed for the listed users in a given context. */ - public function test_delete_data_for_userlist() { + public function test_delete_data_for_userlist(): void { global $DB; $u1 = $this->getDataGenerator()->create_user(); @@ -328,7 +328,7 @@ class provider_test extends provider_testcase { $this->assertEquals($u2->id, $currentrecord->userid); } - public function test_export_data_for_user() { + public function test_export_data_for_user(): void { $admin = \core_user::get_user(2); $u1 = $this->getDataGenerator()->create_user(); $u2 = $this->getDataGenerator()->create_user(); diff --git a/admin/tool/log/store/database/tests/store_test.php b/admin/tool/log/store/database/tests/store_test.php index 0a833172ce8..1a84c3bda10 100644 --- a/admin/tool/log/store/database/tests/store_test.php +++ b/admin/tool/log/store/database/tests/store_test.php @@ -35,7 +35,7 @@ class store_test extends \advanced_testcase { * @param bool $jsonformat True to test with JSON format * @dataProvider log_writing_provider */ - public function test_log_writing(bool $jsonformat) { + public function test_log_writing(bool $jsonformat): void { global $DB, $CFG; $this->resetAfterTest(); $this->preventResetByRollback(); // Logging waits till the transaction gets committed. @@ -263,7 +263,7 @@ class store_test extends \advanced_testcase { /** * Test method is_event_ignored. */ - public function test_is_event_ignored() { + public function test_is_event_ignored(): void { $this->resetAfterTest(); // Test guest filtering. @@ -306,7 +306,7 @@ class store_test extends \advanced_testcase { /** * Test logmanager::get_supported_reports returns all reports that require this store. */ - public function test_get_supported_reports() { + public function test_get_supported_reports(): void { $logmanager = get_log_manager(); $allreports = \core_component::get_plugin_list('report'); diff --git a/admin/tool/log/store/standard/tests/privacy/provider_test.php b/admin/tool/log/store/standard/tests/privacy/provider_test.php index 670039668e7..651abc38a43 100644 --- a/admin/tool/log/store/standard/tests/privacy/provider_test.php +++ b/admin/tool/log/store/standard/tests/privacy/provider_test.php @@ -53,7 +53,7 @@ class provider_test extends provider_testcase { $this->preventResetByRollback(); // Logging waits till the transaction gets committed. } - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { $admin = \core_user::get_user(2); $u1 = $this->getDataGenerator()->create_user(); $u2 = $this->getDataGenerator()->create_user(); @@ -110,7 +110,7 @@ class provider_test extends provider_testcase { $this->assert_contextlist_equals($this->get_contextlist_for_user($admin), [$sysctx, $c1ctx, $c2ctx]); } - public function test_add_userids_for_context() { + public function test_add_userids_for_context(): void { $admin = \core_user::get_user(2); $u1 = $this->getDataGenerator()->create_user(); $u2 = $this->getDataGenerator()->create_user(); @@ -156,7 +156,7 @@ class provider_test extends provider_testcase { $this->assertEmpty(array_diff($expectedresult, $userids)); } - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; $u1 = $this->getDataGenerator()->create_user(); $u2 = $this->getDataGenerator()->create_user(); @@ -197,7 +197,7 @@ class provider_test extends provider_testcase { $this->assertEquals(2, $DB->count_records('logstore_standard_log', ['userid' => $u2->id])); } - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; $u1 = $this->getDataGenerator()->create_user(); $u2 = $this->getDataGenerator()->create_user(); @@ -238,7 +238,7 @@ class provider_test extends provider_testcase { $this->assertEquals(1, $DB->count_records('logstore_standard_log', ['userid' => $u2->id])); } - public function test_delete_data_for_userlist() { + public function test_delete_data_for_userlist(): void { global $DB; $u1 = $this->getDataGenerator()->create_user(); @@ -280,7 +280,7 @@ class provider_test extends provider_testcase { $this->assertEquals($u2->id, $currentrecord->userid); } - public function test_export_data_for_user() { + public function test_export_data_for_user(): void { $admin = \core_user::get_user(2); $u1 = $this->getDataGenerator()->create_user(); $u2 = $this->getDataGenerator()->create_user(); diff --git a/admin/tool/log/store/standard/tests/store_test.php b/admin/tool/log/store/standard/tests/store_test.php index 5358143e59c..a02e2d9d590 100644 --- a/admin/tool/log/store/standard/tests/store_test.php +++ b/admin/tool/log/store/standard/tests/store_test.php @@ -40,7 +40,7 @@ class store_test extends \advanced_testcase { * @param bool $jsonformat True to test with JSON format * @dataProvider log_writing_provider */ - public function test_log_writing(bool $jsonformat) { + public function test_log_writing(bool $jsonformat): void { global $DB; $this->resetAfterTest(); $this->preventResetByRollback(); // Logging waits till the transaction gets committed. @@ -238,7 +238,7 @@ class store_test extends \advanced_testcase { /** * Test logmanager::get_supported_reports returns all reports that require this store. */ - public function test_get_supported_reports() { + public function test_get_supported_reports(): void { $logmanager = get_log_manager(); $allreports = \core_component::get_plugin_list('report'); @@ -261,7 +261,7 @@ class store_test extends \advanced_testcase { /** * Verify that gc disabling works */ - public function test_gc_enabled_as_expected() { + public function test_gc_enabled_as_expected(): void { if (!gc_enabled()) { $this->markTestSkipped('Garbage collector (gc) is globally disabled.'); } @@ -275,7 +275,7 @@ class store_test extends \advanced_testcase { * Test sql_reader::get_events_select_iterator. * @return void */ - public function test_events_traversable() { + public function test_events_traversable(): void { global $DB; $this->disable_gc(); @@ -332,7 +332,7 @@ class store_test extends \advanced_testcase { /** * Test that the standard log cleanup works correctly. */ - public function test_cleanup_task() { + public function test_cleanup_task(): void { global $DB; $this->resetAfterTest(); @@ -372,12 +372,12 @@ class store_test extends \advanced_testcase { * @param mixed $value Value to encode and decode * @dataProvider decode_other_provider */ - public function test_decode_other($value) { + public function test_decode_other($value): void { $this->assertEquals($value, \logstore_standard\log\store::decode_other(serialize($value))); $this->assertEquals($value, \logstore_standard\log\store::decode_other(json_encode($value))); } - public function test_decode_other_with_wrongly_encoded_contents() { + public function test_decode_other_with_wrongly_encoded_contents(): void { $this->assertSame(null, \logstore_standard\log\store::decode_other(null)); } @@ -404,7 +404,7 @@ class store_test extends \advanced_testcase { * @param bool $jsonformat True to test with JSON format * @dataProvider log_writing_provider */ - public function test_backup_restore(bool $jsonformat) { + public function test_backup_restore(bool $jsonformat): void { global $DB; $this->resetAfterTest(); $this->preventResetByRollback(); diff --git a/admin/tool/log/tests/manager_test.php b/admin/tool/log/tests/manager_test.php index a9fb357117a..5d425335ef9 100644 --- a/admin/tool/log/tests/manager_test.php +++ b/admin/tool/log/tests/manager_test.php @@ -24,7 +24,7 @@ namespace tool_log; * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class manager_test extends \advanced_testcase { - public function test_get_log_manager() { + public function test_get_log_manager(): void { global $CFG; $this->resetAfterTest(); diff --git a/admin/tool/log/tests/privacy/provider_test.php b/admin/tool/log/tests/privacy/provider_test.php index 0d078ee1c1c..c71d8fecec1 100644 --- a/admin/tool/log/tests/privacy/provider_test.php +++ b/admin/tool/log/tests/privacy/provider_test.php @@ -57,7 +57,7 @@ class provider_test extends provider_testcase { $this->preventResetByRollback(); // Logging waits till the transaction gets committed. } - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { $admin = \core_user::get_user(2); $u1 = $this->getDataGenerator()->create_user(); $c1 = $this->getDataGenerator()->create_course(); @@ -73,7 +73,7 @@ class provider_test extends provider_testcase { $this->assertEquals($c1ctx->id, provider::get_contexts_for_userid($u1->id)->get_contextids()[0]); } - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; $u1 = $this->getDataGenerator()->create_user(); $u2 = $this->getDataGenerator()->create_user(); @@ -107,7 +107,7 @@ class provider_test extends provider_testcase { $this->assertEquals(1, $DB->count_records('logstore_standard_log', ['userid' => $u2->id])); } - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; $u1 = $this->getDataGenerator()->create_user(); $u2 = $this->getDataGenerator()->create_user(); @@ -141,7 +141,7 @@ class provider_test extends provider_testcase { $this->assertEquals(0, $DB->count_records('logstore_standard_log', ['userid' => $u2->id])); } - public function test_export_data_for_user() { + public function test_export_data_for_user(): void { $admin = \core_user::get_user(2); $u1 = $this->getDataGenerator()->create_user(); $c1 = $this->getDataGenerator()->create_course(); diff --git a/admin/tool/lp/tests/externallib_test.php b/admin/tool/lp/tests/externallib_test.php index db63e158c31..f2b779a5f0e 100644 --- a/admin/tool/lp/tests/externallib_test.php +++ b/admin/tool/lp/tests/externallib_test.php @@ -131,7 +131,7 @@ class externallib_test extends externallib_advanced_testcase { accesslib_clear_all_caches_for_unit_testing(); } - public function test_search_users_by_capability() { + public function test_search_users_by_capability(): void { global $CFG; $this->resetAfterTest(true); @@ -214,7 +214,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Ensures that overrides, as well as system permissions, are respected. */ - public function test_search_users_by_capability_the_comeback() { + public function test_search_users_by_capability_the_comeback(): void { $this->resetAfterTest(); $dg = $this->getDataGenerator(); @@ -275,7 +275,7 @@ class externallib_test extends externallib_advanced_testcase { $this->assertArrayHasKey($slave1->id, $result['users']); } - public function test_search_users() { + public function test_search_users(): void { global $CFG; $this->resetAfterTest(true); @@ -398,7 +398,7 @@ class externallib_test extends externallib_advanced_testcase { $this->assertEmpty($result['users'][0]['institution']); } - public function test_data_for_user_competency_summary_in_plan() { + public function test_data_for_user_competency_summary_in_plan(): void { global $CFG; $this->setUser($this->creator); @@ -428,7 +428,7 @@ class externallib_test extends externallib_advanced_testcase { $this->assertEquals('A', $summary->usercompetencysummary->evidence[1]->gradename); } - public function test_data_for_user_competency_summary() { + public function test_data_for_user_competency_summary(): void { $this->setUser($this->creator); $dg = $this->getDataGenerator(); @@ -446,7 +446,7 @@ class externallib_test extends externallib_advanced_testcase { $this->assertEquals('A', $summary->evidence[1]->gradename); } - public function test_data_for_course_competency_page() { + public function test_data_for_course_competency_page(): void { $this->setAdminUser(); $dg = $this->getDataGenerator(); diff --git a/admin/tool/lpimportcsv/tests/import_test.php b/admin/tool/lpimportcsv/tests/import_test.php index 976381df63f..fafbef13e15 100644 --- a/admin/tool/lpimportcsv/tests/import_test.php +++ b/admin/tool/lpimportcsv/tests/import_test.php @@ -27,7 +27,7 @@ use core_competency\api; */ class import_test extends \advanced_testcase { - public function test_import_framework() { + public function test_import_framework(): void { $this->resetAfterTest(true); $this->setAdminUser(); diff --git a/admin/tool/lpmigrate/tests/processor_test.php b/admin/tool/lpmigrate/tests/processor_test.php index 5d1c427ba7b..2db7d2107c6 100644 --- a/admin/tool/lpmigrate/tests/processor_test.php +++ b/admin/tool/lpmigrate/tests/processor_test.php @@ -166,7 +166,7 @@ class processor_test extends \advanced_testcase { $this->cmcs = $cmcs; } - public function test_simple_migration() { + public function test_simple_migration(): void { $this->setAdminUser(); $mapper = new framework_mapper($this->f1->get('id'), $this->f2->get('id')); @@ -202,7 +202,7 @@ class processor_test extends \advanced_testcase { $this->assertModuleCompetencyExists($this->cms[$this->c1->id]['F1'], $this->f1comps['X1']); } - public function test_remove_when_missing() { + public function test_remove_when_missing(): void { $this->setAdminUser(); $mapper = new framework_mapper($this->f1->get('id'), $this->f2->get('id')); @@ -228,7 +228,7 @@ class processor_test extends \advanced_testcase { $this->assertModuleCompetencyNotExists($this->cms[$this->c1->id]['F1'], $this->f1comps['X1']); } - public function test_allowed_courses() { + public function test_allowed_courses(): void { $this->setAdminUser(); $mapper = new framework_mapper($this->f1->get('id'), $this->f2->get('id')); @@ -261,7 +261,7 @@ class processor_test extends \advanced_testcase { $this->assertModuleCompetencyNotMigrated($this->cms[$this->c2->id]['F1'], $this->f1comps['A3'], $this->f2comps['A3']); } - public function test_disallowed_courses() { + public function test_disallowed_courses(): void { $this->setAdminUser(); $mapper = new framework_mapper($this->f1->get('id'), $this->f2->get('id')); @@ -294,7 +294,7 @@ class processor_test extends \advanced_testcase { $this->assertModuleCompetencyNotMigrated($this->cms[$this->c2->id]['F1'], $this->f1comps['A3'], $this->f2comps['A3']); } - public function test_course_start_date_from() { + public function test_course_start_date_from(): void { $this->setAdminUser(); $mapper = new framework_mapper($this->f1->get('id'), $this->f2->get('id')); @@ -327,7 +327,7 @@ class processor_test extends \advanced_testcase { $this->assertModuleCompetencyMigrated($this->cms[$this->c2->id]['F1'], $this->f1comps['A3'], $this->f2comps['A3']); } - public function test_destination_competency_exists() { + public function test_destination_competency_exists(): void { $this->setAdminUser(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -375,7 +375,7 @@ class processor_test extends \advanced_testcase { $this->assertModuleCompetencyExists($this->cms[$this->c2->id]['F1'], $this->f1comps['A2']); } - public function test_destination_competency_exists_remove_original() { + public function test_destination_competency_exists_remove_original(): void { $this->setAdminUser(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -411,7 +411,7 @@ class processor_test extends \advanced_testcase { $this->assertModuleCompetencyNotExists($this->cms[$this->c2->id]['F1'], $this->f1comps['A2']); } - public function test_permission_exception() { + public function test_permission_exception(): void { $this->preventResetByRollback(); // Test uses transactions, so we cannot use them for speedy reset. diff --git a/admin/tool/messageinbound/tests/manager_test.php b/admin/tool/messageinbound/tests/manager_test.php index 41045357c65..da760cda99e 100644 --- a/admin/tool/messageinbound/tests/manager_test.php +++ b/admin/tool/messageinbound/tests/manager_test.php @@ -43,7 +43,7 @@ class manager_test extends provider_testcase { $CFG->messageinbound_domain = 'example.com'; } - public function test_tidy_old_verification_failures() { + public function test_tidy_old_verification_failures(): void { global $DB; $now = time(); diff --git a/admin/tool/messageinbound/tests/privacy/provider_test.php b/admin/tool/messageinbound/tests/privacy/provider_test.php index 9feca9ad908..a7e5fd25286 100644 --- a/admin/tool/messageinbound/tests/privacy/provider_test.php +++ b/admin/tool/messageinbound/tests/privacy/provider_test.php @@ -57,7 +57,7 @@ class provider_test extends provider_testcase { $CFG->messageinbound_domain = 'example.com'; } - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { $dg = $this->getDataGenerator(); $u1 = $dg->create_user(); $u2 = $dg->create_user(); @@ -76,7 +76,7 @@ class provider_test extends provider_testcase { /** * Test for provider::test_get_users_in_context(). */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { $component = 'tool_messageinbound'; $dg = $this->getDataGenerator(); $u1 = $dg->create_user(); @@ -118,7 +118,7 @@ class provider_test extends provider_testcase { $this->assertCount(0, $userids); } - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; $dg = $this->getDataGenerator(); $u1 = $dg->create_user(); @@ -161,7 +161,7 @@ class provider_test extends provider_testcase { /** * Test for provider::test_delete_data_for_users(). */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { global $DB; $component = 'tool_messageinbound'; $dg = $this->getDataGenerator(); @@ -210,7 +210,7 @@ class provider_test extends provider_testcase { $this->assertTrue($DB->record_exists('messageinbound_messagelist', ['userid' => $u2->id])); } - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; $dg = $this->getDataGenerator(); $u1 = $dg->create_user(); @@ -243,7 +243,7 @@ class provider_test extends provider_testcase { $this->assertTrue($DB->record_exists('messageinbound_messagelist', ['userid' => $u2->id])); } - public function test_export_data_for_user() { + public function test_export_data_for_user(): void { $dg = $this->getDataGenerator(); $u1 = $dg->create_user(); $u2 = $dg->create_user(); diff --git a/admin/tool/mfa/factor/cohort/tests/factor_test.php b/admin/tool/mfa/factor/cohort/tests/factor_test.php index 08bf79df398..f25ae8e9983 100644 --- a/admin/tool/mfa/factor/cohort/tests/factor_test.php +++ b/admin/tool/mfa/factor/cohort/tests/factor_test.php @@ -32,7 +32,7 @@ class factor_test extends \advanced_testcase { * @covers ::get_summary_condition * @covers ::get_cohorts */ - public function test_get_summary_condition() { + public function test_get_summary_condition(): void { $this->resetAfterTest(); set_config('enabled', 1, 'factor_cohort'); diff --git a/admin/tool/mfa/factor/email/tests/factor_test.php b/admin/tool/mfa/factor/email/tests/factor_test.php index 55a45585eda..2ddca03c6e6 100644 --- a/admin/tool/mfa/factor/email/tests/factor_test.php +++ b/admin/tool/mfa/factor/email/tests/factor_test.php @@ -32,7 +32,7 @@ class factor_test extends \advanced_testcase { * @covers ::check_verification_code * @covers ::post_pass_state */ - public function test_check_verification_code() { + public function test_check_verification_code(): void { global $DB, $USER; $this->resetAfterTest(true); diff --git a/admin/tool/mfa/factor/grace/tests/factor_test.php b/admin/tool/mfa/factor/grace/tests/factor_test.php index 140f29b7b26..85e5390115b 100644 --- a/admin/tool/mfa/factor/grace/tests/factor_test.php +++ b/admin/tool/mfa/factor/grace/tests/factor_test.php @@ -32,7 +32,7 @@ class factor_test extends \advanced_testcase { * @covers ::get_affecting_factors * @return void */ - public function test_affecting_factors() { + public function test_affecting_factors(): void { $this->resetAfterTest(true); $user = $this->getDataGenerator()->create_user(); $this->setUser($user); diff --git a/admin/tool/mfa/factor/role/tests/factor_test.php b/admin/tool/mfa/factor/role/tests/factor_test.php index ec89a97aced..d87832e314b 100644 --- a/admin/tool/mfa/factor/role/tests/factor_test.php +++ b/admin/tool/mfa/factor/role/tests/factor_test.php @@ -32,7 +32,7 @@ class factor_test extends \advanced_testcase { * @covers ::get_summary_condition * @covers ::get_roles */ - public function test_get_summary_condition() { + public function test_get_summary_condition(): void { global $DB; $this->resetAfterTest(); diff --git a/admin/tool/mfa/factor/token/tests/factor_test.php b/admin/tool/mfa/factor/token/tests/factor_test.php index 62c63cd92dd..4b8e3c43afd 100644 --- a/admin/tool/mfa/factor/token/tests/factor_test.php +++ b/admin/tool/mfa/factor/token/tests/factor_test.php @@ -45,7 +45,7 @@ class factor_test extends \advanced_testcase { * @covers ::calculate_expiry_time * @return void */ - public function test_calculate_expiry_time_in_general() { + public function test_calculate_expiry_time_in_general(): void { $timestamp = 1642213800; // 1230 UTC. set_config('expireovernight', 0, 'factor_token'); @@ -91,7 +91,7 @@ class factor_test extends \advanced_testcase { * @param int $timestamp * @dataProvider timestamp_provider */ - public function test_calculate_expiry_time_for_overnight_expiry_with_one_day_expiry($timestamp) { + public function test_calculate_expiry_time_for_overnight_expiry_with_one_day_expiry($timestamp): void { // Setup configuration. $method = new \ReflectionMethod($this->factor, 'calculate_expiry_time'); set_config('expireovernight', 1, 'factor_token'); @@ -139,7 +139,7 @@ class factor_test extends \advanced_testcase { * @param int $timestamp * @dataProvider timestamp_provider */ - public function test_calculate_expiry_time_for_overnight_expiry_with_two_day_expiry($timestamp) { + public function test_calculate_expiry_time_for_overnight_expiry_with_two_day_expiry($timestamp): void { // Setup configuration. $method = new \ReflectionMethod($this->factor, 'calculate_expiry_time'); set_config('expireovernight', 1, 'factor_token'); @@ -189,7 +189,7 @@ class factor_test extends \advanced_testcase { * @param int $timestamp * @dataProvider timestamp_provider */ - public function test_calculate_expiry_time_for_overnight_expiry_with_three_hour_expiry($timestamp) { + public function test_calculate_expiry_time_for_overnight_expiry_with_three_hour_expiry($timestamp): void { // Setup configuration. $method = new \ReflectionMethod($this->factor, 'calculate_expiry_time'); set_config('expireovernight', 1, 'factor_token'); @@ -233,7 +233,7 @@ class factor_test extends \advanced_testcase { * @param int $timestamp * @dataProvider timestamp_provider */ - public function test_calculate_expiry_time_for_overnight_expiry_with_an_hour_expiry($timestamp) { + public function test_calculate_expiry_time_for_overnight_expiry_with_an_hour_expiry($timestamp): void { // Setup configuration. $method = new \ReflectionMethod($this->factor, 'calculate_expiry_time'); set_config('expireovernight', 1, 'factor_token'); diff --git a/admin/tool/mfa/factor/totp/tests/factor_test.php b/admin/tool/mfa/factor/totp/tests/factor_test.php index 8dd1985cfdd..ff09290a523 100644 --- a/admin/tool/mfa/factor/totp/tests/factor_test.php +++ b/admin/tool/mfa/factor/totp/tests/factor_test.php @@ -45,7 +45,7 @@ class factor_test extends \advanced_testcase { /** * Test code validation of the TOTP factor */ - public function test_validate_code() { + public function test_validate_code(): void { global $DB; $this->resetAfterTest(true); @@ -123,7 +123,7 @@ class factor_test extends \advanced_testcase { * * @covers ::setup_user_factor */ - public function test_wont_store_same_secret_twice() { + public function test_wont_store_same_secret_twice(): void { global $DB; $this->resetAfterTest(true); $user = $this->getDataGenerator()->create_user(); diff --git a/admin/tool/mfa/tests/admin_setting_managemfa_test.php b/admin/tool/mfa/tests/admin_setting_managemfa_test.php index 5af422fd589..fcfd43a2cf0 100644 --- a/admin/tool/mfa/tests/admin_setting_managemfa_test.php +++ b/admin/tool/mfa/tests/admin_setting_managemfa_test.php @@ -38,7 +38,7 @@ class admin_setting_managemfa_test extends \advanced_testcase { * * @covers ::get_factor_combinations */ - public function test_get_factor_combinations_default() { + public function test_get_factor_combinations_default(): void { $namagemfa = new \tool_mfa\local\admin_setting_managemfa(); $factors = \tool_mfa\plugininfo\factor::get_enabled_factors(); $combinations = $namagemfa->get_factor_combinations($factors, 0, count($factors) - 1); @@ -141,7 +141,7 @@ class admin_setting_managemfa_test extends \advanced_testcase { * @param array $factorset configured factors * @param int $combinationscount expected count of available combinations */ - public function test_get_factor_combinations_with_data_provider($factorset, $combinationscount) { + public function test_get_factor_combinations_with_data_provider($factorset, $combinationscount): void { $this->resetAfterTest(); $enabledcount = 0; @@ -174,7 +174,7 @@ class admin_setting_managemfa_test extends \advanced_testcase { * * @covers ::get_factor_combinations */ - public function test_factor_combination_checker() { + public function test_factor_combination_checker(): void { $this->resetAfterTest(); $managemfa = new \tool_mfa\local\admin_setting_managemfa(); $user = $this->getDataGenerator()->create_user(); diff --git a/admin/tool/mfa/tests/manager_test.php b/admin/tool/mfa/tests/manager_test.php index 1e976cb334e..8eace2573b2 100644 --- a/admin/tool/mfa/tests/manager_test.php +++ b/admin/tool/mfa/tests/manager_test.php @@ -38,7 +38,7 @@ class manager_test extends \advanced_testcase { * @covers ::get_total_weight * @covers ::setup_user_factor */ - public function test_get_total_weight() { + public function test_get_total_weight(): void { $this->resetAfterTest(true); // Create and login a user. @@ -83,7 +83,7 @@ class manager_test extends \advanced_testcase { * * @covers ::get_status */ - public function test_get_status() { + public function test_get_status(): void { $this->resetAfterTest(true); // Create and login a user. @@ -121,7 +121,7 @@ class manager_test extends \advanced_testcase { * * @covers ::passed_enough_factors */ - public function test_passed_enough_factors() { + public function test_passed_enough_factors(): void { $this->resetAfterTest(true); // Create and login a user. @@ -186,7 +186,7 @@ class manager_test extends \advanced_testcase { * @param array|null $params * @dataProvider should_redirect_urls_provider */ - public function test_should_require_mfa_urls($urlstring, $webroot, $status, $params = null) { + public function test_should_require_mfa_urls($urlstring, $webroot, $status, $params = null): void { $this->resetAfterTest(true); global $CFG; $user = $this->getDataGenerator()->create_user(); @@ -201,7 +201,7 @@ class manager_test extends \advanced_testcase { * * @covers ::should_require_mfa */ - public function test_should_require_mfa_checks() { + public function test_should_require_mfa_checks(): void { // Setup test and user. global $CFG; $this->resetAfterTest(true); @@ -273,7 +273,7 @@ class manager_test extends \advanced_testcase { * * @covers ::should_require_mfa */ - public function test_should_require_mfa_redirection_loop() { + public function test_should_require_mfa_redirection_loop(): void { // Setup test and user. global $CFG, $SESSION; $CFG->wwwroot = 'http://phpunit.test'; @@ -330,7 +330,7 @@ class manager_test extends \advanced_testcase { * @covers ::possible_factor_setup * @covers ::setup_user_factor */ - public function test_possible_factor_setup() { + public function test_possible_factor_setup(): void { // Setup test and user. $this->resetAfterTest(true); $user = $this->getDataGenerator()->create_user(); @@ -365,7 +365,7 @@ class manager_test extends \advanced_testcase { * * @covers ::is_ready */ - public function test_is_ready() { + public function test_is_ready(): void { // Setup test and user. global $CFG; $this->resetAfterTest(true); @@ -406,7 +406,7 @@ class manager_test extends \advanced_testcase { * @covers ::mfa_config_hook_test * @covers ::mfa_login_hook_test */ - public function test_core_hooks() { + public function test_core_hooks(): void { // Setup test and user. global $CFG, $SESSION; $this->resetAfterTest(true); @@ -425,7 +425,7 @@ class manager_test extends \advanced_testcase { * * @covers ::should_require_mfa */ - public function test_circular_redirect_auth() { + public function test_circular_redirect_auth(): void { // Setup test and user. $this->resetAfterTest(true); $user = $this->getDataGenerator()->create_user(); diff --git a/admin/tool/mfa/tests/object_factor_base_test.php b/admin/tool/mfa/tests/object_factor_base_test.php index 8465f6fc4da..5d688f58519 100644 --- a/admin/tool/mfa/tests/object_factor_base_test.php +++ b/admin/tool/mfa/tests/object_factor_base_test.php @@ -38,7 +38,7 @@ class object_factor_base_test extends \advanced_testcase { * @covers ::setup_user_factor * @return void */ - public function test_revoke_user_factor() { + public function test_revoke_user_factor(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); $this->setUser($user); diff --git a/admin/tool/mfa/tests/plugininfo_factor_test.php b/admin/tool/mfa/tests/plugininfo_factor_test.php index 0c8b65f55e2..6586898de13 100644 --- a/admin/tool/mfa/tests/plugininfo_factor_test.php +++ b/admin/tool/mfa/tests/plugininfo_factor_test.php @@ -36,7 +36,7 @@ class plugininfo_factor_test extends \advanced_testcase { * @covers ::has_setup * @covers ::get_active_user_factor_types */ - public function test_get_next_user_login_factor() { + public function test_get_next_user_login_factor(): void { $this->resetAfterTest(true); diff --git a/admin/tool/mfa/tests/secret_manager_test.php b/admin/tool/mfa/tests/secret_manager_test.php index d426dfe0b8f..4acbfa45792 100644 --- a/admin/tool/mfa/tests/secret_manager_test.php +++ b/admin/tool/mfa/tests/secret_manager_test.php @@ -31,7 +31,7 @@ class secret_manager_test extends \advanced_testcase { * * @covers ::create_secret */ - public function test_create_secret() { + public function test_create_secret(): void { global $DB; $this->resetAfterTest(true); @@ -85,7 +85,7 @@ class secret_manager_test extends \advanced_testcase { * @covers ::get_record * @covers ::delete_records */ - public function test_add_secret_to_db() { + public function test_add_secret_to_db(): void { global $DB, $USER; $this->resetAfterTest(true); @@ -122,7 +122,7 @@ class secret_manager_test extends \advanced_testcase { * @covers ::validate_secret * @covers ::create_secret */ - public function test_validate_secret() { + public function test_validate_secret(): void { global $DB; // Test adding a code and getting it returned, then validated. @@ -182,7 +182,7 @@ class secret_manager_test extends \advanced_testcase { * @covers ::create_secret * @covers ::revoke_secret */ - public function test_revoke_secret() { + public function test_revoke_secret(): void { global $DB, $SESSION; $this->resetAfterTest(true); @@ -213,7 +213,7 @@ class secret_manager_test extends \advanced_testcase { * @covers ::create_secret * @covers ::revoke_secret */ - public function test_has_active_secret() { + public function test_has_active_secret(): void { global $DB; $this->resetAfterTest(true); diff --git a/admin/tool/mobile/tests/api_test.php b/admin/tool/mobile/tests/api_test.php index e778a278612..17ab1361aec 100644 --- a/admin/tool/mobile/tests/api_test.php +++ b/admin/tool/mobile/tests/api_test.php @@ -35,7 +35,7 @@ class api_test extends \externallib_advanced_testcase { /** * Test get_autologin_key. */ - public function test_get_autologin_key() { + public function test_get_autologin_key(): void { global $USER, $DB; $this->resetAfterTest(true); @@ -57,7 +57,7 @@ class api_test extends \externallib_advanced_testcase { /** * Test get_potential_config_issues. */ - public function test_get_potential_config_issues() { + public function test_get_potential_config_issues(): void { global $CFG; $this->resetAfterTest(true); @@ -84,7 +84,7 @@ class api_test extends \externallib_advanced_testcase { /** * Test pre_processor_message_send callback. */ - public function test_pre_processor_message_send_callback() { + public function test_pre_processor_message_send_callback(): void { global $DB, $CFG; $this->preventResetByRollback(); diff --git a/admin/tool/mobile/tests/externallib_test.php b/admin/tool/mobile/tests/externallib_test.php index a0ce7027c3f..a56bd376b03 100644 --- a/admin/tool/mobile/tests/externallib_test.php +++ b/admin/tool/mobile/tests/externallib_test.php @@ -41,7 +41,7 @@ class externallib_test extends externallib_advanced_testcase { * Test get_plugins_supporting_mobile. * This is a very basic test because currently there aren't plugins supporting Mobile in core. */ - public function test_get_plugins_supporting_mobile() { + public function test_get_plugins_supporting_mobile(): void { $result = external::get_plugins_supporting_mobile(); $result = external_api::clean_returnvalue(external::get_plugins_supporting_mobile_returns(), $result); $this->assertCount(0, $result['warnings']); @@ -49,7 +49,7 @@ class externallib_test extends externallib_advanced_testcase { $this->assertTrue(is_array($result['plugins'])); } - public function test_get_public_config() { + public function test_get_public_config(): void { global $CFG, $SITE, $OUTPUT; $this->resetAfterTest(true); @@ -305,7 +305,7 @@ class externallib_test extends externallib_advanced_testcase { /* * Test get_autologin_key. */ - public function test_get_autologin_key() { + public function test_get_autologin_key(): void { global $DB, $CFG, $USER; $this->resetAfterTest(true); @@ -349,7 +349,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_autologin_key missing ws. */ - public function test_get_autologin_key_missing_ws() { + public function test_get_autologin_key_missing_ws(): void { global $CFG; $this->resetAfterTest(true); @@ -370,7 +370,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_autologin_key missing https. */ - public function test_get_autologin_key_missing_https() { + public function test_get_autologin_key_missing_https(): void { global $CFG; // Fake the app. @@ -391,7 +391,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_autologin_key missing admin. */ - public function test_get_autologin_key_missing_admin() { + public function test_get_autologin_key_missing_admin(): void { global $CFG; $this->resetAfterTest(true); @@ -409,7 +409,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_autologin_key locked. */ - public function test_get_autologin_key_missing_locked() { + public function test_get_autologin_key_missing_locked(): void { global $CFG, $DB, $USER; $this->resetAfterTest(true); @@ -452,7 +452,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_autologin_key missing app_request. */ - public function test_get_autologin_key_missing_app_request() { + public function test_get_autologin_key_missing_app_request(): void { global $CFG; $this->resetAfterTest(true); @@ -466,7 +466,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_content. */ - public function test_get_content() { + public function test_get_content(): void { $paramval = 16; $result = external::get_content('tool_mobile', 'test_view', array(array('name' => 'param1', 'value' => $paramval))); @@ -489,7 +489,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_content disabled. */ - public function test_get_content_disabled() { + public function test_get_content_disabled(): void { $paramval = 16; $result = external::get_content('tool_mobile', 'test_view_disabled', @@ -501,7 +501,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_content non existent function in valid component. */ - public function test_get_content_non_existent_function() { + public function test_get_content_non_existent_function(): void { $this->expectException('coding_exception'); $result = external::get_content('tool_mobile', 'test_blahblah'); @@ -510,7 +510,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_content incorrect component. */ - public function test_get_content_invalid_component() { + public function test_get_content_invalid_component(): void { $this->expectException('moodle_exception'); $result = external::get_content('tool_mobile\hack', 'test_view'); @@ -519,13 +519,13 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_content non existent component. */ - public function test_get_content_non_existent_component() { + public function test_get_content_non_existent_component(): void { $this->expectException('moodle_exception'); $result = external::get_content('tool_blahblahblah', 'test_view'); } - public function test_call_external_functions() { + public function test_call_external_functions(): void { global $SESSION; $this->resetAfterTest(true); @@ -670,7 +670,7 @@ class externallib_test extends externallib_advanced_testcase { /* * Test get_tokens_for_qr_login. */ - public function test_get_tokens_for_qr_login() { + public function test_get_tokens_for_qr_login(): void { global $DB, $CFG, $USER; $this->resetAfterTest(true); @@ -706,7 +706,7 @@ class externallib_test extends externallib_advanced_testcase { /* * Test get_tokens_for_qr_login ignore ip check. */ - public function test_get_tokens_for_qr_login_ignore_ip_check() { + public function test_get_tokens_for_qr_login_ignore_ip_check(): void { global $DB, $CFG, $USER; $this->resetAfterTest(true); @@ -745,7 +745,7 @@ class externallib_test extends externallib_advanced_testcase { /* * Test get_tokens_for_qr_login ip check fails. */ - public function test_get_tokens_for_qr_login_ip_check_mismatch() { + public function test_get_tokens_for_qr_login_ip_check_mismatch(): void { global $DB, $CFG, $USER; $this->resetAfterTest(true); @@ -776,7 +776,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_tokens_for_qr_login missing QR code enabled. */ - public function test_get_tokens_for_qr_login_missing_enableqr() { + public function test_get_tokens_for_qr_login_missing_enableqr(): void { global $CFG, $USER; $this->resetAfterTest(true); $this->setAdminUser(); @@ -790,7 +790,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_tokens_for_qr_login missing ws. */ - public function test_get_tokens_for_qr_login_missing_ws() { + public function test_get_tokens_for_qr_login_missing_ws(): void { global $CFG; $this->resetAfterTest(true); @@ -814,7 +814,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_tokens_for_qr_login missing https. */ - public function test_get_tokens_for_qr_login_missing_https() { + public function test_get_tokens_for_qr_login_missing_https(): void { global $CFG, $USER; // Fake the app. @@ -835,7 +835,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_tokens_for_qr_login missing admin. */ - public function test_get_tokens_for_qr_login_missing_admin() { + public function test_get_tokens_for_qr_login_missing_admin(): void { global $CFG, $USER; $this->resetAfterTest(true); @@ -853,7 +853,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_tokens_for_qr_login missing app_request. */ - public function test_get_tokens_for_qr_login_missing_app_request() { + public function test_get_tokens_for_qr_login_missing_app_request(): void { global $CFG, $USER; $this->resetAfterTest(true); @@ -867,7 +867,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test validate subscription key. */ - public function test_validate_subscription_key_valid() { + public function test_validate_subscription_key_valid(): void { $this->resetAfterTest(true); $sitesubscriptionkey = ['validuntil' => time() + MINSECS, 'key' => complex_random_string(32)]; @@ -882,7 +882,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test validate subscription key invalid first and then a valid one. */ - public function test_validate_subscription_key_invalid_key_first() { + public function test_validate_subscription_key_invalid_key_first(): void { $this->resetAfterTest(true); $sitesubscriptionkey = ['validuntil' => time() + MINSECS, 'key' => complex_random_string(32)]; @@ -903,7 +903,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test validate subscription key invalid. */ - public function test_validate_subscription_key_invalid_key() { + public function test_validate_subscription_key_invalid_key(): void { $this->resetAfterTest(true); $result = external::validate_subscription_key('fakekey'); @@ -915,7 +915,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test validate subscription key invalid. */ - public function test_validate_subscription_key_outdated() { + public function test_validate_subscription_key_outdated(): void { $this->resetAfterTest(true); $sitesubscriptionkey = ['validuntil' => time() - MINSECS, 'key' => complex_random_string(32)]; diff --git a/admin/tool/mobile/tests/privacy/provider_test.php b/admin/tool/mobile/tests/privacy/provider_test.php index d85ee43cf91..eca409f1166 100644 --- a/admin/tool/mobile/tests/privacy/provider_test.php +++ b/admin/tool/mobile/tests/privacy/provider_test.php @@ -50,7 +50,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { * Test to check export_user_preferences. * returns user preferences data. */ - public function test_export_user_preferences() { + public function test_export_user_preferences(): void { $user = $this->getDataGenerator()->create_user(); $expectedtime = time(); set_user_preference('tool_mobile_autologin_request_last', time(), $user); @@ -66,7 +66,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test getting the context for the user ID related to this plugin. */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { // Create user and Mobile user keys. $user = $this->getDataGenerator()->create_user(); $context = \context_user::instance($user->id); @@ -78,7 +78,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test getting the users for a context related to this plugin. */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { $component = 'tool_mobile'; // Create users and Mobile user keys. @@ -103,7 +103,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test that data is exported correctly for this plugin. */ - public function test_export_user_data() { + public function test_export_user_data(): void { global $DB; // Create user and Mobile user keys. $user = $this->getDataGenerator()->create_user(); @@ -124,7 +124,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::delete_data_for_all_users_in_context(). */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; // Create user and Mobile user keys. $user = $this->getDataGenerator()->create_user(); @@ -144,7 +144,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::delete_data_for_user(). */ - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; // Create user and Mobile user keys. $user = $this->getDataGenerator()->create_user(); @@ -166,7 +166,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::test_delete_data_for_users(). */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { global $DB; $component = 'tool_mobile'; diff --git a/admin/tool/monitor/tests/event/events_test.php b/admin/tool/monitor/tests/event/events_test.php index 8fc0c503d14..ffaf8a4f1b0 100644 --- a/admin/tool/monitor/tests/event/events_test.php +++ b/admin/tool/monitor/tests/event/events_test.php @@ -41,7 +41,7 @@ class events_test extends \advanced_testcase { /** * Test the rule created event. */ - public function test_rule_created() { + public function test_rule_created(): void { // Create the items we need to create a rule. $course = $this->getDataGenerator()->create_course(); $user = $this->getDataGenerator()->create_user(); @@ -90,7 +90,7 @@ class events_test extends \advanced_testcase { /** * Test the rule updated event. */ - public function test_rule_updated() { + public function test_rule_updated(): void { // Create the items we need. $monitorgenerator = $this->getDataGenerator()->get_plugin_generator('tool_monitor'); $course = $this->getDataGenerator()->create_course(); @@ -136,7 +136,7 @@ class events_test extends \advanced_testcase { /** * Test the rule deleted event. */ - public function test_rule_deleted() { + public function test_rule_deleted(): void { // Create the items we need. $monitorgenerator = $this->getDataGenerator()->get_plugin_generator('tool_monitor'); $course = $this->getDataGenerator()->create_course(); @@ -179,7 +179,7 @@ class events_test extends \advanced_testcase { /** * Test the subscription created event. */ - public function test_subscription_created() { + public function test_subscription_created(): void { // Create the items we need to test this. $user = $this->getDataGenerator()->create_user(); $course = $this->getDataGenerator()->create_course(); @@ -216,7 +216,7 @@ class events_test extends \advanced_testcase { /** * Test the subscription deleted event. */ - public function test_subscription_deleted() { + public function test_subscription_deleted(): void { // Create the items we need to test this. $user = $this->getDataGenerator()->create_user(); $course = $this->getDataGenerator()->create_course(); @@ -299,7 +299,7 @@ class events_test extends \advanced_testcase { /** * Test the subscription criteria met event. */ - public function test_subscription_criteria_met() { + public function test_subscription_criteria_met(): void { // Create the items we need to test this. $user = $this->getDataGenerator()->create_user(); $course = $this->getDataGenerator()->create_course(); diff --git a/admin/tool/monitor/tests/eventobservers_test.php b/admin/tool/monitor/tests/eventobservers_test.php index 323d842854a..d1581d17d8e 100644 --- a/admin/tool/monitor/tests/eventobservers_test.php +++ b/admin/tool/monitor/tests/eventobservers_test.php @@ -42,7 +42,7 @@ class eventobservers_test extends \advanced_testcase { /** * Test observer for course delete event. */ - public function test_course_deleted() { + public function test_course_deleted(): void { global $DB; $this->setAdminUser(); @@ -117,7 +117,7 @@ class eventobservers_test extends \advanced_testcase { /** * This tests if writing of the events to the table tool_monitor_events is working fine. */ - public function test_flush() { + public function test_flush(): void { global $DB; $this->resetAfterTest(); @@ -215,7 +215,7 @@ class eventobservers_test extends \advanced_testcase { /** * Test the notification sending features. */ - public function test_process_event() { + public function test_process_event(): void { global $DB, $USER; @@ -352,7 +352,7 @@ class eventobservers_test extends \advanced_testcase { /** * Test that same events are not used twice to calculate conditions for a single subscription. */ - public function test_multiple_notification_not_sent() { + public function test_multiple_notification_not_sent(): void { global $USER; $this->resetAfterTest(); @@ -440,7 +440,7 @@ class eventobservers_test extends \advanced_testcase { /** * Tests for replace_placeholders method. */ - public function test_replace_placeholders() { + public function test_replace_placeholders(): void { global $USER; $this->resetAfterTest(); @@ -525,7 +525,7 @@ class eventobservers_test extends \advanced_testcase { /** * Test observer for user delete event. */ - public function test_user_deleted() { + public function test_user_deleted(): void { global $DB; $this->setAdminUser(); @@ -580,7 +580,7 @@ class eventobservers_test extends \advanced_testcase { /** * Test observer for course module delete event. */ - public function test_course_module_deleted() { + public function test_course_module_deleted(): void { global $DB; $this->setAdminUser(); diff --git a/admin/tool/monitor/tests/generator_test.php b/admin/tool/monitor/tests/generator_test.php index d17694b1d40..235f6b79984 100644 --- a/admin/tool/monitor/tests/generator_test.php +++ b/admin/tool/monitor/tests/generator_test.php @@ -38,7 +38,7 @@ class generator_test extends \advanced_testcase { /** * Test create_rule data generator. */ - public function test_create_rule() { + public function test_create_rule(): void { $this->setAdminUser(); $this->resetAfterTest(true); $course = $this->getDataGenerator()->create_course(); @@ -59,7 +59,7 @@ class generator_test extends \advanced_testcase { /** * Test create_subscription data generator. */ - public function test_create_subscription() { + public function test_create_subscription(): void { $this->setAdminUser(); $this->resetAfterTest(true); @@ -88,7 +88,7 @@ class generator_test extends \advanced_testcase { /** * Test create_event data generator. */ - public function test_create_event_entries() { + public function test_create_event_entries(): void { $this->setAdminUser(); $this->resetAfterTest(true); $context = \context_system::instance(); @@ -106,7 +106,7 @@ class generator_test extends \advanced_testcase { /** * Test create_history data generator. */ - public function test_create_history() { + public function test_create_history(): void { $this->setAdminUser(); $this->resetAfterTest(true); $user = $this->getDataGenerator()->create_user(); diff --git a/admin/tool/monitor/tests/privacy/provider_test.php b/admin/tool/monitor/tests/privacy/provider_test.php index 5d75717a3dc..957b5b17cd2 100644 --- a/admin/tool/monitor/tests/privacy/provider_test.php +++ b/admin/tool/monitor/tests/privacy/provider_test.php @@ -84,7 +84,7 @@ class provider_test extends provider_testcase { /** * Test that a collection with data is returned when calling this function. */ - public function test_get_metadata() { + public function test_get_metadata(): void { $collection = new \core_privacy\local\metadata\collection('tool_monitor'); $collection = provider::get_metadata($collection); $this->assertNotEmpty($collection); @@ -93,7 +93,7 @@ class provider_test extends provider_testcase { /** * Check that a user context is returned if there is any user data for this user. */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { $user = $this->getDataGenerator()->create_user(); $user2 = $this->getDataGenerator()->create_user(); $usercontext = \context_user::instance($user->id); @@ -134,7 +134,7 @@ class provider_test extends provider_testcase { /** * Check that the correct userlist is returned if there is any user data for this context. */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { $component = 'tool_monitor'; $user = $this->getDataGenerator()->create_user(); $user2 = $this->getDataGenerator()->create_user(); @@ -183,7 +183,7 @@ class provider_test extends provider_testcase { /** * Test that user data is exported correctly. */ - public function test_export_user_data() { + public function test_export_user_data(): void { $user = $this->getDataGenerator()->create_user(); $usercontext = \context_user::instance($user->id); $monitorgenerator = $this->getDataGenerator()->get_plugin_generator('tool_monitor'); @@ -218,7 +218,7 @@ class provider_test extends provider_testcase { /** * Test deleting all user data for a specific context. */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; $user = $this->getDataGenerator()->create_user(); @@ -285,7 +285,7 @@ class provider_test extends provider_testcase { /** * This should work identical to the above test. */ - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; $user = $this->getDataGenerator()->create_user(); @@ -342,7 +342,7 @@ class provider_test extends provider_testcase { /** * Test deleting user data for an approved userlist in a context. */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { global $DB; $component = 'tool_monitor'; diff --git a/admin/tool/monitor/tests/rule_manager_test.php b/admin/tool/monitor/tests/rule_manager_test.php index f29f2d9b886..9804c834fb7 100644 --- a/admin/tool/monitor/tests/rule_manager_test.php +++ b/admin/tool/monitor/tests/rule_manager_test.php @@ -37,7 +37,7 @@ class rule_manager_test extends \advanced_testcase { /** * Test add_rule method. */ - public function test_add_rule() { + public function test_add_rule(): void { $this->setAdminUser(); $this->resetAfterTest(true); @@ -69,7 +69,7 @@ class rule_manager_test extends \advanced_testcase { /** * Test get_rule method. */ - public function test_get_rule() { + public function test_get_rule(): void { $this->setAdminUser(); $this->resetAfterTest(true); @@ -83,7 +83,7 @@ class rule_manager_test extends \advanced_testcase { /** * Test update_rule method. */ - public function test_update_rule() { + public function test_update_rule(): void { $this->setAdminUser(); $this->resetAfterTest(true); @@ -102,7 +102,7 @@ class rule_manager_test extends \advanced_testcase { /** * Test get_rules_by_courseid method. */ - public function test_get_rules_by_courseid() { + public function test_get_rules_by_courseid(): void { $this->setAdminUser(); $this->resetAfterTest(true); @@ -133,7 +133,7 @@ class rule_manager_test extends \advanced_testcase { /** * Test get_rules_by_plugin method. */ - public function test_get_rules_by_plugin() { + public function test_get_rules_by_plugin(): void { $this->setAdminUser(); $this->resetAfterTest(true); @@ -160,7 +160,7 @@ class rule_manager_test extends \advanced_testcase { /** * Test get_rules_by_event method. */ - public function test_get_rules_by_event() { + public function test_get_rules_by_event(): void { $this->setAdminUser(); $this->resetAfterTest(true); diff --git a/admin/tool/monitor/tests/subscription_manager_test.php b/admin/tool/monitor/tests/subscription_manager_test.php index 39975523f5e..7320a5a6304 100644 --- a/admin/tool/monitor/tests/subscription_manager_test.php +++ b/admin/tool/monitor/tests/subscription_manager_test.php @@ -29,7 +29,7 @@ class subscription_manager_test extends \advanced_testcase { /** * Test count_rule_subscriptions method. */ - public function test_count_rule_subscriptions() { + public function test_count_rule_subscriptions(): void { $this->setAdminUser(); $this->resetAfterTest(true); diff --git a/admin/tool/monitor/tests/subscription_test.php b/admin/tool/monitor/tests/subscription_test.php index 53e5e17188b..552e8b64077 100644 --- a/admin/tool/monitor/tests/subscription_test.php +++ b/admin/tool/monitor/tests/subscription_test.php @@ -52,7 +52,7 @@ class subscription_test extends \advanced_testcase { /** * Test for the magic __isset method. */ - public function test_magic_isset() { + public function test_magic_isset(): void { $this->assertEquals(true, isset($this->subscription->name)); $this->assertEquals(true, isset($this->subscription->courseid)); $this->assertEquals(false, isset($this->subscription->ruleid)); @@ -61,7 +61,7 @@ class subscription_test extends \advanced_testcase { /** * Test for the magic __get method. */ - public function test_magic_get() { + public function test_magic_get(): void { $this->assertEquals(20, $this->subscription->courseid); $this->expectException(\coding_exception::class); $this->subscription->ruleid; diff --git a/admin/tool/monitor/tests/task_check_subscriptions_test.php b/admin/tool/monitor/tests/task_check_subscriptions_test.php index 85d252e83f9..3944dc4f089 100644 --- a/admin/tool/monitor/tests/task_check_subscriptions_test.php +++ b/admin/tool/monitor/tests/task_check_subscriptions_test.php @@ -80,7 +80,7 @@ class task_check_subscriptions_test extends \advanced_testcase { /** * Test to confirm the task is named correctly. */ - public function test_task_name() { + public function test_task_name(): void { $task = new \tool_monitor\task\check_subscriptions(); $this->assertEquals(get_string('taskchecksubscriptions', 'tool_monitor'), $task->get_name()); } @@ -88,7 +88,7 @@ class task_check_subscriptions_test extends \advanced_testcase { /** * Test to confirm that site level subscriptions are activated and deactivated according to system capabilities. */ - public function test_site_level_subscription() { + public function test_site_level_subscription(): void { // Create a site level subscription. $monitorgenerator = $this->getDataGenerator()->get_plugin_generator('tool_monitor'); $sub = new \stdClass(); @@ -119,7 +119,7 @@ class task_check_subscriptions_test extends \advanced_testcase { /** * Test to confirm that if the module is disabled, no changes are made to active subscriptions. */ - public function test_module_disabled() { + public function test_module_disabled(): void { set_config('enablemonitor', 0, 'tool_monitor'); // Subscription should be active to start with. @@ -137,7 +137,7 @@ class task_check_subscriptions_test extends \advanced_testcase { /** * Test to confirm an active, valid subscription stays active once the scheduled task is run. */ - public function test_active_unaffected() { + public function test_active_unaffected(): void { // Enrol the user as a teacher. This role should have the required capability. $this->getDataGenerator()->enrol_user($this->user->id, $this->course->id, $this->teacherrole->id); @@ -156,7 +156,7 @@ class task_check_subscriptions_test extends \advanced_testcase { /** * Test to confirm that a subscription for a user without an enrolment to the course is made inactive. */ - public function test_course_enrolment() { + public function test_course_enrolment(): void { // Subscription should be active until deactivated by the scheduled task. Remember, by default the test setup // doesn't enrol the user, so the first run of the task should deactivate it. $this->assertEquals(true, \tool_monitor\subscription_manager::subscription_is_active($this->subscription)); @@ -184,7 +184,7 @@ class task_check_subscriptions_test extends \advanced_testcase { /** * Test to confirm that subscriptions for enrolled users without the required capability are made inactive. */ - public function test_enrolled_user_with_no_capability() { + public function test_enrolled_user_with_no_capability(): void { // Enrol the user. By default, students won't have the required capability. $this->getDataGenerator()->enrol_user($this->user->id, $this->course->id, $this->studentrole->id); @@ -203,7 +203,7 @@ class task_check_subscriptions_test extends \advanced_testcase { /** * Test to confirm that subscriptions for users who fail can_access_course(), are deactivated. */ - public function test_can_access_course() { + public function test_can_access_course(): void { // Enrol the user as a teacher. This role should have the required capability. $this->getDataGenerator()->enrol_user($this->user->id, $this->course->id, $this->teacherrole->id); @@ -229,7 +229,7 @@ class task_check_subscriptions_test extends \advanced_testcase { /** * Test to confirm that subscriptions for enrolled users who don't have CM access, are deactivated. */ - public function test_cm_access() { + public function test_cm_access(): void { // Enrol the user as a student but grant to ability to subscribe. Students cannot view hidden activities. $context = \context_course::instance($this->course->id); assign_capability('tool/monitor:subscribe', CAP_ALLOW, $this->studentrole->id, $context); @@ -284,7 +284,7 @@ class task_check_subscriptions_test extends \advanced_testcase { /** * Test to confirm that long term inactive subscriptions are removed entirely. */ - public function test_stale_subscription_removal() { + public function test_stale_subscription_removal(): void { global $DB; // Manually set the inactivedate to 1 day older than the limit allowed. $daysold = 1 + \tool_monitor\subscription_manager::INACTIVE_SUBSCRIPTION_LIFESPAN_IN_DAYS; @@ -307,7 +307,7 @@ class task_check_subscriptions_test extends \advanced_testcase { /** * Test to confirm that subscriptions for a partially set up user are deactivated. */ - public function test_user_not_fully_set_up() { + public function test_user_not_fully_set_up(): void { global $DB; // Enrol the user as a teacher. @@ -331,7 +331,7 @@ class task_check_subscriptions_test extends \advanced_testcase { /** * Test to confirm that a suspended user's subscriptions are deactivated properly. */ - public function test_suspended_user() { + public function test_suspended_user(): void { global $DB; // Enrol the user as a teacher. This role should have the required capability. diff --git a/admin/tool/monitor/tests/task_clean_events_test.php b/admin/tool/monitor/tests/task_clean_events_test.php index 94c8c3c48bb..e801ef37361 100644 --- a/admin/tool/monitor/tests/task_clean_events_test.php +++ b/admin/tool/monitor/tests/task_clean_events_test.php @@ -37,7 +37,7 @@ class task_clean_events_test extends \advanced_testcase { /** * Tests the cleaning up of events. */ - public function test_clean_events() { + public function test_clean_events(): void { global $DB; // Create the necessary items for testing. diff --git a/admin/tool/moodlenet/tests/import_backup_helper_test.php b/admin/tool/moodlenet/tests/import_backup_helper_test.php index a6d47020261..f161496fcc7 100644 --- a/admin/tool/moodlenet/tests/import_backup_helper_test.php +++ b/admin/tool/moodlenet/tests/import_backup_helper_test.php @@ -29,7 +29,7 @@ class import_backup_helper_test extends \advanced_testcase { /** * Test that the first available context with the capability to upload backup files is returned. */ - public function test_get_context_for_user() { + public function test_get_context_for_user(): void { global $DB; $this->resetAfterTest(); diff --git a/admin/tool/moodlenet/tests/lib_test.php b/admin/tool/moodlenet/tests/lib_test.php index 1ec8e7466e4..85dd5818714 100644 --- a/admin/tool/moodlenet/tests/lib_test.php +++ b/admin/tool/moodlenet/tests/lib_test.php @@ -42,7 +42,7 @@ class lib_test extends \advanced_testcase { * @param int $section * @param string $expected */ - public function test_generate_mnet_endpoint($profileurl, $course, $section, $expected) { + public function test_generate_mnet_endpoint($profileurl, $course, $section, $expected): void { $endpoint = generate_mnet_endpoint($profileurl, $course, $section); $this->assertEquals($expected, $endpoint); } diff --git a/admin/tool/moodlenet/tests/local/import_handler_info_test.php b/admin/tool/moodlenet/tests/local/import_handler_info_test.php index 8535be29a33..df6d9b59f9e 100644 --- a/admin/tool/moodlenet/tests/local/import_handler_info_test.php +++ b/admin/tool/moodlenet/tests/local/import_handler_info_test.php @@ -38,7 +38,7 @@ class import_handler_info_test extends \advanced_testcase { * @param string $description description of the mod. * @param bool $expectexception whether we expect an exception during init or not. */ - public function test_initialisation($modname, $description, $expectexception) { + public function test_initialisation($modname, $description, $expectexception): void { $this->resetAfterTest(); // Skip those cases we cannot init. if ($expectexception) { diff --git a/admin/tool/moodlenet/tests/local/import_handler_registry_test.php b/admin/tool/moodlenet/tests/local/import_handler_registry_test.php index 0c679515f03..2b5a155ced7 100644 --- a/admin/tool/moodlenet/tests/local/import_handler_registry_test.php +++ b/admin/tool/moodlenet/tests/local/import_handler_registry_test.php @@ -36,7 +36,7 @@ class import_handler_registry_test extends \advanced_testcase { /** * Test confirming the behaviour of get_resource_handlers_for_strategy with different params. */ - public function test_get_resource_handlers_for_strategy() { + public function test_get_resource_handlers_for_strategy(): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -61,7 +61,7 @@ class import_handler_registry_test extends \advanced_testcase { /** * Test confirming that the results are scoped to the provided user. */ - public function test_get_resource_handlers_for_strategy_user_scoping() { + public function test_get_resource_handlers_for_strategy_user_scoping(): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -86,7 +86,7 @@ class import_handler_registry_test extends \advanced_testcase { /** * Test confirming that we can find a unique handler based on the module and strategy name. */ - public function test_get_resource_handler_for_module_and_strategy() { + public function test_get_resource_handler_for_module_and_strategy(): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); diff --git a/admin/tool/moodlenet/tests/local/import_info_test.php b/admin/tool/moodlenet/tests/local/import_info_test.php index 754fbbce8f1..d54167155ac 100644 --- a/admin/tool/moodlenet/tests/local/import_info_test.php +++ b/admin/tool/moodlenet/tests/local/import_info_test.php @@ -52,7 +52,7 @@ class import_info_test extends \advanced_testcase { /** * Test for creation and getters. */ - public function test_getters() { + public function test_getters(): void { $this->resetAfterTest(); [$user, $resource, $importinfo] = $this->create_test_info(); @@ -64,7 +64,7 @@ class import_info_test extends \advanced_testcase { /** * Test for setters. */ - public function test_set_config() { + public function test_set_config(): void { $this->resetAfterTest(); [$user, $resource, $importinfo] = $this->create_test_info(); @@ -79,7 +79,7 @@ class import_info_test extends \advanced_testcase { /** * Verify the object can be stored and loaded. */ - public function test_persistence() { + public function test_persistence(): void { $this->resetAfterTest(); [$user, $resource, $importinfo] = $this->create_test_info(); diff --git a/admin/tool/moodlenet/tests/local/import_processor_test.php b/admin/tool/moodlenet/tests/local/import_processor_test.php index 26f73f668b1..51cb659260b 100644 --- a/admin/tool/moodlenet/tests/local/import_processor_test.php +++ b/admin/tool/moodlenet/tests/local/import_processor_test.php @@ -36,7 +36,7 @@ class import_processor_test extends \advanced_testcase { /** * An integration test, this confirms the ability to construct an import processor and run the import for the current user. */ - public function test_process_valid_resource() { + public function test_process_valid_resource(): void { $this->resetAfterTest(); // Set up a user as a teacher in a course. @@ -83,7 +83,7 @@ class import_processor_test extends \advanced_testcase { /** * Test confirming that an exception is thrown when trying to process a resource which does not exist. */ - public function test_process_invalid_resource() { + public function test_process_invalid_resource(): void { $this->resetAfterTest(); // Set up a user as a teacher in a course. @@ -115,7 +115,7 @@ class import_processor_test extends \advanced_testcase { /** * Test confirming that imports can be completed using alternative import strategies. */ - public function test_process_alternative_import_strategies() { + public function test_process_alternative_import_strategies(): void { $this->resetAfterTest(); // Set up a user as a teacher in a course. diff --git a/admin/tool/moodlenet/tests/local/remote_resource_test.php b/admin/tool/moodlenet/tests/local/remote_resource_test.php index f3195fb7a9c..53b30bfe0f8 100644 --- a/admin/tool/moodlenet/tests/local/remote_resource_test.php +++ b/admin/tool/moodlenet/tests/local/remote_resource_test.php @@ -37,7 +37,7 @@ class remote_resource_test extends \advanced_testcase { * @param string $metadata the resource metadata like name, description, etc. * @param string $expectedextension the extension we expect to find when querying the remote resource. */ - public function test_getters($url, $metadata, $expectedextension) { + public function test_getters($url, $metadata, $expectedextension): void { $this->resetAfterTest(); $remoteres = new remote_resource(new \curl(), new url($url), $metadata); @@ -77,7 +77,7 @@ class remote_resource_test extends \advanced_testcase { /** * Test confirming the network based operations of a remote_resource. */ - public function test_network_features() { + public function test_network_features(): void { $url = $this->getExternalTestFileUrl('/test.html'); $nonexistenturl = $this->getExternalTestFileUrl('/test.htmlzz'); diff --git a/admin/tool/moodlenet/tests/local/url_test.php b/admin/tool/moodlenet/tests/local/url_test.php index f48c0701140..a948732c79f 100644 --- a/admin/tool/moodlenet/tests/local/url_test.php +++ b/admin/tool/moodlenet/tests/local/url_test.php @@ -37,7 +37,7 @@ class url_test extends \advanced_testcase { * @param string $path the expected path component of the URL. * @param bool $exception whether or not an exception is expected during construction. */ - public function test_parsing($urlstring, $host, $path, $exception) { + public function test_parsing($urlstring, $host, $path, $exception): void { if ($exception) { $this->expectException(\coding_exception::class); $url = new url($urlstring); diff --git a/admin/tool/moodlenet/tests/profile_manager_test.php b/admin/tool/moodlenet/tests/profile_manager_test.php index 7d6de581cf1..76896d73a26 100644 --- a/admin/tool/moodlenet/tests/profile_manager_test.php +++ b/admin/tool/moodlenet/tests/profile_manager_test.php @@ -29,14 +29,14 @@ class profile_manager_test extends \advanced_testcase { /** * Test that on this site we use the user table to hold moodle net profile information. */ - public function test_official_profile_exists() { + public function test_official_profile_exists(): void { $this->assertTrue(\tool_moodlenet\profile_manager::official_profile_exists()); } /** * Test a null is returned when the user's mnet profile field is not set. */ - public function test_get_moodlenet_user_profile_no_profile_set() { + public function test_get_moodlenet_user_profile_no_profile_set(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); @@ -47,7 +47,7 @@ class profile_manager_test extends \advanced_testcase { /** * Test a null is returned when the user's mnet profile field is not set. */ - public function test_moodlenet_user_profile_creation_no_profile_set() { + public function test_moodlenet_user_profile_creation_no_profile_set(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); @@ -59,7 +59,7 @@ class profile_manager_test extends \advanced_testcase { /** * Test the return of a moodle net profile. */ - public function test_get_moodlenet_user_profile() { + public function test_get_moodlenet_user_profile(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(['moodlenetprofile' => '@matt@hq.mnet']); @@ -70,7 +70,7 @@ class profile_manager_test extends \advanced_testcase { /** * Test the creation of a user profile category. */ - public function test_create_user_profile_category() { + public function test_create_user_profile_category(): void { global $DB; $this->resetAfterTest(); @@ -95,7 +95,7 @@ class profile_manager_test extends \advanced_testcase { /** * Test the creating of the custom user profile field to hold the moodle net profile. */ - public function test_create_user_profile_text_field() { + public function test_create_user_profile_text_field(): void { global $DB; $this->resetAfterTest(); @@ -120,7 +120,7 @@ class profile_manager_test extends \advanced_testcase { /** * Test that the user moodlenet profile is saved. */ - public function test_save_moodlenet_user_profile() { + public function test_save_moodlenet_user_profile(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); diff --git a/admin/tool/policy/tests/api_test.php b/admin/tool/policy/tests/api_test.php index 5177eb284a5..7a7605a23e6 100644 --- a/admin/tool/policy/tests/api_test.php +++ b/admin/tool/policy/tests/api_test.php @@ -31,7 +31,7 @@ class api_test extends \advanced_testcase { /** * Test the common operations with a policy document and its versions. */ - public function test_policy_document_life_cycle() { + public function test_policy_document_life_cycle(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -134,7 +134,7 @@ class api_test extends \advanced_testcase { /** * Test changing the sort order of the policy documents. */ - public function test_policy_sortorder() { + public function test_policy_sortorder(): void { global $DB; $this->resetAfterTest(); $this->setAdminUser(); @@ -235,7 +235,7 @@ class api_test extends \advanced_testcase { /** * Test behaviour of the {@link api::can_user_view_policy_version()} method. */ - public function test_can_user_view_policy_version() { + public function test_can_user_view_policy_version(): void { global $CFG; $this->resetAfterTest(); $this->setAdminUser(); @@ -313,7 +313,7 @@ class api_test extends \advanced_testcase { /** * Test behaviour of the {@link api::can_accept_policies()} method. */ - public function test_can_accept_policies() { + public function test_can_accept_policies(): void { global $CFG; $this->resetAfterTest(); @@ -389,7 +389,7 @@ class api_test extends \advanced_testcase { /** * Test behaviour of the {@link api::can_decline_policies()} method. */ - public function test_can_decline_policies() { + public function test_can_decline_policies(): void { global $CFG; $this->resetAfterTest(); @@ -471,7 +471,7 @@ class api_test extends \advanced_testcase { /** * Test behaviour of the {@link api::can_revoke_policies()} method. */ - public function test_can_revoke_policies() { + public function test_can_revoke_policies(): void { global $CFG; $this->resetAfterTest(); @@ -553,7 +553,7 @@ class api_test extends \advanced_testcase { /** * Test {@link api::fix_revision_values()} behaviour. */ - public function test_fix_revision_values() { + public function test_fix_revision_values(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -578,7 +578,7 @@ class api_test extends \advanced_testcase { /** * Test that accepting policy updates 'policyagreed' */ - public function test_accept_policies() { + public function test_accept_policies(): void { global $DB, $USER; $this->resetAfterTest(); $this->setAdminUser(); @@ -634,7 +634,7 @@ class api_test extends \advanced_testcase { /** * Test that activating a new policy resets everybody's policyagreed flag in the database. */ - public function test_reset_policyagreed() { + public function test_reset_policyagreed(): void { global $DB; $this->resetAfterTest(); $this->setAdminUser(); @@ -678,7 +678,7 @@ class api_test extends \advanced_testcase { /** * Test behaviour of the {@link api::get_user_minors()} method. */ - public function test_get_user_minors() { + public function test_get_user_minors(): void { $this->resetAfterTest(); // A mother having two children, each child having own father. @@ -727,7 +727,7 @@ class api_test extends \advanced_testcase { /** * Test behaviour of the {@link api::create_acceptances_user_created()} method. */ - public function test_create_acceptances_user_created() { + public function test_create_acceptances_user_created(): void { global $CFG, $DB; $this->resetAfterTest(); $this->setAdminUser(); @@ -756,7 +756,7 @@ class api_test extends \advanced_testcase { /** * Test that user can login if sitepolicyhandler is set but there are no policies. */ - public function test_login_with_handler_without_policies() { + public function test_login_with_handler_without_policies(): void { global $CFG; $this->resetAfterTest(); @@ -771,7 +771,7 @@ class api_test extends \advanced_testcase { /** * Test the three-state logic of the value returned by {@link api::is_user_version_accepted()}. */ - public function test_is_user_version_accepted() { + public function test_is_user_version_accepted(): void { $preloadedacceptances = [ 4 => (object) [ @@ -794,7 +794,7 @@ class api_test extends \advanced_testcase { /** * Test the functionality of {@link api::get_agreement_optional()}. */ - public function test_get_agreement_optional() { + public function test_get_agreement_optional(): void { global $DB; $this->resetAfterTest(); $this->setAdminUser(); diff --git a/admin/tool/policy/tests/externallib_test.php b/admin/tool/policy/tests/externallib_test.php index b7b029ab9bb..b4142457bbd 100644 --- a/admin/tool/policy/tests/externallib_test.php +++ b/admin/tool/policy/tests/externallib_test.php @@ -99,7 +99,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test for the get_policy_version() function. */ - public function test_get_policy_version() { + public function test_get_policy_version(): void { $this->setUser($this->adult); // View current policy version. @@ -151,7 +151,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test tool_mobile\external callback to site_policy_handler. */ - public function test_get_config_with_site_policy_handler() { + public function test_get_config_with_site_policy_handler(): void { global $CFG; $this->resetAfterTest(true); @@ -173,7 +173,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test for core_privacy\sitepolicy\manager::accept() when site policy handler is set. */ - public function test_agree_site_policy_with_handler() { + public function test_agree_site_policy_with_handler(): void { global $CFG, $DB, $USER; $this->resetAfterTest(true); @@ -210,7 +210,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test for core_privacy\sitepolicy\manager::accept() when site policy handler is set. */ - public function test_checkcanaccept_with_handler() { + public function test_checkcanaccept_with_handler(): void { global $CFG; $this->resetAfterTest(true); @@ -243,7 +243,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test for external function get_user_acceptances(). */ - public function test_external_get_user_acceptances() { + public function test_external_get_user_acceptances(): void { global $CFG; $this->resetAfterTest(true); @@ -320,7 +320,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test for external function set_acceptances_status(). */ - public function test_external_set_acceptances_status() { + public function test_external_set_acceptances_status(): void { global $CFG; $this->resetAfterTest(true); @@ -431,7 +431,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test for external function set_acceptances_status decline mandatory. */ - public function test_external_set_acceptances_status_decline_mandatory() { + public function test_external_set_acceptances_status_decline_mandatory(): void { global $CFG; $this->resetAfterTest(true); diff --git a/admin/tool/policy/tests/privacy/provider_test.php b/admin/tool/policy/tests/privacy/provider_test.php index 3b70138f9c2..1140aff36a8 100644 --- a/admin/tool/policy/tests/privacy/provider_test.php +++ b/admin/tool/policy/tests/privacy/provider_test.php @@ -71,7 +71,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test getting the context for the user ID related to this plugin. */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { global $CFG; // When there are no policies or agreements context list is empty. @@ -106,7 +106,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test getting the user IDs within the context related to this plugin. */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { global $CFG; $component = 'tool_policy'; @@ -185,7 +185,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { $this->assertCount(0, $userlist); } - public function test_export_agreements() { + public function test_export_agreements(): void { global $CFG; $otheruser = $this->getDataGenerator()->create_user(); @@ -246,7 +246,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { $this->assertEquals(strip_tags($policy2->get('content')), strip_tags($datauser->content)); } - public function test_export_agreements_for_other() { + public function test_export_agreements_for_other(): void { global $CFG; $managercontext = \context_user::instance($this->manager->id); @@ -305,7 +305,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { $this->assertEquals(strip_tags($policy2->get('content')), strip_tags($datauser->content)); } - public function test_export_created_policies() { + public function test_export_created_policies(): void { global $CFG; // Create policies and agree to them as manager. diff --git a/admin/tool/policy/tests/sitepolicy_handler_test.php b/admin/tool/policy/tests/sitepolicy_handler_test.php index 51ec55afa4c..c97a79ddc1f 100644 --- a/admin/tool/policy/tests/sitepolicy_handler_test.php +++ b/admin/tool/policy/tests/sitepolicy_handler_test.php @@ -32,7 +32,7 @@ class sitepolicy_handler_test extends \advanced_testcase { /** * Test behaviour of the {@link \tool_policy\privacy\local\sitepolicy\handler::get_redirect_url()} method. */ - public function test_get_redirect_url() { + public function test_get_redirect_url(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -56,7 +56,7 @@ class sitepolicy_handler_test extends \advanced_testcase { /** * Test behaviour of the {@link \tool_policy\privacy\local\sitepolicy\handler::get_embed_url()} method. */ - public function test_get_embed_url() { + public function test_get_embed_url(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -82,7 +82,7 @@ class sitepolicy_handler_test extends \advanced_testcase { /** * Test behaviour of the {@link \tool_policy\privacy\local\sitepolicy\handler::accept()} method. */ - public function test_accept() { + public function test_accept(): void { global $DB, $USER; $this->resetAfterTest(); @@ -120,7 +120,7 @@ class sitepolicy_handler_test extends \advanced_testcase { /** * Test presence of the {@link \tool_policy\privacy\local\sitepolicy\handler::signup_form()} method. */ - public function test_signup_form() { + public function test_signup_form(): void { $this->assertTrue(method_exists('\tool_policy\privacy\local\sitepolicy\handler', 'signup_form')); } } diff --git a/admin/tool/recyclebin/tests/category_bin_test.php b/admin/tool/recyclebin/tests/category_bin_test.php index b12aa4de0d3..953a7019912 100644 --- a/admin/tool/recyclebin/tests/category_bin_test.php +++ b/admin/tool/recyclebin/tests/category_bin_test.php @@ -51,7 +51,7 @@ class category_bin_test extends \advanced_testcase { /** * Check that our hook is called when a course is deleted. */ - public function test_pre_course_delete_hook() { + public function test_pre_course_delete_hook(): void { global $DB; // This simulates a temporary course being cleaned up by a course restore. @@ -76,7 +76,7 @@ class category_bin_test extends \advanced_testcase { /** * Check that our hook is called when a course is deleted. */ - public function test_pre_course_category_delete_hook() { + public function test_pre_course_category_delete_hook(): void { global $DB; // Should have nothing in the recycle bin. @@ -98,7 +98,7 @@ class category_bin_test extends \advanced_testcase { /** * Test that we can restore recycle bin items. */ - public function test_restore() { + public function test_restore(): void { global $DB; delete_course($this->course, false); @@ -116,7 +116,7 @@ class category_bin_test extends \advanced_testcase { /** * Test that we can delete recycle bin items. */ - public function test_delete() { + public function test_delete(): void { global $DB; delete_course($this->course, false); @@ -134,7 +134,7 @@ class category_bin_test extends \advanced_testcase { /** * Test the cleanup task. */ - public function test_cleanup_task() { + public function test_cleanup_task(): void { global $DB; // Set the expiry to 1 week. @@ -204,7 +204,7 @@ class category_bin_test extends \advanced_testcase { * @dataProvider recycle_bin_settings_provider * @param array $settings array of plugin, name, value stdClass(). */ - public function test_course_restore_with_userdata($settings) { + public function test_course_restore_with_userdata($settings): void { global $DB; // Force configuration changes from provider. @@ -248,7 +248,7 @@ class category_bin_test extends \advanced_testcase { * @dataProvider recycle_bin_settings_provider * @param array $settings array of plugin, name, value stdClass(). */ - public function test_course_restore_without_userdata($settings) { + public function test_course_restore_without_userdata($settings): void { global $DB; // Force configuration changes from provider. diff --git a/admin/tool/recyclebin/tests/course_bin_test.php b/admin/tool/recyclebin/tests/course_bin_test.php index 95de24e3f5c..c37a619ac59 100644 --- a/admin/tool/recyclebin/tests/course_bin_test.php +++ b/admin/tool/recyclebin/tests/course_bin_test.php @@ -57,7 +57,7 @@ class course_bin_test extends \advanced_testcase { /** * Check that our hook is called when an activity is deleted. */ - public function test_pre_course_module_delete_hook() { + public function test_pre_course_module_delete_hook(): void { global $DB; // Should have nothing in the recycle bin. @@ -80,7 +80,7 @@ class course_bin_test extends \advanced_testcase { /** * Test that we can restore recycle bin items. */ - public function test_restore() { + public function test_restore(): void { global $DB; $startcount = $DB->count_records('course_modules'); @@ -102,7 +102,7 @@ class course_bin_test extends \advanced_testcase { /** * Test that we can delete recycle bin items. */ - public function test_delete() { + public function test_delete(): void { global $DB; $startcount = $DB->count_records('course_modules'); @@ -127,7 +127,7 @@ class course_bin_test extends \advanced_testcase { /** * Test the cleanup task. */ - public function test_cleanup_task() { + public function test_cleanup_task(): void { global $DB; set_config('coursebinexpiry', WEEKSECS, 'tool_recyclebin'); @@ -204,7 +204,7 @@ class course_bin_test extends \advanced_testcase { * @dataProvider recycle_bin_settings_provider * @param array $settings array of plugin, name, value stdClass(). */ - public function test_coursemodule_restore_with_userdata($settings) { + public function test_coursemodule_restore_with_userdata($settings): void { // Force configuration changes from provider. foreach ($settings as $setting) { // Need to create a directory for backup_auto_destination. @@ -252,7 +252,7 @@ class course_bin_test extends \advanced_testcase { * @dataProvider recycle_bin_settings_provider * @covers ::store_item */ - public function test_coursemodule_restore_with_activity_setting_disabled() { + public function test_coursemodule_restore_with_activity_setting_disabled(): void { // Set the configuration to not include activities in the automated backup. set_config('backup_auto_activities', false, 'backup'); @@ -274,7 +274,7 @@ class course_bin_test extends \advanced_testcase { * @dataProvider recycle_bin_settings_provider * @param array $settings array of plugin, name, value stdClass(). */ - public function test_coursemodule_restore_without_userdata($settings) { + public function test_coursemodule_restore_without_userdata($settings): void { // Force configuration changes from provider. foreach ($settings as $setting) { // Need to create a directory for backup_auto_destination. diff --git a/admin/tool/recyclebin/tests/event/events_test.php b/admin/tool/recyclebin/tests/event/events_test.php index 7cdcf42053d..2a203243488 100644 --- a/admin/tool/recyclebin/tests/event/events_test.php +++ b/admin/tool/recyclebin/tests/event/events_test.php @@ -51,7 +51,7 @@ class events_test extends \advanced_testcase { /** * Test the category bin item created event. */ - public function test_category_bin_item_created() { + public function test_category_bin_item_created(): void { // Create a course. $course = $this->getDataGenerator()->create_course(); @@ -78,7 +78,7 @@ class events_test extends \advanced_testcase { /** * Test the category bin item deleted event. */ - public function test_category_bin_item_deleted() { + public function test_category_bin_item_deleted(): void { // Create a course. $course = $this->getDataGenerator()->create_course(); @@ -107,7 +107,7 @@ class events_test extends \advanced_testcase { /** * Test the category bin item restored event. */ - public function test_category_bin_item_restored() { + public function test_category_bin_item_restored(): void { // Create a course. $course = $this->getDataGenerator()->create_course(); @@ -135,7 +135,7 @@ class events_test extends \advanced_testcase { /** * Test the course bin item created event. */ - public function test_course_bin_item_created() { + public function test_course_bin_item_created(): void { // Create a course. $course = $this->getDataGenerator()->create_course(); @@ -164,7 +164,7 @@ class events_test extends \advanced_testcase { /** * Test the course bin item deleted event. */ - public function test_course_bin_item_deleted() { + public function test_course_bin_item_deleted(): void { // Create a course. $course = $this->getDataGenerator()->create_course(); @@ -197,7 +197,7 @@ class events_test extends \advanced_testcase { /** * Test the course bin item restored event. */ - public function test_course_bin_item_restored() { + public function test_course_bin_item_restored(): void { // Create a course. $course = $this->getDataGenerator()->create_course(); diff --git a/admin/tool/task/tests/form_test.php b/admin/tool/task/tests/form_test.php index 8cbb40d189f..df0562444f8 100644 --- a/admin/tool/task/tests/form_test.php +++ b/admin/tool/task/tests/form_test.php @@ -28,7 +28,7 @@ class form_test extends \advanced_testcase { /** * Test validations for minute field. */ - public function test_validate_fields_minute() { + public function test_validate_fields_minute(): void { $checker = new \tool_task\scheduled_checker_task(); $checker->set_minute('*'); $this->assertTrue($checker->is_valid($checker::FIELD_MINUTE)); @@ -74,7 +74,7 @@ class form_test extends \advanced_testcase { /** * Test validations for minute hour. */ - public function test_validate_fields_hour() { + public function test_validate_fields_hour(): void { $checker = new \tool_task\scheduled_checker_task(); $checker->set_hour('*'); $this->assertTrue($checker->is_valid($checker::FIELD_HOUR)); @@ -124,7 +124,7 @@ class form_test extends \advanced_testcase { /** * Test validations for day field. */ - public function test_validate_fields_day() { + public function test_validate_fields_day(): void { $checker = new \tool_task\scheduled_checker_task(); $checker->set_day('*'); $this->assertTrue($checker->is_valid($checker::FIELD_DAY)); @@ -175,7 +175,7 @@ class form_test extends \advanced_testcase { /** * Test validations for month field. */ - public function test_validate_fields_month() { + public function test_validate_fields_month(): void { $checker = new \tool_task\scheduled_checker_task(); $checker->set_month('*'); $this->assertTrue($checker->is_valid($checker::FIELD_MONTH)); @@ -225,7 +225,7 @@ class form_test extends \advanced_testcase { /** * Test validations for dayofweek field. */ - public function test_validate_fields_dayofweek() { + public function test_validate_fields_dayofweek(): void { $checker = new \tool_task\scheduled_checker_task(); $checker->set_day_of_week('*'); $this->assertTrue($checker->is_valid($checker::FIELD_DAYOFWEEK)); diff --git a/admin/tool/templatelibrary/tests/externallib_test.php b/admin/tool/templatelibrary/tests/externallib_test.php index 87144cddef3..151ee1c654d 100644 --- a/admin/tool/templatelibrary/tests/externallib_test.php +++ b/admin/tool/templatelibrary/tests/externallib_test.php @@ -36,7 +36,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test list all. */ - public function test_list_templates() { + public function test_list_templates(): void { $result = external::list_templates('', ''); $count = count($result); // We have 3 templates in this tool - and there must be more else where. @@ -46,7 +46,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test we can filter by component. */ - public function test_list_templates_for_component() { + public function test_list_templates_for_component(): void { $result = external::list_templates('tool_templatelibrary', ''); $count = count($result); $this->assertEquals(3, $count); @@ -59,7 +59,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test we can filter by a string. */ - public function test_list_templates_with_filter() { + public function test_list_templates_with_filter(): void { $result = external::list_templates('tool_templatelibrary', 'page'); $count = count($result); // Should be only one matching template. @@ -67,7 +67,7 @@ class externallib_test extends externallib_advanced_testcase { $this->assertEquals($result[0], "tool_templatelibrary/list_templates_page"); } - public function test_load_canonical_template() { + public function test_load_canonical_template(): void { global $CFG; $originaltheme = $CFG->theme; diff --git a/admin/tool/uploadcourse/tests/course_test.php b/admin/tool/uploadcourse/tests/course_test.php index 1594f40c0a4..70cdc183edf 100644 --- a/admin/tool/uploadcourse/tests/course_test.php +++ b/admin/tool/uploadcourse/tests/course_test.php @@ -78,7 +78,7 @@ class course_test extends \advanced_testcase { $co->proceed(); } - public function test_proceed_when_prepare_failed() { + public function test_proceed_when_prepare_failed(): void { $this->initialise_test(); $mode = tool_uploadcourse_processor::MODE_CREATE_NEW; $updatemode = tool_uploadcourse_processor::UPDATE_NOTHING; @@ -89,7 +89,7 @@ class course_test extends \advanced_testcase { $co->proceed(); } - public function test_proceed_when_already_started() { + public function test_proceed_when_already_started(): void { $this->initialise_test(); $mode = tool_uploadcourse_processor::MODE_CREATE_NEW; $updatemode = tool_uploadcourse_processor::UPDATE_NOTHING; @@ -101,7 +101,7 @@ class course_test extends \advanced_testcase { $co->proceed(); } - public function test_invalid_shortname() { + public function test_invalid_shortname(): void { $this->initialise_test(); $mode = tool_uploadcourse_processor::MODE_CREATE_NEW; $updatemode = tool_uploadcourse_processor::UPDATE_NOTHING; @@ -111,7 +111,7 @@ class course_test extends \advanced_testcase { $this->assertArrayHasKey('invalidshortname', $co->get_errors()); } - public function test_invalid_shortname_too_long() { + public function test_invalid_shortname_too_long(): void { $this->resetAfterTest(); $mode = tool_uploadcourse_processor::MODE_CREATE_NEW; @@ -127,7 +127,7 @@ class course_test extends \advanced_testcase { $this->assertArrayHasKey('invalidshortnametoolong', $upload->get_errors()); } - public function test_invalid_fullname_too_long() { + public function test_invalid_fullname_too_long(): void { $this->initialise_test(); $mode = tool_uploadcourse_processor::MODE_CREATE_NEW; @@ -142,7 +142,7 @@ class course_test extends \advanced_testcase { $this->assertArrayHasKey('invalidfullnametoolong', $upload->get_errors()); } - public function test_invalid_visibility() { + public function test_invalid_visibility(): void { $this->initialise_test(); $mode = tool_uploadcourse_processor::MODE_CREATE_NEW; $updatemode = tool_uploadcourse_processor::UPDATE_NOTHING; @@ -273,7 +273,7 @@ class course_test extends \advanced_testcase { } } - public function test_create() { + public function test_create(): void { global $DB; $this->initialise_test(); @@ -322,7 +322,7 @@ class course_test extends \advanced_testcase { $this->assertEquals(1, course_get_format($course)->get_course()->coursedisplay); } - public function test_create_with_sections() { + public function test_create_with_sections(): void { global $DB; $this->initialise_test(); $updatemode = tool_uploadcourse_processor::UPDATE_NOTHING; @@ -352,7 +352,7 @@ class course_test extends \advanced_testcase { $DB->count_records('course_sections', ['course' => $courseid])); } - public function test_delete() { + public function test_delete(): void { global $DB; $this->initialise_test(); @@ -397,7 +397,7 @@ class course_test extends \advanced_testcase { $this->assertArrayHasKey('cannotdeletecoursenotexist', $co->get_errors()); } - public function test_update() { + public function test_update(): void { global $DB; $this->initialise_test(); @@ -474,7 +474,7 @@ class course_test extends \advanced_testcase { $this->assertEquals(1, course_get_format($course)->get_course()->coursedisplay); } - public function test_data_saved() { + public function test_data_saved(): void { global $DB; $this->initialise_test(); @@ -692,7 +692,7 @@ class course_test extends \advanced_testcase { $this->assertEquals(ENROL_INSTANCE_ENABLED, $enroldata['self']->status); } - public function test_default_data_saved() { + public function test_default_data_saved(): void { global $DB; $this->initialise_test(); @@ -817,7 +817,7 @@ class course_test extends \advanced_testcase { $this->assertEquals($defaultdata['showactivitydates'], $course->showactivitydates); } - public function test_rename() { + public function test_rename(): void { global $DB; $this->initialise_test(); @@ -912,7 +912,7 @@ class course_test extends \advanced_testcase { $this->assertArrayHasKey('cannotrenameshortnamealreadyinuse', $co->get_errors()); } - public function test_restore_course() { + public function test_restore_course(): void { global $DB; $this->initialise_test(); $this->setAdminUser(); @@ -956,7 +956,7 @@ class course_test extends \advanced_testcase { $this->assertTrue($found); } - public function test_restore_file() { + public function test_restore_file(): void { global $DB; $this->initialise_test(); $this->setAdminUser(); @@ -1008,7 +1008,7 @@ class course_test extends \advanced_testcase { /** * Test that specifying course template respects default restore settings */ - public function test_restore_file_settings() { + public function test_restore_file_settings(): void { global $DB; $this->initialise_test(); $this->setAdminUser(); @@ -1032,7 +1032,7 @@ class course_test extends \advanced_testcase { $this->assertEmpty($modinfo->get_instances_of('glossary')); } - public function test_restore_invalid_file() { + public function test_restore_invalid_file(): void { $this->initialise_test(); // Restore from a non-existing file should not be allowed. @@ -1059,7 +1059,7 @@ class course_test extends \advanced_testcase { $this->assertDebuggingCalled(); } - public function test_restore_invalid_course() { + public function test_restore_invalid_course(): void { $this->initialise_test(); // Restore from an invalid file should not be allowed. @@ -1075,7 +1075,7 @@ class course_test extends \advanced_testcase { /** * Testing the reset on groups, group members and enrolments. */ - public function test_reset() { + public function test_reset(): void { global $DB; $this->initialise_test(); @@ -1167,7 +1167,7 @@ class course_test extends \advanced_testcase { $this->assertFalse($DB->record_exists('groups', array('id' => $g1->id))); } - public function test_create_bad_category() { + public function test_create_bad_category(): void { global $DB; $this->initialise_test(); @@ -1222,7 +1222,7 @@ class course_test extends \advanced_testcase { $this->assertEquals($c1->category, $DB->get_field('course', 'category', array('id' => $c1->id))); } - public function test_enrolment_data() { + public function test_enrolment_data(): void { $this->initialise_test(); // We need to set the current user as one with the capability to edit manual enrolment instances in the new course. @@ -1374,7 +1374,7 @@ class course_test extends \advanced_testcase { /** * Test upload processing of course custom fields */ - public function test_custom_fields_data() { + public function test_custom_fields_data(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -1410,7 +1410,7 @@ class course_test extends \advanced_testcase { /** * Test upload processing of course custom field that is required but empty */ - public function test_custom_fields_data_required() { + public function test_custom_fields_data_required(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -1448,7 +1448,7 @@ class course_test extends \advanced_testcase { /** * Test upload processing of course custom field with an invalid select option */ - public function test_custom_fields_data_invalid_select_option() { + public function test_custom_fields_data_invalid_select_option(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -1478,7 +1478,7 @@ class course_test extends \advanced_testcase { /** * Test upload processing of course custom field with an out of range date */ - public function test_custom_fields_data_invalid_date() { + public function test_custom_fields_data_invalid_date(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -1501,7 +1501,7 @@ class course_test extends \advanced_testcase { $this->assertArrayHasKey('customfieldinvalid', $uploader->get_errors()); } - public function test_idnumber_problems() { + public function test_idnumber_problems(): void { $this->initialise_test(); $c1 = $this->getDataGenerator()->create_course(array('shortname' => 'sntaken', 'idnumber' => 'taken')); @@ -1552,7 +1552,7 @@ class course_test extends \advanced_testcase { $this->assertEquals('nottaken', $data['idnumber']); } - public function test_generate_shortname() { + public function test_generate_shortname(): void { $this->initialise_test(); $c1 = $this->getDataGenerator()->create_course(array('shortname' => 'taken')); @@ -1604,7 +1604,7 @@ class course_test extends \advanced_testcase { $this->assertArrayHasKey('courseshortnameincremented', $co->get_statuses()); } - public function test_mess_with_frontpage() { + public function test_mess_with_frontpage(): void { global $SITE; $this->initialise_test(); @@ -1651,7 +1651,7 @@ class course_test extends \advanced_testcase { * * @covers \tool_uploadcourse_course::prepare */ - public function test_role_not_exist() { + public function test_role_not_exist(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -1675,7 +1675,7 @@ class course_test extends \advanced_testcase { * * @covers \tool_uploadcourse_course::proceed */ - public function test_role_not_allowed() { + public function test_role_not_allowed(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -1702,7 +1702,7 @@ class course_test extends \advanced_testcase { * * @covers \tool_uploadcourse_course::proceed */ - public function test_role_allowed() { + public function test_role_allowed(): void { global $DB; $this->resetAfterTest(); diff --git a/admin/tool/uploadcourse/tests/helper_test.php b/admin/tool/uploadcourse/tests/helper_test.php index 5f58c13d181..9cc39944689 100644 --- a/admin/tool/uploadcourse/tests/helper_test.php +++ b/admin/tool/uploadcourse/tests/helper_test.php @@ -27,7 +27,7 @@ use tool_uploadcourse_helper; */ class helper_test extends \advanced_testcase { - public function test_generate_shortname() { + public function test_generate_shortname(): void { $data = (object) array('fullname' => 'Ah bh Ch 01 02 03', 'idnumber' => 'ID123'); $this->assertSame($data->fullname, tool_uploadcourse_helper::generate_shortname($data, '%f')); @@ -43,14 +43,14 @@ class helper_test extends \advanced_testcase { $this->assertNull(tool_uploadcourse_helper::generate_shortname(array(), '%f')); } - public function test_get_course_formats() { + public function test_get_course_formats(): void { $result = tool_uploadcourse_helper::get_course_formats(); $this->assertSame(array_keys(\core_component::get_plugin_list('format')), $result); // Should be similar as first result, as cached. $this->assertSame($result, tool_uploadcourse_helper::get_course_formats()); } - public function test_get_enrolment_data() { + public function test_get_enrolment_data(): void { $this->resetAfterTest(true); $data = array( 'enrolment_1' => 'unknown', @@ -96,7 +96,7 @@ class helper_test extends \advanced_testcase { $this->assertSame(tool_uploadcourse_helper::get_enrolment_data($data), $expected); } - public function test_get_enrolment_plugins() { + public function test_get_enrolment_plugins(): void { $this->resetAfterTest(true); $actual = tool_uploadcourse_helper::get_enrolment_plugins(); $this->assertSame(array_keys(enrol_get_plugins(false)), array_keys($actual)); @@ -105,7 +105,7 @@ class helper_test extends \advanced_testcase { $this->assertEquals($actual, $secondactual); } - public function test_get_restore_content_dir() { + public function test_get_restore_content_dir(): void { global $CFG; require_once($CFG->dirroot . '/backup/util/includes/backup_includes.php'); $this->resetAfterTest(true); @@ -197,7 +197,7 @@ class helper_test extends \advanced_testcase { $CFG->keeptempdirectoriesonbackup = $oldcfg; } - public function test_get_role_ids() { + public function test_get_role_ids(): void { $this->getDataGenerator(); // Mimic function result. $expected = array(); @@ -213,7 +213,7 @@ class helper_test extends \advanced_testcase { $this->assertSame($actual, tool_uploadcourse_helper::get_role_ids()); } - public function test_get_role_names() { + public function test_get_role_names(): void { $this->resetAfterTest(true); create_role('Villain', 'villain', 'The bad guys'); @@ -246,7 +246,7 @@ class helper_test extends \advanced_testcase { /** * Test custom field data processing */ - public function test_get_custom_course_field_data() { + public function test_get_custom_course_field_data(): void { global $DB; $this->resetAfterTest(); @@ -318,7 +318,7 @@ class helper_test extends \advanced_testcase { $this->assertArrayNotHasKey('customfield_mytext', $fields); } - public function test_increment_idnumber() { + public function test_increment_idnumber(): void { $this->resetAfterTest(true); $c1 = $this->getDataGenerator()->create_course(array('idnumber' => 'C1')); @@ -330,7 +330,7 @@ class helper_test extends \advanced_testcase { $this->assertEquals('DoesNotExist', tool_uploadcourse_helper::increment_idnumber('DoesNotExist')); } - public function test_increment_shortname() { + public function test_increment_shortname(): void { $this->resetAfterTest(true); $c1 = $this->getDataGenerator()->create_course(array('shortname' => 'C1')); @@ -343,7 +343,7 @@ class helper_test extends \advanced_testcase { $this->assertEquals('DoesNotExist_2', tool_uploadcourse_helper::increment_shortname('DoesNotExist')); } - public function test_resolve_category() { + public function test_resolve_category(): void { $this->resetAfterTest(true); $c1 = $this->getDataGenerator()->create_category(array('name' => 'First level')); @@ -377,7 +377,7 @@ class helper_test extends \advanced_testcase { $this->assertArrayHasKey('couldnotresolvecatgorybypath', $errors); } - public function test_resolve_category_by_idnumber() { + public function test_resolve_category_by_idnumber(): void { $this->resetAfterTest(true); $c1 = $this->getDataGenerator()->create_category(array('idnumber' => 'C1')); @@ -395,7 +395,7 @@ class helper_test extends \advanced_testcase { $this->assertEmpty(tool_uploadcourse_helper::resolve_category_by_idnumber('DoesNotExist')); } - public function test_resolve_category_by_path() { + public function test_resolve_category_by_path(): void { $this->resetAfterTest(true); $cat1 = $this->getDataGenerator()->create_category(array('name' => 'Cat 1')); diff --git a/admin/tool/uploadcourse/tests/processor_test.php b/admin/tool/uploadcourse/tests/processor_test.php index ff71ca63eb6..9ad956d2114 100644 --- a/admin/tool/uploadcourse/tests/processor_test.php +++ b/admin/tool/uploadcourse/tests/processor_test.php @@ -32,7 +32,7 @@ require_once($CFG->libdir . '/csvlib.class.php'); */ class processor_test extends \advanced_testcase { - public function test_basic() { + public function test_basic(): void { global $DB; $this->resetAfterTest(true); $this->setAdminUser(); @@ -59,7 +59,7 @@ class processor_test extends \advanced_testcase { $this->assertTrue($DB->record_exists('course', array('shortname' => 'c2'))); } - public function test_restore_template_course() { + public function test_restore_template_course(): void { global $DB; $this->resetAfterTest(true); $this->setAdminUser(); @@ -95,7 +95,7 @@ class processor_test extends \advanced_testcase { $this->assertTrue($found); } - public function test_restore_restore_file() { + public function test_restore_restore_file(): void { global $DB; $this->resetAfterTest(true); $this->setAdminUser(); @@ -132,7 +132,7 @@ class processor_test extends \advanced_testcase { $this->assertTrue($found); } - public function test_shortname_template() { + public function test_shortname_template(): void { global $DB; $this->resetAfterTest(true); $this->setAdminUser(); @@ -158,7 +158,7 @@ class processor_test extends \advanced_testcase { $this->assertEquals('ID123: Course 1', $c->shortname); } - public function test_empty_csv() { + public function test_empty_csv(): void { $this->resetAfterTest(true); $content = array(); @@ -173,7 +173,7 @@ class processor_test extends \advanced_testcase { $p = new tool_uploadcourse_processor($cir, $options, array()); } - public function test_not_enough_columns() { + public function test_not_enough_columns(): void { $this->resetAfterTest(true); $content = array( @@ -191,7 +191,7 @@ class processor_test extends \advanced_testcase { $p = new tool_uploadcourse_processor($cir, $options, array()); } - public function test_preview() { + public function test_preview(): void { global $DB; $this->resetAfterTest(true); diff --git a/admin/tool/uploaduser/tests/cli_test.php b/admin/tool/uploaduser/tests/cli_test.php index bea9eab178b..6681591e236 100644 --- a/admin/tool/uploaduser/tests/cli_test.php +++ b/admin/tool/uploaduser/tests/cli_test.php @@ -48,7 +48,7 @@ class cli_test extends \advanced_testcase { /** * Tests simple upload with course enrolment and group allocation */ - public function test_upload_with_course_enrolment() { + public function test_upload_with_course_enrolment(): void { global $CFG; $this->resetAfterTest(); set_config('passwordpolicy', 0); @@ -85,7 +85,7 @@ class cli_test extends \advanced_testcase { /** * Test applying defaults during the user upload */ - public function test_upload_with_applying_defaults() { + public function test_upload_with_applying_defaults(): void { global $CFG; $this->resetAfterTest(); set_config('passwordpolicy', 0); @@ -117,7 +117,7 @@ class cli_test extends \advanced_testcase { /** * User upload with user profile fields */ - public function test_upload_with_profile_fields() { + public function test_upload_with_profile_fields(): void { global $CFG; $this->resetAfterTest(); set_config('passwordpolicy', 0); @@ -150,7 +150,7 @@ class cli_test extends \advanced_testcase { /** * Testing that help for CLI does not throw errors */ - public function test_cli_help() { + public function test_cli_help(): void { $this->resetAfterTest(); $this->setAdminUser(); $clihelper = $this->construct_helper(["--help"]); @@ -168,7 +168,7 @@ class cli_test extends \advanced_testcase { /** * Testing skipped user when one exists */ - public function test_create_when_user_exists() { + public function test_create_when_user_exists(): void { global $CFG; $this->resetAfterTest(); set_config('passwordpolicy', 0); @@ -203,7 +203,7 @@ class cli_test extends \advanced_testcase { /** * Testing update mode - do not update user records but allow enrolments */ - public function test_enrolments_when_user_exists() { + public function test_enrolments_when_user_exists(): void { global $CFG; require_once($CFG->dirroot.'/'.$CFG->admin.'/tool/uploaduser/locallib.php'); @@ -245,7 +245,7 @@ class cli_test extends \advanced_testcase { /** * Testing update mode - update user records and perform enrolments. */ - public function test_udpate_user() { + public function test_udpate_user(): void { global $CFG; require_once($CFG->dirroot.'/'.$CFG->admin.'/tool/uploaduser/locallib.php'); diff --git a/admin/tool/uploaduser/tests/field_value_validators_test.php b/admin/tool/uploaduser/tests/field_value_validators_test.php index 8fd5fea8c34..5d4a2f8fb7a 100644 --- a/admin/tool/uploaduser/tests/field_value_validators_test.php +++ b/admin/tool/uploaduser/tests/field_value_validators_test.php @@ -56,7 +56,7 @@ class field_value_validators_test extends \advanced_testcase { * @param string $expectedstatus The expected status. * @param string $expectedmessage The expected validation message. */ - public function test_validate_theme($userthemesallowed, $themename, $expectedstatus, $expectedmessage) { + public function test_validate_theme($userthemesallowed, $themename, $expectedstatus, $expectedmessage): void { $this->resetAfterTest(); // Set value for $CFG->allowuserthemes. diff --git a/analytics/tests/analysis_test.php b/analytics/tests/analysis_test.php index 9d458a3aa57..5d6fa8804fc 100644 --- a/analytics/tests/analysis_test.php +++ b/analytics/tests/analysis_test.php @@ -29,7 +29,7 @@ class analysis_test extends \advanced_testcase { * Test fill_firstanalyses_cache. * @return null */ - public function test_fill_firstanalyses_cache() { + public function test_fill_firstanalyses_cache(): void { require_once(__DIR__ . '/fixtures/test_timesplitting_upcoming_seconds.php'); $this->resetAfterTest(); diff --git a/analytics/tests/calculation_info_test.php b/analytics/tests/calculation_info_test.php index 84051ad3b7c..6a837ee5c19 100644 --- a/analytics/tests/calculation_info_test.php +++ b/analytics/tests/calculation_info_test.php @@ -35,7 +35,7 @@ class calculation_info_test extends \advanced_testcase { * @param mixed $info4 * @return null */ - public function test_calculation_info_add_pull($info1, $info2, $info3, $info4) { + public function test_calculation_info_add_pull($info1, $info2, $info3, $info4): void { require_once(__DIR__ . '/fixtures/test_indicator_max.php'); require_once(__DIR__ . '/fixtures/test_indicator_min.php'); $this->resetAfterTest(); diff --git a/analytics/tests/course_test.php b/analytics/tests/course_test.php index bff564b4ead..9256b718cc0 100644 --- a/analytics/tests/course_test.php +++ b/analytics/tests/course_test.php @@ -77,7 +77,7 @@ class course_test extends \advanced_testcase { /** * Users tests. */ - public function test_users() { + public function test_users(): void { global $DB; $this->resetAfterTest(true); @@ -97,7 +97,7 @@ class course_test extends \advanced_testcase { * * @return void */ - public function test_course_validation() { + public function test_course_validation(): void { global $DB; $this->resetAfterTest(true); diff --git a/analytics/tests/dataset_manager_test.php b/analytics/tests/dataset_manager_test.php index ab7c28a9681..06235296c0c 100644 --- a/analytics/tests/dataset_manager_test.php +++ b/analytics/tests/dataset_manager_test.php @@ -48,7 +48,7 @@ class dataset_manager_test extends \advanced_testcase { * * @return null */ - public function test_create_dataset() { + public function test_create_dataset(): void { $dataset1 = new \core_analytics\dataset_manager(1, 1, 'whatever', \core_analytics\dataset_manager::LABELLED_FILEAREA, false); $dataset1data = array_merge($this->sharedtoprows, array(array('yeah', 'yeah', 'yeah'))); @@ -66,7 +66,7 @@ class dataset_manager_test extends \advanced_testcase { * * @return null */ - public function test_merge_datasets() { + public function test_merge_datasets(): void { $dataset1 = new \core_analytics\dataset_manager(1, 1, 'whatever', \core_analytics\dataset_manager::LABELLED_FILEAREA, false); $dataset1data = array_merge($this->sharedtoprows, array(array('yeah', 'yeah', 'yeah'))); @@ -93,7 +93,7 @@ class dataset_manager_test extends \advanced_testcase { * * @return null */ - public function test_get_pending_files() { + public function test_get_pending_files(): void { global $DB; $this->resetAfterTest(); diff --git a/analytics/tests/indicator_test.php b/analytics/tests/indicator_test.php index 82966cb04c9..49c02edcba4 100644 --- a/analytics/tests/indicator_test.php +++ b/analytics/tests/indicator_test.php @@ -39,7 +39,7 @@ class indicator_test extends \advanced_testcase { * @dataProvider validate_calculated_value * @return null */ - public function test_validate_calculated_value($indicatorclass, $returnedvalue) { + public function test_validate_calculated_value($indicatorclass, $returnedvalue): void { $indicator = new $indicatorclass(); list($values, $unused) = $indicator->calculate([1], 'notrelevanthere'); $this->assertEquals($returnedvalue, $values[0]); @@ -66,7 +66,7 @@ class indicator_test extends \advanced_testcase { * @dataProvider validate_calculated_value_exceptions * @return null */ - public function test_validate_calculated_value_exceptions($indicatorclass, $willreturn) { + public function test_validate_calculated_value_exceptions($indicatorclass, $willreturn): void { $indicator = new $indicatorclass(); $indicatormock = $this->getMockBuilder(get_class($indicator)) diff --git a/analytics/tests/manager_test.php b/analytics/tests/manager_test.php index eb1bc73e6f3..802ddf52e24 100644 --- a/analytics/tests/manager_test.php +++ b/analytics/tests/manager_test.php @@ -36,7 +36,7 @@ class manager_test extends \advanced_testcase { /** * test_deleted_context */ - public function test_deleted_context() { + public function test_deleted_context(): void { global $DB; $this->resetAfterTest(true); @@ -103,7 +103,7 @@ class manager_test extends \advanced_testcase { /** * test_deleted_analysable */ - public function test_deleted_analysable() { + public function test_deleted_analysable(): void { global $DB; $this->resetAfterTest(true); @@ -150,7 +150,7 @@ class manager_test extends \advanced_testcase { /** * Tests for the {@link \core_analytics\manager::load_default_models_for_component()} implementation. */ - public function test_load_default_models_for_component() { + public function test_load_default_models_for_component(): void { $this->resetAfterTest(); // Attempting to load builtin models should always work without throwing exception. @@ -172,7 +172,7 @@ class manager_test extends \advanced_testcase { /** * Tests for the {@link \core_analytics\manager::load_default_models_for_all_components()} implementation. */ - public function test_load_default_models_for_all_components() { + public function test_load_default_models_for_all_components(): void { $this->resetAfterTest(); $models = \core_analytics\manager::load_default_models_for_all_components(); @@ -186,7 +186,7 @@ class manager_test extends \advanced_testcase { /** * Tests for the successful execution of the {@link \core_analytics\manager::validate_models_declaration()}. */ - public function test_validate_models_declaration() { + public function test_validate_models_declaration(): void { $this->resetAfterTest(); // This is expected to run without an exception. @@ -201,7 +201,7 @@ class manager_test extends \advanced_testcase { * @param array $models Models declaration. * @param string $exception Expected coding exception message. */ - public function test_validate_models_declaration_exceptions(array $models, string $exception) { + public function test_validate_models_declaration_exceptions(array $models, string $exception): void { $this->resetAfterTest(); $this->expectException(\coding_exception::class); @@ -266,7 +266,7 @@ class manager_test extends \advanced_testcase { /** * Test the implementation of the {@link \core_analytics\manager::create_declared_model()}. */ - public function test_create_declared_model() { + public function test_create_declared_model(): void { global $DB; $this->resetAfterTest(); @@ -352,7 +352,7 @@ class manager_test extends \advanced_testcase { /** * Test the implementation of the {@link \core_analytics\manager::update_default_models_for_component()}. */ - public function test_update_default_models_for_component() { + public function test_update_default_models_for_component(): void { $this->resetAfterTest(); $this->setAdminuser(); @@ -402,7 +402,7 @@ class manager_test extends \advanced_testcase { * test_get_time_splitting_methods description * @return null */ - public function test_get_time_splitting_methods() { + public function test_get_time_splitting_methods(): void { $this->resetAfterTest(true); $all = \core_analytics\manager::get_all_time_splittings(); @@ -428,7 +428,7 @@ class manager_test extends \advanced_testcase { /** * Test the implementation of the {@link \core_analytics\manager::model_declaration_identifier()}. */ - public function test_model_declaration_identifier() { + public function test_model_declaration_identifier(): void { $noteaching1 = $this->load_models_from_fixture_file('no_teaching'); $noteaching2 = $this->load_models_from_fixture_file('no_teaching'); @@ -471,7 +471,7 @@ class manager_test extends \advanced_testcase { /** * Tests for the {@link \core_analytics\manager::get_declared_target_and_indicators_instances()}. */ - public function test_get_declared_target_and_indicators_instances() { + public function test_get_declared_target_and_indicators_instances(): void { $this->resetAfterTest(); $definition = $this->load_models_from_fixture_file('no_teaching'); @@ -486,7 +486,7 @@ class manager_test extends \advanced_testcase { /** * test_get_potential_context_restrictions description */ - public function test_get_potential_context_restrictions() { + public function test_get_potential_context_restrictions(): void { $this->resetAfterTest(); // No potential context restrictions. diff --git a/analytics/tests/model_test.php b/analytics/tests/model_test.php index b2a621379a0..8320f8adcac 100644 --- a/analytics/tests/model_test.php +++ b/analytics/tests/model_test.php @@ -63,7 +63,7 @@ class model_test extends \advanced_testcase { $this->modelobj = $this->model->get_model_obj(); } - public function test_enable() { + public function test_enable(): void { $this->resetAfterTest(true); $this->assertEquals(0, $this->model->get_model_obj()->enabled); @@ -76,7 +76,7 @@ class model_test extends \advanced_testcase { $this->assertEquals('\core\analytics\time_splitting\quarters', $this->model->get_model_obj()->timesplitting); } - public function test_create() { + public function test_create(): void { $this->resetAfterTest(true); $target = \core_analytics\manager::get_target('\core_course\analytics\target\course_dropout'); @@ -91,7 +91,7 @@ class model_test extends \advanced_testcase { /** * test_delete */ - public function test_delete() { + public function test_delete(): void { global $DB; $this->resetAfterTest(true); @@ -136,7 +136,7 @@ class model_test extends \advanced_testcase { /** * test_clear */ - public function test_clear() { + public function test_clear(): void { global $DB; $this->resetAfterTest(true); @@ -187,7 +187,7 @@ class model_test extends \advanced_testcase { /** * Test behaviour of {\core_analytics\model::clear()} for static models. */ - public function test_clear_static() { + public function test_clear_static(): void { global $DB; $this->resetAfterTest(); @@ -205,7 +205,7 @@ class model_test extends \advanced_testcase { $this->assertEquals(1, $DB->get_field('analytics_models', 'trained', array('id' => $modelobj->id))); } - public function test_model_manager() { + public function test_model_manager(): void { $this->resetAfterTest(true); $this->assertCount(3, $this->model->get_indicators()); @@ -219,7 +219,7 @@ class model_test extends \advanced_testcase { $this->assertInstanceOf('\core\analytics\analyser\site_courses', $this->model->get_analyser()); } - public function test_output_dir() { + public function test_output_dir(): void { $this->resetAfterTest(true); $dir = make_request_directory(); @@ -230,7 +230,7 @@ class model_test extends \advanced_testcase { $this->assertEquals($modeldir . DIRECTORY_SEPARATOR . 'testing', $this->model->get_output_dir(array('testing'))); } - public function test_unique_id() { + public function test_unique_id(): void { global $DB; $this->resetAfterTest(true); @@ -277,7 +277,7 @@ class model_test extends \advanced_testcase { * * @return void */ - public function test_exists() { + public function test_exists(): void { $this->resetAfterTest(true); $target = \core_analytics\manager::get_target('\core_course\analytics\target\no_teaching'); @@ -295,7 +295,7 @@ class model_test extends \advanced_testcase { * * @return null */ - public function test_model_timelimit() { + public function test_model_timelimit(): void { global $DB; $this->resetAfterTest(true); @@ -359,7 +359,7 @@ class model_test extends \advanced_testcase { /** * Test model_config::get_class_component. */ - public function test_model_config_get_class_component() { + public function test_model_config_get_class_component(): void { $this->resetAfterTest(true); $this->assertEquals('core', @@ -377,7 +377,7 @@ class model_test extends \advanced_testcase { /** * Test that import_model import models' configurations. */ - public function test_import_model_config() { + public function test_import_model_config(): void { $this->resetAfterTest(true); $this->model->enable('\\core\\analytics\\time_splitting\\quarters'); @@ -398,7 +398,7 @@ class model_test extends \advanced_testcase { /** * Test can export configuration */ - public function test_can_export_configuration() { + public function test_can_export_configuration(): void { $this->resetAfterTest(true); // No time splitting method. @@ -419,7 +419,7 @@ class model_test extends \advanced_testcase { /** * Test export_config */ - public function test_export_config() { + public function test_export_config(): void { $this->resetAfterTest(true); $this->model->enable('\\core\\analytics\\time_splitting\\quarters'); @@ -447,7 +447,7 @@ class model_test extends \advanced_testcase { /** * Test the implementation of {@link \core_analytics\model::inplace_editable_name()}. */ - public function test_inplace_editable_name() { + public function test_inplace_editable_name(): void { global $PAGE; $this->resetAfterTest(); @@ -473,7 +473,7 @@ class model_test extends \advanced_testcase { /** * Test how the models present themselves in the UI and that they can be renamed. */ - public function test_get_name_and_rename() { + public function test_get_name_and_rename(): void { global $PAGE; $this->resetAfterTest(); @@ -504,7 +504,7 @@ class model_test extends \advanced_testcase { /** * Tests model::get_potential_timesplittings() */ - public function test_potential_timesplittings() { + public function test_potential_timesplittings(): void { $this->resetAfterTest(); $this->assertArrayNotHasKey('\core\analytics\time_splitting\no_splitting', $this->model->get_potential_timesplittings()); @@ -517,7 +517,7 @@ class model_test extends \advanced_testcase { * * @return null */ - public function test_get_samples() { + public function test_get_samples(): void { $this->resetAfterTest(); if (!PHPUNIT_LONGTEST) { diff --git a/analytics/tests/prediction_actions_test.php b/analytics/tests/prediction_actions_test.php index 005595923a9..ff17cebb6b2 100644 --- a/analytics/tests/prediction_actions_test.php +++ b/analytics/tests/prediction_actions_test.php @@ -105,7 +105,7 @@ class prediction_actions_test extends \advanced_testcase { /** * test_get_predictions */ - public function test_action_executed() { + public function test_action_executed(): void { global $DB; $this->assertEquals(0, $DB->count_records('analytics_prediction_actions')); @@ -196,7 +196,7 @@ class prediction_actions_test extends \advanced_testcase { * * @covers \core_analytics\prediction::get_executed_actions */ - public function test_get_executed_actions(array $actionstoexecute, array $actionnamefilter, int $returned) { + public function test_get_executed_actions(array $actionstoexecute, array $actionnamefilter, int $returned): void { $this->setUser($this->teacher2); list($ignored, $predictions) = $this->model->get_predictions($this->context, true); @@ -213,7 +213,7 @@ class prediction_actions_test extends \advanced_testcase { /** * test_get_predictions */ - public function test_get_predictions() { + public function test_get_predictions(): void { global $DB; // Already logged in as admin. diff --git a/analytics/tests/prediction_test.php b/analytics/tests/prediction_test.php index 08aa1c0f300..2f0750ddedc 100644 --- a/analytics/tests/prediction_test.php +++ b/analytics/tests/prediction_test.php @@ -70,7 +70,7 @@ class prediction_test extends \advanced_testcase { * * @return void */ - public function test_static_prediction() { + public function test_static_prediction(): void { global $DB; $this->resetAfterTest(true); @@ -123,7 +123,7 @@ class prediction_test extends \advanced_testcase { /** * test_model_contexts */ - public function test_model_contexts() { + public function test_model_contexts(): void { global $DB; $this->resetAfterTest(true); @@ -183,7 +183,7 @@ class prediction_test extends \advanced_testcase { * @return void */ public function test_ml_training_and_prediction($timesplittingid, $predictedrangeindex, $nranges, $predictionsprocessorclass, - $forcedconfig) { + $forcedconfig): void { global $DB; $this->resetAfterTest(true); @@ -358,7 +358,7 @@ class prediction_test extends \advanced_testcase { * @param array $forcedconfig * @dataProvider provider_ml_processors */ - public function test_ml_export_import($predictionsprocessorclass, $forcedconfig) { + public function test_ml_export_import($predictionsprocessorclass, $forcedconfig): void { $this->resetAfterTest(true); $this->set_forced_config($forcedconfig); @@ -439,7 +439,7 @@ class prediction_test extends \advanced_testcase { * @param array $forcedconfig * @return void */ - public function test_ml_classifiers_return($success, $nsamples, $classes, $predictionsprocessorclass, $forcedconfig) { + public function test_ml_classifiers_return($success, $nsamples, $classes, $predictionsprocessorclass, $forcedconfig): void { $this->resetAfterTest(); $this->set_forced_config($forcedconfig); @@ -530,7 +530,7 @@ class prediction_test extends \advanced_testcase { * @throws coding_exception * @throws moodle_exception */ - public function test_ml_multi_classifier($timesplittingid, $predictionsprocessorclass, $forcedconfig) { + public function test_ml_multi_classifier($timesplittingid, $predictionsprocessorclass, $forcedconfig): void { global $DB; $this->resetAfterTest(true); @@ -603,7 +603,7 @@ class prediction_test extends \advanced_testcase { * @return void */ public function test_ml_evaluation_configuration($modelquality, $ncourses, $expected, $predictionsprocessorclass, - $forcedconfig) { + $forcedconfig): void { $this->resetAfterTest(true); $this->set_forced_config($forcedconfig); @@ -657,7 +657,7 @@ class prediction_test extends \advanced_testcase { * @param array $forcedconfig * @return null */ - public function test_ml_evaluation_trained_model($predictionsprocessorclass, $forcedconfig) { + public function test_ml_evaluation_trained_model($predictionsprocessorclass, $forcedconfig): void { $this->resetAfterTest(true); $this->set_forced_config($forcedconfig); @@ -691,7 +691,7 @@ class prediction_test extends \advanced_testcase { * * @return void */ - public function test_read_indicator_calculations() { + public function test_read_indicator_calculations(): void { global $DB; $this->resetAfterTest(true); @@ -711,7 +711,7 @@ class prediction_test extends \advanced_testcase { /** * test_not_null_samples */ - public function test_not_null_samples() { + public function test_not_null_samples(): void { $this->resetAfterTest(true); $timesplitting = \core_analytics\manager::get_time_splitting('\core\analytics\time_splitting\quarters'); diff --git a/analytics/tests/privacy/provider_test.php b/analytics/tests/privacy/provider_test.php index 06ed516d99c..5bb2ea85903 100644 --- a/analytics/tests/privacy/provider_test.php +++ b/analytics/tests/privacy/provider_test.php @@ -159,7 +159,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test fetching users within a context. */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { global $CFG; $component = 'core_analytics'; @@ -198,7 +198,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { * * @return null */ - public function test_delete_context_data() { + public function test_delete_context_data(): void { global $DB; // We have 4 predictions for model1 and 8 predictions for model2. @@ -228,7 +228,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { * * @return null */ - public function test_delete_user_data() { + public function test_delete_user_data(): void { global $DB; $usercontexts = provider::get_contexts_for_userid($this->u3->id); @@ -257,7 +257,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test deleting multiple users in a context. */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { global $DB; $component = 'core_analytics'; @@ -412,7 +412,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { * * @return null */ - public function test_export_data() { + public function test_export_data(): void { global $DB; $system = \context_system::instance(); diff --git a/analytics/tests/stats_test.php b/analytics/tests/stats_test.php index 5d8f3019c5c..2d1a9278f59 100644 --- a/analytics/tests/stats_test.php +++ b/analytics/tests/stats_test.php @@ -42,7 +42,7 @@ class stats_test extends \advanced_testcase { /** * Test the {@link \core_analytics\stats::enabled_models()} implementation. */ - public function test_enabled_models() { + public function test_enabled_models(): void { $this->resetAfterTest(true); @@ -68,7 +68,7 @@ class stats_test extends \advanced_testcase { /** * Test the {@link \core_analytics\stats::predictions()} implementation. */ - public function test_predictions() { + public function test_predictions(): void { $this->resetAfterTest(true); @@ -113,7 +113,7 @@ class stats_test extends \advanced_testcase { /** * Test the {@link \core_analytics\stats::actions()} and {@link \core_analytics\stats::actions_not_useful()} implementation. */ - public function test_actions() { + public function test_actions(): void { global $DB; $this->resetAfterTest(true); diff --git a/analytics/tests/time_splittings_test.php b/analytics/tests/time_splittings_test.php index cd5026c08fe..7228c9b5671 100644 --- a/analytics/tests/time_splittings_test.php +++ b/analytics/tests/time_splittings_test.php @@ -64,7 +64,7 @@ class time_splittings_test extends \advanced_testcase { * * @return void */ - public function test_valid_ranges() { + public function test_valid_ranges(): void { // All core time splitting methods. $timesplittings = array( @@ -89,7 +89,7 @@ class time_splittings_test extends \advanced_testcase { * * @return void */ - public function test_range_dates() { + public function test_range_dates(): void { $nov2015 = mktime(0, 0, 0, 11, 24, 2015); $aug2016 = mktime(0, 0, 0, 8, 29, 2016); @@ -158,7 +158,7 @@ class time_splittings_test extends \advanced_testcase { * * @return void */ - public function test_ready_predict() { + public function test_ready_predict(): void { $quarters = new \core\analytics\time_splitting\quarters(); $nosplitting = new \core\analytics\time_splitting\no_splitting(); @@ -194,7 +194,7 @@ class time_splittings_test extends \advanced_testcase { * * @return void */ - public function test_periodic() { + public function test_periodic(): void { // Using a finished course. diff --git a/auth/db/tests/db_test.php b/auth/db/tests/db_test.php index 0e98f086714..981e56cf22e 100644 --- a/auth/db/tests/db_test.php +++ b/auth/db/tests/db_test.php @@ -172,7 +172,7 @@ class db_test extends \advanced_testcase { ini_set('error_log', $this->oldlog); } - public function test_plugin() { + public function test_plugin(): void { global $DB, $CFG; require_once($CFG->dirroot . '/user/profile/lib.php'); @@ -443,7 +443,7 @@ class db_test extends \advanced_testcase { /** * Testing the function _colonscope() from ADOdb. */ - public function test_adodb_colonscope() { + public function test_adodb_colonscope(): void { global $CFG; require_once($CFG->libdir.'/adodb/adodb.inc.php'); require_once($CFG->libdir.'/adodb/drivers/adodb-odbc.inc.php'); @@ -461,7 +461,7 @@ class db_test extends \advanced_testcase { /** * Testing the clean_data() method. */ - public function test_clean_data() { + public function test_clean_data(): void { global $DB; $this->resetAfterTest(false); @@ -505,7 +505,7 @@ class db_test extends \advanced_testcase { /** * Testing the deletion of a user when there are many users in the external DB. */ - public function test_deleting_with_many_users() { + public function test_deleting_with_many_users(): void { global $DB; $this->resetAfterTest(true); diff --git a/auth/email/tests/external/external_test.php b/auth/email/tests/external/external_test.php index bb51a77e34b..5ba47583e0a 100644 --- a/auth/email/tests/external/external_test.php +++ b/auth/email/tests/external/external_test.php @@ -68,7 +68,7 @@ class external_test extends externallib_advanced_testcase { 'datatype' => 'textarea', 'signup' => 1, 'visible' => 1, 'required' => 1, 'sortorder' => 2))->id; } - public function test_get_signup_settings() { + public function test_get_signup_settings(): void { global $CFG; $CFG->defaultcity = 'Bcn'; @@ -113,7 +113,7 @@ class external_test extends externallib_advanced_testcase { /** * Test get_signup_settings with mathjax in a profile field. */ - public function test_get_signup_settings_with_mathjax_in_profile_fields() { + public function test_get_signup_settings_with_mathjax_in_profile_fields(): void { // Enable MathJax filter in content and headings. $this->configure_filters([ ['name' => 'mathjaxloader', 'state' => TEXTFILTER_ON, 'move' => -1, 'applytostrings' => true], @@ -151,7 +151,7 @@ class external_test extends externallib_advanced_testcase { $this->assertEquals($fieldname, $namedarray['mathjaxname']['name']); } - public function test_signup_user() { + public function test_signup_user(): void { global $DB; $username = 'pepe'; diff --git a/auth/ldap/tests/auth_ldap_test.php b/auth/ldap/tests/auth_ldap_test.php index 2fe6a1890f0..48ee545fbf6 100644 --- a/auth/ldap/tests/auth_ldap_test.php +++ b/auth/ldap/tests/auth_ldap_test.php @@ -85,7 +85,7 @@ class auth_ldap_test extends \advanced_testcase { * @param int $pagesize Value to be configured in settings controlling page size. * @param int $subcontext Value to be configured in settings controlling searching in subcontexts. */ - public function test_auth_ldap(int $pagesize, int $subcontext) { + public function test_auth_ldap(int $pagesize, int $subcontext): void { global $DB; if (!extension_loaded('ldap')) { @@ -397,7 +397,7 @@ class auth_ldap_test extends \advanced_testcase { /** * Test logging in via LDAP calls a user_loggedin event. */ - public function test_ldap_user_loggedin_event() { + public function test_ldap_user_loggedin_event(): void { global $CFG, $DB, $USER; $this->resetAfterTest(); @@ -435,7 +435,7 @@ class auth_ldap_test extends \advanced_testcase { /** * Test logging in via LDAP calls a user_loggedin event. */ - public function test_ldap_user_signup() { + public function test_ldap_user_signup(): void { global $CFG, $DB; // User to create. diff --git a/auth/lti/tests/auth_test.php b/auth/lti/tests/auth_test.php index 2ac87189f57..4b585ef68a3 100644 --- a/auth/lti/tests/auth_test.php +++ b/auth/lti/tests/auth_test.php @@ -214,7 +214,7 @@ class auth_test extends \advanced_testcase { * @param array $expected the test case expectations. * @covers ::find_or_create_user_from_launch */ - public function test_find_or_create_user_from_launch(?array $legacydata, array $launchdata, array $expected = []) { + public function test_find_or_create_user_from_launch(?array $legacydata, array $launchdata, array $expected = []): void { $this->resetAfterTest(); global $DB; $auth = get_auth_plugin('lti'); @@ -716,7 +716,7 @@ class auth_test extends \advanced_testcase { * @covers ::find_or_create_user_from_membership */ public function test_find_or_create_user_from_membership(?array $legacydata, array $memberdata, string $iss, - ?string $legacyconsumerkey, array $expected) { + ?string $legacyconsumerkey, array $expected): void { $this->resetAfterTest(); global $DB; @@ -1051,7 +1051,7 @@ class auth_test extends \advanced_testcase { * * @covers ::create_user_binding */ - public function test_create_user_binding() { + public function test_create_user_binding(): void { $this->resetAfterTest(); global $DB; $auth = get_auth_plugin('lti'); diff --git a/auth/lti/tests/privacy/provider_test.php b/auth/lti/tests/privacy/provider_test.php index d58146f9463..d05b542b85d 100644 --- a/auth/lti/tests/privacy/provider_test.php +++ b/auth/lti/tests/privacy/provider_test.php @@ -44,7 +44,7 @@ class provider_test extends provider_testcase { * * @covers ::get_contexts_for_userid */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { $user = $this->getDataGenerator()->create_user(); $this->assertEmpty(provider::get_contexts_for_userid($user->id)); @@ -65,7 +65,7 @@ class provider_test extends provider_testcase { * * @covers ::export_user_data */ - public function test_export_user_data() { + public function test_export_user_data(): void { $user = $this->getDataGenerator()->create_user(); $auth = get_auth_plugin('lti'); $auth->create_user_binding('https://lms.example.com', 'abc123', $user->id); @@ -87,7 +87,7 @@ class provider_test extends provider_testcase { * * @covers ::delete_data_for_all_users_in_context */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; $auth = get_auth_plugin('lti'); @@ -119,7 +119,7 @@ class provider_test extends provider_testcase { * * @covers ::delete_data_for_user */ - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; $auth = get_auth_plugin('lti'); @@ -152,7 +152,7 @@ class provider_test extends provider_testcase { * * @covers ::get_users_in_context */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { $auth = get_auth_plugin('lti'); $component = 'auth_lti'; $user = $this->getDataGenerator()->create_user(); @@ -184,7 +184,7 @@ class provider_test extends provider_testcase { * * @covers ::delete_data_for_users */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { $auth = get_auth_plugin('lti'); $component = 'auth_lti'; $user1 = $this->getDataGenerator()->create_user(); diff --git a/auth/manual/tests/manual_test.php b/auth/manual/tests/manual_test.php index 77503b18e87..938d751eeb4 100644 --- a/auth/manual/tests/manual_test.php +++ b/auth/manual/tests/manual_test.php @@ -51,7 +51,7 @@ class manual_test extends \advanced_testcase { /** * Test user_update_password method. */ - public function test_user_update_password() { + public function test_user_update_password(): void { $user = $this->getDataGenerator()->create_user(); $expectedtime = time(); $passwordisupdated = $this->authplugin->user_update_password($user, 'MyNewPassword*'); @@ -66,7 +66,7 @@ class manual_test extends \advanced_testcase { /** * Test test_password_expire method. */ - public function test_password_expire() { + public function test_password_expire(): void { $userrecord = array(); $expirationtime = 31 * DAYSECS; $userrecord['timecreated'] = time() - $expirationtime; diff --git a/auth/manual/tests/privacy/provider_test.php b/auth/manual/tests/privacy/provider_test.php index 178f3673368..3e71f6fb29d 100644 --- a/auth/manual/tests/privacy/provider_test.php +++ b/auth/manual/tests/privacy/provider_test.php @@ -55,7 +55,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { * Test to check export_user_preferences. * returns user preferences data. */ - public function test_export_user_preferences() { + public function test_export_user_preferences(): void { $user = $this->getDataGenerator()->create_user(); $this->authplugin->user_update_password($user, 'MyPrivacytestPassword*'); diff --git a/auth/mnet/tests/privacy/provider_test.php b/auth/mnet/tests/privacy/provider_test.php index a41ac4de0f8..9a07caf9d67 100644 --- a/auth/mnet/tests/privacy/provider_test.php +++ b/auth/mnet/tests/privacy/provider_test.php @@ -52,7 +52,7 @@ class provider_test extends provider_testcase { /** * Check that a user context is returned if there is any user data for this user. */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { global $DB; $user = $this->getDataGenerator()->create_user(['auth' => 'mnet']); @@ -80,7 +80,7 @@ class provider_test extends provider_testcase { /** * Test that user data is exported correctly. */ - public function test_export_user_data() { + public function test_export_user_data(): void { global $DB; $user = $this->getDataGenerator()->create_user(['auth' => 'mnet']); @@ -121,7 +121,7 @@ class provider_test extends provider_testcase { /** * Test deleting all user data for a specific context. */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; $user1 = $this->getDataGenerator()->create_user(['auth' => 'mnet']); @@ -169,7 +169,7 @@ class provider_test extends provider_testcase { /** * This should work identical to the above test. */ - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; $user1 = $this->getDataGenerator()->create_user(['auth' => 'mnet']); @@ -218,7 +218,7 @@ class provider_test extends provider_testcase { /** * Test that only users with a user context are fetched. */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { global $DB; $this->resetAfterTest(); @@ -258,7 +258,7 @@ class provider_test extends provider_testcase { /** * Test that data for users in approved userlist is deleted. */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { global $DB; $this->resetAfterTest(); diff --git a/auth/oauth2/tests/api_test.php b/auth/oauth2/tests/api_test.php index f41ebecf340..1e69b3b04bb 100644 --- a/auth/oauth2/tests/api_test.php +++ b/auth/oauth2/tests/api_test.php @@ -28,7 +28,7 @@ class api_test extends \advanced_testcase { /** * Test the cleaning of orphaned linked logins for all issuers. */ - public function test_clean_orphaned_linked_logins() { + public function test_clean_orphaned_linked_logins(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -58,7 +58,7 @@ class api_test extends \advanced_testcase { /** * Test the cleaning of orphaned linked logins for a specific issuer. */ - public function test_clean_orphaned_linked_logins_with_issuer_id() { + public function test_clean_orphaned_linked_logins_with_issuer_id(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -94,7 +94,7 @@ class api_test extends \advanced_testcase { * * @covers \auth_oauth2\api::create_new_confirmed_account */ - public function test_create_new_confirmed_account() { + public function test_create_new_confirmed_account(): void { global $DB; $this->resetAfterTest(); $this->setAdminUser(); @@ -130,7 +130,7 @@ class api_test extends \advanced_testcase { /** * Test auto-confirming linked logins. */ - public function test_linked_logins() { + public function test_linked_logins(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -172,7 +172,7 @@ class api_test extends \advanced_testcase { /** * Test that is_enabled correctly identifies when the plugin is enabled. */ - public function test_is_enabled() { + public function test_is_enabled(): void { $this->resetAfterTest(); set_config('auth', 'manual,oauth2'); @@ -182,7 +182,7 @@ class api_test extends \advanced_testcase { /** * Test that is_enabled correctly identifies when the plugin is disabled. */ - public function test_is_enabled_disabled() { + public function test_is_enabled_disabled(): void { $this->resetAfterTest(); set_config('auth', 'manual'); @@ -195,7 +195,7 @@ class api_test extends \advanced_testcase { * * @covers \auth_oauth2\api::send_confirm_account_email */ - public function test_send_confirm_account_email() { + public function test_send_confirm_account_email(): void { global $DB; $this->resetAfterTest(); $this->setAdminUser(); diff --git a/auth/oauth2/tests/auth_test.php b/auth/oauth2/tests/auth_test.php index 29dc8f8b15c..6264b8bed7c 100644 --- a/auth/oauth2/tests/auth_test.php +++ b/auth/oauth2/tests/auth_test.php @@ -27,7 +27,7 @@ namespace auth_oauth2; */ class auth_test extends \advanced_testcase { - public function test_get_password_change_info() { + public function test_get_password_change_info(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(['auth' => 'oauth2']); diff --git a/auth/oauth2/tests/privacy/provider_test.php b/auth/oauth2/tests/privacy/provider_test.php index d398182fac0..05660cb84b8 100644 --- a/auth/oauth2/tests/privacy/provider_test.php +++ b/auth/oauth2/tests/privacy/provider_test.php @@ -51,7 +51,7 @@ class provider_test extends provider_testcase { /** * Check that a user context is returned if there is any user data for this user. */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { $user = $this->getDataGenerator()->create_user(); $this->assertEmpty(provider::get_contexts_for_userid($user->id)); @@ -73,7 +73,7 @@ class provider_test extends provider_testcase { /** * Test that user data is exported correctly. */ - public function test_export_user_data() { + public function test_export_user_data(): void { $user = $this->getDataGenerator()->create_user(); $issuer = \core\oauth2\api::create_standard_issuer('google'); $info = []; @@ -94,7 +94,7 @@ class provider_test extends provider_testcase { /** * Test deleting all user data for a specific context. */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; $user1 = $this->getDataGenerator()->create_user(); @@ -134,7 +134,7 @@ class provider_test extends provider_testcase { /** * This should work identical to the above test. */ - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; $user1 = $this->getDataGenerator()->create_user(); @@ -175,7 +175,7 @@ class provider_test extends provider_testcase { /** * Test that only users with a user context are fetched. */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { $this->resetAfterTest(); $component = 'auth_oauth2'; @@ -211,7 +211,7 @@ class provider_test extends provider_testcase { /** * Test that data for users in approved userlist is deleted. */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { $this->resetAfterTest(); $component = 'auth_oauth2'; diff --git a/auth/tests/digital_consent_test.php b/auth/tests/digital_consent_test.php index 8ad2d411b15..c660c358ac8 100644 --- a/auth/tests/digital_consent_test.php +++ b/auth/tests/digital_consent_test.php @@ -25,7 +25,7 @@ namespace core_auth; */ class digital_consent_test extends \advanced_testcase { - public function test_is_age_digital_consent_verification_enabled() { + public function test_is_age_digital_consent_verification_enabled(): void { global $CFG; $this->resetAfterTest(); @@ -36,7 +36,7 @@ class digital_consent_test extends \advanced_testcase { $this->assertFalse($isenabled); } - public function test_is_minor() { + public function test_is_minor(): void { global $CFG; $this->resetAfterTest(); @@ -69,7 +69,7 @@ class digital_consent_test extends \advanced_testcase { $this->assertFalse($isminor); } - public function test_parse_age_digital_consent_map_valid_format() { + public function test_parse_age_digital_consent_map_valid_format(): void { // Value of agedigitalconsentmap has a valid format. $agedigitalconsentmap = implode(PHP_EOL, [ @@ -88,7 +88,7 @@ class digital_consent_test extends \advanced_testcase { ); } - public function test_parse_age_digital_consent_map_invalid_format_missing_spaces() { + public function test_parse_age_digital_consent_map_invalid_format_missing_spaces(): void { // Value of agedigitalconsentmap has an invalid format (missing space separator between values). $agedigitalconsentmap = implode(PHP_EOL, [ @@ -102,7 +102,7 @@ class digital_consent_test extends \advanced_testcase { \core_auth\digital_consent::parse_age_digital_consent_map($agedigitalconsentmap); } - public function test_parse_age_digital_consent_map_invalid_format_missing_default_value() { + public function test_parse_age_digital_consent_map_invalid_format_missing_default_value(): void { // Value of agedigitalconsentmap has an invalid format (missing default value). $agedigitalconsentmap = implode(PHP_EOL, [ @@ -116,7 +116,7 @@ class digital_consent_test extends \advanced_testcase { \core_auth\digital_consent::parse_age_digital_consent_map($agedigitalconsentmap); } - public function test_parse_age_digital_consent_map_invalid_format_invalid_country() { + public function test_parse_age_digital_consent_map_invalid_format_invalid_country(): void { // Value of agedigitalconsentmap has an invalid format (invalid value for country). $agedigitalconsentmap = implode(PHP_EOL, [ @@ -130,7 +130,7 @@ class digital_consent_test extends \advanced_testcase { \core_auth\digital_consent::parse_age_digital_consent_map($agedigitalconsentmap); } - public function test_parse_age_digital_consent_map_invalid_format_invalid_age_string() { + public function test_parse_age_digital_consent_map_invalid_format_invalid_age_string(): void { // Value of agedigitalconsentmap has an invalid format (string value for age). $agedigitalconsentmap = implode(PHP_EOL, [ @@ -144,7 +144,7 @@ class digital_consent_test extends \advanced_testcase { \core_auth\digital_consent::parse_age_digital_consent_map($agedigitalconsentmap); } - public function test_parse_age_digital_consent_map_invalid_format_missing_age() { + public function test_parse_age_digital_consent_map_invalid_format_missing_age(): void { // Value of agedigitalconsentmap has an invalid format (missing value for age). $agedigitalconsentmap = implode(PHP_EOL, [ @@ -158,7 +158,7 @@ class digital_consent_test extends \advanced_testcase { \core_auth\digital_consent::parse_age_digital_consent_map($agedigitalconsentmap); } - public function test_parse_age_digital_consent_map_invalid_format_missing_country() { + public function test_parse_age_digital_consent_map_invalid_format_missing_country(): void { // Value of agedigitalconsentmap has an invalid format (missing value for country). $agedigitalconsentmap = implode(PHP_EOL, [ diff --git a/auth/tests/external/external_test.php b/auth/tests/external/external_test.php index 07a47aa39c6..7e79a412f40 100644 --- a/auth/tests/external/external_test.php +++ b/auth/tests/external/external_test.php @@ -75,7 +75,7 @@ class external_test extends externallib_advanced_testcase { /** * Test confirm_user */ - public function test_confirm_user() { + public function test_confirm_user(): void { global $DB; $username = 'pepe'; @@ -115,7 +115,7 @@ class external_test extends externallib_advanced_testcase { /** * Test age digital consent not enabled. */ - public function test_age_digital_consent_verification_is_not_enabled() { + public function test_age_digital_consent_verification_is_not_enabled(): void { global $CFG; $CFG->agedigitalconsentverification = 0; @@ -128,7 +128,7 @@ class external_test extends externallib_advanced_testcase { /** * Test age digital consent is enabled. */ - public function test_age_digital_consent_verification_is_enabled() { + public function test_age_digital_consent_verification_is_enabled(): void { global $CFG; $CFG->agedigitalconsentverification = 1; @@ -141,7 +141,7 @@ class external_test extends externallib_advanced_testcase { /** * Test resend_confirmation_email. */ - public function test_resend_confirmation_email() { + public function test_resend_confirmation_email(): void { global $DB; $username = 'pepe'; @@ -167,7 +167,7 @@ class external_test extends externallib_advanced_testcase { /** * Test resend_confirmation_email invalid username. */ - public function test_resend_confirmation_email_invalid_username() { + public function test_resend_confirmation_email_invalid_username(): void { $username = 'pepe'; $password = 'abcdefAª.ªª!!3'; @@ -190,7 +190,7 @@ class external_test extends externallib_advanced_testcase { /** * Test resend_confirmation_email invalid password. */ - public function test_resend_confirmation_email_invalid_password() { + public function test_resend_confirmation_email_invalid_password(): void { $username = 'pepe'; $password = 'abcdefAª.ªª!!3'; @@ -213,7 +213,7 @@ class external_test extends externallib_advanced_testcase { /** * Test resend_confirmation_email already confirmed user. */ - public function test_resend_confirmation_email_already_confirmed_user() { + public function test_resend_confirmation_email_already_confirmed_user(): void { global $DB; $username = 'pepe'; diff --git a/auth/tests/privacy/provider_test.php b/auth/tests/privacy/provider_test.php index 469acfe6ba9..a0c5f3f73b8 100644 --- a/auth/tests/privacy/provider_test.php +++ b/auth/tests/privacy/provider_test.php @@ -48,7 +48,7 @@ class provider_test extends provider_testcase { $this->resetAfterTest(); } - public function test_export_user_preferences() { + public function test_export_user_preferences(): void { $dg = $this->getDataGenerator(); $u1 = $dg->create_user(); $u2 = $dg->create_user(); diff --git a/availability/condition/completion/tests/condition_test.php b/availability/condition/completion/tests/condition_test.php index d76857fdf31..f36e36d4e5e 100644 --- a/availability/condition/completion/tests/condition_test.php +++ b/availability/condition/completion/tests/condition_test.php @@ -51,7 +51,7 @@ class condition_test extends \advanced_testcase { /** * Tests constructing and using condition as part of tree. */ - public function test_in_tree() { + public function test_in_tree(): void { global $USER, $CFG; $this->resetAfterTest(); @@ -101,7 +101,7 @@ class condition_test extends \advanced_testcase { * Tests the constructor including error conditions. Also tests the * string conversion feature (intended for debugging only). */ - public function test_constructor() { + public function test_constructor(): void { // No parameters. $structure = new \stdClass(); try { @@ -165,7 +165,7 @@ class condition_test extends \advanced_testcase { /** * Tests the save() function. */ - public function test_save() { + public function test_save(): void { $structure = (object)['cm' => 42, 'e' => COMPLETION_COMPLETE]; $cond = new condition($structure); $structure->type = 'completion'; @@ -175,7 +175,7 @@ class condition_test extends \advanced_testcase { /** * Tests the is_available and get_description functions. */ - public function test_usage() { + public function test_usage(): void { global $CFG, $DB; require_once($CFG->dirroot . '/mod/assign/locallib.php'); $this->resetAfterTest(); @@ -688,7 +688,7 @@ class condition_test extends \advanced_testcase { /** * Tests completion_value_used static function. */ - public function test_completion_value_used() { + public function test_completion_value_used(): void { global $CFG, $DB; $this->resetAfterTest(); $prevvalue = condition::OPTION_PREVIOUS; @@ -768,7 +768,7 @@ class condition_test extends \advanced_testcase { /** * Tests the update_dependency_id() function. */ - public function test_update_dependency_id() { + public function test_update_dependency_id(): void { $cond = new condition((object)[ 'cm' => 42, 'e' => COMPLETION_COMPLETE, 'selfid' => 43 ]); diff --git a/availability/condition/date/tests/condition_test.php b/availability/condition/date/tests/condition_test.php index e34f6681feb..c28abe2b92c 100644 --- a/availability/condition/date/tests/condition_test.php +++ b/availability/condition/date/tests/condition_test.php @@ -38,7 +38,7 @@ class condition_test extends \advanced_testcase { /** * Tests constructing and using date condition as part of tree. */ - public function test_in_tree() { + public function test_in_tree(): void { global $SITE, $USER, $CFG; $this->resetAfterTest(); $this->setAdminUser(); @@ -80,7 +80,7 @@ class condition_test extends \advanced_testcase { * Tests the constructor including error conditions. Also tests the * string conversion feature (intended for debugging only). */ - public function test_constructor() { + public function test_constructor(): void { // No parameters. $structure = (object)array(); try { @@ -129,7 +129,7 @@ class condition_test extends \advanced_testcase { /** * Tests the save() function. */ - public function test_save() { + public function test_save(): void { $structure = (object)array('d' => '>=', 't' => 12345); $cond = new condition($structure); $structure->type = 'date'; @@ -139,7 +139,7 @@ class condition_test extends \advanced_testcase { /** * Tests the is_available() and is_available_to_all() functions. */ - public function test_is_available() { + public function test_is_available(): void { global $SITE, $USER; $time = strtotime('2014-02-18 14:50:10 GMT'); @@ -170,7 +170,7 @@ class condition_test extends \advanced_testcase { /** * Tests the get_description and get_standalone_description functions. */ - public function test_get_description() { + public function test_get_description(): void { global $SITE, $CFG; $this->resetAfterTest(); @@ -232,7 +232,7 @@ class condition_test extends \advanced_testcase { /** * Tests the update_all_dates function. */ - public function test_update_all_dates() { + public function test_update_all_dates(): void { global $DB; $this->resetAfterTest(); diff --git a/availability/condition/grade/tests/condition_test.php b/availability/condition/grade/tests/condition_test.php index 28c0b35b0e0..6630511c10e 100644 --- a/availability/condition/grade/tests/condition_test.php +++ b/availability/condition/grade/tests/condition_test.php @@ -27,7 +27,7 @@ class condition_test extends \advanced_testcase { /** * Tests constructing and using grade condition. */ - public function test_usage() { + public function test_usage(): void { global $USER, $CFG; require_once($CFG->dirroot . '/mod/assign/locallib.php'); @@ -141,7 +141,7 @@ class condition_test extends \advanced_testcase { * Tests the constructor including error conditions. Also tests the * string conversion feature (intended for debugging only). */ - public function test_constructor() { + public function test_constructor(): void { // No parameters. $structure = new \stdClass(); try { @@ -205,7 +205,7 @@ class condition_test extends \advanced_testcase { /** * Tests the save() function. */ - public function test_save() { + public function test_save(): void { $structure = (object)array('id' => 19); $cond = new condition($structure); $structure->type = 'grade'; @@ -235,7 +235,7 @@ class condition_test extends \advanced_testcase { /** * Tests the update_dependency_id() function. */ - public function test_update_dependency_id() { + public function test_update_dependency_id(): void { $cond = new condition((object)array('id' => 123)); $this->assertFalse($cond->update_dependency_id('frogs', 123, 456)); $this->assertFalse($cond->update_dependency_id('grade_items', 12, 34)); diff --git a/availability/condition/group/tests/condition_test.php b/availability/condition/group/tests/condition_test.php index ca5cb2b609b..96c20a92d82 100644 --- a/availability/condition/group/tests/condition_test.php +++ b/availability/condition/group/tests/condition_test.php @@ -36,7 +36,7 @@ class condition_test extends \advanced_testcase { /** * Tests constructing and using condition. */ - public function test_usage() { + public function test_usage(): void { global $CFG, $USER; $this->resetAfterTest(); $CFG->enableavailability = true; @@ -115,7 +115,7 @@ class condition_test extends \advanced_testcase { * Tests the constructor including error conditions. Also tests the * string conversion feature (intended for debugging only). */ - public function test_constructor() { + public function test_constructor(): void { // Invalid id (not int). $structure = (object)array('id' => 'bourne'); try { @@ -139,7 +139,7 @@ class condition_test extends \advanced_testcase { /** * Tests the save() function. */ - public function test_save() { + public function test_save(): void { $structure = (object)array('id' => 123); $cond = new condition($structure); $structure->type = 'group'; @@ -154,7 +154,7 @@ class condition_test extends \advanced_testcase { /** * Tests the update_dependency_id() function. */ - public function test_update_dependency_id() { + public function test_update_dependency_id(): void { $cond = new condition((object)array('id' => 123)); $this->assertFalse($cond->update_dependency_id('frogs', 123, 456)); $this->assertFalse($cond->update_dependency_id('groups', 12, 34)); @@ -167,7 +167,7 @@ class condition_test extends \advanced_testcase { * Tests the filter_users (bulk checking) function. Also tests the SQL * variant get_user_list_sql. */ - public function test_filter_users() { + public function test_filter_users(): void { global $DB; $this->resetAfterTest(); diff --git a/availability/condition/grouping/tests/condition_test.php b/availability/condition/grouping/tests/condition_test.php index 0de2be5aa28..fa14191e8ba 100644 --- a/availability/condition/grouping/tests/condition_test.php +++ b/availability/condition/grouping/tests/condition_test.php @@ -36,7 +36,7 @@ class condition_test extends \advanced_testcase { /** * Tests constructing and using condition. */ - public function test_usage() { + public function test_usage(): void { global $CFG, $USER; $this->resetAfterTest(); $CFG->enableavailability = true; @@ -115,7 +115,7 @@ class condition_test extends \advanced_testcase { * Tests the constructor including error conditions. Also tests the * string conversion feature (intended for debugging only). */ - public function test_constructor() { + public function test_constructor(): void { // No parameters. $structure = new \stdClass(); try { @@ -168,7 +168,7 @@ class condition_test extends \advanced_testcase { /** * Tests the save() function. */ - public function test_save() { + public function test_save(): void { $structure = (object)array('id' => 123); $cond = new condition($structure); $structure->type = 'grouping'; @@ -183,7 +183,7 @@ class condition_test extends \advanced_testcase { /** * Tests the update_dependency_id() function. */ - public function test_update_dependency_id() { + public function test_update_dependency_id(): void { $cond = new condition((object)array('id' => 123)); $this->assertFalse($cond->update_dependency_id('frogs', 123, 456)); $this->assertFalse($cond->update_dependency_id('groupings', 12, 34)); @@ -199,7 +199,7 @@ class condition_test extends \advanced_testcase { * Tests the filter_users (bulk checking) function. Also tests the SQL * variant get_user_list_sql. */ - public function test_filter_users() { + public function test_filter_users(): void { global $DB, $CFG; $this->resetAfterTest(); $CFG->enableavailability = true; diff --git a/availability/condition/profile/tests/condition_test.php b/availability/condition/profile/tests/condition_test.php index e8a61f4bb8c..6744c939294 100644 --- a/availability/condition/profile/tests/condition_test.php +++ b/availability/condition/profile/tests/condition_test.php @@ -55,7 +55,7 @@ class condition_test extends \advanced_testcase { /** * Tests constructing and using date condition as part of tree. */ - public function test_in_tree() { + public function test_in_tree(): void { global $USER; $this->setAdminUser(); @@ -84,7 +84,7 @@ class condition_test extends \advanced_testcase { * Tests the constructor including error conditions. Also tests the * string conversion feature (intended for debugging only). */ - public function test_constructor() { + public function test_constructor(): void { // No parameters. $structure = new \stdClass(); try { @@ -188,7 +188,7 @@ class condition_test extends \advanced_testcase { /** * Tests the save() function. */ - public function test_save() { + public function test_save(): void { $structure = (object)array('cf' => 'frogtype', 'op' => condition::OP_IS_EMPTY); $cond = new condition($structure); $structure->type = 'profile'; @@ -206,7 +206,7 @@ class condition_test extends \advanced_testcase { * get_full_information because that function is called from is_available * and we test its values here. */ - public function test_is_available() { + public function test_is_available(): void { global $USER, $SITE, $DB; $this->setAdminUser(); $info = new \core_availability\mock_info(); @@ -314,7 +314,7 @@ class condition_test extends \advanced_testcase { * not be offered in the menu because their data is not included in user * object */ - public function test_custom_textarea_field() { + public function test_custom_textarea_field(): void { global $USER, $SITE, $DB; $this->setAdminUser(); $info = new \core_availability\mock_info(); @@ -396,7 +396,7 @@ class condition_test extends \advanced_testcase { /** * Tests the filter_users (bulk checking) function. */ - public function test_filter_users() { + public function test_filter_users(): void { global $DB, $CFG; $this->resetAfterTest(); $CFG->enableavailability = true; @@ -443,7 +443,7 @@ class condition_test extends \advanced_testcase { * Tests getting user list SQL. This is a different test from the above because * there is some additional code in this function so more variants need testing. */ - public function test_get_user_list_sql() { + public function test_get_user_list_sql(): void { global $DB, $CFG; $this->resetAfterTest(); $CFG->enableavailability = true; diff --git a/availability/tests/capability_checker_test.php b/availability/tests/capability_checker_test.php index b228a2f55f4..1248938bf01 100644 --- a/availability/tests/capability_checker_test.php +++ b/availability/tests/capability_checker_test.php @@ -27,7 +27,7 @@ class capability_checker_test extends \advanced_testcase { /** * Tests loading a class from /availability/classes. */ - public function test_capability_checker() { + public function test_capability_checker(): void { global $CFG, $DB; $this->resetAfterTest(); diff --git a/availability/tests/component_test.php b/availability/tests/component_test.php index 993c778361e..3634d8bacea 100644 --- a/availability/tests/component_test.php +++ b/availability/tests/component_test.php @@ -27,7 +27,7 @@ class component_test extends \advanced_testcase { /** * Tests loading a class from /availability/classes. */ - public function test_load_class() { + public function test_load_class(): void { $result = get_class_methods('\core_availability\info'); $this->assertTrue(is_array($result)); } @@ -35,7 +35,7 @@ class component_test extends \advanced_testcase { /** * Tests the plugininfo class is present and working. */ - public function test_plugin_info() { + public function test_plugin_info(): void { // This code will throw debugging information if the plugininfo class // is missing. Unfortunately it doesn't actually cause the test to // fail, but it's obvious when running test at least. diff --git a/availability/tests/info_test.php b/availability/tests/info_test.php index 0e8d01fd5b6..f2a5e9b7127 100644 --- a/availability/tests/info_test.php +++ b/availability/tests/info_test.php @@ -32,7 +32,7 @@ class info_test extends \advanced_testcase { /** * Tests the info_module class (is_available, get_full_information). */ - public function test_info_module() { + public function test_info_module(): void { global $DB, $CFG; // Create a course and pages. @@ -91,7 +91,7 @@ class info_test extends \advanced_testcase { /** * Tests the info_section class (is_available, get_full_information). */ - public function test_info_section() { + public function test_info_section(): void { global $DB; // Create a course. @@ -145,7 +145,7 @@ class info_test extends \advanced_testcase { /** * Tests the is_user_visible() static function in info_module. */ - public function test_is_user_visible() { + public function test_is_user_visible(): void { global $CFG, $DB; require_once($CFG->dirroot . '/course/lib.php'); $this->resetAfterTest(); @@ -243,7 +243,7 @@ class info_test extends \advanced_testcase { /** * Tests the convert_legacy_fields function used in restore. */ - public function test_convert_legacy_fields() { + public function test_convert_legacy_fields(): void { // Check with no availability conditions first. $rec = (object)array('availablefrom' => 0, 'availableuntil' => 0, 'groupingid' => 7, 'showavailability' => 1); @@ -310,7 +310,7 @@ class info_test extends \advanced_testcase { /** * Tests the add_legacy_availability_condition function used in restore. */ - public function test_add_legacy_availability_condition() { + public function test_add_legacy_availability_condition(): void { // Completion condition tests. $rec = (object)array('sourcecmid' => 7, 'requiredcompletion' => 1); // No previous availability, show = true. @@ -354,7 +354,7 @@ class info_test extends \advanced_testcase { /** * Tests the add_legacy_availability_field_condition function used in restore. */ - public function test_add_legacy_availability_field_condition() { + public function test_add_legacy_availability_field_condition(): void { // User field, normal operator. $rec = (object)array('userfield' => 'email', 'shortname' => null, 'operator' => 'contains', 'value' => '@'); @@ -383,7 +383,7 @@ class info_test extends \advanced_testcase { /** * Tests the filter_user_list() and get_user_list_sql() functions. */ - public function test_filter_user_list() { + public function test_filter_user_list(): void { global $CFG, $DB; require_once($CFG->dirroot . '/course/lib.php'); $this->resetAfterTest(); @@ -503,7 +503,7 @@ class info_test extends \advanced_testcase { /** * Tests the info_module class when involved in a recursive call to $cm->name. */ - public function test_info_recursive_name_call() { + public function test_info_recursive_name_call(): void { global $DB; $this->resetAfterTest(); @@ -533,7 +533,7 @@ class info_test extends \advanced_testcase { * Test for the is_available_for_all() method of the info base class. * @covers \core_availability\info_module::is_available_for_all */ - public function test_is_available_for_all() { + public function test_is_available_for_all(): void { global $CFG, $DB; $this->resetAfterTest(); $CFG->enableavailability = 0; diff --git a/availability/tests/tree_test.php b/availability/tests/tree_test.php index 3720e816f34..5972d30e908 100644 --- a/availability/tests/tree_test.php +++ b/availability/tests/tree_test.php @@ -33,7 +33,7 @@ class tree_test extends \advanced_testcase { /** * Tests constructing a tree with errors. */ - public function test_construct_errors() { + public function test_construct_errors(): void { try { new tree('frog'); $this->fail(); @@ -130,7 +130,7 @@ class tree_test extends \advanced_testcase { /** * Tests constructing a tree with plugin that does not exist (ignored). */ - public function test_construct_ignore_missing_plugin() { + public function test_construct_ignore_missing_plugin(): void { // Construct a tree with & combination of one condition that doesn't exist. $tree = new tree(tree::get_root_json(array( (object)array('type' => 'doesnotexist')), tree::OP_OR), true); @@ -141,7 +141,7 @@ class tree_test extends \advanced_testcase { /** * Tests constructing a tree with subtrees using all available operators. */ - public function test_construct_just_trees() { + public function test_construct_just_trees(): void { $structure = tree::get_root_json(array( tree::get_nested_json(array(), tree::OP_OR), tree::get_nested_json(array( @@ -154,7 +154,7 @@ class tree_test extends \advanced_testcase { /** * Tests constructing tree using the mock plugin. */ - public function test_construct_with_mock_plugin() { + public function test_construct_with_mock_plugin(): void { $structure = tree::get_root_json(array( self::mock(array('a' => true, 'm' => ''))), tree::OP_OR); $tree = new tree($structure); @@ -164,7 +164,7 @@ class tree_test extends \advanced_testcase { /** * Tests the check_available and get_result_information functions. */ - public function test_check_available() { + public function test_check_available(): void { global $USER; // Setup. @@ -359,7 +359,7 @@ class tree_test extends \advanced_testcase { /** * Tests the is_available_for_all() function. */ - public function test_is_available_for_all() { + public function test_is_available_for_all(): void { // Empty tree is always available. $structure = tree::get_root_json(array(), tree::OP_OR); $tree = new tree($structure); @@ -398,7 +398,7 @@ class tree_test extends \advanced_testcase { /** * Tests the get_full_information() function. */ - public function test_get_full_information() { + public function test_get_full_information(): void { global $PAGE; // Setup. $info = new \core_availability\mock_info(); @@ -497,7 +497,7 @@ class tree_test extends \advanced_testcase { /** * Tests the is_empty() function. */ - public function test_is_empty() { + public function test_is_empty(): void { // Tree with nothing in should be empty. $structure = tree::get_root_json(array(), tree::OP_OR); $tree = new tree($structure); @@ -512,7 +512,7 @@ class tree_test extends \advanced_testcase { /** * Tests the get_all_children() function. */ - public function test_get_all_children() { + public function test_get_all_children(): void { // Create a tree with nothing in. $structure = tree::get_root_json(array(), tree::OP_OR); $tree1 = new tree($structure); @@ -542,7 +542,7 @@ class tree_test extends \advanced_testcase { /** * Tests the update_dependency_id() function. */ - public function test_update_dependency_id() { + public function test_update_dependency_id(): void { // Create tree with structure of 3 mocks. $structure = tree::get_root_json(array( tree::get_nested_json(array( @@ -575,7 +575,7 @@ class tree_test extends \advanced_testcase { /** * Tests the filter_users function. */ - public function test_filter_users() { + public function test_filter_users(): void { $info = new \core_availability\mock_info(); $checker = new capability_checker($info->get_context()); @@ -637,7 +637,7 @@ class tree_test extends \advanced_testcase { * Tests the get_json methods in tree (which are mainly for use in testing * but might be used elsewhere). */ - public function test_get_json() { + public function test_get_json(): void { // Create a simple child object (fake). $child = (object)array('type' => 'fake'); $childstr = json_encode($child); @@ -685,7 +685,7 @@ class tree_test extends \advanced_testcase { * used. We also use higher number of condition instances to increase the * risk of the counter collision, should there remain a problem. */ - public function test_unique_sql_parameter_behaviour() { + public function test_unique_sql_parameter_behaviour(): void { global $DB; $this->resetAfterTest(); $generator = $this->getDataGenerator(); @@ -732,7 +732,7 @@ class tree_test extends \advanced_testcase { /** * Tests get_user_list_sql. */ - public function test_get_user_list_sql() { + public function test_get_user_list_sql(): void { global $DB; $this->resetAfterTest(); $generator = $this->getDataGenerator(); diff --git a/backup/controller/tests/controller_test.php b/backup/controller/tests/controller_test.php index f2ade3d6136..8c0ef914435 100644 --- a/backup/controller/tests/controller_test.php +++ b/backup/controller/tests/controller_test.php @@ -76,7 +76,7 @@ class controller_test extends \advanced_testcase { * * @covers \restore_controller::get_copy */ - public function test_restore_controller_get_copy() { + public function test_restore_controller_get_copy(): void { $copydata = (object)["some" => "copydata"]; $rc = new \restore_controller(1729, $this->courseid, backup::INTERACTIVE_NO, backup::MODE_COPY, $this->userid, backup::TARGET_NEW_COURSE, null, backup::RELEASESESSION_NO, $copydata); @@ -89,7 +89,7 @@ class controller_test extends \advanced_testcase { * * @covers \restore_controller::__construct */ - public function test_restore_controller_copy_without_copydata() { + public function test_restore_controller_copy_without_copydata(): void { $this->expectException(\restore_controller_exception::class); new \restore_controller(1729, $this->courseid, backup::INTERACTIVE_NO, backup::MODE_COPY, @@ -99,7 +99,7 @@ class controller_test extends \advanced_testcase { /* * test base_setting class */ - public function test_backup_controller() { + public function test_backup_controller(): void { // Instantiate non interactive backup_controller $bc = new mock_backup_controller(backup::TYPE_1ACTIVITY, $this->moduleid, backup::FORMAT_MOODLE, backup::INTERACTIVE_NO, backup::MODE_GENERAL, $this->userid); @@ -120,7 +120,7 @@ class controller_test extends \advanced_testcase { $this->assertTrue($newbc instanceof backup_controller); // This means checksum and load worked ok } - public function test_backup_controller_include_files() { + public function test_backup_controller_include_files(): void { // A MODE_GENERAL controller - this should include files $bc = new mock_backup_controller(backup::TYPE_1ACTIVITY, $this->moduleid, backup::FORMAT_MOODLE, backup::INTERACTIVE_NO, backup::MODE_GENERAL, $this->userid); @@ -142,7 +142,7 @@ class controller_test extends \advanced_testcase { /** * Test set kept roles method. */ - public function test_backup_controller_set_kept_roles() { + public function test_backup_controller_set_kept_roles(): void { $this->expectException(\backup_controller_exception::class); // Set up controller as a non-copy operation. @@ -155,7 +155,7 @@ class controller_test extends \advanced_testcase { /** * Tests the restore_controller. */ - public function test_restore_controller_is_executing() { + public function test_restore_controller_is_executing(): void { global $CFG; // Make a backup. @@ -202,7 +202,7 @@ class controller_test extends \advanced_testcase { /** * Test prepare copy method. */ - public function test_restore_controller_prepare_copy() { + public function test_restore_controller_prepare_copy(): void { $this->expectException(\restore_controller_exception::class); global $CFG; @@ -225,7 +225,7 @@ class controller_test extends \advanced_testcase { /** * Test restore of deadlock causing backup. */ - public function test_restore_of_deadlock_causing_backup() { + public function test_restore_of_deadlock_causing_backup(): void { global $USER, $CFG; $this->preventResetByRollback(); diff --git a/backup/converter/moodle1/tests/moodle1_converter_test.php b/backup/converter/moodle1/tests/moodle1_converter_test.php index b11f5058d11..245a53fbe40 100644 --- a/backup/converter/moodle1/tests/moodle1_converter_test.php +++ b/backup/converter/moodle1/tests/moodle1_converter_test.php @@ -92,23 +92,23 @@ class moodle1_converter_test extends \advanced_testcase { } } - public function test_detect_format() { + public function test_detect_format(): void { $detected = moodle1_converter::detect_format($this->tempdir); $this->assertEquals(backup::FORMAT_MOODLE1, $detected); } - public function test_convert_factory() { + public function test_convert_factory(): void { $converter = convert_factory::get_converter('moodle1', $this->tempdir); $this->assertInstanceOf('moodle1_converter', $converter); } - public function test_stash_storage_not_created() { + public function test_stash_storage_not_created(): void { $converter = convert_factory::get_converter('moodle1', $this->tempdir); $this->expectException(moodle1_convert_storage_exception::class); $converter->set_stash('tempinfo', 12); } - public function test_stash_requiring_empty_stash() { + public function test_stash_requiring_empty_stash(): void { $this->resetAfterTest(true); $converter = convert_factory::get_converter('moodle1', $this->tempdir); $converter->create_stash_storage(); @@ -124,7 +124,7 @@ class moodle1_converter_test extends \advanced_testcase { } } - public function test_stash_storage() { + public function test_stash_storage(): void { $this->resetAfterTest(true); $converter = convert_factory::get_converter('moodle1', $this->tempdir); $converter->create_stash_storage(); @@ -180,7 +180,7 @@ class moodle1_converter_test extends \advanced_testcase { $converter->drop_stash_storage(); } - public function test_get_stash_or_default() { + public function test_get_stash_or_default(): void { $this->resetAfterTest(true); $converter = convert_factory::get_converter('moodle1', $this->tempdir); $converter->create_stash_storage(); @@ -213,7 +213,7 @@ class moodle1_converter_test extends \advanced_testcase { $converter->drop_stash_storage(); } - public function test_get_contextid() { + public function test_get_contextid(): void { $this->resetAfterTest(true); $converter = convert_factory::get_converter('moodle1', $this->tempdir); @@ -254,7 +254,7 @@ class moodle1_converter_test extends \advanced_testcase { $converter->drop_stash_storage(); } - public function test_get_nextid() { + public function test_get_nextid(): void { $this->resetAfterTest(true); $converter = convert_factory::get_converter('moodle1', $this->tempdir); @@ -268,7 +268,7 @@ class moodle1_converter_test extends \advanced_testcase { $this->assertTrue($id2 < $id3); } - public function test_migrate_file() { + public function test_migrate_file(): void { $this->resetAfterTest(true); // set-up the file manager @@ -321,7 +321,7 @@ class moodle1_converter_test extends \advanced_testcase { $converter->drop_stash_storage(); } - public function test_migrate_directory() { + public function test_migrate_directory(): void { $this->resetAfterTest(true); // Set-up the file manager. @@ -369,7 +369,7 @@ class moodle1_converter_test extends \advanced_testcase { $converter->drop_stash_storage(); } - public function test_migrate_directory_with_trailing_slash() { + public function test_migrate_directory_with_trailing_slash(): void { $this->resetAfterTest(true); // Set-up the file manager. @@ -387,7 +387,7 @@ class moodle1_converter_test extends \advanced_testcase { $converter->drop_stash_storage(); } - public function test_convert_path() { + public function test_convert_path(): void { $path = new convert_path('foo_bar', '/ROOT/THINGS/FOO/BAR'); $this->assertEquals('foo_bar', $path->get_name()); $this->assertEquals('/ROOT/THINGS/FOO/BAR', $path->get_path()); @@ -396,7 +396,7 @@ class moodle1_converter_test extends \advanced_testcase { $this->assertEquals('on_foo_bar_end', $path->get_end_method()); } - public function test_convert_path_implicit_recipes() { + public function test_convert_path_implicit_recipes(): void { $path = new convert_path('foo_bar', '/ROOT/THINGS/FOO/BAR'); $data = array( 'ID' => 76, @@ -413,7 +413,7 @@ class moodle1_converter_test extends \advanced_testcase { $this->assertSame(null, $data['empty']); } - public function test_convert_path_explicit_recipes() { + public function test_convert_path_explicit_recipes(): void { $path = new convert_path( 'foo_bar', '/ROOT/THINGS/FOO/BAR', array( @@ -446,7 +446,7 @@ class moodle1_converter_test extends \advanced_testcase { $this->assertSame(null, $data['nothing']); } - public function test_grouped_data_on_nongrouped_convert_path() { + public function test_grouped_data_on_nongrouped_convert_path(): void { // prepare some grouped data $data = array( 'ID' => 77, @@ -475,7 +475,7 @@ class moodle1_converter_test extends \advanced_testcase { $data = $path->apply_recipes($data); } - public function test_grouped_convert_path_with_recipes() { + public function test_grouped_convert_path_with_recipes(): void { // prepare some grouped data $data = array( 'ID' => 77, @@ -513,7 +513,7 @@ class moodle1_converter_test extends \advanced_testcase { ), true); } - public function test_referenced_course_files() { + public function test_referenced_course_files(): void { $text = 'This is a text containing links to file.php as it is parsed from the backup file.

Newsdownload image
@@ -535,7 +535,7 @@ as it is parsed from the backup file.

download manual
'); } - public function test_referenced_files_urlencoded() { + public function test_referenced_files_urlencoded(): void { $text = 'This is a text containing links to file.php as it is parsed from the backup file.

Newsno space
@@ -562,7 +562,7 @@ as it is parsed from the backup file.

Download the full AVI for free! (only plus)', $text); } - public function test_question_bank_conversion() { + public function test_question_bank_conversion(): void { global $CFG; $this->resetAfterTest(true); @@ -575,13 +575,13 @@ as it is parsed from the backup file.

convert(); } - public function test_convert_run_convert() { + public function test_convert_run_convert(): void { $this->resetAfterTest(true); $converter = convert_factory::get_converter('moodle1', $this->tempdir); $converter->convert(); } - public function test_inforef_manager() { + public function test_inforef_manager(): void { $converter = convert_factory::get_converter('moodle1', $this->tempdir); $inforef = $converter->get_inforef_manager('unittest'); $inforef->add_ref('file', 45); diff --git a/backup/moodle2/tests/backup_encrypted_content_test.php b/backup/moodle2/tests/backup_encrypted_content_test.php index 5323b93cecf..2c90f40bb0e 100644 --- a/backup/moodle2/tests/backup_encrypted_content_test.php +++ b/backup/moodle2/tests/backup_encrypted_content_test.php @@ -48,7 +48,7 @@ class backup_encrypted_content_test extends \advanced_testcase { } } - public function test_encrypted_final_element() { + public function test_encrypted_final_element(): void { $this->resetAfterTest(true); diff --git a/backup/moodle2/tests/backup_xml_transformer_test.php b/backup/moodle2/tests/backup_xml_transformer_test.php index 9f061029f25..54c8656d714 100644 --- a/backup/moodle2/tests/backup_xml_transformer_test.php +++ b/backup/moodle2/tests/backup_xml_transformer_test.php @@ -83,7 +83,7 @@ class backup_xml_transformer_test extends \advanced_testcase { * @param string $content Testing content. * @param string $expected Expected result. */ - public function test_filephp_links_replace($content, $expected) { + public function test_filephp_links_replace($content, $expected): void { global $CFG; $CFG->wwwroot = 'http://test.test'; diff --git a/backup/moodle2/tests/moodle2_course_format_test.php b/backup/moodle2/tests/moodle2_course_format_test.php index 1712348315e..c2f585aebe5 100644 --- a/backup/moodle2/tests/moodle2_course_format_test.php +++ b/backup/moodle2/tests/moodle2_course_format_test.php @@ -43,7 +43,7 @@ class moodle2_course_format_test extends \advanced_testcase { * Tests a backup and restore adds the required section option data * when the same course format is used. */ - public function test_course_format_options_restore() { + public function test_course_format_options_restore(): void { global $DB, $CFG; $this->resetAfterTest(true); @@ -76,7 +76,7 @@ class moodle2_course_format_test extends \advanced_testcase { * Tests an import into the same subject successfully * restores the options without error. */ - public function test_course_format_options_import_myself() { + public function test_course_format_options_import_myself(): void { global $DB, $CFG; $this->resetAfterTest(true); @@ -114,7 +114,7 @@ class moodle2_course_format_test extends \advanced_testcase { * 1. Only the relevant options. * 2. Only the data associated with relevant options. */ - public function test_course_format_options_restore_new_format() { + public function test_course_format_options_restore_new_format(): void { global $DB, $CFG; $this->resetAfterTest(true); diff --git a/backup/moodle2/tests/moodle2_test.php b/backup/moodle2/tests/moodle2_test.php index 4e438edfee7..eaa3d78e020 100644 --- a/backup/moodle2/tests/moodle2_test.php +++ b/backup/moodle2/tests/moodle2_test.php @@ -42,7 +42,7 @@ class moodle2_test extends \advanced_testcase { * Tests the availability field on modules and sections is correctly * backed up and restored. */ - public function test_backup_availability() { + public function test_backup_availability(): void { global $DB, $CFG; $this->resetAfterTest(true); @@ -115,7 +115,7 @@ class moodle2_test extends \advanced_testcase { * ensures that a Moodle 2.6 backup with this data can still be correctly * restored. */ - public function test_restore_legacy_availability() { + public function test_restore_legacy_availability(): void { global $DB, $USER, $CFG; require_once($CFG->dirroot . '/grade/querylib.php'); require_once($CFG->libdir . '/completionlib.php'); @@ -262,7 +262,7 @@ class moodle2_test extends \advanced_testcase { * when it contains availability conditions that depend on other items in * course. */ - public function test_duplicate_availability() { + public function test_duplicate_availability(): void { global $DB, $CFG; $this->resetAfterTest(true); @@ -329,7 +329,7 @@ class moodle2_test extends \advanced_testcase { * When restoring a course, you can change the start date, which shifts other * dates. This test checks that certain dates are correctly modified. */ - public function test_restore_dates() { + public function test_restore_dates(): void { global $DB, $CFG; $this->resetAfterTest(true); @@ -387,7 +387,7 @@ class moodle2_test extends \advanced_testcase { * Test front page backup/restore and duplicate activities * @return void */ - public function test_restore_frontpage() { + public function test_restore_frontpage(): void { global $DB, $CFG, $USER; $this->resetAfterTest(true); @@ -648,7 +648,7 @@ class moodle2_test extends \advanced_testcase { /** * Backup a course with enrolment methods and restore it without user data and without enrolment methods */ - public function test_restore_without_users_without_enrolments() { + public function test_restore_without_users_without_enrolments(): void { global $DB; list($course, $newcourseid, $rc) = $this->prepare_for_enrolments_test(backup::TARGET_NEW_COURSE); @@ -673,7 +673,7 @@ class moodle2_test extends \advanced_testcase { /** * Backup a course with enrolment methods and restore it without user data with enrolment methods */ - public function test_restore_without_users_with_enrolments() { + public function test_restore_without_users_with_enrolments(): void { global $DB; list($course, $newcourseid, $rc) = $this->prepare_for_enrolments_test(backup::TARGET_NEW_COURSE, @@ -703,7 +703,7 @@ class moodle2_test extends \advanced_testcase { /** * Backup a course with enrolment methods and restore it with user data and without enrolment methods */ - public function test_restore_with_users_without_enrolments() { + public function test_restore_with_users_without_enrolments(): void { global $DB; list($course, $newcourseid, $rc) = $this->prepare_for_enrolments_test(backup::TARGET_NEW_COURSE, @@ -731,7 +731,7 @@ class moodle2_test extends \advanced_testcase { /** * Backup a course with enrolment methods and restore it with user data with enrolment methods */ - public function test_restore_with_users_with_enrolments() { + public function test_restore_with_users_with_enrolments(): void { global $DB; list($course, $newcourseid, $rc) = $this->prepare_for_enrolments_test(backup::TARGET_NEW_COURSE, @@ -761,7 +761,7 @@ class moodle2_test extends \advanced_testcase { /** * Backup a course with enrolment methods and restore it with user data with enrolment methods merging into another course */ - public function test_restore_with_users_with_enrolments_merging() { + public function test_restore_with_users_with_enrolments_merging(): void { global $DB; list($course, $newcourseid, $rc) = $this->prepare_for_enrolments_test(backup::TARGET_EXISTING_ADDING, @@ -791,7 +791,7 @@ class moodle2_test extends \advanced_testcase { /** * Backup a course with enrolment methods and restore it with user data with enrolment methods into another course deleting it's contents */ - public function test_restore_with_users_with_enrolments_deleting() { + public function test_restore_with_users_with_enrolments_deleting(): void { global $DB; list($course, $newcourseid, $rc) = $this->prepare_for_enrolments_test(backup::TARGET_EXISTING_DELETING, @@ -821,7 +821,7 @@ class moodle2_test extends \advanced_testcase { /** * Test the block instance time fields (timecreated, timemodified) through a backup and restore. */ - public function test_block_instance_times_backup() { + public function test_block_instance_times_backup(): void { global $DB; $this->resetAfterTest(); @@ -882,7 +882,7 @@ class moodle2_test extends \advanced_testcase { * When you restore a site with global search (or search indexing) turned on, then it should * add entries to the search index requests table so that the data gets indexed. */ - public function test_restore_search_index_requests() { + public function test_restore_search_index_requests(): void { global $DB, $CFG, $USER; $this->resetAfterTest(true); @@ -970,7 +970,7 @@ class moodle2_test extends \advanced_testcase { * Test restoring courses based on the backup plan. Primarily used with * the import functionality */ - public function test_restore_course_using_plan_defaults() { + public function test_restore_course_using_plan_defaults(): void { global $DB, $CFG, $USER; $this->resetAfterTest(true); @@ -1017,7 +1017,7 @@ class moodle2_test extends \advanced_testcase { * From 3.5, all question categories in each context are a child of a single top level question category for that context. * This test ensures that both Moodle 3.4 and 3.5 backups can still be correctly restored. */ - public function test_restore_question_category_34_35() { + public function test_restore_question_category_34_35(): void { global $DB, $USER, $CFG; $this->resetAfterTest(true); @@ -1078,7 +1078,7 @@ class moodle2_test extends \advanced_testcase { /** * Test the content bank content through a backup and restore. */ - public function test_contentbank_content_backup() { + public function test_contentbank_content_backup(): void { global $DB, $USER, $CFG; $this->resetAfterTest(); @@ -1109,7 +1109,7 @@ class moodle2_test extends \advanced_testcase { * @covers \backup_xapistate_structure_step * @covers \restore_xapistate_structure_step */ - public function test_xapistate_backup() { + public function test_xapistate_backup(): void { global $DB; $this->resetAfterTest(); $this->setAdminUser(); diff --git a/backup/moodle2/tests/restore_gradebook_structure_step_test.php b/backup/moodle2/tests/restore_gradebook_structure_step_test.php index a541f383cb7..aec1a12e5a1 100644 --- a/backup/moodle2/tests/restore_gradebook_structure_step_test.php +++ b/backup/moodle2/tests/restore_gradebook_structure_step_test.php @@ -63,7 +63,7 @@ class restore_gradebook_structure_step_test extends \advanced_testcase { * @param string $source The source file to test * @param string $expected The expected result of the transformation */ - public function test_rewrite_step_backup_file_for_legacy_freeze($source, $expected) { + public function test_rewrite_step_backup_file_for_legacy_freeze($source, $expected): void { $restore = $this->getMockBuilder('\restore_gradebook_structure_step') ->onlyMethods([]) ->disableOriginalConstructor() diff --git a/backup/moodle2/tests/restore_stepslib_date_test.php b/backup/moodle2/tests/restore_stepslib_date_test.php index 4c79d86a1cb..1505a3fdcd5 100644 --- a/backup/moodle2/tests/restore_stepslib_date_test.php +++ b/backup/moodle2/tests/restore_stepslib_date_test.php @@ -39,7 +39,7 @@ class restore_stepslib_date_test extends \restore_date_testcase { * Restoring a manual grade item does not result in the timecreated or * timemodified dates being changed. */ - public function test_grade_item_date_restore() { + public function test_grade_item_date_restore(): void { $course = $this->getDataGenerator()->create_course(['startdate' => time()]); @@ -98,7 +98,7 @@ class restore_stepslib_date_test extends \restore_date_testcase { * The course section timemodified date does not get rolled forward * when the course is restored. */ - public function test_course_section_date_restore() { + public function test_course_section_date_restore(): void { global $DB; // Create a course. $course = $this->getDataGenerator()->create_course(['startdate' => time()]); @@ -117,7 +117,7 @@ class restore_stepslib_date_test extends \restore_date_testcase { * Test that the timecreated and timemodified dates are not rolled forward when restoring * badge data. */ - public function test_badge_date_restore() { + public function test_badge_date_restore(): void { global $DB, $USER; // Create a course. $course = $this->getDataGenerator()->create_course(['startdate' => time()]); @@ -164,7 +164,7 @@ class restore_stepslib_date_test extends \restore_date_testcase { * Test that course calendar events timemodified field is not rolled forward * when restoring the course. */ - public function test_calendarevents_date_restore() { + public function test_calendarevents_date_restore(): void { global $USER, $DB; // Create course. $course = $this->getDataGenerator()->create_course(['startdate' => time()]); @@ -200,7 +200,7 @@ class restore_stepslib_date_test extends \restore_date_testcase { * Testing that the timeenrolled, timestarted, and timecompleted fields are not rolled forward / back * when doing a course restore. */ - public function test_course_completion_date_restore() { + public function test_course_completion_date_restore(): void { global $DB; // Create course with course completion enabled. @@ -236,7 +236,7 @@ class restore_stepslib_date_test extends \restore_date_testcase { * Testing that the grade grade date information is not changed in the gradebook when a course * restore is performed. */ - public function test_grade_grade_date_restore() { + public function test_grade_grade_date_restore(): void { global $USER, $DB; // Testing the restore of an overridden grade. list($course, $assign) = $this->create_course_and_module('assign', []); @@ -287,7 +287,7 @@ class restore_stepslib_date_test extends \restore_date_testcase { * Checking that the user completion of an activity relating to the timemodified field does not change * when doing a course restore. */ - public function test_usercompletion_date_restore() { + public function test_usercompletion_date_restore(): void { global $USER, $DB; // More completion... $course = $this->getDataGenerator()->create_course(['startdate' => time(), 'enablecompletion' => 1]); @@ -322,7 +322,7 @@ class restore_stepslib_date_test extends \restore_date_testcase { * when doing a course restore. * @covers ::backup_and_restore */ - public function test_usercompletion_view_restore() { + public function test_usercompletion_view_restore(): void { global $DB; // More completion... $course = $this->getDataGenerator()->create_course(['startdate' => time(), 'enablecompletion' => 1]); @@ -356,7 +356,7 @@ class restore_stepslib_date_test extends \restore_date_testcase { * Ensuring that the timemodified field of the question attempt steps table does not change when * a course restore is done. */ - public function test_question_attempt_steps_date_restore() { + public function test_question_attempt_steps_date_restore(): void { global $DB; $course = $this->getDataGenerator()->create_course(['startdate' => time()]); diff --git a/backup/tests/async_backup_test.php b/backup/tests/async_backup_test.php index 03b412bb43d..09a8b99d224 100644 --- a/backup/tests/async_backup_test.php +++ b/backup/tests/async_backup_test.php @@ -38,7 +38,7 @@ class async_backup_test extends \advanced_testcase { /** * Tests the asynchronous backup. */ - public function test_async_backup() { + public function test_async_backup(): void { global $CFG, $DB, $USER; $this->resetAfterTest(true); @@ -181,7 +181,7 @@ class async_backup_test extends \advanced_testcase { /** * Tests the asynchronous backup will resolve in duplicate cases. */ - public function test_complete_async_backup() { + public function test_complete_async_backup(): void { global $CFG, $DB, $USER; $this->resetAfterTest(true); diff --git a/backup/tests/async_restore_test.php b/backup/tests/async_restore_test.php index f528f9b862d..e37c230bc15 100644 --- a/backup/tests/async_restore_test.php +++ b/backup/tests/async_restore_test.php @@ -40,7 +40,7 @@ class async_restore_test extends \advanced_testcase { /** * Tests the asynchronous backup. */ - public function test_async_restore() { + public function test_async_restore(): void { global $CFG, $USER, $DB; $this->resetAfterTest(true); @@ -141,7 +141,7 @@ class async_restore_test extends \advanced_testcase { /** * Tests the asynchronous restore will resolve in duplicate cases where the controller is already removed. */ - public function test_async_restore_missing_controller() { + public function test_async_restore_missing_controller(): void { global $CFG, $USER, $DB; $this->resetAfterTest(true); diff --git a/backup/tests/automated_backup_test.php b/backup/tests/automated_backup_test.php index 42fdd102374..3ad4d875be9 100644 --- a/backup/tests/automated_backup_test.php +++ b/backup/tests/automated_backup_test.php @@ -95,7 +95,7 @@ class automated_backup_test extends \advanced_testcase { /** * Tests the automated backup run when the there is course backup should be skipped. */ - public function test_automated_backup_skipped_run() { + public function test_automated_backup_skipped_run(): void { global $DB; // Enable automated back up. @@ -131,7 +131,7 @@ class automated_backup_test extends \advanced_testcase { /** * Tests the automated backup run when the there is course backup can be pushed to adhoc task. */ - public function test_automated_backup_push_run() { + public function test_automated_backup_push_run(): void { global $DB; // Enable automated back up. @@ -171,7 +171,7 @@ class automated_backup_test extends \advanced_testcase { /** * Tests the automated backup inactive run. */ - public function test_inactive_run() { + public function test_inactive_run(): void { backup_cron_automated_helper::run_automated_backup(); $this->expectOutputString("Checking automated backup status...INACTIVE\n"); } @@ -179,7 +179,7 @@ class automated_backup_test extends \advanced_testcase { /** * Tests the invisible course being skipped. */ - public function test_should_skip_invisible_course() { + public function test_should_skip_invisible_course(): void { global $DB; set_config('backup_auto_active', true, 'backup'); @@ -209,7 +209,7 @@ class automated_backup_test extends \advanced_testcase { /** * Tests the not modified course being skipped. */ - public function test_should_skip_not_modified_course_in_days() { + public function test_should_skip_not_modified_course_in_days(): void { global $DB; set_config('backup_auto_active', true, 'backup'); @@ -243,7 +243,7 @@ class automated_backup_test extends \advanced_testcase { /** * Tests the backup not modified course being skipped. */ - public function test_should_skip_not_modified_course_since_prev() { + public function test_should_skip_not_modified_course_since_prev(): void { global $DB; set_config('backup_auto_active', true, 'backup'); @@ -277,7 +277,7 @@ class automated_backup_test extends \advanced_testcase { /** * Test the task completes when coureid is missing. */ - public function test_task_complete_when_courseid_is_missing() { + public function test_task_complete_when_courseid_is_missing(): void { global $DB; $admin = get_admin(); $classobject = $this->backupcronautomatedhelper->return_this(); @@ -309,7 +309,7 @@ class automated_backup_test extends \advanced_testcase { /** * Test the task completes when backup course is missing. */ - public function test_task_complete_when_backup_course_is_missing() { + public function test_task_complete_when_backup_course_is_missing(): void { global $DB; $admin = get_admin(); $classobject = $this->backupcronautomatedhelper->return_this(); diff --git a/backup/tests/backup_cleanup_task_test.php b/backup/tests/backup_cleanup_task_test.php index 0a10bd65ccd..5ce2f404d6b 100644 --- a/backup/tests/backup_cleanup_task_test.php +++ b/backup/tests/backup_cleanup_task_test.php @@ -62,7 +62,7 @@ class backup_cleanup_task_test extends \advanced_testcase { /** * Test the task idle run. Nothing should explode. */ - public function test_backup_cleanup_task_idle() { + public function test_backup_cleanup_task_idle(): void { $task = new \core\task\backup_cleanup_task(); $task->execute(); } @@ -70,7 +70,7 @@ class backup_cleanup_task_test extends \advanced_testcase { /** * Test the task exits when backup | loglifetime setting is not set. */ - public function test_backup_cleanup_task_exits() { + public function test_backup_cleanup_task_exits(): void { set_config('loglifetime', 0, 'backup'); $task = new \core\task\backup_cleanup_task(); ob_start(); @@ -83,7 +83,7 @@ class backup_cleanup_task_test extends \advanced_testcase { /** * Test the task deletes records from DB. */ - public function test_backup_cleanup_task_deletes_records() { + public function test_backup_cleanup_task_deletes_records(): void { global $DB; // Create a course. @@ -115,7 +115,7 @@ class backup_cleanup_task_test extends \advanced_testcase { /** * Test the task deletes files from file system. */ - public function test_backup_cleanup_task_deletes_files() { + public function test_backup_cleanup_task_deletes_files(): void { global $CFG; // Create a course. diff --git a/backup/tests/externallib_test.php b/backup/tests/externallib_test.php index fed9e126755..1318005da3f 100644 --- a/backup/tests/externallib_test.php +++ b/backup/tests/externallib_test.php @@ -58,7 +58,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test getting course copy progress. */ - public function test_get_copy_progress() { + public function test_get_copy_progress(): void { global $USER; $this->setAdminUser(); @@ -124,7 +124,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test ajax submission of course copy process. */ - public function test_submit_copy_form() { + public function test_submit_copy_form(): void { global $DB; $this->setAdminUser(); diff --git a/backup/tests/privacy/provider_test.php b/backup/tests/privacy/provider_test.php index 11627c5e26e..5e3379f26b8 100644 --- a/backup/tests/privacy/provider_test.php +++ b/backup/tests/privacy/provider_test.php @@ -39,7 +39,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test getting the context for the user ID related to this plugin. */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { global $DB; $this->resetAfterTest(); @@ -77,7 +77,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::export_user_data(). */ - public function test_export_for_context() { + public function test_export_for_context(): void { global $DB; $this->resetAfterTest(); @@ -167,7 +167,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::delete_data_for_all_users_in_context(). */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; $this->resetAfterTest(); @@ -232,7 +232,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::delete_data_for_user(). */ - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; $this->resetAfterTest(); @@ -304,7 +304,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test that only users with a course and module context are fetched. */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { global $DB; $this->resetAfterTest(); @@ -394,7 +394,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test that data for users in approved userlist is deleted. */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { global $DB; $this->resetAfterTest(); diff --git a/backup/tests/quiz_restore_decode_links_test.php b/backup/tests/quiz_restore_decode_links_test.php index e4117d508d9..0cc42ef2f9e 100644 --- a/backup/tests/quiz_restore_decode_links_test.php +++ b/backup/tests/quiz_restore_decode_links_test.php @@ -36,7 +36,7 @@ class quiz_restore_decode_links_test extends \advanced_testcase { /** * Test restore_decode_rule class */ - public function test_restore_quiz_decode_links() { + public function test_restore_quiz_decode_links(): void { global $DB, $CFG, $USER; $this->resetAfterTest(true); diff --git a/backup/util/checks/tests/checks_test.php b/backup/util/checks/tests/checks_test.php index d94f7eff417..ace3a8b749e 100644 --- a/backup/util/checks/tests/checks_test.php +++ b/backup/util/checks/tests/checks_test.php @@ -69,7 +69,7 @@ class checks_test extends \advanced_testcase { /* * test backup_check class */ - public function test_backup_check() { + public function test_backup_check(): void { // Check against existing course module/section course or fail $this->assertTrue(backup_check::check_id(backup::TYPE_1ACTIVITY, $this->moduleid)); diff --git a/backup/util/dbops/tests/backup_dbops_test.php b/backup/util/dbops/tests/backup_dbops_test.php index e644b42d88c..12e9a9316d6 100644 --- a/backup/util/dbops/tests/backup_dbops_test.php +++ b/backup/util/dbops/tests/backup_dbops_test.php @@ -74,14 +74,14 @@ class backup_dbops_test extends \advanced_testcase { /* * test backup_ops class */ - function test_backup_dbops() { + function test_backup_dbops(): void { // Nothing to do here, abstract class + exception, will be tested by the rest } /* * test backup_controller_dbops class */ - function test_backup_controller_dbops() { + function test_backup_controller_dbops(): void { global $DB; $dbman = $DB->get_manager(); // Going to use some database_manager services for testing @@ -175,7 +175,7 @@ class backup_dbops_test extends \advanced_testcase { /** * Check backup_includes_files */ - function test_backup_controller_dbops_includes_files() { + function test_backup_controller_dbops_includes_files(): void { global $DB; $dbman = $DB->get_manager(); // Going to use some database_manager services for testing diff --git a/backup/util/dbops/tests/restore_dbops_test.php b/backup/util/dbops/tests/restore_dbops_test.php index 2be84704e08..389a9814366 100644 --- a/backup/util/dbops/tests/restore_dbops_test.php +++ b/backup/util/dbops/tests/restore_dbops_test.php @@ -39,7 +39,7 @@ class restore_dbops_test extends \advanced_testcase { * Note that those private implementations are tested here by using the public * backup_ids API and later performing low-level tests. */ - public function test_backup_ids_cached() { + public function test_backup_ids_cached(): void { global $DB; $dbman = $DB->get_manager(); // We are going to use database_manager services. @@ -309,7 +309,7 @@ class restore_dbops_test extends \advanced_testcase { * @param bool $samesite * @param mixed $outcome **/ - public function test_precheck_user($dbuser, $backupuser, $samesite, $outcome) { + public function test_precheck_user($dbuser, $backupuser, $samesite, $outcome): void { global $DB; $this->resetAfterTest(); diff --git a/backup/util/destinations/tests/destinations_test.php b/backup/util/destinations/tests/destinations_test.php index ef0b4f346f7..a907c680af2 100644 --- a/backup/util/destinations/tests/destinations_test.php +++ b/backup/util/destinations/tests/destinations_test.php @@ -27,13 +27,13 @@ class destinations_test extends \basic_testcase { /** * test backup_destination class */ - function test_backup_destination() { + function test_backup_destination(): void { } /** * test backup_destination_osfs class */ - function test_backup_destination_osfs() { + function test_backup_destination_osfs(): void { } } diff --git a/backup/util/factories/tests/factories_test.php b/backup/util/factories/tests/factories_test.php index d67f6defc02..d22fc552299 100644 --- a/backup/util/factories/tests/factories_test.php +++ b/backup/util/factories/tests/factories_test.php @@ -61,7 +61,7 @@ class factories_test extends \advanced_testcase { /** * test get_logger_chain() method */ - public function test_backup_factory() { + public function test_backup_factory(): void { global $CFG; // Default instantiate, all levels = backup::LOG_NONE diff --git a/backup/util/helper/tests/async_helper_test.php b/backup/util/helper/tests/async_helper_test.php index 8fd9b48c583..d25e94d6208 100644 --- a/backup/util/helper/tests/async_helper_test.php +++ b/backup/util/helper/tests/async_helper_test.php @@ -39,7 +39,7 @@ class async_helper_test extends \advanced_testcase { /** * Tests sending message for asynchronous backup. */ - public function test_send_message() { + public function test_send_message(): void { global $DB, $USER; $this->preventResetByRollback(); $this->resetAfterTest(true); @@ -93,7 +93,7 @@ class async_helper_test extends \advanced_testcase { /** * Tests getting the asynchronous backup table items. */ - public function test_get_async_backups() { + public function test_get_async_backups(): void { global $DB, $CFG, $USER, $PAGE; $this->resetAfterTest(true); @@ -150,7 +150,7 @@ class async_helper_test extends \advanced_testcase { /** * Tests getting the backup record. */ - public function test_get_backup_record() { + public function test_get_backup_record(): void { global $USER; $this->resetAfterTest(); @@ -172,7 +172,7 @@ class async_helper_test extends \advanced_testcase { /** * Tests is async pending conditions. */ - public function test_is_async_pending() { + public function test_is_async_pending(): void { global $USER; $this->resetAfterTest(); @@ -203,7 +203,7 @@ class async_helper_test extends \advanced_testcase { /** * Tests is async pending conditions for course copies. */ - public function test_is_async_pending_copy() { + public function test_is_async_pending_copy(): void { global $USER; $this->resetAfterTest(); diff --git a/backup/util/helper/tests/backup_encode_content_test.php b/backup/util/helper/tests/backup_encode_content_test.php index 570c22440ab..f4145efdd64 100644 --- a/backup/util/helper/tests/backup_encode_content_test.php +++ b/backup/util/helper/tests/backup_encode_content_test.php @@ -41,7 +41,7 @@ class backup_encode_content_test extends \basic_testcase { /** * Test the encode_content_links method for course. */ - public function test_course_encode_content_links() { + public function test_course_encode_content_links(): void { global $CFG; $httpsroot = "https://moodle.org"; $httproot = "http://moodle.org"; diff --git a/backup/util/helper/tests/converterhelper_test.php b/backup/util/helper/tests/converterhelper_test.php index 6086c10f08a..6c7a365576a 100644 --- a/backup/util/helper/tests/converterhelper_test.php +++ b/backup/util/helper/tests/converterhelper_test.php @@ -44,7 +44,7 @@ require_once($CFG->dirroot . '/backup/util/helper/convert_helper.class.php'); */ class converterhelper_test extends \basic_testcase { - public function test_choose_conversion_path() { + public function test_choose_conversion_path(): void { // no converters available $descriptions = array(); diff --git a/backup/util/helper/tests/copy_helper_test.php b/backup/util/helper/tests/copy_helper_test.php index 7694343658b..86cbd82c51d 100644 --- a/backup/util/helper/tests/copy_helper_test.php +++ b/backup/util/helper/tests/copy_helper_test.php @@ -149,7 +149,7 @@ class copy_helper_test extends \advanced_testcase { * * @covers ::process_formdata */ - public function test_process_formdata_missing_fields() { + public function test_process_formdata_missing_fields(): void { $this->expectException(\moodle_exception::class); \copy_helper::process_formdata(new \stdClass); } @@ -159,7 +159,7 @@ class copy_helper_test extends \advanced_testcase { * * @covers ::process_formdata */ - public function test_process_formdata() { + public function test_process_formdata(): void { $validformdata = [ 'courseid' => 1729, 'fullname' => 'Taxicab Numbers', @@ -195,7 +195,7 @@ class copy_helper_test extends \advanced_testcase { * * @covers ::cleanup_orphaned_copy_controllers */ - public function test_cleanup_orphaned_copy_controllers() { + public function test_cleanup_orphaned_copy_controllers(): void { global $DB; // Mock up the form data. @@ -289,7 +289,7 @@ class copy_helper_test extends \advanced_testcase { * * @covers ::create_copy */ - public function test_create_copy() { + public function test_create_copy(): void { // Mock up the form data. $formdata = new \stdClass; @@ -342,7 +342,7 @@ class copy_helper_test extends \advanced_testcase { * * @covers ::get_copies */ - public function test_get_copies() { + public function test_get_copies(): void { global $USER; // Mock up the form data. @@ -416,7 +416,7 @@ class copy_helper_test extends \advanced_testcase { * * @covers ::get_copies */ - public function test_get_copies_invalid_state() { + public function test_get_copies_invalid_state(): void { global $DB, $USER; // Mock up the form data. @@ -475,7 +475,7 @@ class copy_helper_test extends \advanced_testcase { * * @covers ::get_copies */ - public function test_get_copies_course() { + public function test_get_copies_course(): void { global $USER; // Mock up the form data. @@ -507,7 +507,7 @@ class copy_helper_test extends \advanced_testcase { * * @covers ::get_copies */ - public function test_get_copies_course_deleted() { + public function test_get_copies_course_deleted(): void { global $USER; // Mock up the form data. @@ -539,7 +539,7 @@ class copy_helper_test extends \advanced_testcase { /** * Test course copy. */ - public function test_course_copy() { + public function test_course_copy(): void { global $DB; // Mock up the form data. @@ -616,7 +616,7 @@ class copy_helper_test extends \advanced_testcase { /** * Test course copy, not including any users (or data). */ - public function test_course_copy_no_users() { + public function test_course_copy_no_users(): void { global $DB; // Mock up the form data. @@ -685,7 +685,7 @@ class copy_helper_test extends \advanced_testcase { /** * Test course copy, including students and their data. */ - public function test_course_copy_students_data() { + public function test_course_copy_students_data(): void { global $DB; // Mock up the form data. @@ -754,7 +754,7 @@ class copy_helper_test extends \advanced_testcase { /** * Test course copy, not including any users (or data). */ - public function test_course_copy_no_data() { + public function test_course_copy_no_data(): void { global $DB; // Mock up the form data. @@ -822,7 +822,7 @@ class copy_helper_test extends \advanced_testcase { /** * Test instantiation with incomplete formdata. */ - public function test_malformed_instantiation() { + public function test_malformed_instantiation(): void { // Mock up the form data, missing things so we get an exception. $formdata = new \stdClass; $formdata->courseid = $this->course->id; diff --git a/backup/util/helper/tests/cronhelper_test.php b/backup/util/helper/tests/cronhelper_test.php index 23ed6687dd4..d83f80f26ac 100644 --- a/backup/util/helper/tests/cronhelper_test.php +++ b/backup/util/helper/tests/cronhelper_test.php @@ -47,7 +47,7 @@ class cronhelper_test extends \advanced_testcase { /** * Test {@link backup_cron_automated_helper::calculate_next_automated_backup}. */ - public function test_next_automated_backup() { + public function test_next_automated_backup(): void { global $CFG; $this->resetAfterTest(); @@ -260,7 +260,7 @@ class cronhelper_test extends \advanced_testcase { /** * Test {@link backup_cron_automated_helper::get_backups_to_delete}. */ - public function test_get_backups_to_delete() { + public function test_get_backups_to_delete(): void { $this->resetAfterTest(); // Active only backup_auto_max_kept config to 2 days. set_config('backup_auto_max_kept', '2', 'backup'); @@ -336,7 +336,7 @@ class cronhelper_test extends \advanced_testcase { /** * Test {@link backup_cron_automated_helper::is_course_modified}. */ - public function test_is_course_modified() { + public function test_is_course_modified(): void { $this->resetAfterTest(); $this->preventResetByRollback(); @@ -408,7 +408,7 @@ class cronhelper_test extends \advanced_testcase { /** * Test the selection and ordering of courses to be backed up. */ - public function test_get_courses() { + public function test_get_courses(): void { $this->resetAfterTest(); list($course1, $course2, $course3, $course4) = $this->course_setup(); @@ -444,7 +444,7 @@ class cronhelper_test extends \advanced_testcase { * Test the selection and ordering of courses to be backed up. * Where it is not yet time to start backups for courses with existing backups. */ - public function test_get_courses_starttime() { + public function test_get_courses_starttime(): void { $this->resetAfterTest(); list($course1, $course2, $course3, $course4) = $this->course_setup(); diff --git a/backup/util/helper/tests/decode_test.php b/backup/util/helper/tests/decode_test.php index 772c0ec2256..75830be23f4 100644 --- a/backup/util/helper/tests/decode_test.php +++ b/backup/util/helper/tests/decode_test.php @@ -46,7 +46,7 @@ class decode_test extends \basic_testcase { /** * test restore_decode_rule class */ - function test_restore_decode_rule() { + function test_restore_decode_rule(): void { // Test various incorrect constructors try { @@ -160,14 +160,14 @@ class decode_test extends \basic_testcase { /** * test restore_decode_content class */ - function test_restore_decode_content() { + function test_restore_decode_content(): void { // TODO: restore_decode_content tests } /** * test restore_decode_processor class */ - function test_restore_decode_processor() { + function test_restore_decode_processor(): void { // TODO: restore_decode_processor tests } } diff --git a/backup/util/helper/tests/helper_test.php b/backup/util/helper/tests/helper_test.php index fe1392764c6..9de0ae4237b 100644 --- a/backup/util/helper/tests/helper_test.php +++ b/backup/util/helper/tests/helper_test.php @@ -38,12 +38,12 @@ class helper_test extends \basic_testcase { /* * test backup_helper class */ - function test_backup_helper() { + function test_backup_helper(): void { } /* * test backup_general_helper class */ - function test_backup_general_helper() { + function test_backup_general_helper(): void { } } diff --git a/backup/util/helper/tests/restore_log_rule_test.php b/backup/util/helper/tests/restore_log_rule_test.php index 83c004ffc1b..01bcfab2cb8 100644 --- a/backup/util/helper/tests/restore_log_rule_test.php +++ b/backup/util/helper/tests/restore_log_rule_test.php @@ -34,7 +34,7 @@ require_once($CFG->dirroot . '/backup/util/includes/restore_includes.php'); */ class restore_log_rule_test extends \basic_testcase { - function test_process_keeps_log_unmodified() { + function test_process_keeps_log_unmodified(): void { // Prepare a tiny log entry. $originallog = new \stdClass(); @@ -54,7 +54,7 @@ class restore_log_rule_test extends \basic_testcase { $this->assertEquals($originallog, $log); } - public function test_build_regexp() { + public function test_build_regexp(): void { $original = 'Any (string) with [placeholders] like {this} and {this}. [end].'; $expectation = '~Any \(string\) with (.*) like (.*) and (.*)\. (.*)\.~'; diff --git a/backup/util/helper/tests/restore_structure_parser_processor_test.php b/backup/util/helper/tests/restore_structure_parser_processor_test.php index a5239a10c3e..7f74ec7cef1 100644 --- a/backup/util/helper/tests/restore_structure_parser_processor_test.php +++ b/backup/util/helper/tests/restore_structure_parser_processor_test.php @@ -123,7 +123,7 @@ class restore_structure_parser_processor_test extends advanced_testcase { * @param string $expected Expected result. * @param bool $slasharguments A value for $CFG->slasharguments setting. */ - public function test_process_cdata($content, $expected, $slasharguments) { + public function test_process_cdata($content, $expected, $slasharguments): void { global $CFG; $CFG->slasharguments = $slasharguments; diff --git a/backup/util/loggers/tests/logger_test.php b/backup/util/loggers/tests/logger_test.php index bbcdc4fcedb..4b7052b2803 100644 --- a/backup/util/loggers/tests/logger_test.php +++ b/backup/util/loggers/tests/logger_test.php @@ -60,7 +60,7 @@ class logger_test extends \basic_testcase { /** * test base_logger class */ - function test_base_logger() { + function test_base_logger(): void { // Test logger with simple action (message * level) $lo = new mock_base_logger1(backup::LOG_ERROR); $msg = 13; @@ -141,7 +141,7 @@ class logger_test extends \basic_testcase { /** * test error_log_logger class */ - function test_error_log_logger() { + function test_error_log_logger(): void { // Not much really to test, just instantiate and execute, should return true $lo = new error_log_logger(backup::LOG_ERROR); $this->assertTrue($lo instanceof error_log_logger); @@ -153,7 +153,7 @@ class logger_test extends \basic_testcase { /** * test output_text_logger class */ - function test_output_text_logger() { + function test_output_text_logger(): void { // Instantiate without date nor level output $lo = new output_text_logger(backup::LOG_ERROR); $this->assertTrue($lo instanceof output_text_logger); @@ -183,7 +183,7 @@ class logger_test extends \basic_testcase { /** * test output_indented_logger class */ - function test_output_indented_logger() { + function test_output_indented_logger(): void { // Instantiate without date nor level output $options = array('depth' => 2); $lo = new output_indented_logger(backup::LOG_ERROR); @@ -226,7 +226,7 @@ class logger_test extends \basic_testcase { /** * test database_logger class */ - function test_database_logger() { + function test_database_logger(): void { // Instantiate with date and level output (and with specs from the global moodle "log" table so checks will pass $now = time(); $datecol = 'time'; @@ -250,7 +250,7 @@ class logger_test extends \basic_testcase { /** * test file_logger class */ - function test_file_logger() { + function test_file_logger(): void { global $CFG; $file = $CFG->tempdir . '/test/test_file_logger.txt'; diff --git a/backup/util/plan/tests/plan_test.php b/backup/util/plan/tests/plan_test.php index 8c9c9c9bbec..54861dec22a 100644 --- a/backup/util/plan/tests/plan_test.php +++ b/backup/util/plan/tests/plan_test.php @@ -66,7 +66,7 @@ class plan_test extends \advanced_testcase { /** * test base_plan class */ - function test_base_plan() { + function test_base_plan(): void { // Instantiate $bp = new \mock_base_plan('name'); @@ -81,7 +81,7 @@ class plan_test extends \advanced_testcase { /** * test backup_plan class */ - function test_backup_plan() { + function test_backup_plan(): void { // We need one (non interactive) controller for instantiating plan $bc = new backup_controller(backup::TYPE_1ACTIVITY, $this->moduleid, backup::FORMAT_MOODLE, @@ -101,7 +101,7 @@ class plan_test extends \advanced_testcase { /** * wrong base_plan class tests */ - function test_base_plan_wrong() { + function test_base_plan_wrong(): void { // We need one (non interactive) controller for instantiating plan $bc = new backup_controller(backup::TYPE_1ACTIVITY, $this->moduleid, backup::FORMAT_MOODLE, @@ -121,7 +121,7 @@ class plan_test extends \advanced_testcase { /** * wrong backup_plan class tests */ - function test_backup_plan_wrong() { + function test_backup_plan_wrong(): void { // Try to pass one wrong controller try { diff --git a/backup/util/plan/tests/step_test.php b/backup/util/plan/tests/step_test.php index 81c62b3c3fc..31fe98ef36b 100644 --- a/backup/util/plan/tests/step_test.php +++ b/backup/util/plan/tests/step_test.php @@ -74,7 +74,7 @@ class step_test extends \advanced_testcase { /** * test base_step class */ - function test_base_step() { + function test_base_step(): void { $bp = new \mock_base_plan('planname'); // We need one plan $bt = new \mock_base_task('taskname', $bp); // We need one task @@ -87,7 +87,7 @@ class step_test extends \advanced_testcase { /** * test backup_step class */ - function test_backup_step() { + function test_backup_step(): void { // We need one (non interactive) controller for instatiating plan $bc = new backup_controller(backup::TYPE_1ACTIVITY, $this->moduleid, backup::FORMAT_MOODLE, @@ -107,7 +107,7 @@ class step_test extends \advanced_testcase { /** * test restore_step class, decrypt method */ - public function test_restore_step_decrypt() { + public function test_restore_step_decrypt(): void { $this->resetAfterTest(true); @@ -153,7 +153,7 @@ class step_test extends \advanced_testcase { /** * test backup_structure_step class */ - function test_backup_structure_step() { + function test_backup_structure_step(): void { global $CFG; $file = $CFG->tempdir . '/test/test_backup_structure_step.txt'; @@ -200,7 +200,7 @@ class step_test extends \advanced_testcase { /** * Verify the add_plugin_structure() backup method behavior and created structures. */ - public function test_backup_structure_step_add_plugin_structure() { + public function test_backup_structure_step_add_plugin_structure(): void { // Create mocked task, step and element. $bt = new \mock_backup_task_basepath('taskname'); $bs = new \mock_backup_structure_step('steptest', null, $bt); @@ -227,7 +227,7 @@ class step_test extends \advanced_testcase { /** * Verify the add_subplugin_structure() backup method behavior and created structures. */ - public function test_backup_structure_step_add_subplugin_structure() { + public function test_backup_structure_step_add_subplugin_structure(): void { // Create mocked task, step and element. $bt = new \mock_backup_task_basepath('taskname'); $bs = new \mock_backup_structure_step('steptest', null, $bt); @@ -310,7 +310,7 @@ class step_test extends \advanced_testcase { /** * Verify the add_plugin_structure() restore method behavior and created structures. */ - public function test_restore_structure_step_add_plugin_structure() { + public function test_restore_structure_step_add_plugin_structure(): void { // Create mocked task, step and element. $bt = new \mock_restore_task_basepath('taskname'); $bs = new \mock_restore_structure_step('steptest', null, $bt); @@ -348,7 +348,7 @@ class step_test extends \advanced_testcase { /** * Verify the add_subplugin_structure() restore method behavior and created structures. */ - public function test_restore_structure_step_add_subplugin_structure() { + public function test_restore_structure_step_add_subplugin_structure(): void { // Create mocked task, step and element. $bt = new \mock_restore_task_basepath('taskname'); $bs = new \mock_restore_structure_step('steptest', null, $bt); @@ -454,7 +454,7 @@ class step_test extends \advanced_testcase { /** * wrong base_step class tests */ - function test_base_step_wrong() { + function test_base_step_wrong(): void { // Try to pass one wrong task try { @@ -469,7 +469,7 @@ class step_test extends \advanced_testcase { /** * wrong backup_step class tests */ - function test_backup_test_wrong() { + function test_backup_test_wrong(): void { // Try to pass one wrong task try { diff --git a/backup/util/plan/tests/task_test.php b/backup/util/plan/tests/task_test.php index b928222e90b..023c08c0afc 100644 --- a/backup/util/plan/tests/task_test.php +++ b/backup/util/plan/tests/task_test.php @@ -66,7 +66,7 @@ class task_test extends \advanced_testcase { /** * test base_task class */ - function test_base_task() { + function test_base_task(): void { $bp = new \mock_base_plan('planname'); // We need one plan // Instantiate @@ -82,7 +82,7 @@ class task_test extends \advanced_testcase { /** * test backup_task class */ - function test_backup_task() { + function test_backup_task(): void { // We need one (non interactive) controller for instatiating plan $bc = new backup_controller(backup::TYPE_1ACTIVITY, $this->moduleid, backup::FORMAT_MOODLE, @@ -104,7 +104,7 @@ class task_test extends \advanced_testcase { /** * wrong base_task class tests */ - function test_base_task_wrong() { + function test_base_task_wrong(): void { // Try to pass one wrong plan try { @@ -132,7 +132,7 @@ class task_test extends \advanced_testcase { /** * wrong backup_task class tests */ - function test_backup_task_wrong() { + function test_backup_task_wrong(): void { // Try to pass one wrong plan try { diff --git a/backup/util/settings/tests/settings_test.php b/backup/util/settings/tests/settings_test.php index a11279ca419..c9779a8b912 100644 --- a/backup/util/settings/tests/settings_test.php +++ b/backup/util/settings/tests/settings_test.php @@ -63,7 +63,7 @@ class settings_test extends \basic_testcase { /** * test base_setting class */ - public function test_base_setting() { + public function test_base_setting(): void { // Instantiate base_setting and check everything $bs = new mock_base_setting('test', base_setting::IS_BOOLEAN); $this->assertTrue($bs instanceof base_setting); @@ -312,7 +312,7 @@ class settings_test extends \basic_testcase { * Test that locked and unlocked states on dependent backup settings at the same level * correctly do not flow from the parent to the child setting when the setting is locked by permissions. */ - public function test_dependency_empty_locked_by_permission_child_is_not_unlocked() { + public function test_dependency_empty_locked_by_permission_child_is_not_unlocked(): void { // Check dependencies are working ok. $bs1 = new mock_backup_setting('test1', base_setting::IS_INTEGER, 2); $bs1->set_level(1); @@ -336,7 +336,7 @@ class settings_test extends \basic_testcase { * Test that locked and unlocked states on dependent backup settings at the same level * correctly do flow from the parent to the child setting when the setting is locked by config. */ - public function test_dependency_not_empty_locked_by_config_parent_is_unlocked() { + public function test_dependency_not_empty_locked_by_config_parent_is_unlocked(): void { $bs1 = new mock_backup_setting('test1', base_setting::IS_INTEGER, 0); $bs1->set_level(1); $bs2 = new mock_backup_setting('test2', base_setting::IS_INTEGER, 0); @@ -355,7 +355,7 @@ class settings_test extends \basic_testcase { /** * test backup_setting class */ - public function test_backup_setting() { + public function test_backup_setting(): void { // Instantiate backup_setting class and set level $bs = new mock_backup_setting('test', base_setting::IS_INTEGER, null); $bs->set_level(1); @@ -402,7 +402,7 @@ class settings_test extends \basic_testcase { /** * test activity_backup_setting class */ - public function test_activity_backup_setting() { + public function test_activity_backup_setting(): void { $bs = new mock_activity_backup_setting('test', base_setting::IS_INTEGER, null); $this->assertEquals($bs->get_level(), backup_setting::ACTIVITY_LEVEL); @@ -417,7 +417,7 @@ class settings_test extends \basic_testcase { /** * test section_backup_setting class */ - public function test_section_backup_setting() { + public function test_section_backup_setting(): void { $bs = new mock_section_backup_setting('test', base_setting::IS_INTEGER, null); $this->assertEquals($bs->get_level(), backup_setting::SECTION_LEVEL); @@ -432,7 +432,7 @@ class settings_test extends \basic_testcase { /** * test course_backup_setting class */ - public function test_course_backup_setting() { + public function test_course_backup_setting(): void { $bs = new mock_course_backup_setting('test', base_setting::IS_INTEGER, null); $this->assertEquals($bs->get_level(), backup_setting::COURSE_LEVEL); diff --git a/backup/util/structure/tests/baseatom_test.php b/backup/util/structure/tests/baseatom_test.php index 98070cd1b95..91ed89634a4 100644 --- a/backup/util/structure/tests/baseatom_test.php +++ b/backup/util/structure/tests/baseatom_test.php @@ -41,7 +41,7 @@ class baseatom_test extends \basic_testcase { /** * Correct base_atom_tests */ - function test_base_atom() { + function test_base_atom(): void { $name_with_all_chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_'; $value_to_test = 'Some to test'; @@ -80,7 +80,7 @@ class baseatom_test extends \basic_testcase { /** * Throwing exception base_atom tests */ - function test_base_atom_exceptions() { + function test_base_atom_exceptions(): void { // empty names try { $instance = new mock_base_atom(''); diff --git a/backup/util/structure/tests/baseattribute_test.php b/backup/util/structure/tests/baseattribute_test.php index e8248c0311e..3774e498494 100644 --- a/backup/util/structure/tests/baseattribute_test.php +++ b/backup/util/structure/tests/baseattribute_test.php @@ -40,7 +40,7 @@ class baseattribute_test extends \basic_testcase { /** * Correct base_attribute tests */ - function test_base_attribute() { + function test_base_attribute(): void { $name_with_all_chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_'; $value_to_test = 'Some to test'; diff --git a/backup/util/structure/tests/basefinalelement_test.php b/backup/util/structure/tests/basefinalelement_test.php index 93ce518bce6..baf4321208a 100644 --- a/backup/util/structure/tests/basefinalelement_test.php +++ b/backup/util/structure/tests/basefinalelement_test.php @@ -43,7 +43,7 @@ class basefinalelement_test extends \basic_testcase { /** * Correct base_final_element tests */ - function test_base_final_element() { + function test_base_final_element(): void { // Create instance with name $instance = new mock_base_final_element('TEST'); @@ -130,7 +130,7 @@ class basefinalelement_test extends \basic_testcase { /** * Exception base_final_element tests */ - function test_base_final_element_exceptions() { + function test_base_final_element_exceptions(): void { // Create instance with invalid name try { diff --git a/backup/util/structure/tests/basenestedelement_test.php b/backup/util/structure/tests/basenestedelement_test.php index 50ce8b8003e..bcd6f71d075 100644 --- a/backup/util/structure/tests/basenestedelement_test.php +++ b/backup/util/structure/tests/basenestedelement_test.php @@ -44,7 +44,7 @@ class basenestedelement_test extends \basic_testcase { /** * Correct creation tests (attributes and final elements) */ - public function test_creation() { + public function test_creation(): void { // Create instance with name, attributes and values and check all them $instance = new mock_base_nested_element('NAME', array('ATTR1', 'ATTR2'), array('VAL1', 'VAL2', 'VAL3')); $this->assertInstanceOf('base_nested_element', $instance); @@ -182,7 +182,7 @@ class basenestedelement_test extends \basic_testcase { /** * Incorrect creation tests (attributes and final elements) */ - function test_wrong_creation() { + function test_wrong_creation(): void { // Create instance with invalid name try { @@ -251,7 +251,7 @@ class basenestedelement_test extends \basic_testcase { /** * Correct tree tests (children stuff) */ - function test_tree() { + function test_tree(): void { // Create parent and child instances, tree-ing them $parent = new mock_base_nested_element('PARENT'); @@ -305,7 +305,7 @@ class basenestedelement_test extends \basic_testcase { /** * Incorrect tree tests (children stuff) */ - function test_wrong_tree() { + function test_wrong_tree(): void { // Add null object child $parent = new mock_base_nested_element('PARENT'); diff --git a/backup/util/structure/tests/baseoptigroup_test.php b/backup/util/structure/tests/baseoptigroup_test.php index baa782ddb0b..72936709945 100644 --- a/backup/util/structure/tests/baseoptigroup_test.php +++ b/backup/util/structure/tests/baseoptigroup_test.php @@ -43,7 +43,7 @@ class baseoptigroup_test extends \basic_testcase { /** * Correct creation tests (s) */ - function test_creation() { + function test_creation(): void { $instance = new mock_base_optigroup('optigroup', null, true); $this->assertInstanceOf('base_optigroup', $instance); $this->assertEquals($instance->get_name(), 'optigroup'); @@ -77,7 +77,7 @@ class baseoptigroup_test extends \basic_testcase { /** * Incorrect creation tests (attributes and final elements) */ - function test_wrong_creation() { + function test_wrong_creation(): void { // Create instance with invalid name try { diff --git a/backup/util/structure/tests/structure_test.php b/backup/util/structure/tests/structure_test.php index 4b2a8b1b37e..2d4f72c5ebc 100644 --- a/backup/util/structure/tests/structure_test.php +++ b/backup/util/structure/tests/structure_test.php @@ -147,7 +147,7 @@ class structure_test extends \advanced_testcase { /** * Backup structures tests (construction, definition and execution) */ - function test_backup_structure_construct() { + function test_backup_structure_construct(): void { global $DB; $backupid = 'Testing Backup ID'; // Official backupid for these tests @@ -471,7 +471,7 @@ class structure_test extends \advanced_testcase { /** * Backup structures wrong tests (trying to do things the wrong way) */ - function test_backup_structure_wrong() { + function test_backup_structure_wrong(): void { // Instantiate the backup processor $processor = new backup_structure_processor(new xml_writer(new memory_xml_output())); diff --git a/backup/util/ui/tests/base_setting_ui_test.php b/backup/util/ui/tests/base_setting_ui_test.php index 801bd7c0f0c..a8cfe9afdb0 100644 --- a/backup/util/ui/tests/base_setting_ui_test.php +++ b/backup/util/ui/tests/base_setting_ui_test.php @@ -38,7 +38,7 @@ class base_setting_ui_test extends \advanced_testcase { * * @return void */ - public function test_set_label() { + public function test_set_label(): void { $this->resetAfterTest(); $bs = new mock_base_setting('test', base_setting::IS_BOOLEAN); diff --git a/backup/util/ui/tests/ui_test.php b/backup/util/ui/tests/ui_test.php index 7494909e903..a4455c770eb 100644 --- a/backup/util/ui/tests/ui_test.php +++ b/backup/util/ui/tests/ui_test.php @@ -28,6 +28,6 @@ class ui_test extends \basic_testcase { /** * Test backup_ui class */ - public function test_backup_ui() { + public function test_backup_ui(): void { } } diff --git a/backup/util/xml/output/tests/output_test.php b/backup/util/xml/output/tests/output_test.php index 9deba27581a..4c00c323fea 100644 --- a/backup/util/xml/output/tests/output_test.php +++ b/backup/util/xml/output/tests/output_test.php @@ -51,7 +51,7 @@ class output_test extends \advanced_testcase { /* * test memory_xml_output */ - function test_memory_xml_output() { + function test_memory_xml_output(): void { // Instantiate xml_output $xo = new memory_xml_output(); $this->assertTrue($xo instanceof xml_output); @@ -224,7 +224,7 @@ class output_test extends \advanced_testcase { /* * test file_xml_output */ - function test_file_xml_output() { + function test_file_xml_output(): void { global $CFG; $this->resetAfterTest(); diff --git a/backup/util/xml/parser/tests/parser_test.php b/backup/util/xml/parser/tests/parser_test.php index 06acf90c5f8..7de26b4e065 100644 --- a/backup/util/xml/parser/tests/parser_test.php +++ b/backup/util/xml/parser/tests/parser_test.php @@ -53,7 +53,7 @@ class parser_test extends \advanced_testcase { /* * test progressive_parser public methods */ - function test_parser_public_api() { + function test_parser_public_api(): void { global $CFG; // Instantiate progressive_parser $pp = new progressive_parser(); @@ -168,7 +168,7 @@ class parser_test extends \advanced_testcase { * test progressive_parser parsing results using testing_parser_processor and test1.xml * auto-described file from fixtures */ - function test_parser_results() { + function test_parser_results(): void { global $CFG; // Instantiate progressive_parser $pp = new progressive_parser(); @@ -193,7 +193,7 @@ class parser_test extends \advanced_testcase { * test progressive_parser parsing results using simplified_parser_processor and test4.xml * (one simple glossary backup file example) */ - function test_simplified_parser_results() { + function test_simplified_parser_results(): void { global $CFG; // Instantiate progressive_parser $pp = new progressive_parser(); @@ -353,7 +353,7 @@ class parser_test extends \advanced_testcase { * with one real fragment of one backup 1.9 file, where some problems * were found by David, hence we honor him in the name of the test ;-) */ - function test_simplified_david_backup19_file_fragment() { + function test_simplified_david_backup19_file_fragment(): void { global $CFG; // Instantiate progressive_parser $pp = new progressive_parser(); @@ -419,7 +419,7 @@ class parser_test extends \advanced_testcase { * test progressive_parser parsing results using grouped_parser_processor and test4.xml * (one simple glossary backup file example) */ - function test_grouped_parser_results() { + function test_grouped_parser_results(): void { global $CFG; // Instantiate progressive_parser $pp = new progressive_parser(); @@ -595,7 +595,7 @@ class parser_test extends \advanced_testcase { * with one real fragment of one backup 1.9 file, where some problems * were found by David, hence we honor him in the name of the test ;-) */ - function test_grouped_david_backup19_file_fragment() { + function test_grouped_david_backup19_file_fragment(): void { global $CFG; // Instantiate progressive_parser $pp = new progressive_parser(); @@ -649,7 +649,7 @@ class parser_test extends \advanced_testcase { /** */ - function test_grouped_at_empty_node() { + function test_grouped_at_empty_node(): void { global $CFG; // Instantiate progressive_parser. $pp = new progressive_parser(); diff --git a/backup/util/xml/tests/writer_test.php b/backup/util/xml/tests/writer_test.php index 109d26ba005..979d70d5b8e 100644 --- a/backup/util/xml/tests/writer_test.php +++ b/backup/util/xml/tests/writer_test.php @@ -54,7 +54,7 @@ class writer_test extends \basic_testcase { /** * test xml_writer public methods */ - function test_xml_writer_public_api() { + function test_xml_writer_public_api(): void { global $CFG; // Instantiate xml_output $xo = new memory_xml_output(); diff --git a/badges/tests/badgeslib_test.php b/badges/tests/badgeslib_test.php index a5268d839da..fb7cf730770 100644 --- a/badges/tests/badgeslib_test.php +++ b/badges/tests/badgeslib_test.php @@ -167,14 +167,14 @@ class badgeslib_test extends advanced_testcase { '"@context":"https:\/\/w3id.org\/openbadges\/v2","id":"%s","type":"Issuer"}'; } - public function test_create_badge() { + public function test_create_badge(): void { $badge = new badge($this->badgeid); $this->assertInstanceOf('badge', $badge); $this->assertEquals($this->badgeid, $badge->id); } - public function test_clone_badge() { + public function test_clone_badge(): void { $badge = new badge($this->badgeid); $newid = $badge->make_clone(); $clonedbadge = new badge($newid); @@ -200,7 +200,7 @@ class badgeslib_test extends advanced_testcase { $this->assertEquals($badge->imageauthorurl, $clonedbadge->imageauthorurl); } - public function test_badge_status() { + public function test_badge_status(): void { $badge = new badge($this->badgeid); $old_status = $badge->status; $badge->set_status(BADGE_STATUS_ACTIVE); @@ -208,7 +208,7 @@ class badgeslib_test extends advanced_testcase { $this->assertEquals(BADGE_STATUS_ACTIVE, $badge->status); } - public function test_delete_badge() { + public function test_delete_badge(): void { $badge = new badge($this->badgeid); $badge->delete(); // We don't actually delete badges. We archive them. @@ -218,7 +218,7 @@ class badgeslib_test extends advanced_testcase { /** * Really delete the badge. */ - public function test_delete_badge_for_real() { + public function test_delete_badge_for_real(): void { global $DB; $badge = new badge($this->badgeid); @@ -262,7 +262,7 @@ class badgeslib_test extends advanced_testcase { $this->assertFalse($DB->record_exists('tag_instance', ['itemid' => $this->badgeid])); } - public function test_create_badge_criteria() { + public function test_create_badge_criteria(): void { $badge = new badge($this->badgeid); $criteria_overall = award_criteria::build(array('criteriatype' => BADGE_CRITERIA_TYPE_OVERALL, 'badgeid' => $badge->id)); $criteria_overall->save(array('agg' => BADGE_CRITERIA_AGGREGATION_ALL)); @@ -276,7 +276,7 @@ class badgeslib_test extends advanced_testcase { $this->assertCount(2, $badge->get_criteria()); } - public function test_add_badge_criteria_description() { + public function test_add_badge_criteria_description(): void { $criteriaoverall = award_criteria::build(array('criteriatype' => BADGE_CRITERIA_TYPE_OVERALL, 'badgeid' => $this->badgeid)); $criteriaoverall->save(array( 'agg' => BADGE_CRITERIA_AGGREGATION_ALL, @@ -298,7 +298,7 @@ class badgeslib_test extends advanced_testcase { $this->assertEquals('Description', $badge->criteria[BADGE_CRITERIA_TYPE_PROFILE]->description); } - public function test_delete_badge_criteria() { + public function test_delete_badge_criteria(): void { $criteria_overall = award_criteria::build(array('criteriatype' => BADGE_CRITERIA_TYPE_OVERALL, 'badgeid' => $this->badgeid)); $criteria_overall->save(array('agg' => BADGE_CRITERIA_AGGREGATION_ALL)); $badge = new badge($this->badgeid); @@ -309,7 +309,7 @@ class badgeslib_test extends advanced_testcase { $this->assertEmpty($badge->get_criteria()); } - public function test_badge_awards() { + public function test_badge_awards(): void { global $DB; $this->preventResetByRollback(); // Messaging is not compatible with transactions. $badge = new badge($this->badgeid); @@ -343,7 +343,7 @@ class badgeslib_test extends advanced_testcase { /** * Test the {@link badges_get_user_badges()} function in lib/badgeslib.php */ - public function test_badges_get_user_badges() { + public function test_badges_get_user_badges(): void { global $DB; // Messaging is not compatible with transactions. @@ -520,7 +520,7 @@ class badgeslib_test extends advanced_testcase { /** * @dataProvider data_for_message_from_template */ - public function test_badge_message_from_template($message, $params, $result) { + public function test_badge_message_from_template($message, $params, $result): void { $this->assertEquals(badge_message_from_template($message, $params), $result); } @@ -529,7 +529,7 @@ class badgeslib_test extends advanced_testcase { * * @covers \core_badges\badge::review_all_criteria */ - public function test_badge_activity_criteria_with_a_huge_number_of_coursemodules() { + public function test_badge_activity_criteria_with_a_huge_number_of_coursemodules(): void { global $CFG; require_once($CFG->dirroot.'/completion/criteria/completion_criteria_activity.php'); @@ -605,7 +605,7 @@ class badgeslib_test extends advanced_testcase { /** * Test badges observer when course module completion event id fired. */ - public function test_badges_observer_course_module_criteria_review() { + public function test_badges_observer_course_module_criteria_review(): void { $this->preventResetByRollback(); // Messaging is not compatible with transactions. $badge = new badge($this->coursebadge); $this->assertFalse($badge->is_issued($this->user->id)); @@ -643,7 +643,7 @@ class badgeslib_test extends advanced_testcase { /** * Test badges observer when course_completed event is fired. */ - public function test_badges_observer_course_criteria_review() { + public function test_badges_observer_course_criteria_review(): void { $this->preventResetByRollback(); // Messaging is not compatible with transactions. $badge = new badge($this->coursebadge); $this->assertFalse($badge->is_issued($this->user->id)); @@ -678,7 +678,7 @@ class badgeslib_test extends advanced_testcase { /** * Test badges observer when user_updated event is fired. */ - public function test_badges_observer_profile_criteria_review() { + public function test_badges_observer_profile_criteria_review(): void { global $CFG, $DB; require_once($CFG->dirroot.'/user/profile/lib.php'); @@ -719,7 +719,7 @@ class badgeslib_test extends advanced_testcase { * * @covers \award_criteria_cohort */ - public function test_badges_observer_any_cohort_criteria_review() { + public function test_badges_observer_any_cohort_criteria_review(): void { global $CFG; require_once("$CFG->dirroot/cohort/lib.php"); @@ -762,7 +762,7 @@ class badgeslib_test extends advanced_testcase { * * @covers \award_criteria_cohort */ - public function test_badges_observer_all_cohort_criteria_review() { + public function test_badges_observer_all_cohort_criteria_review(): void { global $CFG; require_once("$CFG->dirroot/cohort/lib.php"); @@ -841,7 +841,7 @@ class badgeslib_test extends advanced_testcase { /** * Test badges assertion generated when a badge is issued. */ - public function test_badges_assertion() { + public function test_badges_assertion(): void { $this->preventResetByRollback(); // Messaging is not compatible with transactions. $badge = new badge($this->coursebadge); $this->assertFalse($badge->is_issued($this->user->id)); @@ -896,7 +896,7 @@ class badgeslib_test extends advanced_testcase { /** * Tests the core_badges_myprofile_navigation() function. */ - public function test_core_badges_myprofile_navigation() { + public function test_core_badges_myprofile_navigation(): void { // Set up the test. $tree = new \core_user\output\myprofile\tree(); $this->setAdminUser(); @@ -918,7 +918,7 @@ class badgeslib_test extends advanced_testcase { /** * Tests the core_badges_myprofile_navigation() function with badges disabled.. */ - public function test_core_badges_myprofile_navigation_badges_disabled() { + public function test_core_badges_myprofile_navigation_badges_disabled(): void { // Set up the test. $tree = new \core_user\output\myprofile\tree(); $this->setAdminUser(); @@ -940,7 +940,7 @@ class badgeslib_test extends advanced_testcase { /** * Tests the core_badges_myprofile_navigation() function with a course badge. */ - public function test_core_badges_myprofile_navigation_with_course_badge() { + public function test_core_badges_myprofile_navigation_with_course_badge(): void { // Set up the test. $tree = new \core_user\output\myprofile\tree(); $this->setAdminUser(); @@ -958,7 +958,7 @@ class badgeslib_test extends advanced_testcase { /** * Test insert and update endorsement with a site badge. */ - public function test_badge_endorsement() { + public function test_badge_endorsement(): void { $badge = new badge($this->badgeid); // Insert Endorsement. @@ -992,7 +992,7 @@ class badgeslib_test extends advanced_testcase { /** * Test insert and delete related badge with a site badge. */ - public function test_badge_related() { + public function test_badge_related(): void { $badge = new badge($this->badgeid); $newid1 = $badge->make_clone(); $newid2 = $badge->make_clone(); @@ -1016,7 +1016,7 @@ class badgeslib_test extends advanced_testcase { /** * Test insert, update, delete alignment with a site badge. */ - public function test_alignments() { + public function test_alignments(): void { $badge = new badge($this->badgeid); // Insert a alignment. @@ -1114,7 +1114,7 @@ class badgeslib_test extends advanced_testcase { * @param string|null $mail Backpack mail address. * @param string|null $password Backpack password. */ - public function test_save_backpack_credentials(bool $addbackpack = true, ?string $mail = null, ?string $password = null) { + public function test_save_backpack_credentials(bool $addbackpack = true, ?string $mail = null, ?string $password = null): void { global $DB; $this->resetAfterTest(); @@ -1210,7 +1210,7 @@ class badgeslib_test extends advanced_testcase { * @param bool $adduser True if a real user has to be used for creating the backpack; false otherwise. * @param bool $duplicates True if duplicates has to be tested too; false otherwise. */ - public function test_badges_save_external_backpack(array $data, bool $adduser, bool $duplicates) { + public function test_badges_save_external_backpack(array $data, bool $adduser, bool $duplicates): void { global $DB; $this->resetAfterTest(); @@ -1321,7 +1321,7 @@ class badgeslib_test extends advanced_testcase { * @param boolean $updatetest * @dataProvider badges_create_site_backpack_provider */ - public function test_badges_create_site_backpack($isadmin, $updatetest) { + public function test_badges_create_site_backpack($isadmin, $updatetest): void { global $DB; $this->resetAfterTest(); @@ -1379,7 +1379,7 @@ class badgeslib_test extends advanced_testcase { /** * Test the badges_open_badges_backpack_api with different backpacks */ - public function test_badges_open_badges_backpack_api() { + public function test_badges_open_badges_backpack_api(): void { $this->resetAfterTest(); $data = [ @@ -1412,7 +1412,7 @@ class badgeslib_test extends advanced_testcase { /** * Test the badges_get_site_backpack function */ - public function test_badges_get_site_backpack() { + public function test_badges_get_site_backpack(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); $data = [ @@ -1453,7 +1453,7 @@ class badgeslib_test extends advanced_testcase { /** * Test the badges_get_user_backpack function */ - public function test_badges_get_user_backpack() { + public function test_badges_get_user_backpack(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); $data = [ @@ -1497,7 +1497,7 @@ class badgeslib_test extends advanced_testcase { * @param boolean $withauth Testing with authentication or not. * @dataProvider badges_get_site_primary_backpack_provider */ - public function test_badges_get_site_primary_backpack($withauth) { + public function test_badges_get_site_primary_backpack($withauth): void { $data = [ 'apiversion' => '2', 'backpackapiurl' => 'https://api.ca.badgr.io/v2', @@ -1630,7 +1630,7 @@ class badgeslib_test extends advanced_testcase { * @param string $expected Expected string result * @dataProvider badgr_open_url_generator */ - public function test_badges_generate_badgr_open_url($type, $expected) { + public function test_badges_generate_badgr_open_url($type, $expected): void { $data = [ 'apiversion' => '2', 'backpackapiurl' => 'https://api.ca.badgr.io/v2', @@ -1671,7 +1671,7 @@ class badgeslib_test extends advanced_testcase { * * @dataProvider badges_external_get_mapping_provider */ - public function test_badges_external_get_mapping($internalid, $externalid, $expected, $field = null) { + public function test_badges_external_get_mapping($internalid, $externalid, $expected, $field = null): void { $data = [ 'apiversion' => '2', 'backpackapiurl' => 'https://api.ca.badgr.io/v2', @@ -1732,7 +1732,7 @@ class badgeslib_test extends advanced_testcase { * * @covers ::badge_get_tagged_badges */ - public function test_badge_get_tagged_badges() { + public function test_badge_get_tagged_badges(): void { $this->resetAfterTest(); $this->setAdminUser(); diff --git a/badges/tests/events_test.php b/badges/tests/events_test.php index ab411a9b542..c319e163cec 100644 --- a/badges/tests/events_test.php +++ b/badges/tests/events_test.php @@ -36,7 +36,7 @@ class events_test extends badgeslib_test { /** * Test badge awarded event. */ - public function test_badge_awarded() { + public function test_badge_awarded(): void { $systemcontext = context_system::instance(); @@ -62,7 +62,7 @@ class events_test extends badgeslib_test { * There is no external API for creating a badge, so the unit test will simply * create and trigger the event and ensure data is returned as expected. */ - public function test_badge_created() { + public function test_badge_created(): void { $badge = new badge($this->badgeid); // Trigger an event: badge created. @@ -92,7 +92,7 @@ class events_test extends badgeslib_test { * Test the badge archived event. * */ - public function test_badge_archived() { + public function test_badge_archived(): void { $badge = new badge($this->badgeid); $sink = $this->redirectEvents(); @@ -115,7 +115,7 @@ class events_test extends badgeslib_test { * Test the badge updated event. * */ - public function test_badge_updated() { + public function test_badge_updated(): void { $badge = new badge($this->badgeid); $sink = $this->redirectEvents(); @@ -135,7 +135,7 @@ class events_test extends badgeslib_test { /** * Test the badge deleted event. */ - public function test_badge_deleted() { + public function test_badge_deleted(): void { $badge = new badge($this->badgeid); $sink = $this->redirectEvents(); @@ -157,7 +157,7 @@ class events_test extends badgeslib_test { * Test the badge duplicated event. * */ - public function test_badge_duplicated() { + public function test_badge_duplicated(): void { $badge = new badge($this->badgeid); $sink = $this->redirectEvents(); @@ -179,7 +179,7 @@ class events_test extends badgeslib_test { * Test the badge disabled event. * */ - public function test_badge_disabled() { + public function test_badge_disabled(): void { $badge = new badge($this->badgeid); $sink = $this->redirectEvents(); @@ -202,7 +202,7 @@ class events_test extends badgeslib_test { * Test the badge enabled event. * */ - public function test_badge_enabled() { + public function test_badge_enabled(): void { $badge = new badge($this->badgeid); $sink = $this->redirectEvents(); @@ -227,7 +227,7 @@ class events_test extends badgeslib_test { * There is no external API for this, so the unit test will simply * create and trigger the event and ensure data is returned as expected. */ - public function test_badge_criteria_created() { + public function test_badge_criteria_created(): void { $badge = new badge($this->badgeid); @@ -257,7 +257,7 @@ class events_test extends badgeslib_test { * There is no external API for this, so the unit test will simply * create and trigger the event and ensure data is returned as expected. */ - public function test_badge_criteria_updated() { + public function test_badge_criteria_updated(): void { $criteriaoverall = award_criteria::build(array('criteriatype' => BADGE_CRITERIA_TYPE_OVERALL, 'badgeid' => $this->badgeid)); $criteriaoverall->save(array('agg' => BADGE_CRITERIA_AGGREGATION_ALL)); @@ -290,7 +290,7 @@ class events_test extends badgeslib_test { * There is no external API for this, so the unit test will simply * create and trigger the event and ensure data is returned as expected. */ - public function test_badge_criteria_deleted() { + public function test_badge_criteria_deleted(): void { $criteriaoverall = award_criteria::build(array('criteriatype' => BADGE_CRITERIA_TYPE_OVERALL, 'badgeid' => $this->badgeid)); $criteriaoverall->save(array('agg' => BADGE_CRITERIA_AGGREGATION_ALL)); @@ -317,7 +317,7 @@ class events_test extends badgeslib_test { * There is no external API for viewing a badge, so the unit test will simply * create and trigger the event and ensure data is returned as expected. */ - public function test_badge_viewed() { + public function test_badge_viewed(): void { $badge = new badge($this->badgeid); // Trigger an event: badge viewed. @@ -349,7 +349,7 @@ class events_test extends badgeslib_test { * There is no external API for viewing a badge, so the unit test will simply * create and trigger the event and ensure data is returned as expected. */ - public function test_badge_listing_viewed() { + public function test_badge_listing_viewed(): void { // Trigger an event: badge listing viewed. $context = context_system::instance(); diff --git a/badges/tests/external/external_test.php b/badges/tests/external/external_test.php index 6bbd8c739ec..40d1c8736c1 100644 --- a/badges/tests/external/external_test.php +++ b/badges/tests/external/external_test.php @@ -159,7 +159,7 @@ class external_test extends externallib_advanced_testcase { * Test get user badges. * These is a basic test since the badges_get_my_user_badges used by the external function already has unit tests. */ - public function test_get_my_user_badges() { + public function test_get_my_user_badges(): void { $this->setUser($this->student); @@ -229,7 +229,7 @@ class external_test extends externallib_advanced_testcase { /** * Test get user badges. */ - public function test_get_other_user_badges() { + public function test_get_other_user_badges(): void { $this->setUser($this->teacher); diff --git a/badges/tests/external/get_user_badge_by_hash_test.php b/badges/tests/external/get_user_badge_by_hash_test.php index 55367228237..0d1eea0b1c2 100644 --- a/badges/tests/external/get_user_badge_by_hash_test.php +++ b/badges/tests/external/get_user_badge_by_hash_test.php @@ -177,7 +177,7 @@ class get_user_badge_by_hash_test extends externallib_advanced_testcase { * These are a basic tests since the badges_get_my_user_badges used by the external function already has unit tests. * @covers ::execute */ - public function test_get_user_badge_by_hash() { + public function test_get_user_badge_by_hash(): void { $data = $this->prepare_test_data(); $this->setUser($data['student1']); @@ -205,7 +205,7 @@ class get_user_badge_by_hash_test extends externallib_advanced_testcase { * Test get user badge by hash with restrictions. * @covers ::execute */ - public function test_get_user_badge_by_hash_with_restrictions() { + public function test_get_user_badge_by_hash_with_restrictions(): void { $data = $this->prepare_test_data(); $this->setUser($data['student2']); diff --git a/badges/tests/output/manage_badge_action_bar_test.php b/badges/tests/output/manage_badge_action_bar_test.php index b93a3c7d2ed..065ef11007f 100644 --- a/badges/tests/output/manage_badge_action_bar_test.php +++ b/badges/tests/output/manage_badge_action_bar_test.php @@ -84,7 +84,7 @@ class manage_badge_action_bar_test extends \advanced_testcase { * @param array $expected * @covers ::generate_badge_navigation */ - public function test_generate_badge_navigation(string $role, array $expected) { + public function test_generate_badge_navigation(string $role, array $expected): void { global $DB; $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); diff --git a/badges/tests/privacy/provider_test.php b/badges/tests/privacy/provider_test.php index 128a6fd8dac..1bf4e80313b 100644 --- a/badges/tests/privacy/provider_test.php +++ b/badges/tests/privacy/provider_test.php @@ -53,7 +53,7 @@ class provider_test extends provider_testcase { $this->resetAfterTest(); } - public function test_get_contexts_for_userid_for_badge_editing() { + public function test_get_contexts_for_userid_for_badge_editing(): void { $dg = $this->getDataGenerator(); $u1 = $dg->create_user(); $u2 = $dg->create_user(); @@ -95,7 +95,7 @@ class provider_test extends provider_testcase { $this->assertTrue(in_array($c2ctx->id, $contexts)); } - public function test_get_contexts_for_userid_for_manual_award() { + public function test_get_contexts_for_userid_for_manual_award(): void { global $DB; $dg = $this->getDataGenerator(); @@ -126,7 +126,7 @@ class provider_test extends provider_testcase { $this->assertEquals($u3ctx->id, $contexts[0]); } - public function test_get_contexts_for_userid_for_my_stuff() { + public function test_get_contexts_for_userid_for_my_stuff(): void { global $DB; $dg = $this->getDataGenerator(); @@ -168,7 +168,7 @@ class provider_test extends provider_testcase { $this->assertEquals($u4ctx->id, $contexts[0]); } - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; $dg = $this->getDataGenerator(); @@ -226,7 +226,7 @@ class provider_test extends provider_testcase { $this->assertTrue($DB->record_exists('badge_criteria_met', ['userid' => $u2->id])); } - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; $dg = $this->getDataGenerator(); @@ -291,7 +291,7 @@ class provider_test extends provider_testcase { $this->assertTrue($DB->record_exists('badge_criteria_met', ['userid' => $u2->id])); } - public function test_export_data_for_user() { + public function test_export_data_for_user(): void { global $DB; $yes = transform::yesno(true); @@ -442,7 +442,7 @@ class provider_test extends provider_testcase { /** * Test that only users within a user, system and course context are fetched. */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { $component = 'core_badges'; // Create course1. @@ -512,7 +512,7 @@ class provider_test extends provider_testcase { /** * Test that data for users in approved userlist is deleted. */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { $component = 'core_badges'; // Create course1. diff --git a/blocks/accessreview/tests/accessibility_review_test.php b/blocks/accessreview/tests/accessibility_review_test.php index 8388fd31e95..7b7e0335564 100644 --- a/blocks/accessreview/tests/accessibility_review_test.php +++ b/blocks/accessreview/tests/accessibility_review_test.php @@ -36,7 +36,7 @@ class accessibility_review_test extends advanced_testcase { require_once(__DIR__ . '/../block_accessreview.php'); } - public function test_get_toggle_link() { + public function test_get_toggle_link(): void { $rc = new ReflectionClass(block_accessreview::class); $rm = $rc->getMethod('get_toggle_link'); @@ -45,7 +45,7 @@ class accessibility_review_test extends advanced_testcase { $this->assertNotEmpty($output); } - public function test_get_download_link() { + public function test_get_download_link(): void { $this->resetAfterTest(); $user1 = $this->getDataGenerator()->create_user(); @@ -70,7 +70,7 @@ class accessibility_review_test extends advanced_testcase { $this->assertEmpty($result); } - public function test_get_report_link() { + public function test_get_report_link(): void { $this->resetAfterTest(); $user1 = $this->getDataGenerator()->create_user(); diff --git a/blocks/comments/tests/event/events_test.php b/blocks/comments/tests/event/events_test.php index 980d497b371..3f74870b51e 100644 --- a/blocks/comments/tests/event/events_test.php +++ b/blocks/comments/tests/event/events_test.php @@ -55,7 +55,7 @@ class events_test extends \advanced_testcase { /** * Test comment_created event. */ - public function test_comment_created() { + public function test_comment_created(): void { global $CFG; require_once($CFG->dirroot . '/comment/lib.php'); @@ -119,7 +119,7 @@ class events_test extends \advanced_testcase { /** * Test comment_deleted event. */ - public function test_comment_deleted() { + public function test_comment_deleted(): void { global $CFG; require_once($CFG->dirroot . '/comment/lib.php'); diff --git a/blocks/comments/tests/privacy/provider_test.php b/blocks/comments/tests/privacy/provider_test.php index f68574c456f..49d13103612 100644 --- a/blocks/comments/tests/privacy/provider_test.php +++ b/blocks/comments/tests/privacy/provider_test.php @@ -169,7 +169,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::get_metadata(). */ - public function test_get_metadata() { + public function test_get_metadata(): void { $collection = new collection('block_comments'); $newcollection = provider::get_metadata($collection); $itemcollection = $newcollection->get_collection(); @@ -185,7 +185,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::get_contexts_for_userid() when user had not posted any comments.. */ - public function test_get_contexts_for_userid_no_comment() { + public function test_get_contexts_for_userid_no_comment(): void { $this->setUser($this->student1); $coursecontext1 = \context_course::instance($this->course1->id); $this->add_comment('New comment', $coursecontext1); @@ -198,7 +198,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::get_contexts_for_userid(). */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { $coursecontext1 = \context_course::instance($this->course1->id); $coursecontext2 = \context_course::instance($this->course2->id); @@ -217,7 +217,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::export_user_data() when the user has not posted any comments. */ - public function test_export_for_context_no_comment() { + public function test_export_for_context_no_comment(): void { $coursecontext1 = \context_course::instance($this->course1->id); $coursecontext2 = \context_course::instance($this->course2->id); @@ -236,7 +236,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::export_user_data(). */ - public function test_export_for_context() { + public function test_export_for_context(): void { $coursecontext1 = \context_course::instance($this->course1->id); $coursecontext2 = \context_course::instance($this->course2->id); @@ -254,7 +254,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::delete_data_for_all_users_in_context(). */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; $coursecontext1 = \context_course::instance($this->course1->id); @@ -298,7 +298,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::delete_data_for_all_users_in_context() when there are also comments from other plugins. */ - public function test_delete_data_for_all_users_in_context_with_comments_from_other_plugins() { + public function test_delete_data_for_all_users_in_context_with_comments_from_other_plugins(): void { global $DB; $assigngenerator = $this->getDataGenerator()->get_plugin_generator('mod_assign'); @@ -360,7 +360,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::delete_data_for_user(). */ - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; $coursecontext1 = \context_course::instance($this->course1->id); @@ -414,7 +414,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::delete_data_for_user() when there are also comments from other plugins. */ - public function test_delete_data_for_user_with_comments_from_other_plugins() { + public function test_delete_data_for_user_with_comments_from_other_plugins(): void { global $DB; $assigngenerator = $this->getDataGenerator()->get_plugin_generator('mod_assign'); @@ -473,7 +473,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { * Test that only users within a course context are fetched. * @group qtesttt */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { $component = 'block_comments'; $coursecontext1 = \context_course::instance($this->course1->id); @@ -510,7 +510,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test that data for users in approved userlist is deleted. */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { $component = 'block_comments'; $coursecontext1 = \context_course::instance($this->course1->id); @@ -551,7 +551,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::delete_data_for_user() when there are also comments from other plugins. */ - public function test_delete_data_for_users_with_comments_from_other_plugins() { + public function test_delete_data_for_users_with_comments_from_other_plugins(): void { $component = 'block_comments'; $assigngenerator = $this->getDataGenerator()->get_plugin_generator('mod_assign'); diff --git a/blocks/html/tests/block_html_test.php b/blocks/html/tests/block_html_test.php index 3c94431fe65..42642764213 100644 --- a/blocks/html/tests/block_html_test.php +++ b/blocks/html/tests/block_html_test.php @@ -31,7 +31,7 @@ class block_html_test extends \advanced_testcase { * Tests instance files copying. * @covers ::instance_copy */ - public function test_instance_copy() { + public function test_instance_copy(): void { global $USER; $this->resetAfterTest(); diff --git a/blocks/html/tests/privacy/provider_test.php b/blocks/html/tests/privacy/provider_test.php index e776d0ae662..6ca758bf8ed 100644 --- a/blocks/html/tests/privacy/provider_test.php +++ b/blocks/html/tests/privacy/provider_test.php @@ -163,7 +163,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test that a block on the dashboard is exported. */ - public function test_user_block() { + public function test_user_block(): void { $this->resetAfterTest(); $title = 'Example title'; @@ -206,7 +206,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test that a block on the dashboard which is not configured is _not_ exported. */ - public function test_user_block_unconfigured() { + public function test_user_block_unconfigured(): void { global $DB; $this->resetAfterTest(); @@ -242,7 +242,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test that a block on the dashboard is exported. */ - public function test_user_multiple_blocks_exported() { + public function test_user_multiple_blocks_exported(): void { $this->resetAfterTest(); $title = 'Example title'; @@ -286,7 +286,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test that a block on the dashboard is not exported. */ - public function test_course_blocks_not_exported() { + public function test_course_blocks_not_exported(): void { $this->resetAfterTest(); $title = 'Example title'; @@ -311,7 +311,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test that a block on the dashboard is exported. */ - public function test_mixed_multiple_blocks_exported() { + public function test_mixed_multiple_blocks_exported(): void { $this->resetAfterTest(); $title = 'Example title'; @@ -349,7 +349,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test that only users with a user context HTML block are fetched. */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { $this->resetAfterTest(); $component = 'block_html'; @@ -392,7 +392,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test that data for users in approved userlist is deleted. */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { $this->resetAfterTest(); $component = 'block_html'; diff --git a/blocks/html/tests/search_content_test.php b/blocks/html/tests/search_content_test.php index c31566d9c30..617fd9a0894 100644 --- a/blocks/html/tests/search_content_test.php +++ b/blocks/html/tests/search_content_test.php @@ -73,7 +73,7 @@ class search_content_test extends \advanced_testcase { /** * Tests all functionality in the search area. */ - public function test_search_area() { + public function test_search_area(): void { global $CFG, $USER, $DB; require_once($CFG->dirroot . '/search/tests/fixtures/testable_core_search.php'); diff --git a/blocks/myoverview/tests/myoverview_test.php b/blocks/myoverview/tests/myoverview_test.php index f667cdc9c22..7af4297cd13 100644 --- a/blocks/myoverview/tests/myoverview_test.php +++ b/blocks/myoverview/tests/myoverview_test.php @@ -29,7 +29,7 @@ class myoverview_test extends \advanced_testcase { /** * Test getting block configuration */ - public function test_get_block_config_for_external() { + public function test_get_block_config_for_external(): void { global $PAGE, $CFG, $OUTPUT; require_once($CFG->dirroot . '/my/lib.php'); diff --git a/blocks/myoverview/tests/privacy/provider_test.php b/blocks/myoverview/tests/privacy/provider_test.php index 12ae75763fe..72b7eb1784d 100644 --- a/blocks/myoverview/tests/privacy/provider_test.php +++ b/blocks/myoverview/tests/privacy/provider_test.php @@ -37,7 +37,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Ensure that export_user_preferences returns no data if the user has not visited the myoverview block. */ - public function test_export_user_preferences_no_pref() { + public function test_export_user_preferences_no_pref(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); provider::export_user_preferences($user->id); @@ -53,7 +53,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { * * @dataProvider user_preference_provider */ - public function test_export_user_preferences($type, $value, $expected) { + public function test_export_user_preferences($type, $value, $expected): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); set_user_preference($type, $value, $user); @@ -90,7 +90,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { ); } - public function test_export_user_preferences_with_hidden_courses() { + public function test_export_user_preferences_with_hidden_courses(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); $name = "block_myoverview_hidden_course_1"; diff --git a/blocks/online_users/tests/generator_test.php b/blocks/online_users/tests/generator_test.php index 01079660a6b..e819d407e67 100644 --- a/blocks/online_users/tests/generator_test.php +++ b/blocks/online_users/tests/generator_test.php @@ -25,7 +25,7 @@ namespace block_online_users; * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class generator_test extends \advanced_testcase { - public function test_generator() { + public function test_generator(): void { global $DB; $this->resetAfterTest(true); diff --git a/blocks/online_users/tests/online_users_test.php b/blocks/online_users/tests/online_users_test.php index 2f653ca62a5..3a38bf5ae9c 100644 --- a/blocks/online_users/tests/online_users_test.php +++ b/blocks/online_users/tests/online_users_test.php @@ -52,7 +52,7 @@ class online_users_test extends \advanced_testcase { * @param int $now Current Unix timestamp * @param int $timetoshowusers The time window (in seconds) to check for the latest logged in users */ - public function test_fetcher_course1_group_members() { + public function test_fetcher_course1_group_members(): void { global $CFG; $groupid = $this->data['group1']->id; @@ -91,7 +91,7 @@ class online_users_test extends \advanced_testcase { * @param int $now Current Unix timestamp * @param int $timetoshowusers The time window (in seconds) to check for the latest logged in users */ - public function test_fetcher_courses() { + public function test_fetcher_courses(): void { global $CFG; @@ -122,7 +122,7 @@ class online_users_test extends \advanced_testcase { * @param int $now Current Unix timestamp * @param int $timetoshowusers The time window (in seconds) to check for the latest logged in users */ - public function test_fetcher_sitelevel() { + public function test_fetcher_sitelevel(): void { global $CFG; $currentgroup = null; @@ -140,7 +140,7 @@ class online_users_test extends \advanced_testcase { /** * Check user visibility setting for course group members. */ - public function test_user_visibility_course1_group1_members() { + public function test_user_visibility_course1_group1_members(): void { global $CFG; // Enable users to set their visibility to others in the online users block. @@ -197,7 +197,7 @@ class online_users_test extends \advanced_testcase { /** * Check user visibility setting at course level. */ - public function test_user_visibility_courses() { + public function test_user_visibility_courses(): void { global $CFG; $currentgroup = null; @@ -253,7 +253,7 @@ class online_users_test extends \advanced_testcase { /** * Check user visibility setting at site level. */ - public function test_user_visibility_sitelevel() { + public function test_user_visibility_sitelevel(): void { global $CFG; $currentgroup = null; diff --git a/blocks/recentlyaccesseditems/tests/externallib_test.php b/blocks/recentlyaccesseditems/tests/externallib_test.php index 6857a237fa1..1aec7bdeb7b 100644 --- a/blocks/recentlyaccesseditems/tests/externallib_test.php +++ b/blocks/recentlyaccesseditems/tests/externallib_test.php @@ -38,7 +38,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test the get_recent_items function. */ - public function test_get_recent_items() { + public function test_get_recent_items(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator(); diff --git a/blocks/recentlyaccesseditems/tests/helper_test.php b/blocks/recentlyaccesseditems/tests/helper_test.php index 3eff6f7e09a..c0bbfbd4d0e 100644 --- a/blocks/recentlyaccesseditems/tests/helper_test.php +++ b/blocks/recentlyaccesseditems/tests/helper_test.php @@ -28,7 +28,7 @@ class helper_test extends \advanced_testcase { /** * Tests that the get recent items method can handle getting records when courses have been deleted. */ - public function test_get_recent_items() { + public function test_get_recent_items(): void { $this->resetAfterTest(); $course = self::getDataGenerator()->create_course(); $coursetodelete = self::getDataGenerator()->create_course(); diff --git a/blocks/recentlyaccesseditems/tests/observer_test.php b/blocks/recentlyaccesseditems/tests/observer_test.php index 774cb86d972..c6bff27502d 100644 --- a/blocks/recentlyaccesseditems/tests/observer_test.php +++ b/blocks/recentlyaccesseditems/tests/observer_test.php @@ -95,7 +95,7 @@ class observer_test extends \advanced_testcase { * * When items events are triggered they are stored in the block_recentlyaccesseditems table. */ - public function test_item_view_recorded_testcase() { + public function test_item_view_recorded_testcase(): void { global $DB; // Empty table at the beggining. @@ -140,7 +140,7 @@ class observer_test extends \advanced_testcase { * * When a course module is removed, the records associated in the block_recentlyaccesseditems table are deleted. */ - public function test_item_delete_record_testcase() { + public function test_item_delete_record_testcase(): void { global $DB; // Empty table at the beggining. diff --git a/blocks/recentlyaccesseditems/tests/privacy/provider_test.php b/blocks/recentlyaccesseditems/tests/privacy/provider_test.php index de95e8bcfc5..2c2b8d4c9e6 100644 --- a/blocks/recentlyaccesseditems/tests/privacy/provider_test.php +++ b/blocks/recentlyaccesseditems/tests/privacy/provider_test.php @@ -43,7 +43,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test getting the context for the user ID related to this plugin. */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator(); @@ -89,7 +89,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test getting users in the context ID related to this plugin. */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator(); $component = 'block_recentlyaccesseditems'; @@ -146,7 +146,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test fetching information about user data stored. */ - public function test_get_metadata() { + public function test_get_metadata(): void { $collection = new \core_privacy\local\metadata\collection('block_recentlyaccesseditems'); $newcollection = provider::get_metadata($collection); $itemcollection = $newcollection->get_collection(); @@ -168,7 +168,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test exporting data for an approved contextlist. */ - public function test_export_user_data() { + public function test_export_user_data(): void { global $DB; $this->resetAfterTest(); @@ -221,7 +221,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test exporting data for an approved contextlist with a deleted course */ - public function test_export_user_data_with_deleted_course() { + public function test_export_user_data_with_deleted_course(): void { global $DB; $this->resetAfterTest(); @@ -268,7 +268,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test deleting data for all users within an approved contextlist. */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; $this->resetAfterTest(); @@ -336,7 +336,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test deleting data within an approved contextlist for a user. */ - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; $this->resetAfterTest(); @@ -416,7 +416,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test deleting data within a context for an approved userlist. */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { global $DB; $this->resetAfterTest(); diff --git a/blocks/rss_client/tests/cron_test.php b/blocks/rss_client/tests/cron_test.php index 5f8f3b3dd89..21379fb617a 100644 --- a/blocks/rss_client/tests/cron_test.php +++ b/blocks/rss_client/tests/cron_test.php @@ -33,7 +33,7 @@ class cron_test extends \advanced_testcase { * Test that when a record has a skipuntil time that is greater * than the current time the attempt is skipped. */ - public function test_skip() { + public function test_skip(): void { global $DB, $CFG; $this->resetAfterTest(); // Create a RSS feed record with a skip until time set to the future. @@ -93,7 +93,7 @@ class cron_test extends \advanced_testcase { * * @dataProvider skip_time_increase_provider */ - public function test_error($skiptime, $skipuntil, $newvalue) { + public function test_error($skiptime, $skipuntil, $newvalue): void { global $DB, $CFG; $this->resetAfterTest(); diff --git a/blocks/rss_client/tests/privacy/provider_test.php b/blocks/rss_client/tests/privacy/provider_test.php index e04f0b4fd3a..7ec3f3e0c7a 100644 --- a/blocks/rss_client/tests/privacy/provider_test.php +++ b/blocks/rss_client/tests/privacy/provider_test.php @@ -46,7 +46,7 @@ class provider_test extends provider_testcase { /** * Test getting the context for the user ID related to this plugin. */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { $user = $this->getDataGenerator()->create_user(); $context = \context_user::instance($user->id); @@ -61,7 +61,7 @@ class provider_test extends provider_testcase { /** * Test that data is exported correctly for this plugin. */ - public function test_export_user_data() { + public function test_export_user_data(): void { $user = $this->getDataGenerator()->create_user(); $context = \context_user::instance($user->id); @@ -86,7 +86,7 @@ class provider_test extends provider_testcase { /** * Test that only users within a course context are fetched. */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { $component = 'block_rss_client'; // Create a user. @@ -116,7 +116,7 @@ class provider_test extends provider_testcase { /** * Test that data for users in approved userlist is deleted. */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { $component = 'block_rss_client'; $user1 = $this->getDataGenerator()->create_user(); @@ -173,7 +173,7 @@ class provider_test extends provider_testcase { /** * Test that user data is deleted using the context. */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; $user = $this->getDataGenerator()->create_user(); @@ -195,7 +195,7 @@ class provider_test extends provider_testcase { /** * Test that user data is deleted for this user. */ - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; $user = $this->getDataGenerator()->create_user(); diff --git a/blocks/tag_youtube/tests/block_tag_youtube_test.php b/blocks/tag_youtube/tests/block_tag_youtube_test.php index deae56cfbdc..f5470ea9489 100644 --- a/blocks/tag_youtube/tests/block_tag_youtube_test.php +++ b/blocks/tag_youtube/tests/block_tag_youtube_test.php @@ -31,7 +31,7 @@ class block_tag_youtube_test extends \advanced_testcase { * * @return void */ - public function test_after_install() { + public function test_after_install(): void { global $DB; $this->resetAfterTest(true); diff --git a/blocks/tests/externallib_test.php b/blocks/tests/externallib_test.php index 5d5b92784d6..afdfd4b98a7 100644 --- a/blocks/tests/externallib_test.php +++ b/blocks/tests/externallib_test.php @@ -40,7 +40,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_course_blocks */ - public function test_get_course_blocks() { + public function test_get_course_blocks(): void { global $DB, $FULLME; $this->resetAfterTest(true); @@ -73,7 +73,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_course_blocks on site home */ - public function test_get_course_blocks_site_home() { + public function test_get_course_blocks_site_home(): void { global $DB, $FULLME; $this->resetAfterTest(true); @@ -102,7 +102,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_course_blocks */ - public function test_get_course_blocks_overrides() { + public function test_get_course_blocks_overrides(): void { global $DB, $CFG, $FULLME; $this->resetAfterTest(true); @@ -137,7 +137,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_course_blocks contents */ - public function test_get_course_blocks_contents() { + public function test_get_course_blocks_contents(): void { global $DB, $FULLME; $this->resetAfterTest(true); @@ -233,7 +233,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_course_blocks contents with mathjax. */ - public function test_get_course_blocks_contents_with_mathjax() { + public function test_get_course_blocks_contents_with_mathjax(): void { global $DB, $CFG; $this->resetAfterTest(true); @@ -310,7 +310,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test user get default dashboard blocks. */ - public function test_get_dashboard_blocks_default_dashboard() { + public function test_get_dashboard_blocks_default_dashboard(): void { global $PAGE, $DB; $this->resetAfterTest(true); @@ -359,7 +359,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test user get default dashboard blocks including a sticky block. */ - public function test_get_dashboard_blocks_default_dashboard_including_sticky_block() { + public function test_get_dashboard_blocks_default_dashboard_including_sticky_block(): void { global $PAGE, $DB; $this->resetAfterTest(true); @@ -407,7 +407,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test admin get user's custom dashboard blocks. */ - public function test_get_dashboard_blocks_custom_user_dashboard() { + public function test_get_dashboard_blocks_custom_user_dashboard(): void { global $PAGE, $DB; $this->resetAfterTest(true); @@ -458,7 +458,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test user tries to get other user blocks not having permission. */ - public function test_get_dashboard_blocks_other_user_missing_permissions() { + public function test_get_dashboard_blocks_other_user_missing_permissions(): void { $this->resetAfterTest(true); $user1 = $this->getDataGenerator()->create_user(); @@ -473,7 +473,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test user get default dashboard blocks for my courses page. */ - public function test_get_dashboard_blocks_my_courses() { + public function test_get_dashboard_blocks_my_courses(): void { global $PAGE, $DB; $this->resetAfterTest(true); @@ -522,7 +522,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test user passing the wrong page type and getting an exception. */ - public function test_get_dashboard_blocks_incorrect_page() { + public function test_get_dashboard_blocks_incorrect_page(): void { global $PAGE; $this->resetAfterTest(true); diff --git a/blocks/tests/privacy/provider_test.php b/blocks/tests/privacy/provider_test.php index 6438ccc081c..1f142795c6c 100644 --- a/blocks/tests/privacy/provider_test.php +++ b/blocks/tests/privacy/provider_test.php @@ -49,7 +49,7 @@ class provider_test extends provider_testcase { $this->resetAfterTest(); } - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { $dg = $this->getDataGenerator(); $c1 = $dg->create_course(); $c2 = $dg->create_course(); @@ -97,7 +97,7 @@ class provider_test extends provider_testcase { /** * Test that user IDs are returned for a given context. */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { global $DB; $u1 = $this->getDataGenerator()->create_user(); $u2 = $this->getDataGenerator()->create_user(); @@ -125,7 +125,7 @@ class provider_test extends provider_testcase { } - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; $dg = $this->getDataGenerator(); $c1 = $dg->create_course(); @@ -195,7 +195,7 @@ class provider_test extends provider_testcase { 'name' => "docked_block_instance_{$blockmentees->instance->id}"])); } - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; $dg = $this->getDataGenerator(); $c1 = $dg->create_course(); @@ -301,7 +301,7 @@ class provider_test extends provider_testcase { /** * Test the deletion of data related to a context and a list of users. */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { global $DB; $u1 = $this->getDataGenerator()->create_user(); $u2 = $this->getDataGenerator()->create_user(); @@ -339,7 +339,7 @@ class provider_test extends provider_testcase { ['name' => "block{$blockcontext->instanceid}hidden"])); } - public function test_export_data_for_user() { + public function test_export_data_for_user(): void { global $DB; $dg = $this->getDataGenerator(); $c1 = $dg->create_course(); diff --git a/blocks/timeline/tests/privacy/provider_test.php b/blocks/timeline/tests/privacy/provider_test.php index 4850b9ea82b..b6f404c9a07 100644 --- a/blocks/timeline/tests/privacy/provider_test.php +++ b/blocks/timeline/tests/privacy/provider_test.php @@ -40,7 +40,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Ensure that export_user_preferences returns no data if the user has not visited the myoverview block. */ - public function test_export_user_preferences_no_pref() { + public function test_export_user_preferences_no_pref(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); @@ -58,7 +58,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { * * @dataProvider user_preference_provider */ - public function test_export_user_preferences($type, $value, $expected) { + public function test_export_user_preferences($type, $value, $expected): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); set_user_preference($type, $value, $user); diff --git a/blog/tests/event/events_test.php b/blog/tests/event/events_test.php index 23c5a5223d9..e5fd6279de8 100644 --- a/blog/tests/event/events_test.php +++ b/blog/tests/event/events_test.php @@ -109,7 +109,7 @@ class events_test extends \advanced_testcase { /** * Test various blog related events. */ - public function test_blog_entry_created_event() { + public function test_blog_entry_created_event(): void { global $USER; $this->setAdminUser(); @@ -143,7 +143,7 @@ class events_test extends \advanced_testcase { /** * Tests for event blog_entry_updated. */ - public function test_blog_entry_updated_event() { + public function test_blog_entry_updated_event(): void { global $USER; $this->setAdminUser(); @@ -174,7 +174,7 @@ class events_test extends \advanced_testcase { /** * Tests for event blog_entry_deleted. */ - public function test_blog_entry_deleted_event() { + public function test_blog_entry_deleted_event(): void { global $USER, $DB; $this->setAdminUser(); @@ -205,7 +205,7 @@ class events_test extends \advanced_testcase { /** * Tests for event blog_association_deleted. */ - public function test_blog_association_deleted_event() { + public function test_blog_association_deleted_event(): void { global $USER; $this->setAdminUser(); @@ -250,7 +250,7 @@ class events_test extends \advanced_testcase { /** * Tests for event blog_association_created. */ - public function test_blog_association_created_event() { + public function test_blog_association_created_event(): void { global $USER; $this->setAdminUser(); @@ -298,7 +298,7 @@ class events_test extends \advanced_testcase { /** * Tests for event blog_association_created validations. */ - public function test_blog_association_created_event_validations() { + public function test_blog_association_created_event_validations(): void { $this->resetAfterTest(); @@ -356,7 +356,7 @@ class events_test extends \advanced_testcase { /** * Tests for event blog_entries_viewed. */ - public function test_blog_entries_viewed_event() { + public function test_blog_entries_viewed_event(): void { $this->setAdminUser(); @@ -381,7 +381,7 @@ class events_test extends \advanced_testcase { /** * Test comment_created event. */ - public function test_blog_comment_created_event() { + public function test_blog_comment_created_event(): void { global $USER, $CFG; $this->setAdminUser(); @@ -417,7 +417,7 @@ class events_test extends \advanced_testcase { /** * Test comment_deleted event. */ - public function test_blog_comment_deleted_event() { + public function test_blog_comment_deleted_event(): void { global $USER, $CFG; $this->setAdminUser(); @@ -457,7 +457,7 @@ class events_test extends \advanced_testcase { * There is no external API for this, so the unit test will simply * create and trigger the event and ensure data is returned as expected. */ - public function test_external_blog_added_event() { + public function test_external_blog_added_event(): void { // Trigger an event: external blog added. $eventparams = array( @@ -486,7 +486,7 @@ class events_test extends \advanced_testcase { * There is no external API for this, so the unit test will simply * create and trigger the event and ensure data is returned as expected. */ - public function test_external_blog_updated_event() { + public function test_external_blog_updated_event(): void { // Trigger an event: external blog updated. $eventparams = array( @@ -515,7 +515,7 @@ class events_test extends \advanced_testcase { * There is no external API for this, so the unit test will simply * create and trigger the event and ensure data is returned as expected. */ - public function test_external_blog_removed_event() { + public function test_external_blog_removed_event(): void { // Trigger an event: external blog removed. $eventparams = array( @@ -542,7 +542,7 @@ class events_test extends \advanced_testcase { * There is no external API for this, so the unit test will simply * create and trigger the event and ensure data is returned as expected. */ - public function test_external_blogs_viewed_event() { + public function test_external_blogs_viewed_event(): void { // Trigger an event: external blogs viewed. $eventparams = array( diff --git a/blog/tests/external/external_test.php b/blog/tests/external/external_test.php index efe707a2e57..dc98b27ed8d 100644 --- a/blog/tests/external/external_test.php +++ b/blog/tests/external/external_test.php @@ -105,7 +105,7 @@ class external_test extends \externallib_advanced_testcase { * Get global public entries even for not authenticated users. * We get the entry since is public. */ - public function test_get_public_entries_global_level_by_non_logged_users() { + public function test_get_public_entries_global_level_by_non_logged_users(): void { global $CFG, $DB; $CFG->bloglevel = BLOG_GLOBAL_LEVEL; @@ -126,7 +126,7 @@ class external_test extends \externallib_advanced_testcase { /** * Get global public entries even for not authenticated users in closed site. */ - public function test_get_public_entries_global_level_by_non_logged_users_closed_site() { + public function test_get_public_entries_global_level_by_non_logged_users_closed_site(): void { global $CFG, $DB; $CFG->bloglevel = BLOG_GLOBAL_LEVEL; @@ -142,7 +142,7 @@ class external_test extends \externallib_advanced_testcase { * Get global public entries for guest users. * We get the entry since is public. */ - public function test_get_public_entries_global_level_by_guest_users() { + public function test_get_public_entries_global_level_by_guest_users(): void { global $CFG, $DB; $CFG->bloglevel = BLOG_GLOBAL_LEVEL; @@ -163,7 +163,7 @@ class external_test extends \externallib_advanced_testcase { * Get global not public entries even for not authenticated users withouth being authenticated. * We don't get any because they are not public (restricted to site users). */ - public function test_get_not_public_entries_global_level_by_non_logged_users() { + public function test_get_not_public_entries_global_level_by_non_logged_users(): void { global $CFG; $CFG->bloglevel = BLOG_GLOBAL_LEVEL; @@ -177,7 +177,7 @@ class external_test extends \externallib_advanced_testcase { * Get global not public entries users being guest. * We don't get any because they are not public (restricted to real site users). */ - public function test_get_not_public_entries_global_level_by_guest_user() { + public function test_get_not_public_entries_global_level_by_guest_user(): void { global $CFG; $CFG->bloglevel = BLOG_GLOBAL_LEVEL; @@ -192,7 +192,7 @@ class external_test extends \externallib_advanced_testcase { * Get site not public entries for not authenticated users. * We don't get any because they are not public (restricted to real site users). */ - public function test_get_not_public_entries_site_level_by_non_logged_users() { + public function test_get_not_public_entries_site_level_by_non_logged_users(): void { $this->expectException('require_login_exception'); // In this case we get a security exception. $result = \core_blog\external::get_entries(); } @@ -201,7 +201,7 @@ class external_test extends \externallib_advanced_testcase { * Get site not public entries for guest users. * We don't get any because they are not public (restricted to real site users). */ - public function test_get_not_public_entries_site_level_by_guest_users() { + public function test_get_not_public_entries_site_level_by_guest_users(): void { $this->setGuestUser(); $result = \core_blog\external::get_entries(); @@ -212,7 +212,7 @@ class external_test extends \externallib_advanced_testcase { /** * Get site entries at site level by system users. */ - public function test_get_site_entries_site_level_by_normal_users() { + public function test_get_site_entries_site_level_by_normal_users(): void { $this->setUser($this->userid); $result = \core_blog\external::get_entries(); @@ -224,7 +224,7 @@ class external_test extends \externallib_advanced_testcase { /** * Get draft site entries by authors. */ - public function test_get_draft_entries_site_level_by_author_users() { + public function test_get_draft_entries_site_level_by_author_users(): void { global $DB; // Set current entry global. @@ -240,7 +240,7 @@ class external_test extends \externallib_advanced_testcase { /** * Get draft site entries by not authors. */ - public function test_get_draft_entries_site_level_by_not_author_users() { + public function test_get_draft_entries_site_level_by_not_author_users(): void { global $DB; // Set current entry global. @@ -256,7 +256,7 @@ class external_test extends \externallib_advanced_testcase { /** * Get draft site entries by admin. */ - public function test_get_draft_entries_site_level_by_admin_users() { + public function test_get_draft_entries_site_level_by_admin_users(): void { global $DB; // Set current entry global. @@ -274,7 +274,7 @@ class external_test extends \externallib_advanced_testcase { /** * Get draft user entries by authors. */ - public function test_get_draft_entries_user_level_by_author_users() { + public function test_get_draft_entries_user_level_by_author_users(): void { global $CFG, $DB; $CFG->bloglevel = BLOG_USER_LEVEL; @@ -292,7 +292,7 @@ class external_test extends \externallib_advanced_testcase { /** * Get draft user entries by not authors. */ - public function test_get_draft_entries_user_level_by_not_author_users() { + public function test_get_draft_entries_user_level_by_not_author_users(): void { global $CFG, $DB; $CFG->bloglevel = BLOG_USER_LEVEL; @@ -309,7 +309,7 @@ class external_test extends \externallib_advanced_testcase { /** * Get draft user entries by admin. */ - public function test_get_draft_entries_user_level_by_admin_users() { + public function test_get_draft_entries_user_level_by_admin_users(): void { global $CFG, $DB; $CFG->bloglevel = BLOG_USER_LEVEL; @@ -327,7 +327,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test get all entries including testing pagination. */ - public function test_get_all_entries_including_pagination() { + public function test_get_all_entries_including_pagination(): void { global $DB, $USER; $DB->set_field('post', 'publishstate', 'site', array('id' => $this->postid)); @@ -368,7 +368,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test get entries filtering by course. */ - public function test_get_entries_filtering_by_course() { + public function test_get_entries_filtering_by_course(): void { global $CFG, $DB; $DB->set_field('post', 'publishstate', 'site', array('id' => $this->postid)); @@ -402,7 +402,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test get entries filtering by module. */ - public function test_get_entries_filtering_by_module() { + public function test_get_entries_filtering_by_module(): void { global $CFG, $DB; $DB->set_field('post', 'publishstate', 'site', array('id' => $this->postid)); @@ -435,7 +435,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test get entries filtering by author. */ - public function test_get_entries_filtering_by_author() { + public function test_get_entries_filtering_by_author(): void { $this->setAdminUser(); // Filter by author. $result = \core_blog\external::get_entries(array(array('name' => 'userid', 'value' => $this->userid))); @@ -451,7 +451,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test get entries filtering by entry. */ - public function test_get_entries_filtering_by_entry() { + public function test_get_entries_filtering_by_entry(): void { $this->setAdminUser(); // Filter by correct entry. $result = \core_blog\external::get_entries(array(array('name' => 'entryid', 'value' => $this->postid))); @@ -465,7 +465,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test get entries filtering by search. */ - public function test_get_entries_filtering_by_search() { + public function test_get_entries_filtering_by_search(): void { $this->setAdminUser(); // Filter by correct search. $result = \core_blog\external::get_entries(array(array('name' => 'search', 'value' => 'test'))); @@ -480,7 +480,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test get entries filtering by tag. */ - public function test_get_entries_filtering_by_tag() { + public function test_get_entries_filtering_by_tag(): void { $this->setAdminUser(); // Filter by correct tag. $result = \core_blog\external::get_entries(array(array('name' => 'tag', 'value' => 'tag1'))); @@ -498,7 +498,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test get entries filtering by tag id. */ - public function test_get_entries_filtering_by_tagid() { + public function test_get_entries_filtering_by_tagid(): void { $this->setAdminUser(); // Filter by correct tag. $result = \core_blog\external::get_entries(array(array('name' => 'tagid', 'value' => $this->tagid))); @@ -518,7 +518,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test get entries filtering by group. */ - public function test_get_entries_filtering_by_group() { + public function test_get_entries_filtering_by_group(): void { $this->setAdminUser(); // Add blog associations with a course. $coursecontext = \context_course::instance($this->courseid); @@ -538,7 +538,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test get entries multiple filter. */ - public function test_get_entries_multiple_filter() { + public function test_get_entries_multiple_filter(): void { $this->setAdminUser(); // Add blog associations with a course. $coursecontext = \context_course::instance($this->courseid); @@ -564,7 +564,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test get entries filtering by invalid_filter. */ - public function test_get_entries_filtering_by_invalid_filter() { + public function test_get_entries_filtering_by_invalid_filter(): void { $this->setAdminUser(); // Filter by incorrect filter. $this->expectException('\moodle_exception'); @@ -574,7 +574,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test get entries when blog is disabled. */ - public function test_get_entries_blog_disabled() { + public function test_get_entries_blog_disabled(): void { global $CFG; $this->setAdminUser(); @@ -587,7 +587,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test view_blog_entries without filter. */ - public function test_view_blog_entries_without_filtering() { + public function test_view_blog_entries_without_filtering(): void { // Test user with full capabilities. $this->setUser($this->userid); // Trigger and capture the event. @@ -615,7 +615,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test view_blog_entries doing filtering. */ - public function test_view_blog_entries_with_filtering() { + public function test_view_blog_entries_with_filtering(): void { // Test user with full capabilities. $this->setUser($this->userid); // Trigger and capture the event. @@ -646,7 +646,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test get_access_information */ - public function test_get_access_information() { + public function test_get_access_information(): void { global $CFG; $this->setAdminUser(); @@ -677,7 +677,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test add_entry */ - public function test_add_entry() { + public function test_add_entry(): void { global $USER; $this->resetAfterTest(true); @@ -754,7 +754,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test add_entry when blogs not enabled. */ - public function test_add_entry_blog_not_enabled() { + public function test_add_entry_blog_not_enabled(): void { global $CFG; $this->resetAfterTest(true); @@ -769,7 +769,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test add_entry without permissions. */ - public function test_add_entry_no_permission() { + public function test_add_entry_no_permission(): void { global $CFG; $this->resetAfterTest(true); @@ -788,7 +788,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test add_entry invalid parameter. */ - public function test_add_entry_invalid_parameter() { + public function test_add_entry_invalid_parameter(): void { $this->resetAfterTest(true); $this->setAdminUser(); @@ -801,7 +801,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test add_entry diabled associations. */ - public function test_add_entry_disabled_assoc() { + public function test_add_entry_disabled_assoc(): void { global $CFG; $CFG->useblogassociations = 0; @@ -817,7 +817,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test add_entry invalid publish state. */ - public function test_add_entry_invalid_publishstate() { + public function test_add_entry_invalid_publishstate(): void { $this->resetAfterTest(true); $this->setAdminUser(); @@ -830,7 +830,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test add_entry invalid association. */ - public function test_add_entry_invalid_association() { + public function test_add_entry_invalid_association(): void { $this->resetAfterTest(true); $course = $this->getDataGenerator()->create_course(); @@ -851,7 +851,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test delete_entry */ - public function test_delete_entry() { + public function test_delete_entry(): void { $this->resetAfterTest(true); // I can delete my own entry. @@ -865,7 +865,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test delete_entry from another user (no permissions) */ - public function test_delete_entry_no_permissions() { + public function test_delete_entry_no_permissions(): void { $this->resetAfterTest(true); $user = $this->getDataGenerator()->create_user(); @@ -881,7 +881,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test delete_entry when blogs not enabled. */ - public function test_delete_entry_blog_not_enabled() { + public function test_delete_entry_blog_not_enabled(): void { global $CFG; $this->resetAfterTest(true); @@ -896,7 +896,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test delete_entry invalid entry id. */ - public function test_delete_entry_invalid_entry() { + public function test_delete_entry_invalid_entry(): void { global $CFG; $this->resetAfterTest(true); @@ -909,7 +909,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test prepare_entry_for_edition. */ - public function test_prepare_entry_for_edition() { + public function test_prepare_entry_for_edition(): void { $this->resetAfterTest(true); $this->setAdminUser(); @@ -931,7 +931,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test prepare_entry_for_edition when blogs not enabled. */ - public function test_prepare_entry_for_edition_blog_not_enabled() { + public function test_prepare_entry_for_edition_blog_not_enabled(): void { global $CFG; $this->resetAfterTest(true); @@ -946,7 +946,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test prepare_entry_for_edition invalid entry id. */ - public function test_prepare_entry_for_edition_invalid_entry() { + public function test_prepare_entry_for_edition_invalid_entry(): void { $this->resetAfterTest(true); $this->setAdminUser(); @@ -957,7 +957,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test prepare_entry_for_edition without permissions. */ - public function test_prepare_entry_for_edition_no_permission() { + public function test_prepare_entry_for_edition_no_permission(): void { $this->resetAfterTest(true); $user = $this->getDataGenerator()->create_user(); @@ -972,7 +972,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test update_entry */ - public function test_update_entry() { + public function test_update_entry(): void { global $USER; $this->resetAfterTest(true); @@ -1111,7 +1111,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test update_entry when blogs not enabled. */ - public function test_update_entry_blog_not_enabled() { + public function test_update_entry_blog_not_enabled(): void { global $CFG; $this->resetAfterTest(true); @@ -1126,7 +1126,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test update_entry without permissions. */ - public function test_update_entry_no_permission() { + public function test_update_entry_no_permission(): void { global $CFG; $this->resetAfterTest(true); @@ -1145,7 +1145,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test update_entry invalid parameter. */ - public function test_update_entry_invalid_parameter() { + public function test_update_entry_invalid_parameter(): void { $this->resetAfterTest(true); $this->setAdminUser(); @@ -1158,7 +1158,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test update_entry diabled associations. */ - public function test_update_entry_disabled_assoc() { + public function test_update_entry_disabled_assoc(): void { global $CFG; $CFG->useblogassociations = 0; @@ -1174,7 +1174,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test update_entry invalid publish state. */ - public function test_update_entry_invalid_publishstate() { + public function test_update_entry_invalid_publishstate(): void { $this->resetAfterTest(true); $this->setAdminUser(); @@ -1187,7 +1187,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test update_entry invalid association. */ - public function test_update_entry_invalid_association() { + public function test_update_entry_invalid_association(): void { $this->resetAfterTest(true); $course = $this->getDataGenerator()->create_course(); @@ -1208,7 +1208,7 @@ class external_test extends \externallib_advanced_testcase { /** * Test update_entry from another user (no permissions) */ - public function test_update_entry_no_permissions() { + public function test_update_entry_no_permissions(): void { $this->resetAfterTest(true); $user = $this->getDataGenerator()->create_user(); diff --git a/blog/tests/lib_test.php b/blog/tests/lib_test.php index 0eb80f70e9b..f4965927590 100644 --- a/blog/tests/lib_test.php +++ b/blog/tests/lib_test.php @@ -91,7 +91,7 @@ class lib_test extends \advanced_testcase { } - public function test_overrides() { + public function test_overrides(): void { global $SITE; // Try all the filters at once: Only the entry filter is active. @@ -132,25 +132,25 @@ class lib_test extends \advanced_testcase { // The following series of 'test_blog..' functions correspond to the blog_get_headers() function within blog/lib.php. // Some cases are omitted due to the optional_param variables used. - public function test_blog_get_headers_case_1() { + public function test_blog_get_headers_case_1(): void { global $CFG, $PAGE, $OUTPUT; $blogheaders = blog_get_headers(); $this->assertEquals($blogheaders['heading'], get_string('siteblogheading', 'blog')); } - public function test_blog_get_headers_case_6() { + public function test_blog_get_headers_case_6(): void { global $CFG, $PAGE, $OUTPUT; $blogheaders = blog_get_headers($this->courseid, null, $this->userid); $this->assertNotEquals($blogheaders['heading'], ''); } - public function test_blog_get_headers_case_7() { + public function test_blog_get_headers_case_7(): void { global $CFG, $PAGE, $OUTPUT; $blogheaders = blog_get_headers(null, $this->groupid); $this->assertNotEquals($blogheaders['heading'], ''); } - public function test_blog_get_headers_case_10() { + public function test_blog_get_headers_case_10(): void { global $CFG, $PAGE, $OUTPUT; $blogheaders = blog_get_headers($this->courseid); $this->assertNotEquals($blogheaders['heading'], ''); @@ -159,7 +159,7 @@ class lib_test extends \advanced_testcase { /** * Tests the core_blog_myprofile_navigation() function. */ - public function test_core_blog_myprofile_navigation() { + public function test_core_blog_myprofile_navigation(): void { global $USER; // Set up the test. @@ -181,7 +181,7 @@ class lib_test extends \advanced_testcase { /** * Tests the core_blog_myprofile_navigation() function as a guest. */ - public function test_core_blog_myprofile_navigation_as_guest() { + public function test_core_blog_myprofile_navigation_as_guest(): void { global $USER; // Set up the test. @@ -202,7 +202,7 @@ class lib_test extends \advanced_testcase { /** * Tests the core_blog_myprofile_navigation() function when blogs are disabled. */ - public function test_core_blog_myprofile_navigation_blogs_disabled() { + public function test_core_blog_myprofile_navigation_blogs_disabled(): void { global $USER; // Set up the test. @@ -221,7 +221,7 @@ class lib_test extends \advanced_testcase { $this->assertArrayNotHasKey('blogs', $nodes->getValue($tree)); } - public function test_blog_get_listing_course() { + public function test_blog_get_listing_course(): void { $this->setAdminUser(); $coursecontext = \context_course::instance($this->courseid); $anothercourse = $this->getDataGenerator()->create_course(); @@ -251,7 +251,7 @@ class lib_test extends \advanced_testcase { $this->assertCount(1, $bloglisting->get_entries()); } - public function test_blog_get_listing_module() { + public function test_blog_get_listing_module(): void { $this->setAdminUser(); $coursecontext = \context_course::instance($this->courseid); $contextmodule = \context_module::instance($this->cmid); diff --git a/blog/tests/privacy/provider_test.php b/blog/tests/privacy/provider_test.php index a2fe8eb0de0..05d1e6594e8 100644 --- a/blog/tests/privacy/provider_test.php +++ b/blog/tests/privacy/provider_test.php @@ -52,7 +52,7 @@ class provider_test extends provider_testcase { $this->resetAfterTest(); } - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { $dg = $this->getDataGenerator(); $c1 = $dg->create_course(); $c2 = $dg->create_course(); @@ -112,7 +112,7 @@ class provider_test extends provider_testcase { $this->assertTrue(in_array($u1ctx->id, $contextids)); } - public function test_get_contexts_for_userid_with_one_associated_post_only() { + public function test_get_contexts_for_userid_with_one_associated_post_only(): void { $dg = $this->getDataGenerator(); $c1 = $dg->create_course(); $u1 = $dg->create_user(); @@ -133,7 +133,7 @@ class provider_test extends provider_testcase { /** * Test that user IDs are returned for a specificed course or module context. */ - public function test_get_users_in_context_course_and_module() { + public function test_get_users_in_context_course_and_module(): void { $user1 = $this->getDataGenerator()->create_user(); $user2 = $this->getDataGenerator()->create_user(); $course = $this->getDataGenerator()->create_course(); @@ -170,7 +170,7 @@ class provider_test extends provider_testcase { /** * Test that user IDs are returned for a specificed user context. */ - public function test_get_users_in_context_user_context() { + public function test_get_users_in_context_user_context(): void { $user1 = $this->getDataGenerator()->create_user(); $user2 = $this->getDataGenerator()->create_user(); $u1ctx = \context_user::instance($user1->id); @@ -192,7 +192,7 @@ class provider_test extends provider_testcase { /** * Test that user IDs are returned for a specificed user context for an external blog. */ - public function test_get_users_in_context_external_blog() { + public function test_get_users_in_context_external_blog(): void { $user1 = $this->getDataGenerator()->create_user(); $u1ctx = \context_user::instance($user1->id); $extu1 = $this->create_external_blog(['userid' => $user1->id]); @@ -203,7 +203,7 @@ class provider_test extends provider_testcase { $this->assertCount(1, $userids); } - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; $dg = $this->getDataGenerator(); @@ -376,7 +376,7 @@ class provider_test extends provider_testcase { * * @return void */ - public function test_delete_data_for_user_empty_context() { + public function test_delete_data_for_user_empty_context(): void { global $DB; $user = $this->getDataGenerator()->create_user(); @@ -402,7 +402,7 @@ class provider_test extends provider_testcase { $this->assertEmpty($DB->get_records('blog_association', ['contextid' => $context->id])); } - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; $dg = $this->getDataGenerator(); @@ -539,7 +539,7 @@ class provider_test extends provider_testcase { $this->assertCount(1, $DB->get_records('blog_external', ['userid' => $u2->id])); } - public function test_export_data_for_user() { + public function test_export_data_for_user(): void { global $DB; $dg = $this->getDataGenerator(); @@ -737,7 +737,7 @@ class provider_test extends provider_testcase { /** * Test that deleting of blog information in a user context works as desired. */ - public function test_delete_data_for_users_user_context() { + public function test_delete_data_for_users_user_context(): void { global $DB; $u1 = $this->getDataGenerator()->create_user(); @@ -780,7 +780,7 @@ class provider_test extends provider_testcase { /** * Test that deleting of an external blog in a user context works as desired. */ - public function test_delete_data_for_users_external_blog() { + public function test_delete_data_for_users_external_blog(): void { global $DB; $u1 = $this->getDataGenerator()->create_user(); @@ -800,7 +800,7 @@ class provider_test extends provider_testcase { $this->assertCount(1, $DB->get_records('blog_external')); } - public function test_delete_data_for_users_course_and_module_context() { + public function test_delete_data_for_users_course_and_module_context(): void { global $DB; $u1 = $this->getDataGenerator()->create_user(); diff --git a/cache/stores/apcu/tests/store_test.php b/cache/stores/apcu/tests/store_test.php index 975ac673897..f4fee05346c 100644 --- a/cache/stores/apcu/tests/store_test.php +++ b/cache/stores/apcu/tests/store_test.php @@ -53,7 +53,7 @@ class store_test extends \cachestore_tests { /** * Test that the Moodle APCu store doesn't cross paths with other code using APCu as well. */ - public function test_cross_application_interaction() { + public function test_cross_application_interaction(): void { $definition = cache_definition::load_adhoc(cache_store::MODE_APPLICATION, 'cachestore_apcu', 'phpunit_test'); $instance = new cachestore_apcu('Test', cachestore_apcu::unit_test_configuration()); $instance->initialise($definition); @@ -72,7 +72,7 @@ class store_test extends \cachestore_tests { $this->assertSame('pirate', apcu_fetch('test')); } - public function test_different_caches_have_different_prefixes() { + public function test_different_caches_have_different_prefixes(): void { $definition = cache_definition::load_adhoc(cache_store::MODE_APPLICATION, 'cachestore_apcu', 'phpunit_test'); $instance = new cachestore_apcu('Test', cachestore_apcu::unit_test_configuration()); $instance->initialise($definition); diff --git a/cache/stores/file/tests/asyncpurge_test.php b/cache/stores/file/tests/asyncpurge_test.php index 79bb5dac3b5..66bde847190 100644 --- a/cache/stores/file/tests/asyncpurge_test.php +++ b/cache/stores/file/tests/asyncpurge_test.php @@ -39,7 +39,7 @@ class asyncpurge_test extends \advanced_testcase { * @covers ::get * @covers ::purge */ - public function test_cache_async_purge() { + public function test_cache_async_purge(): void { $this->resetAfterTest(true); // Cache definition. @@ -72,7 +72,7 @@ class asyncpurge_test extends \advanced_testcase { * * @covers \cachestore_file\task */ - public function test_cache_async_purge_cron() { + public function test_cache_async_purge_cron(): void { global $CFG, $USER; $this->resetAfterTest(true); diff --git a/cache/stores/file/tests/store_test.php b/cache/stores/file/tests/store_test.php index d39725bd2c7..9153b091225 100644 --- a/cache/stores/file/tests/store_test.php +++ b/cache/stores/file/tests/store_test.php @@ -51,7 +51,7 @@ class store_test extends \cachestore_tests { * The deleting of cache simulates some other process purging * the cache. */ - public function test_cache_get_with_prescan_and_purge() { + public function test_cache_get_with_prescan_and_purge(): void { global $CFG; $definition = cache_definition::load_adhoc(cache_store::MODE_REQUEST, 'cachestore_file', 'phpunit_test'); @@ -101,7 +101,7 @@ class store_test extends \cachestore_tests { $this->assertEquals(21, $store->get_last_io_bytes()); } - public function test_lock() { + public function test_lock(): void { $store = new \cachestore_file('Test'); $this->assertTrue($store->acquire_lock('lock', '123')); diff --git a/cache/stores/redis/tests/compressor_test.php b/cache/stores/redis/tests/compressor_test.php index f12377d0e6e..6df84410465 100644 --- a/cache/stores/redis/tests/compressor_test.php +++ b/cache/stores/redis/tests/compressor_test.php @@ -71,7 +71,7 @@ class compressor_test extends \advanced_testcase { /** * It misses a value. */ - public function test_it_can_miss_one() { + public function test_it_can_miss_one(): void { $store = $this->create_store(cachestore_redis::COMPRESSOR_PHP_GZIP, \Redis::SERIALIZER_PHP); self::assertFalse($store->get('missme')); @@ -80,7 +80,7 @@ class compressor_test extends \advanced_testcase { /** * It misses many values. */ - public function test_it_can_miss_many() { + public function test_it_can_miss_many(): void { $store = $this->create_store(cachestore_redis::COMPRESSOR_PHP_GZIP, \Redis::SERIALIZER_PHP); $expected = ['missme' => false, 'missmetoo' => false]; @@ -91,7 +91,7 @@ class compressor_test extends \advanced_testcase { /** * It misses some values. */ - public function test_it_can_miss_some() { + public function test_it_can_miss_some(): void { $store = $this->create_store(cachestore_redis::COMPRESSOR_PHP_GZIP, \Redis::SERIALIZER_PHP); $store->set('iamhere', 'youfoundme'); @@ -134,7 +134,7 @@ class compressor_test extends \advanced_testcase { * @param string $key * @param mixed $value */ - public function test_it_works_with_different_types($key, $value) { + public function test_it_works_with_different_types($key, $value): void { $store = $this->create_store(cachestore_redis::COMPRESSOR_PHP_GZIP, \Redis::SERIALIZER_PHP); $store->set($key, $value); @@ -144,7 +144,7 @@ class compressor_test extends \advanced_testcase { /** * Test it works with different types for many. */ - public function test_it_works_with_different_types_for_many() { + public function test_it_works_with_different_types_for_many(): void { $store = $this->create_store(cachestore_redis::COMPRESSOR_PHP_GZIP, \Redis::SERIALIZER_PHP); $provider = $this->provider_for_test_it_works_with_different_types(); @@ -234,7 +234,7 @@ class compressor_test extends \advanced_testcase { * @param string $rawexpected1 * @param string $rawexpected2 */ - public function test_it_can_use_getset($name, $serializer, $compressor, $rawexpected1, $rawexpected2) { + public function test_it_can_use_getset($name, $serializer, $compressor, $rawexpected1, $rawexpected2): void { // Create a connection with the desired serialisation. $store = $this->create_store($compressor, $serializer); $store->set('key', 'value1'); @@ -258,7 +258,7 @@ class compressor_test extends \advanced_testcase { * @param string $rawexpected1 * @param string $rawexpected2 */ - public function test_it_can_use_getsetmany($name, $serializer, $compressor, $rawexpected1, $rawexpected2) { + public function test_it_can_use_getsetmany($name, $serializer, $compressor, $rawexpected1, $rawexpected2): void { $many = [ ['key' => 'key1', 'value' => 'value1'], ['key' => 'key2', 'value' => 'value2'], diff --git a/cache/stores/redis/tests/store_test.php b/cache/stores/redis/tests/store_test.php index 525848bf06b..8dcbe42df60 100644 --- a/cache/stores/redis/tests/store_test.php +++ b/cache/stores/redis/tests/store_test.php @@ -105,7 +105,7 @@ class store_test extends \cachestore_tests { return $store; } - public function test_has() { + public function test_has(): void { $store = $this->create_cachestore_redis(); $this->assertTrue($store->set('foo', 'bar')); @@ -113,7 +113,7 @@ class store_test extends \cachestore_tests { $this->assertFalse($store->has('bat')); } - public function test_has_any() { + public function test_has_any(): void { $store = $this->create_cachestore_redis(); $this->assertTrue($store->set('foo', 'bar')); @@ -121,7 +121,7 @@ class store_test extends \cachestore_tests { $this->assertFalse($store->has_any(array('bat', 'baz'))); } - public function test_has_all() { + public function test_has_all(): void { $store = $this->create_cachestore_redis(); $this->assertTrue($store->set('foo', 'bar')); @@ -130,7 +130,7 @@ class store_test extends \cachestore_tests { $this->assertFalse($store->has_all(array('foo', 'bat', 'this'))); } - public function test_lock() { + public function test_lock(): void { $store = $this->create_cachestore_redis(); $this->assertTrue($store->acquire_lock('lock', '123')); diff --git a/cache/stores/session/tests/store_test.php b/cache/stores/session/tests/store_test.php index 0c9ec4a1e13..4ccef41df28 100644 --- a/cache/stores/session/tests/store_test.php +++ b/cache/stores/session/tests/store_test.php @@ -44,7 +44,7 @@ class store_test extends \cachestore_tests { /** * Test the maxsize option. */ - public function test_maxsize() { + public function test_maxsize(): void { $config = \cache_config_testing::instance(); $config->phpunit_add_definition('phpunit/one', array( 'mode' => cache_store::MODE_SESSION, @@ -166,7 +166,7 @@ class store_test extends \cachestore_tests { $cacheone->get_many(array('keyC', 'keyE', 'keyD', 'keyF'))); } - public function test_ttl() { + public function test_ttl(): void { $config = \cache_config_testing::instance(); $config->phpunit_add_definition('phpunit/three', array( 'mode' => cache_store::MODE_SESSION, diff --git a/cache/stores/static/tests/store_test.php b/cache/stores/static/tests/store_test.php index 0e4615a42c8..329e608596e 100644 --- a/cache/stores/static/tests/store_test.php +++ b/cache/stores/static/tests/store_test.php @@ -46,7 +46,7 @@ class store_test extends \cachestore_tests { /** * Test the maxsize option. */ - public function test_maxsize() { + public function test_maxsize(): void { $defid = 'phpunit/testmaxsize'; $config = \cache_config_testing::instance(); $config->phpunit_add_definition($defid, array( @@ -119,7 +119,7 @@ class store_test extends \cachestore_tests { /** * Simple test to verify igbinary availability and check basic serialization is working ok. */ - public function test_igbinary_serializer() { + public function test_igbinary_serializer(): void { // Skip if igbinary is not available. if (!extension_loaded('igbinary')) { $this->markTestSkipped('Cannot test igbinary serializer. Extension missing'); diff --git a/cache/tests/administration_helper_test.php b/cache/tests/administration_helper_test.php index 7ae3e16cbb0..b61cc087a8a 100644 --- a/cache/tests/administration_helper_test.php +++ b/cache/tests/administration_helper_test.php @@ -151,7 +151,7 @@ class administration_helper_test extends \advanced_testcase { /** * Test instantiating an add store form. */ - public function test_get_add_store_form() { + public function test_get_add_store_form(): void { $form = cache_factory::get_administration_display_helper()->get_add_store_form('file'); $this->assertInstanceOf('moodleform', $form); @@ -166,7 +166,7 @@ class administration_helper_test extends \advanced_testcase { /** * Test instantiating a form to edit a store instance. */ - public function test_get_edit_store_form() { + public function test_get_edit_store_form(): void { // Always instantiate a new core display helper here. $administrationhelper = new local\administration_display_helper; $config = cache_config_writer::instance(); @@ -193,7 +193,7 @@ class administration_helper_test extends \advanced_testcase { /** * Test the hash_key functionality. */ - public function test_hash_key() { + public function test_hash_key(): void { $this->resetAfterTest(); set_debugging(DEBUG_ALL); diff --git a/cache/tests/cache_test.php b/cache/tests/cache_test.php index a080816856c..a5b06f9e293 100644 --- a/cache/tests/cache_test.php +++ b/cache/tests/cache_test.php @@ -121,7 +121,7 @@ class cache_test extends \advanced_testcase { /** * Tests cache configuration */ - public function test_cache_config() { + public function test_cache_config(): void { global $CFG; if (defined('TEST_CACHE_USING_ALT_CACHE_CONFIG_PATH') && TEST_CACHE_USING_ALT_CACHE_CONFIG_PATH && @@ -197,7 +197,7 @@ class cache_test extends \advanced_testcase { /** * Tests for cache keys that would break on windows. */ - public function test_windows_nasty_keys() { + public function test_windows_nasty_keys(): void { $instance = cache_config_testing::instance(); $instance->phpunit_add_definition('phpunit/windowskeytest', array( 'mode' => cache_store::MODE_APPLICATION, @@ -216,7 +216,7 @@ class cache_test extends \advanced_testcase { * * set_identifiers cannot be called after initial cache instantiation, as you need to create a difference cache. */ - public function test_set_identifiers() { + public function test_set_identifiers(): void { $instance = cache_config_testing::instance(); $instance->phpunit_add_definition('phpunit/identifier', array( 'mode' => cache_store::MODE_APPLICATION, @@ -237,7 +237,7 @@ class cache_test extends \advanced_testcase { /** * Tests the default application cache */ - public function test_default_application_cache() { + public function test_default_application_cache(): void { $cache = cache::make_from_params(cache_store::MODE_APPLICATION, 'phpunit', 'applicationtest'); $this->assertInstanceOf(cache_application::class, $cache); $this->run_on_cache($cache); @@ -258,7 +258,7 @@ class cache_test extends \advanced_testcase { /** * Tests the default session cache */ - public function test_default_session_cache() { + public function test_default_session_cache(): void { $cache = cache::make_from_params(cache_store::MODE_SESSION, 'phpunit', 'applicationtest'); $this->assertInstanceOf(cache_session::class, $cache); $this->run_on_cache($cache); @@ -267,7 +267,7 @@ class cache_test extends \advanced_testcase { /** * Tests the default request cache */ - public function test_default_request_cache() { + public function test_default_request_cache(): void { $cache = cache::make_from_params(cache_store::MODE_REQUEST, 'phpunit', 'applicationtest'); $this->assertInstanceOf(cache_request::class, $cache); $this->run_on_cache($cache); @@ -276,7 +276,7 @@ class cache_test extends \advanced_testcase { /** * Tests using a cache system when there are no stores available (who knows what the admin did to achieve this). */ - public function test_on_cache_without_store() { + public function test_on_cache_without_store(): void { $instance = cache_config_testing::instance(true); $instance->phpunit_add_definition('phpunit/nostoretest1', array( 'mode' => cache_store::MODE_APPLICATION, @@ -535,7 +535,7 @@ class cache_test extends \advanced_testcase { /** * Tests a definition using a data loader */ - public function test_definition_data_loader() { + public function test_definition_data_loader(): void { $instance = cache_config_testing::instance(true); $instance->phpunit_add_definition('phpunit/datasourcetest', array( 'mode' => cache_store::MODE_APPLICATION, @@ -579,7 +579,7 @@ class cache_test extends \advanced_testcase { * @covers ::get_versioned * @covers ::set_versioned */ - public function test_definition_data_loader_versioned() { + public function test_definition_data_loader_versioned(): void { // Create two definitions, one using a non-versionable data source and the other using // a versionable one. $instance = cache_config_testing::instance(true); @@ -631,7 +631,7 @@ class cache_test extends \advanced_testcase { /** * Tests a definition using an overridden loader */ - public function test_definition_overridden_loader() { + public function test_definition_overridden_loader(): void { $instance = cache_config_testing::instance(true); $instance->phpunit_add_definition('phpunit/overridetest', array( 'mode' => cache_store::MODE_APPLICATION, @@ -656,7 +656,7 @@ class cache_test extends \advanced_testcase { /** * Test the mappingsonly setting. */ - public function test_definition_mappings_only() { + public function test_definition_mappings_only(): void { /** @var cache_config_testing $instance */ $instance = cache_config_testing::instance(true); $instance->phpunit_add_definition('phpunit/mappingsonly', array( @@ -685,7 +685,7 @@ class cache_test extends \advanced_testcase { /** * Test a very basic definition. */ - public function test_definition() { + public function test_definition(): void { $instance = cache_config_testing::instance(); $instance->phpunit_add_definition('phpunit/test', array( 'mode' => cache_store::MODE_APPLICATION, @@ -703,7 +703,7 @@ class cache_test extends \advanced_testcase { /** * Test a definition using the simple keys. */ - public function test_definition_simplekeys() { + public function test_definition_simplekeys(): void { $instance = cache_config_testing::instance(); $instance->phpunit_add_definition('phpunit/simplekeytest', array( 'mode' => cache_store::MODE_APPLICATION, @@ -729,7 +729,7 @@ class cache_test extends \advanced_testcase { /** * Test a negative TTL on an application cache. */ - public function test_application_ttl_negative() { + public function test_application_ttl_negative(): void { $instance = cache_config_testing::instance(true); $instance->phpunit_add_definition('phpunit/ttltest', array( 'mode' => cache_store::MODE_APPLICATION, @@ -778,7 +778,7 @@ class cache_test extends \advanced_testcase { /** * Test a positive TTL on an application cache. */ - public function test_application_ttl_positive() { + public function test_application_ttl_positive(): void { $instance = cache_config_testing::instance(true); $instance->phpunit_add_definition('phpunit/ttltest', array( 'mode' => cache_store::MODE_APPLICATION, @@ -827,7 +827,7 @@ class cache_test extends \advanced_testcase { /** * Test a negative TTL on an session cache. */ - public function test_session_ttl_positive() { + public function test_session_ttl_positive(): void { $instance = cache_config_testing::instance(true); $instance->phpunit_add_definition('phpunit/ttltest', array( 'mode' => cache_store::MODE_SESSION, @@ -876,7 +876,7 @@ class cache_test extends \advanced_testcase { /** * Tests manual locking operations on an application cache */ - public function test_application_manual_locking() { + public function test_application_manual_locking(): void { $instance = cache_config_testing::instance(); $instance->phpunit_add_definition('phpunit/lockingtest', array( 'mode' => cache_store::MODE_APPLICATION, @@ -914,7 +914,7 @@ class cache_test extends \advanced_testcase { /** * Tests application cache event invalidation */ - public function test_application_event_invalidation() { + public function test_application_event_invalidation(): void { $instance = cache_config_testing::instance(); $instance->phpunit_add_definition('phpunit/eventinvalidationtest', array( 'mode' => cache_store::MODE_APPLICATION, @@ -949,7 +949,7 @@ class cache_test extends \advanced_testcase { /** * Tests session cache event invalidation */ - public function test_session_event_invalidation() { + public function test_session_event_invalidation(): void { $instance = cache_config_testing::instance(); $instance->phpunit_add_definition('phpunit/test_session_event_invalidation', array( 'mode' => cache_store::MODE_SESSION, @@ -985,7 +985,7 @@ class cache_test extends \advanced_testcase { /** * Tests application cache definition invalidation */ - public function test_application_definition_invalidation() { + public function test_application_definition_invalidation(): void { $instance = cache_config_testing::instance(); $instance->phpunit_add_definition('phpunit/definitioninvalidation', array( 'mode' => cache_store::MODE_APPLICATION, @@ -1021,7 +1021,7 @@ class cache_test extends \advanced_testcase { /** * Tests session cache definition invalidation */ - public function test_session_definition_invalidation() { + public function test_session_definition_invalidation(): void { $instance = cache_config_testing::instance(); $instance->phpunit_add_definition('phpunit/test_session_definition_invalidation', array( 'mode' => cache_store::MODE_SESSION, @@ -1060,7 +1060,7 @@ class cache_test extends \advanced_testcase { /** * Tests application cache event invalidation over a distributed setup. */ - public function test_distributed_application_event_invalidation() { + public function test_distributed_application_event_invalidation(): void { global $CFG; // This is going to be an intense wee test. // We need to add data the to cache, invalidate it by event, manually force it back without MUC knowing to simulate a @@ -1186,7 +1186,7 @@ class cache_test extends \advanced_testcase { /** * Tests application cache event purge */ - public function test_application_event_purge() { + public function test_application_event_purge(): void { $instance = cache_config_testing::instance(); $instance->phpunit_add_definition('phpunit/eventpurgetest', array( 'mode' => cache_store::MODE_APPLICATION, @@ -1237,7 +1237,7 @@ class cache_test extends \advanced_testcase { /** * Tests session cache event purge */ - public function test_session_event_purge() { + public function test_session_event_purge(): void { $instance = cache_config_testing::instance(); $instance->phpunit_add_definition('phpunit/eventpurgetest', array( 'mode' => cache_store::MODE_SESSION, @@ -1288,7 +1288,7 @@ class cache_test extends \advanced_testcase { /** * Tests application cache definition purge */ - public function test_application_definition_purge() { + public function test_application_definition_purge(): void { $instance = cache_config_testing::instance(); $instance->phpunit_add_definition('phpunit/definitionpurgetest', array( 'mode' => cache_store::MODE_APPLICATION, @@ -1317,7 +1317,7 @@ class cache_test extends \advanced_testcase { * Test the use of an alt path. * If we can generate a config instance we are done :) */ - public function test_alt_cache_path() { + public function test_alt_cache_path(): void { global $CFG; if ((defined('TEST_CACHE_USING_ALT_CACHE_CONFIG_PATH') && TEST_CACHE_USING_ALT_CACHE_CONFIG_PATH) || !empty($CFG->altcacheconfigpath)) { $this->markTestSkipped('Skipped testing alt cache path as it is already being used.'); @@ -1331,7 +1331,7 @@ class cache_test extends \advanced_testcase { /** * Test disabling the cache stores. */ - public function test_disable_stores() { + public function test_disable_stores(): void { $instance = cache_config_testing::instance(); $instance->phpunit_add_definition('phpunit/disabletest1', array( 'mode' => cache_store::MODE_APPLICATION, @@ -1395,7 +1395,7 @@ class cache_test extends \advanced_testcase { /** * Test disabling the cache. */ - public function test_disable() { + public function test_disable(): void { global $CFG; if ((defined('TEST_CACHE_USING_ALT_CACHE_CONFIG_PATH') && TEST_CACHE_USING_ALT_CACHE_CONFIG_PATH) || !empty($CFG->altcacheconfigpath)) { @@ -1478,7 +1478,7 @@ class cache_test extends \advanced_testcase { /** * Test that multiple application loaders work ok. */ - public function test_multiple_application_loaders() { + public function test_multiple_application_loaders(): void { $instance = cache_config_testing::instance(true); $instance->phpunit_add_file_store('phpunittest1'); $instance->phpunit_add_file_store('phpunittest2'); @@ -1909,7 +1909,7 @@ class cache_test extends \advanced_testcase { /** * Test that multiple application loaders work ok. */ - public function test_multiple_session_loaders() { + public function test_multiple_session_loaders(): void { /* @var cache_config_testing $instance */ $instance = cache_config_testing::instance(true); $instance->phpunit_add_session_store('phpunittest1'); @@ -1978,7 +1978,7 @@ class cache_test extends \advanced_testcase { /** * Test switching users with session caches. */ - public function test_session_cache_switch_user() { + public function test_session_cache_switch_user(): void { $this->resetAfterTest(true); $cache = cache::make_from_params(cache_store::MODE_SESSION, 'phpunit', 'sessioncache'); $user1 = $this->getDataGenerator()->create_user(); @@ -2006,7 +2006,7 @@ class cache_test extends \advanced_testcase { /** * Test switching users with session caches. */ - public function test_session_cache_switch_user_application_mapping() { + public function test_session_cache_switch_user_application_mapping(): void { $this->resetAfterTest(true); $instance = cache_config_testing::instance(true); $instance->phpunit_add_file_store('testfilestore'); @@ -2042,7 +2042,7 @@ class cache_test extends \advanced_testcase { /** * Test two session caches being used at once to confirm collisions don't occur. */ - public function test_dual_session_caches() { + public function test_dual_session_caches(): void { $instance = cache_config_testing::instance(true); $instance->phpunit_add_definition('phpunit/testsess1', array( 'mode' => cache_store::MODE_SESSION, @@ -2076,7 +2076,7 @@ class cache_test extends \advanced_testcase { /** * Test multiple session caches when switching user. */ - public function test_session_cache_switch_user_multiple() { + public function test_session_cache_switch_user_multiple(): void { $this->resetAfterTest(true); $cache1 = cache::make_from_params(cache_store::MODE_SESSION, 'phpunit', 'sessioncache1'); $cache2 = cache::make_from_params(cache_store::MODE_SESSION, 'phpunit', 'sessioncache2'); @@ -2110,7 +2110,7 @@ class cache_test extends \advanced_testcase { * * @covers \cache_application */ - public function test_application_locking_multiple_identifier_cache() { + public function test_application_locking_multiple_identifier_cache(): void { // Get an arbitrary definition (modinfo). $instance = cache_config_testing::instance(true); $definitions = $instance->get_definitions(); @@ -2133,7 +2133,7 @@ class cache_test extends \advanced_testcase { * * @covers ::set_implementation */ - public function test_application_locking_before_write() { + public function test_application_locking_before_write(): void { $instance = cache_config_testing::instance(true); $instance->phpunit_add_definition('phpunit/test_application_locking', array( 'mode' => cache_store::MODE_APPLICATION, @@ -2232,7 +2232,7 @@ class cache_test extends \advanced_testcase { * @covers \cache_loader * @return void */ - public function test_application_locking_multiple_layers() { + public function test_application_locking_multiple_layers(): void { $instance = cache_config_testing::instance(true); $instance->phpunit_add_definition('phpunit/test_application_locking', array( @@ -2400,7 +2400,7 @@ class cache_test extends \advanced_testcase { /** * Test the static cache_helper method purge_stores_used_by_definition. */ - public function test_purge_stores_used_by_definition() { + public function test_purge_stores_used_by_definition(): void { $instance = cache_config_testing::instance(true); $instance->phpunit_add_definition('phpunit/test_purge_stores_used_by_definition', array( 'mode' => cache_store::MODE_APPLICATION, @@ -2422,7 +2422,7 @@ class cache_test extends \advanced_testcase { /** * Test purge routines. */ - public function test_purge_routines() { + public function test_purge_routines(): void { $instance = cache_config_testing::instance(true); $instance->phpunit_add_definition('phpunit/purge1', array( 'mode' => cache_store::MODE_APPLICATION, @@ -2469,7 +2469,7 @@ class cache_test extends \advanced_testcase { /** * Tests that ad-hoc caches are correctly purged with a purge_all call. */ - public function test_purge_all_with_adhoc_caches() { + public function test_purge_all_with_adhoc_caches(): void { $cache = cache::make_from_params(cache_store::MODE_REQUEST, 'core_cache', 'test'); $cache->set('test', 123); cache_helper::purge_all(); @@ -2479,7 +2479,7 @@ class cache_test extends \advanced_testcase { /** * Test that the default stores all support searching. */ - public function test_defaults_support_searching() { + public function test_defaults_support_searching(): void { $instance = cache_config_testing::instance(true); $instance->phpunit_add_definition('phpunit/search1', array( 'mode' => cache_store::MODE_APPLICATION, @@ -2532,7 +2532,7 @@ class cache_test extends \advanced_testcase { * Note: All the assertGreaterThanOrEqual() in this test should be assertGreaterThan() be because of some microtime() * resolution problems under some OSs / PHP versions, we are accepting equal as valid outcome. For more info see MDL-57147. */ - public function test_static_acceleration() { + public function test_static_acceleration(): void { $instance = cache_config_testing::instance(); $instance->phpunit_add_definition('phpunit/accelerated', array( 'mode' => cache_store::MODE_APPLICATION, @@ -2762,7 +2762,7 @@ class cache_test extends \advanced_testcase { $this->assertEquals('b', $returnedinstance2->name); } - public function test_identifiers_have_separate_caches() { + public function test_identifiers_have_separate_caches(): void { $cachepg = cache::make('core', 'databasemeta', array('dbfamily' => 'pgsql')); $cachepg->set(1, 'here'); $cachemy = cache::make('core', 'databasemeta', array('dbfamily' => 'mysql')); @@ -2772,7 +2772,7 @@ class cache_test extends \advanced_testcase { $this->assertFalse($cachemy->get(1)); } - public function test_performance_debug() { + public function test_performance_debug(): void { global $CFG; $this->resetAfterTest(true); $CFG->perfdebug = 15; @@ -3107,7 +3107,7 @@ class cache_test extends \advanced_testcase { } - public function test_static_cache() { + public function test_static_cache(): void { global $CFG; $this->resetAfterTest(true); $CFG->perfdebug = 15; @@ -3140,7 +3140,7 @@ class cache_test extends \advanced_testcase { $this->assertEquals(3, $endstats[$applicationid]['stores']['** static accel. **']['hits']); } - public function test_performance_debug_off() { + public function test_performance_debug_off(): void { global $CFG; $this->resetAfterTest(true); $CFG->perfdebug = 7; @@ -3201,7 +3201,7 @@ class cache_test extends \advanced_testcase { * A new request is started a short time later. * The cache should be filled. */ - public function test_session_event_purge_same_second() { + public function test_session_event_purge_same_second(): void { $instance = cache_config_testing::instance(); $instance->phpunit_add_definition('phpunit/eventpurgetest', array( 'mode' => cache_store::MODE_SESSION, @@ -3241,7 +3241,7 @@ class cache_test extends \advanced_testcase { /** * Test that values set in different sessions are stored with different key prefixes. */ - public function test_session_distinct_storage_key() { + public function test_session_distinct_storage_key(): void { $this->resetAfterTest(); // Prepare a dummy session cache configuration. diff --git a/cache/tests/config_writer_test.php b/cache/tests/config_writer_test.php index e0f28649eb8..40a5cbc235c 100644 --- a/cache/tests/config_writer_test.php +++ b/cache/tests/config_writer_test.php @@ -58,7 +58,7 @@ class config_writer_test extends \advanced_testcase { /** * Test getting an instance. Pretty basic. */ - public function test_instance() { + public function test_instance(): void { $config = cache_config_writer::instance(); $this->assertInstanceOf('cache_config_writer', $config); } @@ -66,7 +66,7 @@ class config_writer_test extends \advanced_testcase { /** * Test the default configuration. */ - public function test_default_configuration() { + public function test_default_configuration(): void { $config = cache_config_writer::instance(); // First check stores. @@ -149,7 +149,7 @@ class config_writer_test extends \advanced_testcase { /** * Test updating the definitions. */ - public function test_update_definitions() { + public function test_update_definitions(): void { $config = cache_config_writer::instance(); // Remove the definition. $config->phpunit_remove_definition('core/string'); @@ -166,7 +166,7 @@ class config_writer_test extends \advanced_testcase { /** * Test adding/editing/deleting store instances. */ - public function test_add_edit_delete_plugin_instance() { + public function test_add_edit_delete_plugin_instance(): void { $config = cache_config_writer::instance(); $this->assertArrayNotHasKey('addplugintest', $config->get_all_stores()); $this->assertArrayNotHasKey('addplugintestwlock', $config->get_all_stores()); @@ -236,7 +236,7 @@ class config_writer_test extends \advanced_testcase { /** * Test setting some mode mappings. */ - public function test_set_mode_mappings() { + public function test_set_mode_mappings(): void { $config = cache_config_writer::instance(); $this->assertTrue($config->add_store_instance('setmodetest', 'file')); $this->assertTrue($config->set_mode_mappings(array( @@ -257,7 +257,7 @@ class config_writer_test extends \advanced_testcase { /** * Test setting some definition mappings. */ - public function test_set_definition_mappings() { + public function test_set_definition_mappings(): void { $config = cache_config_testing::instance(true); $config->phpunit_add_definition('phpunit/testdefinition', array( 'mode' => cache_store::MODE_APPLICATION, diff --git a/calendar/tests/action_event_test.php b/calendar/tests/action_event_test.php index 55881793dba..55d4c5cd0e4 100644 --- a/calendar/tests/action_event_test.php +++ b/calendar/tests/action_event_test.php @@ -48,7 +48,7 @@ class action_event_test extends \advanced_testcase { * @dataProvider getters_testcases() * @param array $constructorparams Associative array of constructor parameters. */ - public function test_getters($constructorparams) { + public function test_getters($constructorparams): void { $event = new action_event( $constructorparams['event'], $constructorparams['action'] diff --git a/calendar/tests/action_factory_test.php b/calendar/tests/action_factory_test.php index e6e1507673d..129afe171c6 100644 --- a/calendar/tests/action_factory_test.php +++ b/calendar/tests/action_factory_test.php @@ -29,7 +29,7 @@ class action_factory_test extends \advanced_testcase { /** * Test action factory. */ - public function test_action_factory() { + public function test_action_factory(): void { $factory = new action_factory(); $instance = $factory->create_instance( 'test', diff --git a/calendar/tests/action_test.php b/calendar/tests/action_test.php index efad0b55721..4ecb81378da 100644 --- a/calendar/tests/action_test.php +++ b/calendar/tests/action_test.php @@ -32,7 +32,7 @@ class action_test extends \advanced_testcase { * @dataProvider getters_testcases() * @param array $constructorparams Associative array of constructor parameters. */ - public function test_getters($constructorparams) { + public function test_getters($constructorparams): void { $action = new action( $constructorparams['name'], $constructorparams['url'], diff --git a/calendar/tests/calendar_event_exporter_test.php b/calendar/tests/calendar_event_exporter_test.php index e092c4689b3..5b9eb1bed0f 100644 --- a/calendar/tests/calendar_event_exporter_test.php +++ b/calendar/tests/calendar_event_exporter_test.php @@ -72,7 +72,7 @@ class calendar_event_exporter_test extends \advanced_testcase { /** * @dataProvider get_timestamp_min_limit_test_cases() */ - public function test_get_timestamp_min_limit($starttime, $min, $expected) { + public function test_get_timestamp_min_limit($starttime, $min, $expected): void { $class = calendar_event_exporter::class; $mock = $this->getMockBuilder($class) ->disableOriginalConstructor() @@ -128,7 +128,7 @@ class calendar_event_exporter_test extends \advanced_testcase { /** * @dataProvider get_timestamp_max_limit_test_cases() */ - public function test_get_timestamp_max_limit($starttime, $max, $expected) { + public function test_get_timestamp_max_limit($starttime, $max, $expected): void { $class = calendar_event_exporter::class; $mock = $this->getMockBuilder($class) ->disableOriginalConstructor() @@ -145,7 +145,7 @@ class calendar_event_exporter_test extends \advanced_testcase { /** * Exporting a course event should generate the course URL. */ - public function test_calendar_event_exporter_course_url_course_event() { + public function test_calendar_event_exporter_course_url_course_event(): void { global $CFG, $PAGE; require_once($CFG->dirroot . '/course/lib.php'); @@ -185,7 +185,7 @@ class calendar_event_exporter_test extends \advanced_testcase { /** * Exporting a user event should generate the site course URL. */ - public function test_calendar_event_exporter_course_url_user_event() { + public function test_calendar_event_exporter_course_url_user_event(): void { global $CFG, $PAGE; require_once($CFG->dirroot . '/course/lib.php'); @@ -224,7 +224,7 @@ class calendar_event_exporter_test extends \advanced_testcase { /** * Popup name respects filters for course shortname. */ - public function test_calendar_event_exporter_popupname_course_shortname_strips_links() { + public function test_calendar_event_exporter_popupname_course_shortname_strips_links(): void { global $CFG, $PAGE; $this->resetAfterTest(true); @@ -262,7 +262,7 @@ class calendar_event_exporter_test extends \advanced_testcase { /** * Exported event contains the exported course. */ - public function test_calendar_event_exporter_exports_course() { + public function test_calendar_event_exporter_exports_course(): void { global $CFG, $PAGE; $this->resetAfterTest(true); diff --git a/calendar/tests/calendar_information_test.php b/calendar/tests/calendar_information_test.php index ac8761d9b8d..9dadc7fbf1e 100644 --- a/calendar/tests/calendar_information_test.php +++ b/calendar/tests/calendar_information_test.php @@ -76,7 +76,7 @@ class calendar_information_test extends \advanced_testcase { * And I should see no other courses. * And I should see no categories. */ - public function test_site_visibility_no_enrolment() { + public function test_site_visibility_no_enrolment(): void { $this->resetAfterTest(); list ($courses, $categories) = $this->mock_structure(); @@ -102,7 +102,7 @@ class calendar_information_test extends \advanced_testcase { * And I should see the site course. * And I should see no other courses. */ - public function test_site_visibility_no_enrolment_category() { + public function test_site_visibility_no_enrolment_category(): void { $this->resetAfterTest(); list ($courses, $categories) = $this->mock_structure(); @@ -133,7 +133,7 @@ class calendar_information_test extends \advanced_testcase { * And I should see the site course. * And I should see no other courses. */ - public function test_site_visibility_category_manager_site() { + public function test_site_visibility_category_manager_site(): void { global $DB; $this->resetAfterTest(); @@ -170,7 +170,7 @@ class calendar_information_test extends \advanced_testcase { * And I should see the site course. * And I should see no other courses. */ - public function test_site_visibility_category_manager_own_category() { + public function test_site_visibility_category_manager_own_category(): void { global $DB; $this->resetAfterTest(); @@ -207,7 +207,7 @@ class calendar_information_test extends \advanced_testcase { * And I should see the site course. * And I should see no other courses. */ - public function test_site_visibility_category_manager_parent_category() { + public function test_site_visibility_category_manager_parent_category(): void { global $DB; $this->resetAfterTest(); @@ -244,7 +244,7 @@ class calendar_information_test extends \advanced_testcase { * And I should see the site course. * And I should see no other courses. */ - public function test_site_visibility_category_manager_child_category() { + public function test_site_visibility_category_manager_child_category(): void { global $DB; $this->resetAfterTest(); @@ -280,7 +280,7 @@ class calendar_information_test extends \advanced_testcase { * And I should see the category that my enrolled course is in. * And I should see the parents of the category that my enrolled course is in. */ - public function test_site_visibility_single_course_site() { + public function test_site_visibility_single_course_site(): void { $this->resetAfterTest(); list ($courses, $categories) = $this->mock_structure(); @@ -316,7 +316,7 @@ class calendar_information_test extends \advanced_testcase { * And I should see the category of that course. * And I should see the parents of that course category. */ - public function test_site_visibility_single_course_course_course() { + public function test_site_visibility_single_course_course_course(): void { $this->resetAfterTest(); list ($courses, $categories) = $this->mock_structure(); @@ -365,7 +365,7 @@ class calendar_information_test extends \advanced_testcase { * And I should see no other courses. * And I should see no categories. */ - public function test_site_visibility_single_course_category() { + public function test_site_visibility_single_course_category(): void { $this->resetAfterTest(); list ($courses, $categories) = $this->mock_structure(); @@ -406,7 +406,7 @@ class calendar_information_test extends \advanced_testcase { * And I should see no other courses. * And I should see no categories. */ - public function test_site_visibility_single_course_parent_category() { + public function test_site_visibility_single_course_parent_category(): void { $this->resetAfterTest(); list ($courses, $categories) = $this->mock_structure(); @@ -450,7 +450,7 @@ class calendar_information_test extends \advanced_testcase { * And I should see no other courses. * And I should see no categories. */ - public function test_site_visibility_single_course_sibling_category() { + public function test_site_visibility_single_course_sibling_category(): void { $this->resetAfterTest(); list ($courses, $categories) = $this->mock_structure(); @@ -490,7 +490,7 @@ class calendar_information_test extends \advanced_testcase { * And I should see no other courses. * And I should see no categories. */ - public function test_site_visibility_single_course_different_category() { + public function test_site_visibility_single_course_different_category(): void { $this->resetAfterTest(); list ($courses, $categories) = $this->mock_structure(); @@ -526,7 +526,7 @@ class calendar_information_test extends \advanced_testcase { * And I should see the category that my enrolled course is in. * And I should see the parents of the category that my enrolled course is in. */ - public function test_site_visibility_two_courses_one_category_site() { + public function test_site_visibility_two_courses_one_category_site(): void { $this->resetAfterTest(); list ($courses, $categories) = $this->mock_structure(); @@ -562,7 +562,7 @@ class calendar_information_test extends \advanced_testcase { * And I should see the category that my enrolled courses are in. * And I should see the parents of the category that my enrolled course are in. */ - public function test_site_visibility_two_courses_one_category_course() { + public function test_site_visibility_two_courses_one_category_course(): void { $this->resetAfterTest(); list ($courses, $categories) = $this->mock_structure(); @@ -608,7 +608,7 @@ class calendar_information_test extends \advanced_testcase { * And I should see the category that my enrolled courses are in. * And I should see the parents of the category that my enrolled course are in. */ - public function test_site_visibility_two_courses_one_category_courseb() { + public function test_site_visibility_two_courses_one_category_courseb(): void { $this->resetAfterTest(); list ($courses, $categories) = $this->mock_structure(); @@ -655,7 +655,7 @@ class calendar_information_test extends \advanced_testcase { * And I should see the category that my enrolled courses are in. * And I should see the parents of the category that my enrolled course are in. */ - public function test_site_visibility_two_courses_one_category_category() { + public function test_site_visibility_two_courses_one_category_category(): void { $this->resetAfterTest(); list ($courses, $categories) = $this->mock_structure(); @@ -691,7 +691,7 @@ class calendar_information_test extends \advanced_testcase { * And I should see the category that my enrolled courses are in. * And I should see the parents of the category that my enrolled course are in. */ - public function test_site_visibility_two_courses_one_category_othercategory() { + public function test_site_visibility_two_courses_one_category_othercategory(): void { $this->resetAfterTest(); list ($courses, $categories) = $this->mock_structure(); @@ -725,7 +725,7 @@ class calendar_information_test extends \advanced_testcase { * And I should see the categories that my enrolled courses are in. * And I should see the parents of those categories. */ - public function test_site_visibility_two_courses_two_categories_site() { + public function test_site_visibility_two_courses_two_categories_site(): void { $this->resetAfterTest(); list ($courses, $categories) = $this->mock_structure(); @@ -762,7 +762,7 @@ class calendar_information_test extends \advanced_testcase { * And I should see the categories that my enrolled courses are in. * And I should see the parents of those categories. */ - public function test_site_visibility_two_courses_two_categories_coursea() { + public function test_site_visibility_two_courses_two_categories_coursea(): void { $this->resetAfterTest(); list ($courses, $categories) = $this->mock_structure(); @@ -809,7 +809,7 @@ class calendar_information_test extends \advanced_testcase { * And I should see the categories that my enrolled courses are in. * And I should see the parents of those categories. */ - public function test_site_visibility_two_courses_two_categories_courseb() { + public function test_site_visibility_two_courses_two_categories_courseb(): void { $this->resetAfterTest(); list ($courses, $categories) = $this->mock_structure(); @@ -857,7 +857,7 @@ class calendar_information_test extends \advanced_testcase { * And I should see the categories that my enrolled courses are in. * And I should see the parents of those categories. */ - public function test_site_visibility_two_courses_two_categories_category() { + public function test_site_visibility_two_courses_two_categories_category(): void { $this->resetAfterTest(); list ($courses, $categories) = $this->mock_structure(); @@ -898,7 +898,7 @@ class calendar_information_test extends \advanced_testcase { * And I should see the categories that my enrolled courses are in. * And I should see the parents of those categories. */ - public function test_site_visibility_two_courses_two_categories_different_category() { + public function test_site_visibility_two_courses_two_categories_different_category(): void { $this->resetAfterTest(); list ($courses, $categories) = $this->mock_structure(); @@ -931,7 +931,7 @@ class calendar_information_test extends \advanced_testcase { * And I should see no other courses. * And I should see no categories. */ - public function test_site_visibility_admin_user() { + public function test_site_visibility_admin_user(): void { $this->resetAfterTest(); list ($courses, $categories) = $this->mock_structure(); @@ -957,7 +957,7 @@ class calendar_information_test extends \advanced_testcase { * And I should see no other courses. * And I should see no other categories. */ - public function test_site_visibility_admin_user_with_enrolment_site() { + public function test_site_visibility_admin_user_with_enrolment_site(): void { global $USER; $this->resetAfterTest(); @@ -988,7 +988,7 @@ class calendar_information_test extends \advanced_testcase { * And I should see the category of that course. * And I should see the parents of that course category. */ - public function test_site_visibility_admin_user_with_enrolment_course() { + public function test_site_visibility_admin_user_with_enrolment_course(): void { global $USER; $this->resetAfterTest(); @@ -1035,7 +1035,7 @@ class calendar_information_test extends \advanced_testcase { * And I should see no other courses. * And I should see no categories. */ - public function test_site_visibility_admin_user_with_enrolment_category() { + public function test_site_visibility_admin_user_with_enrolment_category(): void { global $USER; $this->resetAfterTest(); diff --git a/calendar/tests/calendartype_test.php b/calendar/tests/calendartype_test.php index 57d5038a2f8..428aebbd9b2 100644 --- a/calendar/tests/calendartype_test.php +++ b/calendar/tests/calendartype_test.php @@ -72,7 +72,7 @@ class calendartype_test extends \advanced_testcase { /** * Test that setting the calendar type works. */ - public function test_calendar_type_set() { + public function test_calendar_type_set(): void { // We want to reset the test data after this run. $this->resetAfterTest(); @@ -89,7 +89,7 @@ class calendartype_test extends \advanced_testcase { * Test that calling core Moodle functions responsible for displaying the date * have the same results as directly calling the same function in the calendar type. */ - public function test_calendar_type_core_functions() { + public function test_calendar_type_core_functions(): void { // We want to reset the test data after this run. $this->resetAfterTest(); @@ -105,7 +105,7 @@ class calendartype_test extends \advanced_testcase { * unixtime is being converted back to a valid date to display in the date selector elements for * different calendar types. */ - public function test_calendar_type_dateselector_elements() { + public function test_calendar_type_dateselector_elements(): void { // We want to reset the test data after this run. $this->resetAfterTest(); @@ -161,7 +161,7 @@ class calendartype_test extends \advanced_testcase { * Test that the user profile field datetime minimum and maximum year settings are saved as the * equivalent Gregorian years. */ - public function test_calendar_type_datetime_field_submission() { + public function test_calendar_type_datetime_field_submission(): void { // We want to reset the test data after this run. $this->resetAfterTest(); diff --git a/calendar/tests/cm_info_proxy_test.php b/calendar/tests/cm_info_proxy_test.php index fcab933fae7..2f10bf51724 100644 --- a/calendar/tests/cm_info_proxy_test.php +++ b/calendar/tests/cm_info_proxy_test.php @@ -30,7 +30,7 @@ class cm_info_proxy_test extends \advanced_testcase { /** * Test creating cm_info_std_proxy, using getter and setter. */ - public function test_proxy() { + public function test_proxy(): void { $this->resetAfterTest(true); $course = $this->getDataGenerator()->create_course(); diff --git a/calendar/tests/container_test.php b/calendar/tests/container_test.php index b833859538b..00a9f8badf2 100644 --- a/calendar/tests/container_test.php +++ b/calendar/tests/container_test.php @@ -51,7 +51,7 @@ class container_test extends \advanced_testcase { /** * Test getting the event factory. */ - public function test_get_event_factory() { + public function test_get_event_factory(): void { $factory = \core_calendar\local\event\container::get_event_factory(); // Test that the container is returning the right type. @@ -70,7 +70,7 @@ class container_test extends \advanced_testcase { * @dataProvider get_event_factory_testcases() * @param \stdClass $dbrow Row from the "database". */ - public function test_event_factory_create_instance($dbrow) { + public function test_event_factory_create_instance($dbrow): void { $legacyevent = $this->create_event($dbrow); $factory = \core_calendar\local\event\container::get_event_factory(); $course = $this->getDataGenerator()->create_course(); @@ -131,7 +131,7 @@ class container_test extends \advanced_testcase { * @dataProvider get_event_factory_testcases() * @param \stdClass $dbrow Row from the "database". */ - public function test_event_factory_when_module_visibility_is_toggled_as_admin($dbrow) { + public function test_event_factory_when_module_visibility_is_toggled_as_admin($dbrow): void { $legacyevent = $this->create_event($dbrow); $factory = \core_calendar\local\event\container::get_event_factory(); $course = $this->getDataGenerator()->create_course(); @@ -157,7 +157,7 @@ class container_test extends \advanced_testcase { * @dataProvider get_event_factory_testcases() * @param \stdClass $dbrow Row from the "database". */ - public function test_event_factory_when_module_visibility_is_toggled_as_guest($dbrow) { + public function test_event_factory_when_module_visibility_is_toggled_as_guest($dbrow): void { $legacyevent = $this->create_event($dbrow); $factory = \core_calendar\local\event\container::get_event_factory(); $course = $this->getDataGenerator()->create_course(); @@ -186,7 +186,7 @@ class container_test extends \advanced_testcase { * @dataProvider get_event_factory_testcases() * @param \stdClass $dbrow Row from the "database". */ - public function test_event_factory_when_course_visibility_is_toggled_as_admin($dbrow) { + public function test_event_factory_when_course_visibility_is_toggled_as_admin($dbrow): void { $legacyevent = $this->create_event($dbrow); $factory = \core_calendar\local\event\container::get_event_factory(); @@ -211,7 +211,7 @@ class container_test extends \advanced_testcase { * @dataProvider get_event_factory_testcases() * @param \stdClass $dbrow Row from the "database". */ - public function test_event_factory_when_course_visibility_is_toggled_as_student($dbrow) { + public function test_event_factory_when_course_visibility_is_toggled_as_student($dbrow): void { $legacyevent = $this->create_event($dbrow); $factory = \core_calendar\local\event\container::get_event_factory(); @@ -240,7 +240,7 @@ class container_test extends \advanced_testcase { /** * Test that the event factory deals with invisible categorys as an admin. */ - public function test_event_factory_when_category_visibility_is_toggled_as_admin() { + public function test_event_factory_when_category_visibility_is_toggled_as_admin(): void { // Create a hidden category. $category = $this->getDataGenerator()->create_category(['visible' => 0]); @@ -263,7 +263,7 @@ class container_test extends \advanced_testcase { /** * Test that the event factory deals with invisible categorys as an user. */ - public function test_event_factory_when_category_visibility_is_toggled_as_user() { + public function test_event_factory_when_category_visibility_is_toggled_as_user(): void { // Create a hidden category. $category = $this->getDataGenerator()->create_category(['visible' => 0]); @@ -292,7 +292,7 @@ class container_test extends \advanced_testcase { /** * Test that the event factory deals with invisible categorys as an guest. */ - public function test_event_factory_when_category_visibility_is_toggled_as_guest() { + public function test_event_factory_when_category_visibility_is_toggled_as_guest(): void { // Create a hidden category. $category = $this->getDataGenerator()->create_category(['visible' => 0]); @@ -318,7 +318,7 @@ class container_test extends \advanced_testcase { /** * Test that the event factory deals with completion related events properly. */ - public function test_event_factory_with_completion_related_event() { + public function test_event_factory_with_completion_related_event(): void { global $CFG; $CFG->enablecompletion = true; @@ -371,7 +371,7 @@ class container_test extends \advanced_testcase { * Checks that completed activities events do not show. * @covers \core_calendar\local\event::init */ - public function test_event_factory_with_completed_module_related_event() { + public function test_event_factory_with_completed_module_related_event(): void { global $CFG, $DB; $this->setAdminUser(); @@ -406,7 +406,7 @@ class container_test extends \advanced_testcase { * Test that the event factory only returns an event if the logged in user * is enrolled in the course. */ - public function test_event_factory_unenrolled_user() { + public function test_event_factory_unenrolled_user(): void { $user = $this->getDataGenerator()->create_user(); // Create the course we will be using. $course = $this->getDataGenerator()->create_course(); @@ -459,7 +459,7 @@ class container_test extends \advanced_testcase { /** * Test that when course module is deleted all events are also deleted. */ - public function test_delete_module_delete_events() { + public function test_delete_module_delete_events(): void { global $DB; $user = $this->getDataGenerator()->create_user(); // Create the course we will be using. @@ -490,7 +490,7 @@ class container_test extends \advanced_testcase { /** * Test getting the event mapper. */ - public function test_get_event_mapper() { + public function test_get_event_mapper(): void { $mapper = \core_calendar\local\event\container::get_event_mapper(); $this->assertInstanceOf(event_mapper_interface::class, $mapper); diff --git a/calendar/tests/coursecat_proxy_test.php b/calendar/tests/coursecat_proxy_test.php index 669105cae29..9505a827b24 100644 --- a/calendar/tests/coursecat_proxy_test.php +++ b/calendar/tests/coursecat_proxy_test.php @@ -27,7 +27,7 @@ use core_calendar\local\event\proxies\coursecat_proxy; */ class coursecat_proxy_test extends \advanced_testcase { - public function test_valid_coursecat() { + public function test_valid_coursecat(): void { global $DB; $this->resetAfterTest(); diff --git a/calendar/tests/event/events_test.php b/calendar/tests/event/events_test.php index b7019305f25..73214109eed 100644 --- a/calendar/tests/event/events_test.php +++ b/calendar/tests/event/events_test.php @@ -63,7 +63,7 @@ class events_test extends \advanced_testcase { /** * Tests for calendar_event_created event. */ - public function test_calendar_event_created() { + public function test_calendar_event_created(): void { $this->resetAfterTest(); @@ -111,7 +111,7 @@ class events_test extends \advanced_testcase { /** * Tests for event validations related to calendar_event_created event. */ - public function test_calendar_event_created_validations() { + public function test_calendar_event_created_validations(): void { $this->resetAfterTest(); $context = \context_user::instance($this->user->id); @@ -167,7 +167,7 @@ class events_test extends \advanced_testcase { /** * Tests for calendar_event_updated event. */ - public function test_calendar_event_updated() { + public function test_calendar_event_updated(): void { $this->resetAfterTest(); @@ -222,7 +222,7 @@ class events_test extends \advanced_testcase { /** * Tests for calendar_event_updated event. */ - public function test_calendar_event_updated_toggle_visibility() { + public function test_calendar_event_updated_toggle_visibility(): void { global $DB; $siteid = 0; @@ -255,7 +255,7 @@ class events_test extends \advanced_testcase { /** * Tests for event validations related to calendar_event_created event. */ - public function test_calendar_event_updated_validations() { + public function test_calendar_event_updated_validations(): void { $this->resetAfterTest(); $context = \context_user::instance($this->user->id); @@ -311,7 +311,7 @@ class events_test extends \advanced_testcase { /** * Tests for calendar_event_deleted event. */ - public function test_calendar_event_deleted() { + public function test_calendar_event_deleted(): void { global $DB; $this->resetAfterTest(); @@ -367,7 +367,7 @@ class events_test extends \advanced_testcase { /** * Tests for event validations related to calendar_event_deleted event. */ - public function test_calendar_event_deleted_validations() { + public function test_calendar_event_deleted_validations(): void { $this->resetAfterTest(); $context = \context_user::instance($this->user->id); @@ -423,7 +423,7 @@ class events_test extends \advanced_testcase { /** * Tests for calendar_subscription_added event for a site subscription. */ - public function test_calendar_subscription_created_site() { + public function test_calendar_subscription_created_site(): void { global $CFG; require_once($CFG->dirroot . '/calendar/lib.php'); $this->resetAfterTest(true); @@ -454,7 +454,7 @@ class events_test extends \advanced_testcase { /** * Tests for calendar_subscription_added event for a category subscription. */ - public function test_calendar_subscription_created_category() { + public function test_calendar_subscription_created_category(): void { global $CFG; require_once($CFG->dirroot . '/calendar/lib.php'); $this->resetAfterTest(true); @@ -487,7 +487,7 @@ class events_test extends \advanced_testcase { /** * Tests for calendar_subscription_added event for a course subscription. */ - public function test_calendar_subscription_created_course() { + public function test_calendar_subscription_created_course(): void { global $CFG; require_once($CFG->dirroot . '/calendar/lib.php'); $this->resetAfterTest(true); @@ -519,7 +519,7 @@ class events_test extends \advanced_testcase { /** * Tests for calendar_subscription_added event for a group subscription. */ - public function test_calendar_subscription_created_group() { + public function test_calendar_subscription_created_group(): void { global $CFG; require_once($CFG->dirroot . '/calendar/lib.php'); $this->resetAfterTest(true); @@ -554,7 +554,7 @@ class events_test extends \advanced_testcase { /** * Tests for calendar_subscription_updated event for a site subscription. */ - public function test_calendar_subscription_updated_site() { + public function test_calendar_subscription_updated_site(): void { global $CFG; require_once($CFG->dirroot . '/calendar/lib.php'); $this->resetAfterTest(true); @@ -587,7 +587,7 @@ class events_test extends \advanced_testcase { /** * Tests for calendar_subscription_updated event for a category subscription. */ - public function test_calendar_subscription_updated_category() { + public function test_calendar_subscription_updated_category(): void { global $CFG; require_once($CFG->dirroot . '/calendar/lib.php'); $this->resetAfterTest(true); @@ -622,7 +622,7 @@ class events_test extends \advanced_testcase { /** * Tests for calendar_subscription_updated event for a group subscription. */ - public function test_calendar_subscription_updated_course() { + public function test_calendar_subscription_updated_course(): void { global $CFG; require_once($CFG->dirroot . '/calendar/lib.php'); $this->resetAfterTest(true); @@ -655,7 +655,7 @@ class events_test extends \advanced_testcase { /** * Tests for calendar_subscription_updated event for a course subscription. */ - public function test_calendar_subscription_updated_group() { + public function test_calendar_subscription_updated_group(): void { global $CFG; require_once($CFG->dirroot . '/calendar/lib.php'); $this->resetAfterTest(true); @@ -693,7 +693,7 @@ class events_test extends \advanced_testcase { /** * Tests for calendar_subscription_deleted event for a site subscription. */ - public function test_calendar_subscription_deleted_site() { + public function test_calendar_subscription_deleted_site(): void { global $CFG; require_once($CFG->dirroot . '/calendar/lib.php'); $this->resetAfterTest(true); @@ -722,7 +722,7 @@ class events_test extends \advanced_testcase { /** * Tests for calendar_subscription_deleted event for a category subscription. */ - public function test_calendar_subscription_deleted_category() { + public function test_calendar_subscription_deleted_category(): void { global $CFG; require_once($CFG->dirroot . '/calendar/lib.php'); $this->resetAfterTest(true); @@ -755,7 +755,7 @@ class events_test extends \advanced_testcase { /** * Tests for calendar_subscription_deleted event for a course. */ - public function test_calendar_subscription_deleted_course() { + public function test_calendar_subscription_deleted_course(): void { global $CFG; require_once($CFG->dirroot . '/calendar/lib.php'); $this->resetAfterTest(true); @@ -786,7 +786,7 @@ class events_test extends \advanced_testcase { /** * Tests for calendar_subscription_deleted event for a group. */ - public function test_calendar_subscription_deleted_group() { + public function test_calendar_subscription_deleted_group(): void { global $CFG; require_once($CFG->dirroot . '/calendar/lib.php'); $this->resetAfterTest(true); diff --git a/calendar/tests/event_description_test.php b/calendar/tests/event_description_test.php index fd5fdf1179c..d071dbe394c 100644 --- a/calendar/tests/event_description_test.php +++ b/calendar/tests/event_description_test.php @@ -32,7 +32,7 @@ class event_description_test extends \advanced_testcase { * @dataProvider getters_testcases() * @param array $constructorparams Associative array of constructor parameters. */ - public function test_getters($constructorparams) { + public function test_getters($constructorparams): void { $eventdescription = new event_description( $constructorparams['value'], $constructorparams['format'] diff --git a/calendar/tests/event_factory_test.php b/calendar/tests/event_factory_test.php index 52ef17fa40c..3fabf8e8559 100644 --- a/calendar/tests/event_factory_test.php +++ b/calendar/tests/event_factory_test.php @@ -50,7 +50,7 @@ class event_factory_test extends \advanced_testcase { callable $bailoutcheck, $expectedclass, $expectedattributevalue - ) { + ): void { $this->resetAfterTest(true); $this->setAdminUser(); $event = $this->create_event(); diff --git a/calendar/tests/event_mapper_test.php b/calendar/tests/event_mapper_test.php index 2fe720b51df..fed62b2c4ea 100644 --- a/calendar/tests/event_mapper_test.php +++ b/calendar/tests/event_mapper_test.php @@ -51,7 +51,7 @@ class event_mapper_test extends \advanced_testcase { /** * Test legacy event -> event. */ - public function test_from_legacy_event_to_event() { + public function test_from_legacy_event_to_event(): void { $this->resetAfterTest(true); $this->setAdminUser(); $legacyevent = $this->create_event(); @@ -65,7 +65,7 @@ class event_mapper_test extends \advanced_testcase { /** * Test event -> legacy event. */ - public function test_from_event_to_legacy_event() { + public function test_from_event_to_legacy_event(): void { $this->resetAfterTest(true); $this->setAdminUser(); $legacyevent = $this->create_event(['modname' => 'assign', 'instance' => 1]); @@ -80,7 +80,7 @@ class event_mapper_test extends \advanced_testcase { /** * Test event -> stdClass. */ - public function test_from_event_to_stdclass() { + public function test_from_event_to_stdclass(): void { $this->resetAfterTest(true); $this->setAdminUser(); $legacyevent = $this->create_event(['modname' => 'assign', 'instance' => 1]); @@ -98,7 +98,7 @@ class event_mapper_test extends \advanced_testcase { /** * Test event -> array. */ - public function test_from_event_to_assoc_array() { + public function test_from_event_to_assoc_array(): void { $this->resetAfterTest(true); $this->setAdminUser(); $legacyevent = $this->create_event(['modname' => 'assign', 'instance' => 1]); @@ -116,7 +116,7 @@ class event_mapper_test extends \advanced_testcase { /** * Test for action event -> legacy event. */ - public function test_from_action_event_to_legacy_event() { + public function test_from_action_event_to_legacy_event(): void { $this->resetAfterTest(true); $this->setAdminUser(); $legacyevent = $this->create_event(['modname' => 'assign', 'instance' => 1]); diff --git a/calendar/tests/event_test.php b/calendar/tests/event_test.php index b6cedc6e70f..150018ea088 100644 --- a/calendar/tests/event_test.php +++ b/calendar/tests/event_test.php @@ -39,7 +39,7 @@ class event_test extends \advanced_testcase { * @dataProvider getters_testcases() * @param array $constructorparams Associative array of constructor parameters. */ - public function test_getters($constructorparams) { + public function test_getters($constructorparams): void { $event = new event( $constructorparams['id'], $constructorparams['name'], diff --git a/calendar/tests/event_times_test.php b/calendar/tests/event_times_test.php index 70fd9e22039..22f21b234b2 100644 --- a/calendar/tests/event_times_test.php +++ b/calendar/tests/event_times_test.php @@ -32,7 +32,7 @@ class event_times_test extends \advanced_testcase { * @dataProvider getters_testcases() * @param array $constructorparams Associative array of constructor parameters. */ - public function test_getters($constructorparams) { + public function test_getters($constructorparams): void { $eventtimes = new event_times( $constructorparams['start_time'], $constructorparams['end_time'], diff --git a/calendar/tests/event_vault_test.php b/calendar/tests/event_vault_test.php index 579e6461f3a..d03ab45ea80 100644 --- a/calendar/tests/event_vault_test.php +++ b/calendar/tests/event_vault_test.php @@ -38,7 +38,7 @@ class event_vault_test extends \advanced_testcase { * Test that get_action_events_by_timesort returns events after the * provided timesort value. */ - public function test_get_action_events_by_timesort_after_time() { + public function test_get_action_events_by_timesort_after_time(): void { $this->resetAfterTest(true); $user = $this->getDataGenerator()->create_user(); @@ -79,7 +79,7 @@ class event_vault_test extends \advanced_testcase { * Test that get_action_events_by_timesort returns events before the * provided timesort value. */ - public function test_get_action_events_by_timesort_before_time() { + public function test_get_action_events_by_timesort_before_time(): void { $this->resetAfterTest(true); $this->setAdminuser(); @@ -120,7 +120,7 @@ class event_vault_test extends \advanced_testcase { * Test that get_action_events_by_timesort returns events between the * provided timesort values. */ - public function test_get_action_events_by_timesort_between_time() { + public function test_get_action_events_by_timesort_between_time(): void { $this->resetAfterTest(true); $this->setAdminuser(); @@ -158,7 +158,7 @@ class event_vault_test extends \advanced_testcase { * provided timesort values and after the last seen event when one is * provided. */ - public function test_get_action_events_by_timesort_between_time_after_event() { + public function test_get_action_events_by_timesort_between_time_after_event(): void { $this->resetAfterTest(true); $this->setAdminuser(); @@ -293,7 +293,7 @@ class event_vault_test extends \advanced_testcase { * provided. This should work even when the event ids aren't ordered the * same as the timesort order. */ - public function test_get_action_events_by_timesort_non_consecutive_ids() { + public function test_get_action_events_by_timesort_non_consecutive_ids(): void { $this->resetAfterTest(true); $this->setAdminuser(); @@ -556,7 +556,7 @@ class event_vault_test extends \advanced_testcase { * Test that if a user is suspended that events related to that course are not shown. * User 1 is suspended. User 2 is active. */ - public function test_get_action_events_by_timesort_with_suspended_user() { + public function test_get_action_events_by_timesort_with_suspended_user(): void { $this->resetAfterTest(); $user1 = $this->getDataGenerator()->create_user(); $user2 = $this->getDataGenerator()->create_user(); @@ -587,7 +587,7 @@ class event_vault_test extends \advanced_testcase { * Test that get_action_events_by_course returns events after the * provided timesort value. */ - public function test_get_action_events_by_course_after_time() { + public function test_get_action_events_by_course_after_time(): void { $user = $this->getDataGenerator()->create_user(); $course1 = $this->getDataGenerator()->create_course(); $course2 = $this->getDataGenerator()->create_course(); @@ -642,7 +642,7 @@ class event_vault_test extends \advanced_testcase { * Test that get_action_events_by_course returns events before the * provided timesort value. */ - public function test_get_action_events_by_course_before_time() { + public function test_get_action_events_by_course_before_time(): void { $user = $this->getDataGenerator()->create_user(); $course1 = $this->getDataGenerator()->create_course(); $course2 = $this->getDataGenerator()->create_course(); @@ -698,7 +698,7 @@ class event_vault_test extends \advanced_testcase { * Test that get_action_events_by_course returns events between the * provided timesort values. */ - public function test_get_action_events_by_course_between_time() { + public function test_get_action_events_by_course_between_time(): void { $user = $this->getDataGenerator()->create_user(); $course1 = $this->getDataGenerator()->create_course(); $course2 = $this->getDataGenerator()->create_course(); @@ -751,7 +751,7 @@ class event_vault_test extends \advanced_testcase { * provided timesort values and after the last seen event when one is * provided. */ - public function test_get_action_events_by_course_between_time_after_event() { + public function test_get_action_events_by_course_between_time_after_event(): void { $user = $this->getDataGenerator()->create_user(); $course1 = $this->getDataGenerator()->create_course(); $course2 = $this->getDataGenerator()->create_course(); @@ -931,7 +931,7 @@ class event_vault_test extends \advanced_testcase { * provided. This should work even when the event ids aren't ordered the * same as the timesort order. */ - public function test_get_action_events_by_course_non_consecutive_ids() { + public function test_get_action_events_by_course_non_consecutive_ids(): void { $this->resetAfterTest(true); $this->setAdminuser(); diff --git a/calendar/tests/events_related_objects_cache_test.php b/calendar/tests/events_related_objects_cache_test.php index 91ed2a3ff48..8ed622c8fd1 100644 --- a/calendar/tests/events_related_objects_cache_test.php +++ b/calendar/tests/events_related_objects_cache_test.php @@ -43,7 +43,7 @@ class events_related_objects_cache_test extends \advanced_testcase { * An event with no module should return null when trying to retrieve * the module instance. */ - public function test_get_module_instance_no_module() { + public function test_get_module_instance_no_module(): void { $this->setAdminUser(); $mapper = container::get_event_mapper(); $legacyevent = create_event([ @@ -60,7 +60,7 @@ class events_related_objects_cache_test extends \advanced_testcase { * The get_module_instance should return the correct module instances * for the given set of events in the cache. */ - public function test_get_module_instance_with_modules() { + public function test_get_module_instance_with_modules(): void { $this->setAdminUser(); $mapper = container::get_event_mapper(); $generator = $this->getDataGenerator(); @@ -102,7 +102,7 @@ class events_related_objects_cache_test extends \advanced_testcase { * Trying to load the course module of an event that isn't in * the cache should return null. */ - public function test_module_instance_unknown_event() { + public function test_module_instance_unknown_event(): void { $this->setAdminUser(); $mapper = container::get_event_mapper(); $generator = $this->getDataGenerator(); diff --git a/calendar/tests/externallib_test.php b/calendar/tests/externallib_test.php index 737ec32eada..33ee8a22d90 100644 --- a/calendar/tests/externallib_test.php +++ b/calendar/tests/externallib_test.php @@ -134,7 +134,7 @@ class externallib_test extends externallib_advanced_testcase { return $event->create($prop); } - public function test_create_calendar_events() { + public function test_create_calendar_events(): void { global $DB, $USER; $this->setAdminUser(); @@ -162,7 +162,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test delete_calendar_events */ - public function test_delete_calendar_events() { + public function test_delete_calendar_events(): void { global $DB, $USER; $this->resetAfterTest(true); @@ -291,7 +291,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_calendar_events */ - public function test_get_calendar_events() { + public function test_get_calendar_events(): void { global $DB, $USER; $this->resetAfterTest(true); @@ -548,7 +548,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_calendar_events with mathjax in the name. */ - public function test_get_calendar_events_with_mathjax() { + public function test_get_calendar_events_with_mathjax(): void { global $USER; $this->resetAfterTest(true); @@ -584,7 +584,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test core_calendar_external::create_calendar_events */ - public function test_core_create_calendar_events() { + public function test_core_create_calendar_events(): void { global $DB, $USER, $SITE; $this->resetAfterTest(true); @@ -668,7 +668,7 @@ class externallib_test extends externallib_advanced_testcase { * If there are no events on or after the given time then an empty result set should * be returned. */ - public function test_get_calendar_action_events_by_timesort_after_time() { + public function test_get_calendar_action_events_by_timesort_after_time(): void { $user = $this->getDataGenerator()->create_user(); $course = $this->getDataGenerator()->create_course(); $generator = $this->getDataGenerator()->get_plugin_generator('mod_assign'); @@ -745,7 +745,7 @@ class externallib_test extends externallib_advanced_testcase { * If there are no events before the given time then an empty result set should be * returned. */ - public function test_get_calendar_action_events_by_timesort_before_time() { + public function test_get_calendar_action_events_by_timesort_before_time(): void { $user = $this->getDataGenerator()->create_user(); $course = $this->getDataGenerator()->create_course(); $generator = $this->getDataGenerator()->get_plugin_generator('mod_assign'); @@ -818,7 +818,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test retrieving event that was overridden for a user */ - public function test_get_calendar_events_override() { + public function test_get_calendar_events_override(): void { $user = $this->getDataGenerator()->create_user(); $user2 = $this->getDataGenerator()->create_user(); $teacher = $this->getDataGenerator()->create_user(); @@ -888,7 +888,7 @@ class externallib_test extends externallib_advanced_testcase { * If there are no events in the given time range then an empty result set should be * returned. */ - public function test_get_calendar_action_events_by_timesort_time_range() { + public function test_get_calendar_action_events_by_timesort_time_range(): void { $user = $this->getDataGenerator()->create_user(); $course = $this->getDataGenerator()->create_course(); $generator = $this->getDataGenerator()->get_plugin_generator('mod_assign'); @@ -948,7 +948,7 @@ class externallib_test extends externallib_advanced_testcase { * If there are no events in the given time range then an empty result set should be * returned. */ - public function test_get_calendar_action_events_by_timesort_time_limit_offset() { + public function test_get_calendar_action_events_by_timesort_time_limit_offset(): void { $user = $this->getDataGenerator()->create_user(); $course = $this->getDataGenerator()->create_course(); $generator = $this->getDataGenerator()->get_plugin_generator('mod_assign'); @@ -1014,7 +1014,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Check that it is possible to restrict the calendar events to events where the user is not suspended in the course. */ - public function test_get_calendar_action_events_by_timesort_suspended_course() { + public function test_get_calendar_action_events_by_timesort_suspended_course(): void { $this->resetAfterTest(); $user1 = $this->getDataGenerator()->create_user(); $user2 = $this->getDataGenerator()->create_user(); @@ -1042,7 +1042,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Check that it is possible to get other user's events without the permission. */ - public function test_get_calendar_action_events_by_timesort_for_other_users() { + public function test_get_calendar_action_events_by_timesort_for_other_users(): void { $this->resetAfterTest(); // Create test users. $user1 = $this->getDataGenerator()->create_user(['email' => 'student1@localhost.com']); @@ -1095,7 +1095,7 @@ class externallib_test extends externallib_advanced_testcase { * If there are no events on or after the given time then an empty result set should * be returned. */ - public function test_get_calendar_action_events_by_course_after_time() { + public function test_get_calendar_action_events_by_course_after_time(): void { $user = $this->getDataGenerator()->create_user(); $course1 = $this->getDataGenerator()->create_course(); $course2 = $this->getDataGenerator()->create_course(); @@ -1159,7 +1159,7 @@ class externallib_test extends externallib_advanced_testcase { * If there are no events before the given time then an empty result set should be * returned. */ - public function test_get_calendar_action_events_by_course_before_time() { + public function test_get_calendar_action_events_by_course_before_time(): void { $user = $this->getDataGenerator()->create_user(); $course1 = $this->getDataGenerator()->create_course(); $course2 = $this->getDataGenerator()->create_course(); @@ -1223,7 +1223,7 @@ class externallib_test extends externallib_advanced_testcase { * If there are no events in the given time range then an empty result set should be * returned. */ - public function test_get_calendar_action_events_by_course_time_range() { + public function test_get_calendar_action_events_by_course_time_range(): void { $user = $this->getDataGenerator()->create_user(); $course1 = $this->getDataGenerator()->create_course(); $course2 = $this->getDataGenerator()->create_course(); @@ -1288,7 +1288,7 @@ class externallib_test extends externallib_advanced_testcase { * If there are no events in the given time range then an empty result set should be * returned. */ - public function test_get_calendar_action_events_by_course_time_limit_offset() { + public function test_get_calendar_action_events_by_course_time_limit_offset(): void { $user = $this->getDataGenerator()->create_user(); $course1 = $this->getDataGenerator()->create_course(); $course2 = $this->getDataGenerator()->create_course(); @@ -1359,7 +1359,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_calendar_action_events_by_course with search feature */ - public function test_get_calendar_action_events_by_course_with_search() { + public function test_get_calendar_action_events_by_course_with_search(): void { // Generate data. $user = $this->getDataGenerator()->create_user(); $course = $this->getDataGenerator()->create_course(); @@ -1664,7 +1664,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test for deleting module events. */ - public function test_delete_calendar_events_for_modules() { + public function test_delete_calendar_events_for_modules(): void { $this->resetAfterTest(); $this->setAdminUser(); $course = $this->getDataGenerator()->create_course(); @@ -1688,7 +1688,7 @@ class externallib_test extends externallib_advanced_testcase { * Updating the event start day should change the date value but leave * the time of day unchanged. */ - public function test_update_event_start_day() { + public function test_update_event_start_day(): void { $generator = $this->getDataGenerator(); $user = $generator->create_user(); $roleid = $generator->create_role(); @@ -1728,7 +1728,7 @@ class externallib_test extends externallib_advanced_testcase { * A user should not be able to edit an event that they don't have * capabilities for. */ - public function test_update_event_start_day_no_permission() { + public function test_update_event_start_day_no_permission(): void { $generator = $this->getDataGenerator(); $user = $generator->create_user(); $roleid = $generator->create_role(); @@ -1767,7 +1767,7 @@ class externallib_test extends externallib_advanced_testcase { /** * A user should not be able to update a module event. */ - public function test_update_event_start_day_module_event() { + public function test_update_event_start_day_module_event(): void { $generator = $this->getDataGenerator(); $user = $generator->create_user(); $course = $generator->create_course(); @@ -1812,7 +1812,7 @@ class externallib_test extends externallib_advanced_testcase { * Submit a request where the time duration until is earlier than the time * start in order to get a validation error from the server. */ - public function test_submit_create_update_form_validation_error() { + public function test_submit_create_update_form_validation_error(): void { $user = $this->getDataGenerator()->create_user(); $timestart = new \DateTime(); $interval = new \DateInterval("P1D"); // One day. @@ -1867,7 +1867,7 @@ class externallib_test extends externallib_advanced_testcase { * A user with the moodle/calendar:manageownentries capability at the * system context should be able to create a user event. */ - public function test_submit_create_update_form_create_user_event() { + public function test_submit_create_update_form_create_user_event(): void { $generator = $this->getDataGenerator(); $user = $generator->create_user(); $roleid = $generator->create_role(); @@ -1932,7 +1932,7 @@ class externallib_test extends externallib_advanced_testcase { * A user without the moodle/calendar:manageownentries capability at the * system context should not be able to create a user event. */ - public function test_submit_create_update_form_create_user_event_no_permission() { + public function test_submit_create_update_form_create_user_event_no_permission(): void { $generator = $this->getDataGenerator(); $user = $generator->create_user(); $roleid = $generator->create_role(); @@ -1993,7 +1993,7 @@ class externallib_test extends externallib_advanced_testcase { * A user with the moodle/calendar:manageentries capability at the * site course context should be able to create a site event. */ - public function test_submit_create_update_form_create_site_event() { + public function test_submit_create_update_form_create_site_event(): void { $generator = $this->getDataGenerator(); $user = $generator->create_user(); $context = \context_system::instance(); @@ -2059,7 +2059,7 @@ class externallib_test extends externallib_advanced_testcase { * A user without the moodle/calendar:manageentries capability at the * site course context should not be able to create a site event. */ - public function test_submit_create_update_form_create_site_event_no_permission() { + public function test_submit_create_update_form_create_site_event_no_permission(): void { $generator = $this->getDataGenerator(); $user = $generator->create_user(); $context = \context_course::instance(SITEID); @@ -2121,7 +2121,7 @@ class externallib_test extends externallib_advanced_testcase { * A user that has the moodle/calendar:manageentries in a course that they * are enrolled in should be able to create a course event in that course. */ - public function test_submit_create_update_form_create_course_event() { + public function test_submit_create_update_form_create_course_event(): void { $generator = $this->getDataGenerator(); $user = $generator->create_user(); $course = $generator->create_course(); @@ -2191,7 +2191,7 @@ class externallib_test extends externallib_advanced_testcase { * A user without the moodle/calendar:manageentries capability in a course * that they are enrolled in should not be able to create a course event in that course. */ - public function test_submit_create_update_form_create_course_event_no_permission() { + public function test_submit_create_update_form_create_course_event_no_permission(): void { $generator = $this->getDataGenerator(); $user = $generator->create_user(); $course = $generator->create_course(); @@ -2256,7 +2256,7 @@ class externallib_test extends externallib_advanced_testcase { * A user should not be able to create an event for a course that they are * not enrolled in. */ - public function test_submit_create_update_form_create_course_event_not_enrolled() { + public function test_submit_create_update_form_create_course_event_not_enrolled(): void { $generator = $this->getDataGenerator(); $user = $generator->create_user(); $course = $generator->create_course(); @@ -2322,7 +2322,7 @@ class externallib_test extends externallib_advanced_testcase { * A user should be able to create an event for a group that they are a member of in * a course in which they are enrolled and have the moodle/calendar:manageentries capability. */ - public function test_submit_create_update_form_create_group_event_group_member_manage_course() { + public function test_submit_create_update_form_create_group_event_group_member_manage_course(): void { $generator = $this->getDataGenerator(); $user = $generator->create_user(); $course = $generator->create_course(); @@ -2395,7 +2395,7 @@ class externallib_test extends externallib_advanced_testcase { * A user should be able to create an event for a group that they are a member of in * a course in which they are enrolled and have the moodle/calendar:managegroupentries capability. */ - public function test_submit_create_update_form_create_group_event_group_member_manage_group_entries() { + public function test_submit_create_update_form_create_group_event_group_member_manage_group_entries(): void { $generator = $this->getDataGenerator(); $user = $generator->create_user(); $course = $generator->create_course(); @@ -2469,7 +2469,7 @@ class externallib_test extends externallib_advanced_testcase { * A user should be able to create an event for any group in a course in which * they are enrolled and have the moodle/site:accessallgroups capability. */ - public function test_submit_create_update_form_create_group_event_access_all_groups() { + public function test_submit_create_update_form_create_group_event_access_all_groups(): void { $generator = $this->getDataGenerator(); $user = $generator->create_user(); $course = $generator->create_course(); @@ -2543,7 +2543,7 @@ class externallib_test extends externallib_advanced_testcase { * member of in a course in which they are enrolled but don't have the * moodle/site:accessallgroups capability. */ - public function test_submit_create_update_form_create_group_event_non_member_no_permission() { + public function test_submit_create_update_form_create_group_event_non_member_no_permission(): void { $generator = $this->getDataGenerator(); $user = $generator->create_user(); $course = $generator->create_course(); @@ -2610,7 +2610,7 @@ class externallib_test extends externallib_advanced_testcase { /** * A user should not be able load the calendar monthly view for a course they cannot access. */ - public function test_get_calendar_monthly_view_no_course_permission() { + public function test_get_calendar_monthly_view_no_course_permission(): void { global $USER; $this->resetAfterTest(true); $this->setAdminUser(); @@ -2654,7 +2654,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_calendar_monthly_view when a day parameter is provided. */ - public function test_get_calendar_monthly_view_with_day_provided() { + public function test_get_calendar_monthly_view_with_day_provided(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -2670,7 +2670,7 @@ class externallib_test extends externallib_advanced_testcase { /** * A user should not be able load the calendar day view for a course they cannot access. */ - public function test_get_calendar_day_view_no_course_permission() { + public function test_get_calendar_day_view_no_course_permission(): void { global $USER; $this->resetAfterTest(true); $this->setAdminUser(); @@ -2714,7 +2714,7 @@ class externallib_test extends externallib_advanced_testcase { /** * A user should not be able load the calendar upcoming view for a course they cannot access. */ - public function test_get_calendar_upcoming_view_no_course_permission() { + public function test_get_calendar_upcoming_view_no_course_permission(): void { global $USER; $this->resetAfterTest(true); $this->setAdminUser(); @@ -2754,7 +2754,7 @@ class externallib_test extends externallib_advanced_testcase { /** * A user should not be able load the calendar event for a course they cannot access. */ - public function test_get_calendar_event_by_id_no_course_permission() { + public function test_get_calendar_event_by_id_no_course_permission(): void { global $USER; $this->resetAfterTest(true); $this->setAdminUser(); @@ -2821,7 +2821,7 @@ class externallib_test extends externallib_advanced_testcase { */ public function test_get_calendar_event_by_id_prevent_read_other_users_events( bool $isadminevent, bool $isadmin, ?\stdClass $readerrolecontext, - ?string $readerrolename, bool $expectexception) { + ?string $readerrolename, bool $expectexception): void { global $USER, $DB; $this->resetAfterTest(); @@ -2890,7 +2890,7 @@ class externallib_test extends externallib_advanced_testcase { * @param bool $expectexception Whether the test should throw an exception or not. */ public function test_delete_other_users_events(bool $isadmin, bool $isadminevent, - ?\stdClass $writerrolecontext, ?string $writerrolename, bool $expectexception) { + ?\stdClass $writerrolecontext, ?string $writerrolename, bool $expectexception): void { global $DB, $USER; $this->resetAfterTest(); @@ -2937,7 +2937,7 @@ class externallib_test extends externallib_advanced_testcase { * @param bool $expectexception Whether the test should throw an exception or not. */ public function test_edit_other_users_events(bool $isadmin, bool $isadminevent, - ?\stdClass $writerrolecontext, ?string $writerrolename, bool $expectexception) { + ?\stdClass $writerrolecontext, ?string $writerrolename, bool $expectexception): void { global $DB, $USER; $this->resetAfterTest(); @@ -2998,7 +2998,7 @@ class externallib_test extends externallib_advanced_testcase { /** * A user should not be able load the calendar events for a category they cannot see. */ - public function test_get_calendar_events_hidden_category() { + public function test_get_calendar_events_hidden_category(): void { global $USER; $this->resetAfterTest(true); $this->setAdminUser(); @@ -3034,7 +3034,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_calendar_access_information for admins. */ - public function test_get_calendar_access_information_for_admins() { + public function test_get_calendar_access_information_for_admins(): void { global $CFG; $this->resetAfterTest(true); $this->setAdminUser(); @@ -3053,7 +3053,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_calendar_access_information for authenticated users. */ - public function test_get_calendar_access_information_for_authenticated_users() { + public function test_get_calendar_access_information_for_authenticated_users(): void { $this->resetAfterTest(true); $this->setUser($this->getDataGenerator()->create_user()); @@ -3069,7 +3069,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_calendar_access_information for student users. */ - public function test_get_calendar_access_information_for_student_users() { + public function test_get_calendar_access_information_for_student_users(): void { global $DB; $this->resetAfterTest(true); @@ -3092,7 +3092,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_calendar_access_information for teacher users. */ - public function test_get_calendar_access_information_for_teacher_users() { + public function test_get_calendar_access_information_for_teacher_users(): void { global $DB; $this->resetAfterTest(true); @@ -3116,7 +3116,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_allowed_event_types for admins. */ - public function test_get_allowed_event_types_for_admins() { + public function test_get_allowed_event_types_for_admins(): void { global $CFG; $this->resetAfterTest(true); $this->setAdminUser(); @@ -3130,7 +3130,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_allowed_event_types for authenticated users. */ - public function test_get_allowed_event_types_for_authenticated_users() { + public function test_get_allowed_event_types_for_authenticated_users(): void { $this->resetAfterTest(true); $this->setUser($this->getDataGenerator()->create_user()); $data = external_api::clean_returnvalue( @@ -3142,7 +3142,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_allowed_event_types for student users. */ - public function test_get_allowed_event_types_for_student_users() { + public function test_get_allowed_event_types_for_student_users(): void { global $DB; $this->resetAfterTest(true); $user = $this->getDataGenerator()->create_user(); @@ -3159,7 +3159,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_allowed_event_types for teacher users. */ - public function test_get_allowed_event_types_for_teacher_users() { + public function test_get_allowed_event_types_for_teacher_users(): void { global $DB; $this->resetAfterTest(true); $user = $this->getDataGenerator()->create_user(); @@ -3178,7 +3178,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_timestamps with string keys, with and without optional hour/minute values. */ - public function test_get_timestamps_string_keys() { + public function test_get_timestamps_string_keys(): void { $this->resetAfterTest(true); $this->setAdminUser(); @@ -3221,7 +3221,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_timestamps with no keys specified, with and without optional hour/minute values. */ - public function test_get_timestamps_no_keys() { + public function test_get_timestamps_no_keys(): void { $this->resetAfterTest(true); $this->setAdminUser(); diff --git a/calendar/tests/lib_test.php b/calendar/tests/lib_test.php index f212cdff9e9..e23396c6640 100644 --- a/calendar/tests/lib_test.php +++ b/calendar/tests/lib_test.php @@ -44,7 +44,7 @@ class lib_test extends \advanced_testcase { /** * Test that the get_events() function only returns activity events that are enabled. */ - public function test_get_events_with_disabled_module() { + public function test_get_events_with_disabled_module(): void { global $DB; $this->setAdminUser(); $generator = $this->getDataGenerator(); @@ -106,7 +106,7 @@ class lib_test extends \advanced_testcase { $this->assertEquals('assign', $event->modulename); } - public function test_get_course_cached() { + public function test_get_course_cached(): void { // Setup some test courses. $course1 = $this->getDataGenerator()->create_course(); $course2 = $this->getDataGenerator()->create_course(); @@ -141,7 +141,7 @@ class lib_test extends \advanced_testcase { /** * Test the update_subscription() function. */ - public function test_update_subscription() { + public function test_update_subscription(): void { $this->resetAfterTest(true); $subscription = new \stdClass(); @@ -169,7 +169,7 @@ class lib_test extends \advanced_testcase { calendar_update_subscription($subscription); } - public function test_add_subscription() { + public function test_add_subscription(): void { global $DB, $CFG; require_once($CFG->dirroot . '/lib/bennu/bennu.inc.php'); @@ -253,7 +253,7 @@ class lib_test extends \advanced_testcase { /** * Test for calendar_get_legacy_events() when there are user and group overrides. */ - public function test_get_legacy_events_with_overrides() { + public function test_get_legacy_events_with_overrides(): void { $generator = $this->getDataGenerator(); $course = $generator->create_course(); @@ -439,7 +439,7 @@ class lib_test extends \advanced_testcase { $this->assertCount(3, $events); } - public function test_calendar_get_default_courses() { + public function test_calendar_get_default_courses(): void { global $USER, $CFG; $this->resetAfterTest(true); @@ -519,7 +519,7 @@ class lib_test extends \advanced_testcase { * Confirm that the skip events flag causes the calendar_get_view function * to avoid querying for the calendar events. */ - public function test_calendar_get_view_skip_events() { + public function test_calendar_get_view_skip_events(): void { $this->resetAfterTest(true); $this->setAdminUser(); @@ -544,7 +544,7 @@ class lib_test extends \advanced_testcase { $this->assertEquals($event->id, $data->events[0]->id); } - public function test_calendar_get_allowed_event_types_course() { + public function test_calendar_get_allowed_event_types_course(): void { $generator = $this->getDataGenerator(); $user = $generator->create_user(); $course1 = $generator->create_course(); // Has capability. @@ -595,7 +595,7 @@ class lib_test extends \advanced_testcase { $this->assertFalse($types['course']); } - public function test_calendar_get_allowed_event_types_group_no_acces_to_diff_groups() { + public function test_calendar_get_allowed_event_types_group_no_acces_to_diff_groups(): void { $generator = $this->getDataGenerator(); $user = $generator->create_user(); $course = $generator->create_course(); @@ -622,7 +622,7 @@ class lib_test extends \advanced_testcase { $this->assertFalse($types['group']); } - public function test_calendar_get_allowed_event_types_group_no_groups() { + public function test_calendar_get_allowed_event_types_group_no_groups(): void { $generator = $this->getDataGenerator(); $user = $generator->create_user(); $course = $generator->create_course(); @@ -644,7 +644,7 @@ class lib_test extends \advanced_testcase { $this->assertFalse($types['group']); } - public function test_calendar_get_allowed_event_types_group_access_all_groups() { + public function test_calendar_get_allowed_event_types_group_access_all_groups(): void { $generator = $this->getDataGenerator(); $user = $generator->create_user(); $course1 = $generator->create_course(); @@ -673,7 +673,7 @@ class lib_test extends \advanced_testcase { $this->assertTrue($types['group']); } - public function test_calendar_get_allowed_event_types_group_no_access_all_groups() { + public function test_calendar_get_allowed_event_types_group_no_access_all_groups(): void { $generator = $this->getDataGenerator(); $user = $generator->create_user(); $course = $generator->create_course(); @@ -706,7 +706,7 @@ class lib_test extends \advanced_testcase { $this->assertTrue($types['group']); } - public function test_calendar_get_allowed_event_types_group_cap_no_groups() { + public function test_calendar_get_allowed_event_types_group_cap_no_groups(): void { $generator = $this->getDataGenerator(); $user = $generator->create_user(); $course = $generator->create_course(); @@ -728,7 +728,7 @@ class lib_test extends \advanced_testcase { $this->assertFalse($types['group']); } - public function test_calendar_get_allowed_event_types_group_cap_has_group() { + public function test_calendar_get_allowed_event_types_group_cap_has_group(): void { $generator = $this->getDataGenerator(); $user = $generator->create_user(); $course = $generator->create_course(); @@ -751,7 +751,7 @@ class lib_test extends \advanced_testcase { $this->assertTrue($types['group']); } - public function test_calendar_get_allowed_event_types_group_cap_access_all_groups() { + public function test_calendar_get_allowed_event_types_group_cap_access_all_groups(): void { $generator = $this->getDataGenerator(); $user = $generator->create_user(); $course = $generator->create_course(); @@ -822,7 +822,7 @@ class lib_test extends \advanced_testcase { /** * This function tests calendar_set_filters for the case when user is not logged in. */ - public function test_calendar_set_filters_not_logged_in() { + public function test_calendar_set_filters_not_logged_in(): void { $this->resetAfterTest(); list($users, $courses, $coursegroups) = $this->setup_test_calendar_set_filters(); @@ -840,7 +840,7 @@ class lib_test extends \advanced_testcase { /** * This function tests calendar_set_filters for the case when no one is logged in, but a user id is provided. */ - public function test_calendar_set_filters_not_logged_in_with_user() { + public function test_calendar_set_filters_not_logged_in_with_user(): void { $this->resetAfterTest(); list($users, $courses, $coursegroups) = $this->setup_test_calendar_set_filters(); @@ -866,7 +866,7 @@ class lib_test extends \advanced_testcase { /** * This function tests calendar_set_filters for the case when user is logged in, but no user id is provided. */ - public function test_calendar_set_filters_logged_in_no_user() { + public function test_calendar_set_filters_logged_in_no_user(): void { $this->resetAfterTest(); list($users, $courses, $coursegroups) = $this->setup_test_calendar_set_filters(); @@ -882,7 +882,7 @@ class lib_test extends \advanced_testcase { /** * This function tests calendar_set_filters for the case when a user is logged in, but another user id is provided. */ - public function test_calendar_set_filters_logged_in_another_user() { + public function test_calendar_set_filters_logged_in_another_user(): void { $this->resetAfterTest(); list($users, $courses, $coursegroups) = $this->setup_test_calendar_set_filters(); @@ -899,7 +899,7 @@ class lib_test extends \advanced_testcase { /** * Test for calendar_view_event_allowed for course event types. */ - public function test_calendar_view_event_allowed_course_event() { + public function test_calendar_view_event_allowed_course_event(): void { global $USER; $this->setAdminUser(); @@ -967,7 +967,7 @@ class lib_test extends \advanced_testcase { /** * Test for calendar_get_export_token for current user. */ - public function test_calendar_get_export_token_for_current_user() { + public function test_calendar_get_export_token_for_current_user(): void { global $USER, $DB, $CFG; $this->setAdminUser(); @@ -982,7 +982,7 @@ class lib_test extends \advanced_testcase { /** * Test for calendar_get_export_token for another user. */ - public function test_calendar_get_export_token_for_another_user() { + public function test_calendar_get_export_token_for_another_user(): void { global $CFG; // Get any user token. @@ -1001,7 +1001,7 @@ class lib_test extends \advanced_testcase { * * @covers ::calendar_can_manage_user_event */ - public function test_calendar_can_manage_user_event() { + public function test_calendar_can_manage_user_event(): void { global $DB, $USER; $generator = $this->getDataGenerator(); $sitecontext = \context_system::instance(); diff --git a/calendar/tests/local_api_test.php b/calendar/tests/local_api_test.php index 0d3e7d1184e..e1f3e503890 100644 --- a/calendar/tests/local_api_test.php +++ b/calendar/tests/local_api_test.php @@ -78,7 +78,7 @@ class local_api_test extends \advanced_testcase { * If there are no events on or after the given time then an empty result set should * be returned. */ - public function test_get_calendar_action_events_by_timesort_after_time() { + public function test_get_calendar_action_events_by_timesort_after_time(): void { $user = $this->getDataGenerator()->create_user(); $course = $this->getDataGenerator()->create_course(); $generator = $this->getDataGenerator()->get_plugin_generator('mod_assign'); @@ -134,7 +134,7 @@ class local_api_test extends \advanced_testcase { * If there are no events before the given time then an empty result set should be * returned. */ - public function test_get_calendar_action_events_by_timesort_before_time() { + public function test_get_calendar_action_events_by_timesort_before_time(): void { $user = $this->getDataGenerator()->create_user(); $course = $this->getDataGenerator()->create_course(); $generator = $this->getDataGenerator()->get_plugin_generator('mod_assign'); @@ -185,7 +185,7 @@ class local_api_test extends \advanced_testcase { * If there are no events in the given time range then an empty result set should be * returned. */ - public function test_get_calendar_action_events_by_timesort_time_range() { + public function test_get_calendar_action_events_by_timesort_time_range(): void { $user = $this->getDataGenerator()->create_user(); $course = $this->getDataGenerator()->create_course(); $generator = $this->getDataGenerator()->get_plugin_generator('mod_assign'); @@ -237,7 +237,7 @@ class local_api_test extends \advanced_testcase { * If there are no events in the given time range then an empty result set should be * returned. */ - public function test_get_calendar_action_events_by_timesort_time_limit_offset() { + public function test_get_calendar_action_events_by_timesort_time_limit_offset(): void { $user = $this->getDataGenerator()->create_user(); $course = $this->getDataGenerator()->create_course(); $generator = $this->getDataGenerator()->get_plugin_generator('mod_assign'); @@ -289,7 +289,7 @@ class local_api_test extends \advanced_testcase { * Test get_calendar_action_events_by_timesort with search feature. * @covers ::get_action_events_by_timesort */ - public function test_get_calendar_action_events_by_timesort_with_search() { + public function test_get_calendar_action_events_by_timesort_with_search(): void { // Generate data. $user = $this->getDataGenerator()->create_user(); $course = $this->getDataGenerator()->create_course(); @@ -366,7 +366,7 @@ class local_api_test extends \advanced_testcase { * If there are no events on or after the given time then an empty result set should * be returned. */ - public function test_get_calendar_action_events_by_course_after_time() { + public function test_get_calendar_action_events_by_course_after_time(): void { $user = $this->getDataGenerator()->create_user(); $course1 = $this->getDataGenerator()->create_course(); $course2 = $this->getDataGenerator()->create_course(); @@ -431,7 +431,7 @@ class local_api_test extends \advanced_testcase { * If there are no events before the given time then an empty result set should be * returned. */ - public function test_get_calendar_action_events_by_course_before_time() { + public function test_get_calendar_action_events_by_course_before_time(): void { $user = $this->getDataGenerator()->create_user(); $course1 = $this->getDataGenerator()->create_course(); $course2 = $this->getDataGenerator()->create_course(); @@ -496,7 +496,7 @@ class local_api_test extends \advanced_testcase { * If there are no events in the given time range then an empty result set should be * returned. */ - public function test_get_calendar_action_events_by_course_time_range() { + public function test_get_calendar_action_events_by_course_time_range(): void { $user = $this->getDataGenerator()->create_user(); $course1 = $this->getDataGenerator()->create_course(); $course2 = $this->getDataGenerator()->create_course(); @@ -562,7 +562,7 @@ class local_api_test extends \advanced_testcase { * If there are no events in the given time range then an empty result set should be * returned. */ - public function test_get_calendar_action_events_by_course_time_limit_offset() { + public function test_get_calendar_action_events_by_course_time_limit_offset(): void { $user = $this->getDataGenerator()->create_user(); $course1 = $this->getDataGenerator()->create_course(); $course2 = $this->getDataGenerator()->create_course(); @@ -627,7 +627,7 @@ class local_api_test extends \advanced_testcase { * Test that get_action_events_by_courses will return a list of events for each * course you provided as long as the user is enrolled in the course. */ - public function test_get_action_events_by_courses() { + public function test_get_action_events_by_courses(): void { $user = $this->getDataGenerator()->create_user(); $course1 = $this->getDataGenerator()->create_course(); $course2 = $this->getDataGenerator()->create_course(); @@ -716,7 +716,7 @@ class local_api_test extends \advanced_testcase { * Test get_action_events_by_courses with search feature. * @covers ::get_action_events_by_courses */ - public function test_get_action_events_by_courses_with_search() { + public function test_get_action_events_by_courses_with_search(): void { // Generate data. $user = $this->getDataGenerator()->create_user(); $course1 = $this->getDataGenerator()->create_course(['fullname' => 'Course with advanced name']); @@ -787,7 +787,7 @@ class local_api_test extends \advanced_testcase { /** * Test that the get_legacy_events() function only returns activity events that are enabled. */ - public function test_get_legacy_events_with_disabled_module() { + public function test_get_legacy_events_with_disabled_module(): void { global $DB; $this->setAdminUser(); @@ -858,7 +858,7 @@ class local_api_test extends \advanced_testcase { /** * Test for \core_calendar\local\api::get_legacy_events() when there are user and group overrides. */ - public function test_get_legacy_events_with_overrides() { + public function test_get_legacy_events_with_overrides(): void { $generator = $this->getDataGenerator(); $course = $generator->create_course(); @@ -1048,7 +1048,7 @@ class local_api_test extends \advanced_testcase { * Setting the start date on the calendar event should update the date * of the event but should leave the time of day unchanged. */ - public function test_update_event_start_day_updates_date() { + public function test_update_event_start_day_updates_date(): void { $generator = $this->getDataGenerator(); $user = $generator->create_user(); $roleid = $generator->create_role(); @@ -1083,7 +1083,7 @@ class local_api_test extends \advanced_testcase { * A user should not be able to update the start date of the event * that they don't have the capabilities to modify. */ - public function test_update_event_start_day_no_permission() { + public function test_update_event_start_day_no_permission(): void { $generator = $this->getDataGenerator(); $user = $generator->create_user(); $roleid = $generator->create_role(); @@ -1119,7 +1119,7 @@ class local_api_test extends \advanced_testcase { * Note: This test uses the feedback activity because it requires * module callbacks to be in place to test. */ - public function test_update_event_start_day_activity_event_no_max() { + public function test_update_event_start_day_activity_event_no_max(): void { global $CFG, $DB; require_once($CFG->dirroot . '/mod/feedback/lib.php'); @@ -1154,7 +1154,7 @@ class local_api_test extends \advanced_testcase { * Note: This test uses the feedback activity because it requires * module callbacks to be in place to test. */ - public function test_update_event_start_day_activity_event_less_than_max() { + public function test_update_event_start_day_activity_event_less_than_max(): void { global $CFG, $DB; require_once($CFG->dirroot . '/mod/feedback/lib.php'); @@ -1191,7 +1191,7 @@ class local_api_test extends \advanced_testcase { * Note: This test uses the feedback activity because it requires * module callbacks to be in place to test. */ - public function test_update_event_start_day_activity_event_equal_to_max() { + public function test_update_event_start_day_activity_event_equal_to_max(): void { global $CFG, $DB; require_once($CFG->dirroot . '/mod/feedback/lib.php'); @@ -1227,7 +1227,7 @@ class local_api_test extends \advanced_testcase { * Note: This test uses the feedback activity because it requires * module callbacks to be in place to test. */ - public function test_update_event_start_day_activity_event_after_max() { + public function test_update_event_start_day_activity_event_after_max(): void { global $CFG, $DB; require_once($CFG->dirroot . '/mod/feedback/lib.php'); @@ -1258,7 +1258,7 @@ class local_api_test extends \advanced_testcase { * Note: This test uses the feedback activity because it requires * module callbacks to be in place to test. */ - public function test_update_event_start_day_activity_event_no_min() { + public function test_update_event_start_day_activity_event_no_min(): void { global $CFG, $DB; require_once($CFG->dirroot . '/mod/feedback/lib.php'); @@ -1294,7 +1294,7 @@ class local_api_test extends \advanced_testcase { * Note: This test uses the feedback activity because it requires * module callbacks to be in place to test. */ - public function test_update_event_start_day_activity_event_greater_than_min() { + public function test_update_event_start_day_activity_event_greater_than_min(): void { global $CFG, $DB; require_once($CFG->dirroot . '/mod/feedback/lib.php'); @@ -1331,7 +1331,7 @@ class local_api_test extends \advanced_testcase { * Note: This test uses the feedback activity because it requires * module callbacks to be in place to test. */ - public function test_update_event_start_day_activity_event_equal_to_min() { + public function test_update_event_start_day_activity_event_equal_to_min(): void { global $CFG, $DB; require_once($CFG->dirroot . '/mod/feedback/lib.php'); @@ -1368,7 +1368,7 @@ class local_api_test extends \advanced_testcase { * Note: This test uses the feedback activity because it requires * module callbacks to be in place to test. */ - public function test_update_event_start_day_activity_event_before_min() { + public function test_update_event_start_day_activity_event_before_min(): void { global $CFG, $DB; require_once($CFG->dirroot . '/mod/feedback/lib.php'); @@ -1400,7 +1400,7 @@ class local_api_test extends \advanced_testcase { * Note: This test uses the quiz activity because it requires * module callbacks to be in place and override event support to test. */ - public function test_update_event_start_day_activity_event_override() { + public function test_update_event_start_day_activity_event_override(): void { global $CFG, $DB; require_once($CFG->dirroot . '/calendar/lib.php'); require_once($CFG->dirroot . '/mod/quiz/lib.php'); diff --git a/calendar/tests/privacy/provider_test.php b/calendar/tests/privacy/provider_test.php index 12f8ac248cf..b468df121de 100644 --- a/calendar/tests/privacy/provider_test.php +++ b/calendar/tests/privacy/provider_test.php @@ -58,7 +58,7 @@ class provider_test extends provider_testcase { * * @throws coding_exception */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { // Create test user to create Calendar Events and Subscriptions. $user = $this->getDataGenerator()->create_user(); $this->setUser($user); @@ -130,7 +130,7 @@ class provider_test extends provider_testcase { * * @throws coding_exception */ - public function test_export_user_data() { + public function test_export_user_data(): void { global $DB; // Create test user to create Calendar Events and Subscriptions with. @@ -274,7 +274,7 @@ class provider_test extends provider_testcase { /** * Test for provider::test_export_user_preferences(). */ - public function test_export_user_preferences() { + public function test_export_user_preferences(): void { global $DB; // Test setup. @@ -306,7 +306,7 @@ class provider_test extends provider_testcase { * * @throws dml_exception */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; // Create test user to create Calendar Events and Subscriptions with. @@ -392,7 +392,7 @@ class provider_test extends provider_testcase { * * @throws dml_exception */ - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; // Create test user to create Calendar Events and Subscriptions with. @@ -447,7 +447,7 @@ class provider_test extends provider_testcase { /** * Test that only users with a user context are fetched. */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { $component = 'core_calendar'; // Create user1 to create Calendar Events and Subscriptions. @@ -569,7 +569,7 @@ class provider_test extends provider_testcase { /** * Test that data for users in approved userlist is deleted. */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { $component = 'core_calendar'; // Create user1 to create Calendar Events and Subscriptions. diff --git a/calendar/tests/raw_event_retrieval_strategy_test.php b/calendar/tests/raw_event_retrieval_strategy_test.php index 235d68fe7f2..b794682e7d9 100644 --- a/calendar/tests/raw_event_retrieval_strategy_test.php +++ b/calendar/tests/raw_event_retrieval_strategy_test.php @@ -34,7 +34,7 @@ class raw_event_retrieval_strategy_test extends \advanced_testcase { /** * Test retrieval strategy when module is disabled. */ - public function test_get_raw_events_with_disabled_module() { + public function test_get_raw_events_with_disabled_module(): void { global $DB; $this->resetAfterTest(); @@ -113,7 +113,7 @@ class raw_event_retrieval_strategy_test extends \advanced_testcase { /** * Test retrieval strategy when there are overrides. */ - public function test_get_raw_event_strategy_with_overrides() { + public function test_get_raw_event_strategy_with_overrides(): void { $this->resetAfterTest(); $retrievalstrategy = new raw_event_retrieval_strategy(); @@ -298,7 +298,7 @@ class raw_event_retrieval_strategy_test extends \advanced_testcase { /** * Test retrieval strategy with category specifications. */ - public function test_get_raw_events_category() { + public function test_get_raw_events_category(): void { $this->resetAfterTest(); $retrievalstrategy = new raw_event_retrieval_strategy(); $generator = $this->getDataGenerator(); @@ -359,7 +359,7 @@ class raw_event_retrieval_strategy_test extends \advanced_testcase { $this->assertCount(2, $events); } - public function test_get_raw_events_for_multiple_users() { + public function test_get_raw_events_for_multiple_users(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator(); @@ -402,7 +402,7 @@ class raw_event_retrieval_strategy_test extends \advanced_testcase { array_column($events, 'name')); } - public function test_get_raw_events_for_groups_with_no_members() { + public function test_get_raw_events_for_groups_with_no_members(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator(); @@ -447,7 +447,7 @@ class raw_event_retrieval_strategy_test extends \advanced_testcase { * db compatible. The test is ensuring we don't get a DML Exception with * the filters setup this way. */ - public function test_get_raw_events_with_empty_user_and_category_lists() { + public function test_get_raw_events_with_empty_user_and_category_lists(): void { $retrievalstrategy = new raw_event_retrieval_strategy; $retrievalstrategy->get_raw_events([], null, null, []); } diff --git a/calendar/tests/repeat_event_collection_test.php b/calendar/tests/repeat_event_collection_test.php index 935eb2bf159..785cb95fdf9 100644 --- a/calendar/tests/repeat_event_collection_test.php +++ b/calendar/tests/repeat_event_collection_test.php @@ -50,7 +50,7 @@ class repeat_event_collection_test extends \advanced_testcase { * Test that the collection id is set to the parent id if the repeat id * is falsey. */ - public function test_parent_id_no_repeat_id() { + public function test_parent_id_no_repeat_id(): void { $this->resetAfterTest(true); $dbrow = (object) [ 'id' => 123122131, @@ -66,7 +66,7 @@ class repeat_event_collection_test extends \advanced_testcase { * Test that the repeat id is set to the parent id if the repeat id * is not falsey (even if the parent id is provided). */ - public function test_parent_id_and_repeat_id() { + public function test_parent_id_and_repeat_id(): void { $this->resetAfterTest(true); $dbrow = (object) [ 'id' => 123122131, @@ -81,7 +81,7 @@ class repeat_event_collection_test extends \advanced_testcase { /** * Test that an empty collection is valid. */ - public function test_empty_collection() { + public function test_empty_collection(): void { $this->resetAfterTest(true); $this->setAdminUser(); @@ -108,7 +108,7 @@ class repeat_event_collection_test extends \advanced_testcase { /** * Test that a collection with values behaves correctly. */ - public function test_values_collection() { + public function test_values_collection(): void { $this->resetAfterTest(true); $this->setAdminUser(); diff --git a/calendar/tests/rrule_manager_test.php b/calendar/tests/rrule_manager_test.php index 12b625a27a8..2e904ac9689 100644 --- a/calendar/tests/rrule_manager_test.php +++ b/calendar/tests/rrule_manager_test.php @@ -78,7 +78,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test parse_rrule() method. */ - public function test_parse_rrule() { + public function test_parse_rrule(): void { $rules = [ 'FREQ=YEARLY', 'COUNT=3', @@ -131,7 +131,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test exception is thrown for invalid property. */ - public function test_parse_rrule_validation() { + public function test_parse_rrule_validation(): void { $rrule = "RANDOM=PROPERTY;"; $mang = new rrule_manager($rrule); $this->expectException('moodle_exception'); @@ -141,7 +141,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test exception is thrown for invalid frequency. */ - public function test_freq_validation() { + public function test_freq_validation(): void { $rrule = "FREQ=RANDOMLY;"; $mang = new rrule_manager($rrule); $this->expectException('moodle_exception'); @@ -151,7 +151,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test parsing of rules with both COUNT and UNTIL parameters. */ - public function test_until_count_validation() { + public function test_until_count_validation(): void { $until = $this->event->timestart + DAYSECS * 4; $until = date('Y-m-d', $until); $rrule = "FREQ=DAILY;COUNT=2;UNTIL=$until"; @@ -163,7 +163,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test parsing of INTERVAL rule. */ - public function test_interval_validation() { + public function test_interval_validation(): void { $rrule = "INTERVAL=0"; $mang = new rrule_manager($rrule); $this->expectException('moodle_exception'); @@ -173,7 +173,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test parsing of BYSECOND rule. */ - public function test_bysecond_validation() { + public function test_bysecond_validation(): void { $rrule = "BYSECOND=30,45,60"; $mang = new rrule_manager($rrule); $this->expectException('moodle_exception'); @@ -183,7 +183,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test parsing of BYMINUTE rule. */ - public function test_byminute_validation() { + public function test_byminute_validation(): void { $rrule = "BYMINUTE=30,45,60"; $mang = new rrule_manager($rrule); $this->expectException('moodle_exception'); @@ -193,7 +193,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test parsing of BYMINUTE rule. */ - public function test_byhour_validation() { + public function test_byhour_validation(): void { $rrule = "BYHOUR=23,45"; $mang = new rrule_manager($rrule); $this->expectException('moodle_exception'); @@ -203,7 +203,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test parsing of BYDAY rule. */ - public function test_byday_validation() { + public function test_byday_validation(): void { $rrule = "BYDAY=MO,2SE"; $mang = new rrule_manager($rrule); $this->expectException('moodle_exception'); @@ -213,7 +213,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test parsing of BYDAY rule with prefixes. */ - public function test_byday_with_prefix_validation() { + public function test_byday_with_prefix_validation(): void { // This is acceptable. $rrule = "FREQ=MONTHLY;BYDAY=-1MO,2SA"; $mang = new rrule_manager($rrule); @@ -234,7 +234,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test parsing of BYMONTHDAY rule. */ - public function test_bymonthday_upper_bound_validation() { + public function test_bymonthday_upper_bound_validation(): void { $rrule = "BYMONTHDAY=1,32"; $mang = new rrule_manager($rrule); $this->expectException('moodle_exception'); @@ -244,7 +244,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test parsing of BYMONTHDAY rule. */ - public function test_bymonthday_0_validation() { + public function test_bymonthday_0_validation(): void { $rrule = "BYMONTHDAY=1,0"; $mang = new rrule_manager($rrule); $this->expectException('moodle_exception'); @@ -254,7 +254,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test parsing of BYMONTHDAY rule. */ - public function test_bymonthday_lower_bound_validation() { + public function test_bymonthday_lower_bound_validation(): void { $rrule = "BYMONTHDAY=1,-31,-32"; $mang = new rrule_manager($rrule); $this->expectException('moodle_exception'); @@ -264,7 +264,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test parsing of BYYEARDAY rule. */ - public function test_byyearday_upper_bound_validation() { + public function test_byyearday_upper_bound_validation(): void { $rrule = "BYYEARDAY=1,366,367"; $mang = new rrule_manager($rrule); $this->expectException('moodle_exception'); @@ -274,7 +274,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test parsing of BYYEARDAY rule. */ - public function test_byyearday_0_validation() { + public function test_byyearday_0_validation(): void { $rrule = "BYYEARDAY=0"; $mang = new rrule_manager($rrule); $this->expectException('moodle_exception'); @@ -284,7 +284,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test parsing of BYYEARDAY rule. */ - public function test_byyearday_lower_bound_validation() { + public function test_byyearday_lower_bound_validation(): void { $rrule = "BYYEARDAY=-1,-366,-367"; $mang = new rrule_manager($rrule); $this->expectException('moodle_exception'); @@ -294,7 +294,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test parsing of BYWEEKNO rule. */ - public function test_non_yearly_freq_with_byweekno() { + public function test_non_yearly_freq_with_byweekno(): void { $rrule = "BYWEEKNO=1,53"; $mang = new rrule_manager($rrule); $this->expectException('moodle_exception'); @@ -304,7 +304,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test parsing of BYWEEKNO rule. */ - public function test_byweekno_upper_bound_validation() { + public function test_byweekno_upper_bound_validation(): void { $rrule = "FREQ=YEARLY;BYWEEKNO=1,53,54"; $mang = new rrule_manager($rrule); $this->expectException('moodle_exception'); @@ -314,7 +314,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test parsing of BYWEEKNO rule. */ - public function test_byweekno_0_validation() { + public function test_byweekno_0_validation(): void { $rrule = "FREQ=YEARLY;BYWEEKNO=0"; $mang = new rrule_manager($rrule); $this->expectException('moodle_exception'); @@ -324,7 +324,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test parsing of BYWEEKNO rule. */ - public function test_byweekno_lower_bound_validation() { + public function test_byweekno_lower_bound_validation(): void { $rrule = "FREQ=YEARLY;BYWEEKNO=-1,-53,-54"; $mang = new rrule_manager($rrule); $this->expectException('moodle_exception'); @@ -334,7 +334,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test parsing of BYMONTH rule. */ - public function test_bymonth_upper_bound_validation() { + public function test_bymonth_upper_bound_validation(): void { $rrule = "BYMONTH=1,12,13"; $mang = new rrule_manager($rrule); $this->expectException('moodle_exception'); @@ -344,7 +344,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test parsing of BYMONTH rule. */ - public function test_bymonth_lower_bound_validation() { + public function test_bymonth_lower_bound_validation(): void { $rrule = "BYMONTH=0"; $mang = new rrule_manager($rrule); $this->expectException('moodle_exception'); @@ -354,7 +354,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test parsing of BYSETPOS rule. */ - public function test_bysetpos_without_other_byrules() { + public function test_bysetpos_without_other_byrules(): void { $rrule = "BYSETPOS=1,366"; $mang = new rrule_manager($rrule); $this->expectException('moodle_exception'); @@ -364,7 +364,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test parsing of BYSETPOS rule. */ - public function test_bysetpos_upper_bound_validation() { + public function test_bysetpos_upper_bound_validation(): void { $rrule = "BYSETPOS=1,366,367"; $mang = new rrule_manager($rrule); $this->expectException('moodle_exception'); @@ -374,7 +374,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test parsing of BYSETPOS rule. */ - public function test_bysetpos_0_validation() { + public function test_bysetpos_0_validation(): void { $rrule = "BYSETPOS=0"; $mang = new rrule_manager($rrule); $this->expectException('moodle_exception'); @@ -384,7 +384,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test parsing of BYSETPOS rule. */ - public function test_bysetpos_lower_bound_validation() { + public function test_bysetpos_lower_bound_validation(): void { $rrule = "BYSETPOS=-1,-366,-367"; $mang = new rrule_manager($rrule); $this->expectException('moodle_exception'); @@ -394,7 +394,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test recurrence rules for daily frequency. */ - public function test_daily_events() { + public function test_daily_events(): void { global $DB; $rrule = 'FREQ=DAILY;COUNT=3'; // This should generate 2 child events + 1 parent. @@ -439,7 +439,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Every 300 days, forever. */ - public function test_every_300_days_forever() { + public function test_every_300_days_forever(): void { global $DB; // Change the start date for forever events to 9am of the current date. @@ -481,7 +481,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test recurrence rules for weekly frequency. */ - public function test_weekly_events() { + public function test_weekly_events(): void { global $DB; $rrule = 'FREQ=WEEKLY;COUNT=1'; @@ -551,7 +551,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test recurrence rules for weekly frequency for RRULE with BYDAY rule set, recurring forever. */ - public function test_weekly_byday_forever() { + public function test_weekly_byday_forever(): void { global $DB; // Set the next Monday as the starting date of this event. @@ -591,7 +591,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test recurrence rules for monthly frequency for RRULE with COUNT and BYMONTHDAY rules set. */ - public function test_monthly_events_with_count_bymonthday() { + public function test_monthly_events_with_count_bymonthday(): void { global $DB; $startdatetime = new \DateTime(date('Y-m-d H:i:s', $this->event->timestart)); @@ -615,7 +615,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test recurrence rules for monthly frequency for RRULE with BYMONTHDAY and UNTIL rules set. */ - public function test_monthly_events_with_until_bymonthday() { + public function test_monthly_events_with_until_bymonthday(): void { global $DB; // This should generate 10 child event + 1 parent, since by then until bound would be hit. @@ -637,7 +637,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test recurrence rules for monthly frequency for RRULE with BYMONTHDAY and UNTIL rules set. */ - public function test_monthly_events_with_until_bymonthday_multi() { + public function test_monthly_events_with_until_bymonthday_multi(): void { global $DB; $startdatetime = new \DateTime(date('Y-m-d H:i:s', $this->event->timestart)); @@ -680,7 +680,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test recurrence rules for monthly frequency for RRULE with BYMONTHDAY forever. */ - public function test_monthly_events_with_bymonthday_forever() { + public function test_monthly_events_with_bymonthday_forever(): void { global $DB; // Change the start date for forever events to 9am of the 2nd day of the current month and year. @@ -723,7 +723,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test recurrence rules for monthly frequency for RRULE with COUNT and BYDAY rules set. */ - public function test_monthly_events_with_count_byday() { + public function test_monthly_events_with_count_byday(): void { global $DB; $startdatetime = new \DateTime(date('Y-m-d H:i:s', $this->event->timestart)); @@ -756,7 +756,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test recurrence rules for monthly frequency for RRULE with BYDAY and UNTIL rules set. */ - public function test_monthly_events_with_until_byday() { + public function test_monthly_events_with_until_byday(): void { global $DB; // This much seconds after the start of the day. @@ -794,7 +794,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test recurrence rules for monthly frequency for RRULE with BYMONTHDAY and UNTIL rules set. */ - public function test_monthly_events_with_until_byday_multi() { + public function test_monthly_events_with_until_byday_multi(): void { global $DB; $startdatetime = new \DateTime(date('Y-m-d H:i:s', $this->event->timestart)); @@ -836,7 +836,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test recurrence rules for monthly frequency for RRULE with BYDAY forever. */ - public function test_monthly_events_with_byday_forever() { + public function test_monthly_events_with_byday_forever(): void { global $DB; // Change the start date for forever events to 9am of the 2nd day of the current month and year. @@ -882,7 +882,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test recurrence rules for yearly frequency. */ - public function test_yearly_events() { + public function test_yearly_events(): void { global $DB; $startdatetime = new \DateTime(date('Y-m-d H:i:s', $this->event->timestart)); @@ -1015,7 +1015,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test for rrule with FREQ=YEARLY and INTERVAL=2 with BYMONTH rule set, recurring forever. */ - public function test_yearly_september_every_two_years_forever() { + public function test_yearly_september_every_two_years_forever(): void { global $DB; // Change the start date for forever events to 9am on the 2nd day of September of the current year. @@ -1045,7 +1045,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test for rrule with FREQ=YEARLY with BYMONTH and BYDAY rules set, recurring forever. */ - public function test_yearly_bymonth_byday_forever() { + public function test_yearly_bymonth_byday_forever(): void { global $DB; // Change the start date for forever events to the first day of September of the current year at 9am. @@ -1088,7 +1088,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Test for rrule with FREQ=YEARLY recurring forever. */ - public function test_yearly_forever() { + public function test_yearly_forever(): void { global $DB; // Change the start date for forever events to 9am of the current date. @@ -1130,7 +1130,7 @@ class rrule_manager_test extends \advanced_testcase { * RRULE:FREQ=DAILY;COUNT=10 * ==> (1997 9:00 AM EDT)September 2-11 */ - public function test_daily_count() { + public function test_daily_count(): void { global $DB; $startdatetime = new \DateTime(date('Y-m-d H:i:s', $this->event->timestart)); @@ -1161,7 +1161,7 @@ class rrule_manager_test extends \advanced_testcase { * ==> (1997 9:00 AM EDT)September 2-30;October 1-25 * (1997 9:00 AM EST)October 26-31;November 1-30;December 1-23 */ - public function test_daily_until() { + public function test_daily_until(): void { global $DB; $startdatetime = new \DateTime(date('Y-m-d H:i:s', $this->event->timestart)); @@ -1198,7 +1198,7 @@ class rrule_manager_test extends \advanced_testcase { * (1997 9:00 AM EDT)September2,4,6,8...24,26,28,30;October 2,4,6...20,22,24 * (1997 9:00 AM EST)October 26,28,30;November 1,3,5,7...25,27,29;Dec 1,3,... */ - public function test_every_other_day_forever() { + public function test_every_other_day_forever(): void { global $DB; // Change the start date for forever events to 9am of the current date in US/Eastern time. @@ -1236,7 +1236,7 @@ class rrule_manager_test extends \advanced_testcase { * RRULE:FREQ=DAILY;INTERVAL=10;COUNT=5 * ==> (1997 9:00 AM EDT)September 2,12,22;October 2,12 */ - public function test_every_10_days_5_count() { + public function test_every_10_days_5_count(): void { global $DB; $startdatetime = new \DateTime(date('Y-m-d H:i:s', $this->event->timestart)); @@ -1267,7 +1267,7 @@ class rrule_manager_test extends \advanced_testcase { * (1999 9:00 AM EDT)January 1-31 * (2000 9:00 AM EDT)January 1-31 */ - public function test_everyday_in_jan_for_3_years_yearly() { + public function test_everyday_in_jan_for_3_years_yearly(): void { global $DB; // Change our event's date to 01-01-1998, based on the example from the RFC. @@ -1301,7 +1301,7 @@ class rrule_manager_test extends \advanced_testcase { * (1999 9:00 AM EDT)January 1-31 * (2000 9:00 AM EDT)January 1-31 */ - public function test_everyday_in_jan_for_3_years_daily() { + public function test_everyday_in_jan_for_3_years_daily(): void { global $DB; // Change our event's date to 01-01-1998, based on the example from the RFC. @@ -1334,7 +1334,7 @@ class rrule_manager_test extends \advanced_testcase { * ==> (1997 9:00 AM EDT)September 2,9,16,23,30;October 7,14,21 * (1997 9:00 AM EST)October 28;November 4 */ - public function test_weekly_10_count() { + public function test_weekly_10_count(): void { global $DB; $interval = new \DateInterval('P1W'); @@ -1363,7 +1363,7 @@ class rrule_manager_test extends \advanced_testcase { * ==> (1997 9:00 AM EDT)September 2,9,16,23,30;October 7,14,21,28 * (1997 9:00 AM EST)November 4,11,18,25;December 2,9,16,23 */ - public function test_weekly_until_24_dec_1997() { + public function test_weekly_until_24_dec_1997(): void { global $DB; $interval = new \DateInterval('P1W'); @@ -1400,7 +1400,7 @@ class rrule_manager_test extends \advanced_testcase { * (1998 9:00 AM EST)January 6,20;February * ... */ - public function test_every_other_week_forever() { + public function test_every_other_week_forever(): void { global $DB; // Change the start date for forever events to 9am of the current date in US/Eastern time. @@ -1437,7 +1437,7 @@ class rrule_manager_test extends \advanced_testcase { * RRULE:FREQ=WEEKLY;UNTIL=19971007T000000Z;WKST=SU;BYDAY=TU,TH * ==> (1997 9:00 AM EDT)September 2,4,9,11,16,18,23,25,30;October 2 */ - public function test_weekly_on_tue_thu_for_5_weeks_by_until() { + public function test_weekly_on_tue_thu_for_5_weeks_by_until(): void { global $DB; $rrule = 'FREQ=WEEKLY;UNTIL=19971007T000000Z;WKST=SU;BYDAY=TU,TH'; @@ -1475,7 +1475,7 @@ class rrule_manager_test extends \advanced_testcase { * RRULE:FREQ=WEEKLY;COUNT=10;WKST=SU;BYDAY=TU,TH * ==> (1997 9:00 AM EDT)September 2,4,9,11,16,18,23,25,30;October 2 */ - public function test_weekly_on_tue_thu_for_5_weeks_by_count() { + public function test_weekly_on_tue_thu_for_5_weeks_by_count(): void { global $DB; $rrule = 'FREQ=WEEKLY;COUNT=10;WKST=SU;BYDAY=TU,TH'; @@ -1510,7 +1510,7 @@ class rrule_manager_test extends \advanced_testcase { * ==> (1997 9:00 AM EDT)September 3,5,15,17,19,29;October 1,3,13,15,17 * (1997 9:00 AM EST)October 27,29,31;November 10,12,14,24,26,28;December 8,10,12,22 */ - public function test_every_other_week_until_24_dec_1997_byday() { + public function test_every_other_week_until_24_dec_1997_byday(): void { global $DB; $rrule = 'FREQ=WEEKLY;INTERVAL=2;UNTIL=19971224T000000Z;WKST=SU;BYDAY=MO,WE,FR'; @@ -1563,7 +1563,7 @@ class rrule_manager_test extends \advanced_testcase { * RRULE:FREQ=WEEKLY;INTERVAL=2;COUNT=8;WKST=SU;BYDAY=TU,TH * ==> (1997 9:00 AM EDT)September 2,4,16,18,30;October 2,14,16 */ - public function test_every_other_week_byday_8_count() { + public function test_every_other_week_byday_8_count(): void { global $DB; $rrule = 'FREQ=WEEKLY;INTERVAL=2;COUNT=8;WKST=SU;BYDAY=TU,TH'; @@ -1610,7 +1610,7 @@ class rrule_manager_test extends \advanced_testcase { * (1998 9:00 AM EST)January 2;February 6;March 6;April 3 * (1998 9:00 AM EDT)May 1;June 5 */ - public function test_monthly_every_first_friday_10_count() { + public function test_monthly_every_first_friday_10_count(): void { global $DB; // Change our event's date to 05-09-1997, based on the example from the RFC. @@ -1646,7 +1646,7 @@ class rrule_manager_test extends \advanced_testcase { * ==> (1997 9:00 AM EDT)September 5;October 3 * (1997 9:00 AM EST)November 7;December 5 */ - public function test_monthly_every_first_friday_until() { + public function test_monthly_every_first_friday_until(): void { global $DB; // Change our event's date to 05-09-1997, based on the example from the RFC. @@ -1684,7 +1684,7 @@ class rrule_manager_test extends \advanced_testcase { * (1998 9:00 AM EST)January 4,25;March 1,29 * (1998 9:00 AM EDT)May 3,31 */ - public function test_every_other_month_1st_and_last_sunday_10_count() { + public function test_every_other_month_1st_and_last_sunday_10_count(): void { global $DB; // Change our event's date to 05-09-1997, based on the example from the RFC. @@ -1727,7 +1727,7 @@ class rrule_manager_test extends \advanced_testcase { * (1997 9:00 AM EST)November 17;December 22 * (1998 9:00 AM EST)January 19;February 16 */ - public function test_monthly_last_monday_for_6_months() { + public function test_monthly_last_monday_for_6_months(): void { global $DB; // Change our event's date to 05-09-1997, based on the example from the RFC. @@ -1769,7 +1769,7 @@ class rrule_manager_test extends \advanced_testcase { * (1998 9:00 AM EST)January 29;February 26 * ... */ - public function test_third_to_the_last_day_of_the_month_forever() { + public function test_third_to_the_last_day_of_the_month_forever(): void { global $DB; // Change our event's date to 28 September of the current year, based on the example from the RFC. @@ -1812,7 +1812,7 @@ class rrule_manager_test extends \advanced_testcase { * (1997 9:00 AM EST)November 2,15;December 2,15 * (1998 9:00 AM EST)January 2,15 */ - public function test_every_2nd_and_15th_of_the_month_10_count() { + public function test_every_2nd_and_15th_of_the_month_10_count(): void { global $DB; $startdatetime = new \DateTime(date('Y-m-d H:i:s', $this->event->timestart)); @@ -1856,7 +1856,7 @@ class rrule_manager_test extends \advanced_testcase { * (1997 9:00 AM EST)October 31;November 1,30;December 1,31 * (1998 9:00 AM EST)January 1,31;February 1 */ - public function test_every_first_and_last_day_of_the_month_10_count() { + public function test_every_first_and_last_day_of_the_month_10_count(): void { global $DB; $startdatetime = $this->change_event_startdate('19970930T090000', 'US/Eastern'); @@ -1901,7 +1901,7 @@ class rrule_manager_test extends \advanced_testcase { * ==> (1997 9:00 AM EDT)September 10,11,12,13,14,15 * (1999 9:00 AM EST)March 10,11,12,13 */ - public function test_every_18_months_days_10_to_15_10_count() { + public function test_every_18_months_days_10_to_15_10_count(): void { global $DB; $startdatetime = $this->change_event_startdate('19970910T090000', 'US/Eastern'); @@ -1946,7 +1946,7 @@ class rrule_manager_test extends \advanced_testcase { * (1998 9:00 AM EST)January 6,13,20,27;March 3,10,17,24,31 * ... */ - public function test_every_tuesday_every_other_month_forever() { + public function test_every_tuesday_every_other_month_forever(): void { global $DB; // Change the start date for forever events to 9am of the Tuesday on or before of the current date in US/Eastern time. @@ -2001,7 +2001,7 @@ class rrule_manager_test extends \advanced_testcase { * (2001 9:00 AM EDT)June 10;July 10 * Note: Since none of the BYDAY, BYMONTHDAY or BYYEARDAY components are specified, the day is gotten from DTSTART. */ - public function test_yearly_in_june_july_10_count() { + public function test_yearly_in_june_july_10_count(): void { global $DB; $startdatetime = $this->change_event_startdate('19970610T090000', 'US/Eastern'); @@ -2044,7 +2044,7 @@ class rrule_manager_test extends \advanced_testcase { * (2001 9:00 AM EST)January 10;February 10;March 10 * (2003 9:00 AM EST)January 10;February 10;March 10 */ - public function test_every_other_year_in_june_july_10_count() { + public function test_every_other_year_in_june_july_10_count(): void { global $DB; $startdatetime = $this->change_event_startdate('19970310T090000', 'US/Eastern'); @@ -2091,7 +2091,7 @@ class rrule_manager_test extends \advanced_testcase { * (2003 9:00 AM EDT)April 10;July 19 * (2006 9:00 AM EST)January 1 */ - public function test_every_3_years_1st_100th_200th_days_10_count() { + public function test_every_3_years_1st_100th_200th_days_10_count(): void { global $DB; $startdatetime = $this->change_event_startdate('19970101T090000', 'US/Eastern'); @@ -2138,7 +2138,7 @@ class rrule_manager_test extends \advanced_testcase { * (1999 9:00 AM EDT)May 17 * ... */ - public function test_yearly_every_20th_monday_forever() { + public function test_yearly_every_20th_monday_forever(): void { global $DB; // Change our event's date to the 20th Monday of the current year. @@ -2184,7 +2184,7 @@ class rrule_manager_test extends \advanced_testcase { * (1999 9:00 AM EDT)May 17 * ... */ - public function test_yearly_byweekno_forever() { + public function test_yearly_byweekno_forever(): void { global $DB; // Change our event's date to the start of the 20th week of the current year. @@ -2234,7 +2234,7 @@ class rrule_manager_test extends \advanced_testcase { * (1999 9:00 AM EST)March 4,11,18,25 * ... */ - public function test_every_thursday_in_march_forever() { + public function test_every_thursday_in_march_forever(): void { global $DB; // Change our event's date to the first Thursday of March of the current year at 9am US/Eastern time. @@ -2293,7 +2293,7 @@ class rrule_manager_test extends \advanced_testcase { * (1999 9:00 AM EDT)June 3,10,17,24;July 1,8,15,22,29;August 5,12,19,26 * ... */ - public function test_every_thursday_june_july_august_forever() { + public function test_every_thursday_june_july_august_forever(): void { global $DB; // Change our event's date to the first Thursday of June in the current year at 9am US/Eastern time. @@ -2350,7 +2350,7 @@ class rrule_manager_test extends \advanced_testcase { * (2000 9:00 AM EDT)October 13 * ... */ - public function test_friday_the_thirteenth_forever() { + public function test_friday_the_thirteenth_forever(): void { global $DB; // Change our event's date to the first Thursday of June in the current year at 9am US/Eastern time. @@ -2387,7 +2387,7 @@ class rrule_manager_test extends \advanced_testcase { * (1998 9:00 AM EST)January 10;February 7;March 7 * (1998 9:00 AM EDT)April 11;May 9;June 13... */ - public function test_first_saturday_following_first_sunday_forever() { + public function test_first_saturday_following_first_sunday_forever(): void { global $DB; // Change our event's date to the next Saturday after the first Sunday of the the current month at 9am US/Eastern time. @@ -2438,7 +2438,7 @@ class rrule_manager_test extends \advanced_testcase { * (2004 9:00 AM EST)November 2 * ... */ - public function test_every_us_presidential_election_forever() { + public function test_every_us_presidential_election_forever(): void { global $DB; // Calculate the most recent election date, starting from 1996 (e.g. today's 2017 so the most recent election was in 2016). @@ -2491,7 +2491,7 @@ class rrule_manager_test extends \advanced_testcase { * ==> (1997 9:00 AM EDT)September 4;October 7 * (1997 9:00 AM EST)November 6 */ - public function test_monthly_bysetpos_3_count() { + public function test_monthly_bysetpos_3_count(): void { global $DB; $this->change_event_startdate('19970904T090000', 'US/Eastern'); @@ -2528,7 +2528,7 @@ class rrule_manager_test extends \advanced_testcase { * (Original RFC example is set to recur forever. But we just want to verify that the results match the dates listed from * the RFC example. So just limit the count to 7.) */ - public function test_second_to_the_last_weekday_of_the_month() { + public function test_second_to_the_last_weekday_of_the_month(): void { global $DB; $this->change_event_startdate('19970929T090000', 'US/Eastern'); @@ -2572,7 +2572,7 @@ class rrule_manager_test extends \advanced_testcase { * RRULE:FREQ=HOURLY;INTERVAL=3;UNTIL=19970902T210000Z * ==> (September 2, 1997 EDT)09:00,12:00,15:00 */ - public function test_every_3hours_9am_to_5pm() { + public function test_every_3hours_9am_to_5pm(): void { global $DB; $rrule = 'FREQ=HOURLY;INTERVAL=3;UNTIL=19970902T210000Z'; @@ -2601,7 +2601,7 @@ class rrule_manager_test extends \advanced_testcase { * RRULE:FREQ=MINUTELY;INTERVAL=15;COUNT=6 * ==> (September 2, 1997 EDT)09:00,09:15,09:30,09:45,10:00,10:15 */ - public function test_every_15minutes_6_count() { + public function test_every_15minutes_6_count(): void { global $DB; $rrule = 'FREQ=MINUTELY;INTERVAL=15;COUNT=6'; @@ -2633,7 +2633,7 @@ class rrule_manager_test extends \advanced_testcase { * RRULE:FREQ=MINUTELY;INTERVAL=90;COUNT=4 * ==> (September 2, 1997 EDT)09:00,10:30;12:00;13:30 */ - public function test_every_90minutes_4_count() { + public function test_every_90minutes_4_count(): void { global $DB; $rrule = 'FREQ=MINUTELY;INTERVAL=90;COUNT=4'; @@ -2668,7 +2668,7 @@ class rrule_manager_test extends \advanced_testcase { * (September 3, 1997 EDT)9:00,9:20,9:40,10:00,10:20,...16:00,16:20,16:40 * ... */ - public function test_every_20minutes_daily_byhour_byminute_50_count() { + public function test_every_20minutes_daily_byhour_byminute_50_count(): void { global $DB; $rrule = 'FREQ=DAILY;BYHOUR=9,10,11,12,13,14,15,16;BYMINUTE=0,20,40;COUNT=50'; @@ -2713,7 +2713,7 @@ class rrule_manager_test extends \advanced_testcase { * (September 3, 1997 EDT)9:00,9:20,9:40,10:00,10:20,...16:00,16:20,16:40 * ... */ - public function test_every_20minutes_minutely_byhour_50_count() { + public function test_every_20minutes_minutely_byhour_50_count(): void { global $DB; $rrule = 'FREQ=MINUTELY;INTERVAL=20;BYHOUR=9,10,11,12,13,14,15,16;COUNT=50'; @@ -2753,7 +2753,7 @@ class rrule_manager_test extends \advanced_testcase { * RRULE:FREQ=WEEKLY;INTERVAL=2;COUNT=4;BYDAY=TU,SU;WKST=MO * ==> (1997 EDT)Aug 5,10,19,24 */ - public function test_weekly_byday_with_wkst_mo() { + public function test_weekly_byday_with_wkst_mo(): void { global $DB; $this->change_event_startdate('19970805T090000', 'US/Eastern'); @@ -2786,7 +2786,7 @@ class rrule_manager_test extends \advanced_testcase { * RRULE:FREQ=WEEKLY;INTERVAL=2;COUNT=4;BYDAY=TU,SU;WKST=SU * ==> (1997 EDT)August 5,17,19,31 */ - public function test_weekly_byday_with_wkst_su() { + public function test_weekly_byday_with_wkst_su(): void { global $DB; $this->change_event_startdate('19970805T090000', 'US/Eastern'); @@ -2820,7 +2820,7 @@ class rrule_manager_test extends \advanced_testcase { * Tests for MONTHLY RRULE with BYMONTHDAY set to 31. * Should not include February, April, June, September and November. */ - public function test_monthly_bymonthday_31() { + public function test_monthly_bymonthday_31(): void { global $DB; $rrule = 'FREQ=MONTHLY;BYMONTHDAY=31;COUNT=20'; @@ -2842,7 +2842,7 @@ class rrule_manager_test extends \advanced_testcase { /** * Tests for the last day in February. (Leap year test) */ - public function test_yearly_on_the_last_day_of_february() { + public function test_yearly_on_the_last_day_of_february(): void { global $DB; $rrule = 'FREQ=YEARLY;BYMONTH=2;BYMONTHDAY=-1;COUNT=30'; diff --git a/cohort/tests/customfield/cohort_handler_test.php b/cohort/tests/customfield/cohort_handler_test.php index ffcd5a13f5d..87ea881d02d 100644 --- a/cohort/tests/customfield/cohort_handler_test.php +++ b/cohort/tests/customfield/cohort_handler_test.php @@ -65,14 +65,14 @@ class cohort_handler_test extends advanced_testcase { /** * Test configuration context. */ - public function test_get_configuration_context() { + public function test_get_configuration_context(): void { $this->assertInstanceOf(context_system::class, $this->handler->get_configuration_context()); } /** * Test getting config URL. */ - public function test_get_configuration_url() { + public function test_get_configuration_url(): void { $this->assertInstanceOf(moodle_url::class, $this->handler->get_configuration_url()); $this->assertEquals('/cohort/customfield.php', $this->handler->get_configuration_url()->out_as_local_url()); } @@ -80,7 +80,7 @@ class cohort_handler_test extends advanced_testcase { /** * Test can configure check. */ - public function test_can_configure() { + public function test_can_configure(): void { $this->resetAfterTest(); $user = self::getDataGenerator()->create_user(); @@ -98,7 +98,7 @@ class cohort_handler_test extends advanced_testcase { /** * Test getting instance context. */ - public function test_get_instance_context() { + public function test_get_instance_context(): void { $this->resetAfterTest(); $category = self::getDataGenerator()->create_category(); @@ -117,7 +117,7 @@ class cohort_handler_test extends advanced_testcase { /** * Test can edit functionality. */ - public function test_can_edit() { + public function test_can_edit(): void { $this->resetAfterTest(); $roleid = self::getDataGenerator()->create_role(); @@ -137,7 +137,7 @@ class cohort_handler_test extends advanced_testcase { /** * Test can view functionality. */ - public function test_can_view() { + public function test_can_view(): void { $this->resetAfterTest(); $manageroleid = self::getDataGenerator()->create_role(); diff --git a/cohort/tests/externallib_test.php b/cohort/tests/externallib_test.php index 0d25c58ff9f..0eaa2588fe4 100644 --- a/cohort/tests/externallib_test.php +++ b/cohort/tests/externallib_test.php @@ -64,7 +64,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test create_cohorts */ - public function test_create_cohorts() { + public function test_create_cohorts(): void { global $DB; $this->resetAfterTest(true); @@ -200,7 +200,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test delete_cohorts */ - public function test_delete_cohorts() { + public function test_delete_cohorts(): void { global $USER, $CFG, $DB; $this->resetAfterTest(true); @@ -232,7 +232,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_cohorts */ - public function test_get_cohorts() { + public function test_get_cohorts(): void { $this->resetAfterTest(true); // Custom fields. @@ -315,7 +315,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test update_cohorts */ - public function test_update_cohorts() { + public function test_update_cohorts(): void { global $DB; $this->resetAfterTest(true); @@ -414,7 +414,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Verify handling of 'id' param. */ - public function test_update_cohorts_invalid_id_param() { + public function test_update_cohorts_invalid_id_param(): void { $this->resetAfterTest(true); $cohort = self::getDataGenerator()->create_cohort(); @@ -444,7 +444,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test update_cohorts without permission on the dest category. */ - public function test_update_cohorts_missing_dest() { + public function test_update_cohorts_missing_dest(): void { global $USER, $CFG, $DB; $this->resetAfterTest(true); @@ -485,7 +485,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test update_cohorts without permission on the src category. */ - public function test_update_cohorts_missing_src() { + public function test_update_cohorts_missing_src(): void { global $USER, $CFG, $DB; $this->resetAfterTest(true); @@ -526,7 +526,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test add_cohort_members */ - public function test_add_cohort_members() { + public function test_add_cohort_members(): void { global $DB; $this->resetAfterTest(true); // Reset all changes automatically after this test. @@ -577,7 +577,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test delete_cohort_members */ - public function test_delete_cohort_members() { + public function test_delete_cohort_members(): void { global $DB; $this->resetAfterTest(true); // Reset all changes automatically after this test. @@ -634,7 +634,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Search cohorts. */ - public function test_search_cohorts() { + public function test_search_cohorts(): void { global $DB, $CFG; $this->resetAfterTest(true); diff --git a/cohort/tests/lib_test.php b/cohort/tests/lib_test.php index 639a48be4bd..a535c85df7f 100644 --- a/cohort/tests/lib_test.php +++ b/cohort/tests/lib_test.php @@ -55,7 +55,7 @@ class lib_test extends \advanced_testcase { ]); } - public function test_cohort_add_cohort() { + public function test_cohort_add_cohort(): void { global $DB; $this->resetAfterTest(); @@ -89,7 +89,7 @@ class lib_test extends \advanced_testcase { $this->assertEquals('Test value 1', $customfieldsdata->testfield1); } - public function test_cohort_add_cohort_missing_name() { + public function test_cohort_add_cohort_missing_name(): void { $cohort = new \stdClass(); $cohort->contextid = \context_system::instance()->id; $cohort->name = null; @@ -102,7 +102,7 @@ class lib_test extends \advanced_testcase { cohort_add_cohort($cohort); } - public function test_cohort_add_cohort_event() { + public function test_cohort_add_cohort_event(): void { $this->resetAfterTest(); // Setup cohort data structure. @@ -136,7 +136,7 @@ class lib_test extends \advanced_testcase { $this->assertEventContextNotUsed($event); } - public function test_cohort_update_cohort() { + public function test_cohort_update_cohort(): void { global $DB; $this->resetAfterTest(); @@ -180,7 +180,7 @@ class lib_test extends \advanced_testcase { $this->assertEquals('Test value updated', $customfieldsdata->testfield1); } - public function test_cohort_update_cohort_event() { + public function test_cohort_update_cohort_event(): void { global $DB; $this->resetAfterTest(); @@ -223,7 +223,7 @@ class lib_test extends \advanced_testcase { $this->assertEventContextNotUsed($event); } - public function test_cohort_delete_cohort() { + public function test_cohort_delete_cohort(): void { global $DB; $this->resetAfterTest(); @@ -240,7 +240,7 @@ class lib_test extends \advanced_testcase { $this->assertFalse($DB->record_exists('customfield_data', ['instanceid' => $cohort->id, 'fieldid' => $field->get('id')])); } - public function test_cohort_delete_cohort_event() { + public function test_cohort_delete_cohort_event(): void { $this->resetAfterTest(); @@ -267,7 +267,7 @@ class lib_test extends \advanced_testcase { $this->assertEventContextNotUsed($event); } - public function test_cohort_delete_category() { + public function test_cohort_delete_category(): void { global $DB; $this->resetAfterTest(); @@ -283,7 +283,7 @@ class lib_test extends \advanced_testcase { $this->assertEquals(\context_system::instance()->id, $newcohort->contextid); } - public function test_cohort_add_member() { + public function test_cohort_add_member(): void { global $DB; $this->resetAfterTest(); @@ -296,7 +296,7 @@ class lib_test extends \advanced_testcase { $this->assertTrue($DB->record_exists('cohort_members', array('cohortid'=>$cohort->id, 'userid'=>$user->id))); } - public function test_cohort_add_member_event() { + public function test_cohort_add_member_event(): void { global $USER; $this->resetAfterTest(); @@ -326,7 +326,7 @@ class lib_test extends \advanced_testcase { $this->assertEventContextNotUsed($event); } - public function test_cohort_remove_member() { + public function test_cohort_remove_member(): void { global $DB; $this->resetAfterTest(); @@ -341,7 +341,7 @@ class lib_test extends \advanced_testcase { $this->assertFalse($DB->record_exists('cohort_members', array('cohortid'=>$cohort->id, 'userid'=>$user->id))); } - public function test_cohort_remove_member_event() { + public function test_cohort_remove_member_event(): void { global $USER; $this->resetAfterTest(); @@ -371,7 +371,7 @@ class lib_test extends \advanced_testcase { $this->assertEventContextNotUsed($event); } - public function test_cohort_is_member() { + public function test_cohort_is_member(): void { global $DB; $this->resetAfterTest(); @@ -384,7 +384,7 @@ class lib_test extends \advanced_testcase { $this->assertTrue(cohort_is_member($cohort->id, $user->id)); } - public function test_cohort_get_cohorts() { + public function test_cohort_get_cohorts(): void { global $DB; $this->resetAfterTest(); @@ -443,7 +443,7 @@ class lib_test extends \advanced_testcase { $this->assertEquals(1, $result['allcohorts']); } - public function test_cohort_get_all_cohorts() { + public function test_cohort_get_all_cohorts(): void { global $DB; $this->resetAfterTest(); @@ -507,7 +507,7 @@ class lib_test extends \advanced_testcase { $this->assertEquals(2, $result['allcohorts']); } - public function test_cohort_get_available_cohorts() { + public function test_cohort_get_available_cohorts(): void { global $DB; $this->resetAfterTest(); @@ -696,7 +696,7 @@ class lib_test extends \advanced_testcase { * @covers \cohort_get_cohort, \cohort_get_cohorts, \cohort_get_all_cohorts * @covers \cohort_get_available_cohorts, \cohort_get_user_cohorts */ - public function test_get_functions_return_custom_fields() { + public function test_get_functions_return_custom_fields(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -829,7 +829,7 @@ class lib_test extends \advanced_testcase { /** * Create a cohort with allowcohortthemes enabled/disabled. */ - public function test_cohort_add_theme_cohort() { + public function test_cohort_add_theme_cohort(): void { global $DB; $this->resetAfterTest(); @@ -871,7 +871,7 @@ class lib_test extends \advanced_testcase { /** * Update a cohort with allowcohortthemes enabled/disabled. */ - public function test_cohort_update_theme_cohort() { + public function test_cohort_update_theme_cohort(): void { global $DB; $this->resetAfterTest(); @@ -914,7 +914,7 @@ class lib_test extends \advanced_testcase { * * @covers \cohort_get_custom_fields_data */ - public function test_cohort_get_custom_fields_data() { + public function test_cohort_get_custom_fields_data(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -945,7 +945,7 @@ class lib_test extends \advanced_testcase { * * @covers ::cohort_get_cohort */ - public function test_cohort_get_cohort() { + public function test_cohort_get_cohort(): void { $this->resetAfterTest(); $cat = $this->getDataGenerator()->create_category(); diff --git a/cohort/tests/privacy/provider_test.php b/cohort/tests/privacy/provider_test.php index 7f1fc5a8b0f..85099a7c599 100644 --- a/cohort/tests/privacy/provider_test.php +++ b/cohort/tests/privacy/provider_test.php @@ -50,7 +50,7 @@ class provider_test extends provider_testcase { /** * Test getting the context for the user ID related to this plugin. */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { // Create system cohort and category cohort. $coursecategory = $this->getDataGenerator()->create_category(); $coursecategoryctx = \context_coursecat::instance($coursecategory->id); @@ -79,7 +79,7 @@ class provider_test extends provider_testcase { /** * Test that data is exported correctly for this plugin. */ - public function test_export_user_data() { + public function test_export_user_data(): void { // Create system cohort and category cohort. $coursecategory = $this->getDataGenerator()->create_category(); $coursecategoryctx = \context_coursecat::instance($coursecategory->id); @@ -122,7 +122,7 @@ class provider_test extends provider_testcase { /** * Test for provider::delete_data_for_all_users_in_context(). */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; // Create system cohort and category cohort. @@ -167,7 +167,7 @@ class provider_test extends provider_testcase { /** * Test for provider::delete_data_for_user(). */ - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; // Create system cohort and category cohort. @@ -224,7 +224,7 @@ class provider_test extends provider_testcase { /** * Test that only users within a course context are fetched. */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { $component = 'core_cohort'; // Create system cohort and category cohort. @@ -280,7 +280,7 @@ class provider_test extends provider_testcase { /** * Test that data for users in approved userlist is deleted. */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { $component = 'core_cohort'; // Create system cohort and category cohort. diff --git a/comment/tests/context_freeze_test.php b/comment/tests/context_freeze_test.php index 29bbd81fa0c..75dac331343 100644 --- a/comment/tests/context_freeze_test.php +++ b/comment/tests/context_freeze_test.php @@ -72,7 +72,7 @@ class context_freeze_test extends \advanced_testcase { /** * Test that a student cannot delete their own comments in frozen contexts via the external service. */ - public function test_delete_student_external() { + public function test_delete_student_external(): void { global $CFG; require_once($CFG->dirroot . '/comment/lib.php'); @@ -95,7 +95,7 @@ class context_freeze_test extends \advanced_testcase { /** * Test that a student cannot delete their own comments in frozen contexts. */ - public function test_delete_student() { + public function test_delete_student(): void { global $CFG; require_once($CFG->dirroot . '/comment/lib.php'); @@ -118,7 +118,7 @@ class context_freeze_test extends \advanced_testcase { /** * Test that an admin cannot delete comments in frozen contexts via the external service. */ - public function test_delete_admin_external() { + public function test_delete_admin_external(): void { global $CFG; require_once($CFG->dirroot . '/comment/lib.php'); @@ -140,7 +140,7 @@ class context_freeze_test extends \advanced_testcase { /** * Test that an admin cannot delete comments in frozen contexts. */ - public function test_delete_admin() { + public function test_delete_admin(): void { global $CFG; require_once($CFG->dirroot . '/comment/lib.php'); diff --git a/comment/tests/externallib_test.php b/comment/tests/externallib_test.php index 4ac3746dc2f..dd9abf52d51 100644 --- a/comment/tests/externallib_test.php +++ b/comment/tests/externallib_test.php @@ -97,7 +97,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_comments */ - public function test_get_comments() { + public function test_get_comments(): void { global $CFG; [$module1, $recordid, $teacher1, $student1, $student2] = $this->setup_course_and_users_basic(); @@ -172,7 +172,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test add_comments not enabled site level */ - public function test_add_comments_not_enabled_site_level() { + public function test_add_comments_not_enabled_site_level(): void { global $CFG; [$module1, $recordid, $teacher1, $student1, $student2] = $this->setup_course_and_users_basic(); @@ -196,7 +196,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test add_comments not enabled module level */ - public function test_add_comments_not_enabled_module_level() { + public function test_add_comments_not_enabled_module_level(): void { global $DB; [$module1, $recordid, $teacher1, $student1, $student2] = $this->setup_course_and_users_basic(); @@ -221,7 +221,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test add_comments */ - public function test_add_comments_single() { + public function test_add_comments_single(): void { [$module1, $recordid, $teacher1, $student1, $student2] = $this->setup_course_and_users_basic(); // Add a comment as student 1. @@ -264,7 +264,7 @@ class externallib_test extends externallib_advanced_testcase { * * This simply verifies that the entire operation fails. */ - public function test_add_comments_multiple_contains_invalid() { + public function test_add_comments_multiple_contains_invalid(): void { [$module1, $recordid, $teacher1, $student1, $student2] = $this->setup_course_and_users_basic(); // Try to create some comments as student 1, but provide a bad area for the second comment. @@ -295,7 +295,7 @@ class externallib_test extends externallib_advanced_testcase { * * This simply verifies that the entire operation fails. */ - public function test_add_comments_multiple_all_valid() { + public function test_add_comments_multiple_all_valid(): void { [$module1, $recordid, $teacher1, $student1, $student2] = $this->setup_course_and_users_basic(); // Try to create some comments as student 1. @@ -335,7 +335,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test add_comments invalid area */ - public function test_add_comments_invalid_area() { + public function test_add_comments_invalid_area(): void { [$module1, $recordid, $teacher1, $student1, $student2] = $this->setup_course_and_users_basic(); // Try to create a comment with an invalid area, verifying failure. @@ -357,7 +357,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test delete_comment invalid comment. */ - public function test_delete_comments_invalid_comment_id() { + public function test_delete_comments_invalid_comment_id(): void { [$module1, $recordid, $teacher1, $student1, $student2] = $this->setup_course_and_users_basic(); $this->setUser($student1); @@ -368,7 +368,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test delete_comment own user. */ - public function test_delete_comments_own_user() { + public function test_delete_comments_own_user(): void { [$module1, $recordid, $teacher1, $student1, $student2] = $this->setup_course_and_users_basic(); // Create a few comments as student 1. @@ -405,7 +405,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test delete_comment other student. */ - public function test_delete_comment_other_student() { + public function test_delete_comment_other_student(): void { [$module1, $recordid, $teacher1, $student1, $student2] = $this->setup_course_and_users_basic(); // Create a comment as the student. @@ -431,7 +431,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test delete_comment as teacher. */ - public function test_delete_comments_as_teacher() { + public function test_delete_comments_as_teacher(): void { [$module1, $recordid, $teacher1, $student1, $student2] = $this->setup_course_and_users_basic(); // Create a comment as the student. diff --git a/comment/tests/privacy/provider_test.php b/comment/tests/privacy/provider_test.php index 4e49cf29a56..088ac4894d0 100644 --- a/comment/tests/privacy/provider_test.php +++ b/comment/tests/privacy/provider_test.php @@ -48,7 +48,7 @@ class provider_test extends provider_testcase { /** * Check the exporting of comments for a user id in a context. */ - public function test_export_comments() { + public function test_export_comments(): void { $course = $this->getDataGenerator()->create_course(); $context = \context_course::instance($course->id); @@ -98,7 +98,7 @@ class provider_test extends provider_testcase { /** * Tests the deletion of all comments in a context. */ - public function test_delete_comments_for_all_users() { + public function test_delete_comments_for_all_users(): void { global $DB; $course1 = $this->getDataGenerator()->create_course(); @@ -166,7 +166,7 @@ class provider_test extends provider_testcase { /** * Tests the deletion of all comments in a context. */ - public function test_delete_comments_for_all_users_select() { + public function test_delete_comments_for_all_users_select(): void { global $DB; $course1 = $this->getDataGenerator()->create_course(); @@ -236,7 +236,7 @@ class provider_test extends provider_testcase { /** * Tests deletion of comments for a specified user and contexts. */ - public function test_delete_comments_for_user() { + public function test_delete_comments_for_user(): void { global $DB; $course1 = $this->getDataGenerator()->create_course(); @@ -319,7 +319,7 @@ class provider_test extends provider_testcase { /** * Tests deletion of comments for a specified userlist and context. */ - public function test_delete_comments_for_users() { + public function test_delete_comments_for_users(): void { global $DB; $course1 = $this->getDataGenerator()->create_course(); diff --git a/competency/tests/api_test.php b/competency/tests/api_test.php index ab1eaebd6f9..abab660795a 100644 --- a/competency/tests/api_test.php +++ b/competency/tests/api_test.php @@ -25,7 +25,7 @@ namespace core_competency; */ class api_test extends \advanced_testcase { - public function test_get_framework_related_contexts() { + public function test_get_framework_related_contexts(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $cat1 = $dg->create_category(); @@ -48,7 +48,7 @@ class api_test extends \advanced_testcase { $this->assertEquals($expected, api::get_related_contexts($cat2ctx, 'parents')); } - public function test_get_framework_related_contexts_with_capabilities() { + public function test_get_framework_related_contexts_with_capabilities(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $user = $dg->create_user(); @@ -86,7 +86,7 @@ class api_test extends \advanced_testcase { $this->assertEquals($expected, api::get_related_contexts($cat2ctx, 'parents', $requiredcap)); } - public function test_get_template_related_contexts() { + public function test_get_template_related_contexts(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $cat1 = $dg->create_category(); @@ -109,7 +109,7 @@ class api_test extends \advanced_testcase { $this->assertEquals($expected, api::get_related_contexts($cat2ctx, 'parents')); } - public function test_get_template_related_contexts_with_capabilities() { + public function test_get_template_related_contexts_with_capabilities(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $user = $dg->create_user(); @@ -150,7 +150,7 @@ class api_test extends \advanced_testcase { /** * Test updating a template. */ - public function test_update_template() { + public function test_update_template(): void { $cat = $this->getDataGenerator()->create_category(); $this->resetAfterTest(true); $this->setAdminUser(); @@ -174,7 +174,7 @@ class api_test extends \advanced_testcase { /** * Test listing framework with order param. */ - public function test_list_frameworks() { + public function test_list_frameworks(): void { $this->resetAfterTest(true); $this->setAdminUser(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -263,7 +263,7 @@ class api_test extends \advanced_testcase { /** * Test duplicate a framework. */ - public function test_duplicate_framework() { + public function test_duplicate_framework(): void { $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); $this->resetAfterTest(true); $this->setAdminUser(); @@ -372,7 +372,7 @@ class api_test extends \advanced_testcase { /** * Test update plan. */ - public function test_update_plan() { + public function test_update_plan(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $usermanageowndraft = $dg->create_user(); @@ -494,7 +494,7 @@ class api_test extends \advanced_testcase { } } - public function test_create_plan_from_template() { + public function test_create_plan_from_template(): void { $this->resetAfterTest(true); $this->setAdminUser(); @@ -520,7 +520,7 @@ class api_test extends \advanced_testcase { $plan = api::create_plan($record); } - public function test_update_plan_based_on_template() { + public function test_update_plan_based_on_template(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $dg->get_plugin_generator('core_competency'); @@ -564,7 +564,7 @@ class api_test extends \advanced_testcase { } } - public function test_unlink_plan_from_template() { + public function test_unlink_plan_from_template(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $dg->get_plugin_generator('core_competency'); @@ -645,7 +645,7 @@ class api_test extends \advanced_testcase { $this->assertEquals($before->get('sortorder'), $after->get('sortorder')); } - public function test_update_template_updates_plans() { + public function test_update_template_updates_plans(): void { $this->resetAfterTest(true); $this->setAdminUser(); @@ -738,7 +738,7 @@ class api_test extends \advanced_testcase { /** * Test that the method to complete a plan. */ - public function test_complete_plan() { + public function test_complete_plan(): void { global $DB; $this->resetAfterTest(true); @@ -865,7 +865,7 @@ class api_test extends \advanced_testcase { /** * Testing requesting the review of a plan. */ - public function test_plan_request_review() { + public function test_plan_request_review(): void { $data = $this->setup_workflow_data(); $dg = $data['dg']; $lpg = $data['lpg']; @@ -963,7 +963,7 @@ class api_test extends \advanced_testcase { /** * Testing cancelling the review request. */ - public function test_plan_cancel_review_request() { + public function test_plan_cancel_review_request(): void { $data = $this->setup_workflow_data(); $dg = $data['dg']; $lpg = $data['lpg']; @@ -1064,7 +1064,7 @@ class api_test extends \advanced_testcase { /** * Testing starting the review. */ - public function test_plan_start_review() { + public function test_plan_start_review(): void { $data = $this->setup_workflow_data(); $dg = $data['dg']; $lpg = $data['lpg']; @@ -1168,7 +1168,7 @@ class api_test extends \advanced_testcase { /** * Testing stopping the review. */ - public function test_plan_stop_review() { + public function test_plan_stop_review(): void { $data = $this->setup_workflow_data(); $dg = $data['dg']; $lpg = $data['lpg']; @@ -1269,7 +1269,7 @@ class api_test extends \advanced_testcase { /** * Testing approving the plan. */ - public function test_approve_plan() { + public function test_approve_plan(): void { $data = $this->setup_workflow_data(); $dg = $data['dg']; $lpg = $data['lpg']; @@ -1364,7 +1364,7 @@ class api_test extends \advanced_testcase { /** * Testing stopping the review. */ - public function test_unapprove_plan() { + public function test_unapprove_plan(): void { $data = $this->setup_workflow_data(); $dg = $data['dg']; $lpg = $data['lpg']; @@ -1465,7 +1465,7 @@ class api_test extends \advanced_testcase { /** * Test update plan and the managing of archived user competencies. */ - public function test_update_plan_manage_archived_competencies() { + public function test_update_plan_manage_archived_competencies(): void { global $DB; $this->resetAfterTest(true); @@ -1573,7 +1573,7 @@ class api_test extends \advanced_testcase { /** * Test completing plan does not change the order of competencies. */ - public function test_complete_plan_doesnot_change_order() { + public function test_complete_plan_doesnot_change_order(): void { global $DB; $this->resetAfterTest(true); @@ -1663,7 +1663,7 @@ class api_test extends \advanced_testcase { /** * Test remove plan and the managing of archived user competencies. */ - public function test_delete_plan_manage_archived_competencies() { + public function test_delete_plan_manage_archived_competencies(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -1712,7 +1712,7 @@ class api_test extends \advanced_testcase { /** * Test listing of plan competencies. */ - public function test_list_plan_competencies_manage_archived_competencies() { + public function test_list_plan_competencies_manage_archived_competencies(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -1791,7 +1791,7 @@ class api_test extends \advanced_testcase { $this->assertNull($plancompetencies[2]->usercompetency); } - public function test_create_template_cohort() { + public function test_create_template_cohort(): void { $this->resetAfterTest(true); $this->setAdminUser(); @@ -1819,7 +1819,7 @@ class api_test extends \advanced_testcase { array('id' => $t2->get('id')))); } - public function test_create_template_cohort_permissions() { + public function test_create_template_cohort_permissions(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); @@ -1863,7 +1863,7 @@ class api_test extends \advanced_testcase { $this->assertInstanceOf('core_competency\\template_cohort', $result); } - public function test_reorder_template_competencies_permissions() { + public function test_reorder_template_competencies_permissions(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); @@ -1928,7 +1928,7 @@ class api_test extends \advanced_testcase { } } - public function test_delete_template() { + public function test_delete_template(): void { $this->resetAfterTest(true); $this->setAdminUser(); @@ -1958,7 +1958,7 @@ class api_test extends \advanced_testcase { $this->assertEquals(0, \core_competency\template_cohort::count_records(array('templateid' => $id))); } - public function test_delete_template_cohort() { + public function test_delete_template_cohort(): void { $this->resetAfterTest(true); $this->setAdminUser(); @@ -1997,7 +1997,7 @@ class api_test extends \advanced_testcase { array('id' => $t2->get('id')))); } - public function test_add_evidence_log() { + public function test_add_evidence_log(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $dg->get_plugin_generator('core_competency'); @@ -2062,7 +2062,7 @@ class api_test extends \advanced_testcase { } } - public function test_add_evidence_complete() { + public function test_add_evidence_complete(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $dg->get_plugin_generator('core_competency'); @@ -2158,7 +2158,7 @@ class api_test extends \advanced_testcase { } } - public function test_add_evidence_override() { + public function test_add_evidence_override(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $dg->get_plugin_generator('core_competency'); @@ -2233,7 +2233,7 @@ class api_test extends \advanced_testcase { $this->assertSame(null, $evidence->get('grade')); } - public function test_add_evidence_and_send_for_review() { + public function test_add_evidence_and_send_for_review(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $dg->get_plugin_generator('core_competency'); @@ -2267,7 +2267,7 @@ class api_test extends \advanced_testcase { /** * Test add evidence for existing user_competency. */ - public function test_add_evidence_existing_user_competency() { + public function test_add_evidence_existing_user_competency(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -2309,7 +2309,7 @@ class api_test extends \advanced_testcase { /** * Test add evidence for non-existing user_competency. */ - public function test_add_evidence_no_existing_user_competency() { + public function test_add_evidence_no_existing_user_competency(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -2346,7 +2346,7 @@ class api_test extends \advanced_testcase { $this->assertEquals(0, $uc->get('proficiency')); } - public function test_add_evidence_applies_competency_rules() { + public function test_add_evidence_applies_competency_rules(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $dg->get_plugin_generator('core_competency'); @@ -2446,7 +2446,7 @@ class api_test extends \advanced_testcase { * Tests for the user_competency_course data when api::add_evidence() is invoked when * grading a user competency in the system context. */ - public function test_add_evidence_for_user_competency_course_grade_outside_course() { + public function test_add_evidence_for_user_competency_course_grade_outside_course(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $syscontext = \context_system::instance(); @@ -2477,7 +2477,7 @@ class api_test extends \advanced_testcase { * Tests for the user_competency_course data when api::add_evidence() is invoked when * grading a user competency in a course. */ - public function test_add_evidence_user_competency_course_grade_in_course() { + public function test_add_evidence_user_competency_course_grade_in_course(): void { global $USER; $this->resetAfterTest(true); @@ -2539,7 +2539,7 @@ class api_test extends \advanced_testcase { $this->assertNotEquals($usercompcourse->get('proficiency'), $usercompetency->get('proficiency')); } - public function test_observe_course_completed() { + public function test_observe_course_completed(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $dg->get_plugin_generator('core_competency'); @@ -2634,7 +2634,7 @@ class api_test extends \advanced_testcase { $this->assertEquals(null, $ev4->get('actionuserid')); } - public function test_list_evidence_in_course() { + public function test_list_evidence_in_course(): void { global $SITE; $this->resetAfterTest(true); @@ -2675,7 +2675,7 @@ class api_test extends \advanced_testcase { $this->assertEquals($evidence2->get('id'), $result[1]->get('id')); } - public function test_list_course_modules_using_competency() { + public function test_list_course_modules_using_competency(): void { global $SITE; $this->resetAfterTest(true); @@ -2754,7 +2754,7 @@ class api_test extends \advanced_testcase { /** * Test update ruleoutcome for course_competency. */ - public function test_set_ruleoutcome_course_competency() { + public function test_set_ruleoutcome_course_competency(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $dg->get_plugin_generator('core_competency'); @@ -2784,7 +2784,7 @@ class api_test extends \advanced_testcase { /** * Test validation on grade on user_competency. */ - public function test_validate_grade_in_user_competency() { + public function test_validate_grade_in_user_competency(): void { global $DB; $this->resetAfterTest(true); @@ -2859,7 +2859,7 @@ class api_test extends \advanced_testcase { /** * Test when adding competency that belong to hidden framework to plan/template/course. */ - public function test_hidden_framework() { + public function test_hidden_framework(): void { $this->resetAfterTest(true); $this->setAdminUser(); $dg = $this->getDataGenerator(); @@ -2909,7 +2909,7 @@ class api_test extends \advanced_testcase { /** * Test when using hidden template in plan/cohort. */ - public function test_hidden_template() { + public function test_hidden_template(): void { $this->resetAfterTest(true); $this->setAdminUser(); $dg = $this->getDataGenerator(); @@ -2937,7 +2937,7 @@ class api_test extends \advanced_testcase { /** * Test that completed plan created form a template does not change when template is modified. */ - public function test_completed_plan_doesnot_change() { + public function test_completed_plan_doesnot_change(): void { global $DB; $this->resetAfterTest(true); @@ -3032,7 +3032,7 @@ class api_test extends \advanced_testcase { ); } - public function test_moving_competency_reset_rules_updown() { + public function test_moving_competency_reset_rules_updown(): void { $data = $this->setup_framework_for_reset_rules_tests(); $f1 = $data['f1']; $c1 = $data['c1']; @@ -3062,7 +3062,7 @@ class api_test extends \advanced_testcase { $this->assertEquals(competency::OUTCOME_EVIDENCE, $c1a1->get('ruleoutcome')); } - public function test_moving_competency_reset_rules_parent() { + public function test_moving_competency_reset_rules_parent(): void { $data = $this->setup_framework_for_reset_rules_tests(); $f1 = $data['f1']; $c1 = $data['c1']; @@ -3089,7 +3089,7 @@ class api_test extends \advanced_testcase { $this->assertEquals(competency::OUTCOME_EVIDENCE, $c2->get('ruleoutcome')); } - public function test_moving_competency_reset_rules_totoplevel() { + public function test_moving_competency_reset_rules_totoplevel(): void { $data = $this->setup_framework_for_reset_rules_tests(); $f1 = $data['f1']; $c1 = $data['c1']; @@ -3116,7 +3116,7 @@ class api_test extends \advanced_testcase { $this->assertEquals(competency::OUTCOME_EVIDENCE, $c2->get('ruleoutcome')); } - public function test_moving_competency_reset_rules_fromtoplevel() { + public function test_moving_competency_reset_rules_fromtoplevel(): void { $data = $this->setup_framework_for_reset_rules_tests(); $f1 = $data['f1']; $c1 = $data['c1']; @@ -3143,7 +3143,7 @@ class api_test extends \advanced_testcase { $this->assertEquals(competency::OUTCOME_EVIDENCE, $c2->get('ruleoutcome')); } - public function test_moving_competency_reset_rules_child() { + public function test_moving_competency_reset_rules_child(): void { $data = $this->setup_framework_for_reset_rules_tests(); $f1 = $data['f1']; $c1 = $data['c1']; @@ -3170,7 +3170,7 @@ class api_test extends \advanced_testcase { $this->assertEquals(competency::OUTCOME_EVIDENCE, $c2->get('ruleoutcome')); } - public function test_create_competency_reset_rules() { + public function test_create_competency_reset_rules(): void { $data = $this->setup_framework_for_reset_rules_tests(); $f1 = $data['f1']; $c1 = $data['c1']; @@ -3198,7 +3198,7 @@ class api_test extends \advanced_testcase { $this->assertEquals(competency::OUTCOME_EVIDENCE, $c2->get('ruleoutcome')); } - public function test_delete_competency_reset_rules() { + public function test_delete_competency_reset_rules(): void { $data = $this->setup_framework_for_reset_rules_tests(); $f1 = $data['f1']; $c1 = $data['c1']; @@ -3221,7 +3221,7 @@ class api_test extends \advanced_testcase { $this->assertEquals(competency::OUTCOME_EVIDENCE, $c2->get('ruleoutcome')); } - public function test_template_has_related_data() { + public function test_template_has_related_data(): void { $this->resetAfterTest(true); $this->setAdminUser(); @@ -3241,7 +3241,7 @@ class api_test extends \advanced_testcase { } - public function test_delete_template_delete_plans() { + public function test_delete_template_delete_plans(): void { $this->resetAfterTest(true); $this->setAdminUser(); @@ -3280,7 +3280,7 @@ class api_test extends \advanced_testcase { $this->assertEquals(0, count(\core_competency\plan::get_records(array('templateid' => $tpl->get('id'))))); } - public function test_delete_template_unlink_plans() { + public function test_delete_template_unlink_plans(): void { $this->resetAfterTest(true); $this->setAdminUser(); @@ -3322,7 +3322,7 @@ class api_test extends \advanced_testcase { $this->assertNull($plans[0]->get('templateid')); } - public function test_delete_competency() { + public function test_delete_competency(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $dg->get_plugin_generator('core_competency'); @@ -3382,7 +3382,7 @@ class api_test extends \advanced_testcase { $this->assertFalse(competency::record_exists($c2->get('id'))); } - public function test_delete_competency_used_in_plan() { + public function test_delete_competency_used_in_plan(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $dg->get_plugin_generator('core_competency'); @@ -3415,7 +3415,7 @@ class api_test extends \advanced_testcase { $this->assertFalse(competency::record_exists($c12b->get('id'))); } - public function test_delete_competency_used_in_usercompetency() { + public function test_delete_competency_used_in_usercompetency(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $dg->get_plugin_generator('core_competency'); @@ -3447,7 +3447,7 @@ class api_test extends \advanced_testcase { $this->assertFalse(competency::record_exists($c12b->get('id'))); } - public function test_delete_competency_used_in_usercompetencyplan() { + public function test_delete_competency_used_in_usercompetencyplan(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $dg->get_plugin_generator('core_competency'); @@ -3485,7 +3485,7 @@ class api_test extends \advanced_testcase { $this->assertFalse(competency::record_exists($c12b->get('id'))); } - public function test_delete_competency_used_in_template() { + public function test_delete_competency_used_in_template(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $dg->get_plugin_generator('core_competency'); @@ -3519,7 +3519,7 @@ class api_test extends \advanced_testcase { $this->assertFalse(competency::record_exists($c12b->get('id'))); } - public function test_delete_competency_used_in_course() { + public function test_delete_competency_used_in_course(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $dg->get_plugin_generator('core_competency'); @@ -3556,7 +3556,7 @@ class api_test extends \advanced_testcase { $this->assertFalse(competency::record_exists($c12b->get('id'))); } - public function test_delete_framework() { + public function test_delete_framework(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $dg->get_plugin_generator('core_competency'); @@ -3610,7 +3610,7 @@ class api_test extends \advanced_testcase { $this->assertFalse(competency_framework::record_exists($f2->get('id'))); } - public function test_delete_framework_competency_used_in_plan() { + public function test_delete_framework_competency_used_in_plan(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $dg->get_plugin_generator('core_competency'); @@ -3668,7 +3668,7 @@ class api_test extends \advanced_testcase { $this->assertEquals(0, count(\core_competency\related_competency::get_multiple_relations(array($c2id)))); } - public function test_delete_framework_competency_used_in_usercompetency() { + public function test_delete_framework_competency_used_in_usercompetency(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $dg->get_plugin_generator('core_competency'); @@ -3725,7 +3725,7 @@ class api_test extends \advanced_testcase { $this->assertEquals(0, count(\core_competency\related_competency::get_multiple_relations(array($c2id)))); } - public function test_delete_framework_competency_used_in_usercompetencyplan() { + public function test_delete_framework_competency_used_in_usercompetencyplan(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $dg->get_plugin_generator('core_competency'); @@ -3788,7 +3788,7 @@ class api_test extends \advanced_testcase { $this->assertEquals(0, count(\core_competency\related_competency::get_multiple_relations(array($c2id)))); } - public function test_delete_framework_competency_used_in_template() { + public function test_delete_framework_competency_used_in_template(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $dg->get_plugin_generator('core_competency'); @@ -3848,7 +3848,7 @@ class api_test extends \advanced_testcase { $this->assertEquals(0, count(\core_competency\related_competency::get_multiple_relations(array($c2id)))); } - public function test_delete_framework_competency_used_in_course() { + public function test_delete_framework_competency_used_in_course(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $dg->get_plugin_generator('core_competency'); @@ -3910,7 +3910,7 @@ class api_test extends \advanced_testcase { $this->assertEquals(0, count(\core_competency\related_competency::get_multiple_relations(array($c2id)))); } - public function test_grade_competency_in_course_permissions() { + public function test_grade_competency_in_course_permissions(): void { $this->resetAfterTest(); $dg = $this->getDataGenerator(); @@ -4061,7 +4061,7 @@ class api_test extends \advanced_testcase { /** * Test list of evidences for plan completed and not completed. */ - public function test_list_evidence() { + public function test_list_evidence(): void { global $DB; $this->resetAfterTest(true); @@ -4114,7 +4114,7 @@ class api_test extends \advanced_testcase { /** * Get a user competency in a course. */ - public function test_get_user_competency_in_course() { + public function test_get_user_competency_in_course(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $dg->get_plugin_generator('core_competency'); @@ -4157,7 +4157,7 @@ class api_test extends \advanced_testcase { /** * Test course statistics api functions. */ - public function test_course_statistics() { + public function test_course_statistics(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $dg->get_plugin_generator('core_competency'); @@ -4247,7 +4247,7 @@ class api_test extends \advanced_testcase { /** * Test template statistics api functions. */ - public function test_template_statistics() { + public function test_template_statistics(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $dg->get_plugin_generator('core_competency'); @@ -4386,7 +4386,7 @@ class api_test extends \advanced_testcase { } } - public function test_is_scale_used_anywhere() { + public function test_is_scale_used_anywhere(): void { $this->resetAfterTest(); $dg = $this->getDataGenerator(); $lpg = $dg->get_plugin_generator('core_competency'); @@ -4474,7 +4474,7 @@ class api_test extends \advanced_testcase { $this->assertTrue(api::is_scale_used_anywhere($scale4->id)); } - public function test_delete_evidence() { + public function test_delete_evidence(): void { $this->resetAfterTest(); $dg = $this->getDataGenerator(); $ccg = $dg->get_plugin_generator('core_competency'); @@ -4496,7 +4496,7 @@ class api_test extends \advanced_testcase { $this->assertTrue(evidence::record_exists($ev2->get('id'))); } - public function test_delete_evidence_without_permissions() { + public function test_delete_evidence_without_permissions(): void { $this->resetAfterTest(); $dg = $this->getDataGenerator(); $ccg = $dg->get_plugin_generator('core_competency'); @@ -4513,7 +4513,7 @@ class api_test extends \advanced_testcase { api::delete_evidence($ev1); } - public function test_list_plans_to_review() { + public function test_list_plans_to_review(): void { $dg = $this->getDataGenerator(); $this->resetAfterTest(); $ccg = $dg->get_plugin_generator('core_competency'); @@ -4558,7 +4558,7 @@ class api_test extends \advanced_testcase { $this->assertEquals($p1b->get('id'), $result['plans'][1]->plan->get('id')); } - public function test_list_user_competencies_to_review() { + public function test_list_user_competencies_to_review(): void { global $CFG; require_once($CFG->dirroot . '/user/lib.php'); @@ -4626,7 +4626,7 @@ class api_test extends \advanced_testcase { /** * Test we can get all of a users plans with a competency. */ - public function test_list_plans_with_competency() { + public function test_list_plans_with_competency(): void { $this->resetAfterTest(true); $this->setAdminUser(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); diff --git a/competency/tests/competency_rule_test.php b/competency/tests/competency_rule_test.php index 893fa724c45..6ed32522898 100644 --- a/competency/tests/competency_rule_test.php +++ b/competency/tests/competency_rule_test.php @@ -30,7 +30,7 @@ require_once($CFG->dirroot . '/webservice/tests/helpers.php'); */ class competency_rule_test extends \externallib_advanced_testcase { - public function test_rule_all_matching() { + public function test_rule_all_matching(): void { $this->resetAfterTest(true); $this->setAdminUser(); @@ -82,7 +82,7 @@ class competency_rule_test extends \externallib_advanced_testcase { $this->assertFalse($cr->matches($uc13)); } - public function test_rule_points_validation() { + public function test_rule_points_validation(): void { $this->resetAfterTest(true); $this->setAdminUser(); @@ -212,7 +212,7 @@ class competency_rule_test extends \externallib_advanced_testcase { $this->assertTrue($rule->validate_config($config)); } - public function test_rule_points_matching() { + public function test_rule_points_matching(): void { $this->resetAfterTest(true); $this->setAdminUser(); diff --git a/competency/tests/competency_test.php b/competency/tests/competency_test.php index eb1c3d523ae..d1ab714b65e 100644 --- a/competency/tests/competency_test.php +++ b/competency/tests/competency_test.php @@ -25,7 +25,7 @@ namespace core_competency; */ class competency_test extends \advanced_testcase { - public function test_get_framework_depth() { + public function test_get_framework_depth(): void { $this->resetAfterTest(); $ccg = $this->getDataGenerator()->get_plugin_generator('core_competency'); diff --git a/competency/tests/course_competency_settings_test.php b/competency/tests/course_competency_settings_test.php index b825af74325..d0350d5dce8 100644 --- a/competency/tests/course_competency_settings_test.php +++ b/competency/tests/course_competency_settings_test.php @@ -25,7 +25,7 @@ namespace core_competency; */ class course_competency_settings_test extends \advanced_testcase { - public function test_who_can_change_settings() { + public function test_who_can_change_settings(): void { global $CFG, $DB; $this->resetAfterTest(true); diff --git a/competency/tests/course_competency_test.php b/competency/tests/course_competency_test.php index ae1da6a99c8..bfbefd6538d 100644 --- a/competency/tests/course_competency_test.php +++ b/competency/tests/course_competency_test.php @@ -25,7 +25,7 @@ namespace core_competency; */ class course_competency_test extends \advanced_testcase { - public function test_get_courses_with_competency_and_user() { + public function test_get_courses_with_competency_and_user(): void { global $CFG, $DB; $this->resetAfterTest(true); diff --git a/competency/tests/course_module_competency_test.php b/competency/tests/course_module_competency_test.php index 1d7bd3b0ac2..e0ea5f03ad2 100644 --- a/competency/tests/course_module_competency_test.php +++ b/competency/tests/course_module_competency_test.php @@ -25,7 +25,7 @@ namespace core_competency; */ class course_module_competency_test extends \advanced_testcase { - public function test_count_competencies() { + public function test_count_competencies(): void { global $CFG, $DB; $this->resetAfterTest(true); diff --git a/competency/tests/event/events_test.php b/competency/tests/event/events_test.php index 3c916dfeb88..f75509cb84e 100644 --- a/competency/tests/event/events_test.php +++ b/competency/tests/event/events_test.php @@ -37,7 +37,7 @@ class events_test extends \advanced_testcase { * Test the competency framework created event. * */ - public function test_competency_framework_created() { + public function test_competency_framework_created(): void { $this->resetAfterTest(true); $this->setAdminUser(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -68,7 +68,7 @@ class events_test extends \advanced_testcase { * Test the competency framework deleted event. * */ - public function test_competency_framework_deleted() { + public function test_competency_framework_deleted(): void { $this->resetAfterTest(true); $this->setAdminUser(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -95,7 +95,7 @@ class events_test extends \advanced_testcase { * Test the competency framework updated event. * */ - public function test_competency_framework_updated() { + public function test_competency_framework_updated(): void { $this->resetAfterTest(true); $this->setAdminUser(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -123,7 +123,7 @@ class events_test extends \advanced_testcase { * Test the competency framework viewed event. * */ - public function test_competency_framework_viewed() { + public function test_competency_framework_viewed(): void { $this->resetAfterTest(true); $this->setAdminUser(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -150,7 +150,7 @@ class events_test extends \advanced_testcase { * Test the competency viewed event. * */ - public function test_competency_viewed() { + public function test_competency_viewed(): void { $this->resetAfterTest(true); $this->setAdminUser(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -175,7 +175,7 @@ class events_test extends \advanced_testcase { * Test the template viewed event. * */ - public function test_template_viewed() { + public function test_template_viewed(): void { $this->resetAfterTest(true); $this->setAdminUser(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -198,7 +198,7 @@ class events_test extends \advanced_testcase { * Test the template created event. * */ - public function test_template_created() { + public function test_template_created(): void { $this->resetAfterTest(true); $this->setAdminUser(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -227,7 +227,7 @@ class events_test extends \advanced_testcase { * Test the template deleted event. * */ - public function test_template_deleted() { + public function test_template_deleted(): void { $this->resetAfterTest(true); $this->setAdminUser(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -254,7 +254,7 @@ class events_test extends \advanced_testcase { * Test the template updated event. * */ - public function test_template_updated() { + public function test_template_updated(): void { $this->resetAfterTest(true); $this->setAdminUser(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -282,7 +282,7 @@ class events_test extends \advanced_testcase { * Test the competency updated event. * */ - public function test_competency_updated() { + public function test_competency_updated(): void { $this->resetAfterTest(true); $this->setAdminUser(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -315,7 +315,7 @@ class events_test extends \advanced_testcase { * Test the competency created event. * */ - public function test_competency_created() { + public function test_competency_created(): void { $this->resetAfterTest(true); $this->setAdminUser(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -346,7 +346,7 @@ class events_test extends \advanced_testcase { * Test the competency created event by duplicate framework. * */ - public function test_competency_created_by_duplicateframework() { + public function test_competency_created_by_duplicateframework(): void { $this->resetAfterTest(true); $this->setAdminUser(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -382,7 +382,7 @@ class events_test extends \advanced_testcase { * Test the competency deleted event. * */ - public function test_competency_deleted() { + public function test_competency_deleted(): void { $this->resetAfterTest(true); $this->setAdminUser(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -412,7 +412,7 @@ class events_test extends \advanced_testcase { * Test the competency deleted event by delete framework. * */ - public function test_competency_deleted_by_deleteframework() { + public function test_competency_deleted_by_deleteframework(): void { $this->resetAfterTest(true); $this->setAdminUser(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -448,7 +448,7 @@ class events_test extends \advanced_testcase { * Test the plan created event. * */ - public function test_plan_created() { + public function test_plan_created(): void { $this->resetAfterTest(true); $this->setAdminUser(); $dg = $this->getDataGenerator(); @@ -476,7 +476,7 @@ class events_test extends \advanced_testcase { * Test the plan created event using template_cohort. * */ - public function test_plan_created_using_templatecohort() { + public function test_plan_created_using_templatecohort(): void { $this->resetAfterTest(true); $this->setAdminUser(); $dg = $this->getDataGenerator(); @@ -519,7 +519,7 @@ class events_test extends \advanced_testcase { * Test the plan updated event. * */ - public function test_plan_updated() { + public function test_plan_updated(): void { $this->resetAfterTest(true); $this->setAdminUser(); $dg = $this->getDataGenerator(); @@ -547,7 +547,7 @@ class events_test extends \advanced_testcase { * Test the plan deleted event. * */ - public function test_plan_deleted() { + public function test_plan_deleted(): void { $this->resetAfterTest(true); $this->setAdminUser(); $dg = $this->getDataGenerator(); @@ -574,7 +574,7 @@ class events_test extends \advanced_testcase { * Test the plan viewed event. * */ - public function test_plan_viewed() { + public function test_plan_viewed(): void { $this->resetAfterTest(true); $this->setAdminUser(); $dg = $this->getDataGenerator(); @@ -599,7 +599,7 @@ class events_test extends \advanced_testcase { * Test the evidence of prior learning created event. * */ - public function test_user_evidence_created() { + public function test_user_evidence_created(): void { $this->resetAfterTest(true); $this->setAdminUser(); $dg = $this->getDataGenerator(); @@ -630,7 +630,7 @@ class events_test extends \advanced_testcase { * Test the evidence of prior learning deleted event. * */ - public function test_user_evidence_deleted() { + public function test_user_evidence_deleted(): void { $this->resetAfterTest(true); $this->setAdminUser(); $dg = $this->getDataGenerator(); @@ -659,7 +659,7 @@ class events_test extends \advanced_testcase { * Test the evidence of prior learning updated event. * */ - public function test_user_evidence_updated() { + public function test_user_evidence_updated(): void { $this->resetAfterTest(true); $this->setAdminUser(); $dg = $this->getDataGenerator(); @@ -689,7 +689,7 @@ class events_test extends \advanced_testcase { * Test the user competency viewed event in plan. * */ - public function test_user_competency_viewed_in_plan() { + public function test_user_competency_viewed_in_plan(): void { $this->resetAfterTest(true); $this->setAdminUser(); $dg = $this->getDataGenerator(); @@ -771,7 +771,7 @@ class events_test extends \advanced_testcase { * Test the user competency viewed event in course. * */ - public function test_user_competency_viewed_in_course() { + public function test_user_competency_viewed_in_course(): void { $this->resetAfterTest(true); $this->setAdminUser(); $dg = $this->getDataGenerator(); @@ -833,7 +833,7 @@ class events_test extends \advanced_testcase { * Test the user competency plan viewed event. * */ - public function test_user_competency_plan_viewed() { + public function test_user_competency_plan_viewed(): void { $this->resetAfterTest(true); $this->setAdminUser(); $dg = $this->getDataGenerator(); @@ -918,7 +918,7 @@ class events_test extends \advanced_testcase { * Test the user competency viewed event. * */ - public function test_user_competency_viewed() { + public function test_user_competency_viewed(): void { $this->resetAfterTest(true); $this->setAdminUser(); $dg = $this->getDataGenerator(); @@ -968,7 +968,7 @@ class events_test extends \advanced_testcase { * Test the plan approved event. * */ - public function test_plan_approved() { + public function test_plan_approved(): void { $this->resetAfterTest(true); $this->setAdminUser(); $dg = $this->getDataGenerator(); @@ -996,7 +996,7 @@ class events_test extends \advanced_testcase { * Test the plan unapproved event. * */ - public function test_plan_unapproved() { + public function test_plan_unapproved(): void { $this->resetAfterTest(true); $this->setAdminUser(); $dg = $this->getDataGenerator(); @@ -1024,7 +1024,7 @@ class events_test extends \advanced_testcase { * Test the plan reopened event. * */ - public function test_plan_reopened() { + public function test_plan_reopened(): void { $this->resetAfterTest(true); $this->setAdminUser(); $dg = $this->getDataGenerator(); @@ -1052,7 +1052,7 @@ class events_test extends \advanced_testcase { * Test the plan completed event. * */ - public function test_plan_completed() { + public function test_plan_completed(): void { $this->resetAfterTest(true); $this->setAdminUser(); $dg = $this->getDataGenerator(); @@ -1080,7 +1080,7 @@ class events_test extends \advanced_testcase { * Test the plan unlinked event. * */ - public function test_plan_unlinked() { + public function test_plan_unlinked(): void { $this->resetAfterTest(true); $this->setAdminUser(); $dg = $this->getDataGenerator(); @@ -1113,7 +1113,7 @@ class events_test extends \advanced_testcase { * Test the plan review requested event. * */ - public function test_plan_review_requested() { + public function test_plan_review_requested(): void { $this->resetAfterTest(true); $this->setAdminUser(); $dg = $this->getDataGenerator(); @@ -1141,7 +1141,7 @@ class events_test extends \advanced_testcase { * Test the plan review request cancelled event. * */ - public function test_plan_review_request_cancelled() { + public function test_plan_review_request_cancelled(): void { $this->resetAfterTest(true); $this->setAdminUser(); $dg = $this->getDataGenerator(); @@ -1169,7 +1169,7 @@ class events_test extends \advanced_testcase { * Test the plan review started event. * */ - public function test_plan_review_started() { + public function test_plan_review_started(): void { $this->resetAfterTest(true); $this->setAdminUser(); $dg = $this->getDataGenerator(); @@ -1197,7 +1197,7 @@ class events_test extends \advanced_testcase { * Test the plan review stopped event. * */ - public function test_plan_review_stopped() { + public function test_plan_review_stopped(): void { $this->resetAfterTest(true); $this->setAdminUser(); $dg = $this->getDataGenerator(); @@ -1224,7 +1224,7 @@ class events_test extends \advanced_testcase { /** * Test plan comment created event. */ - public function test_plan_comment_created() { + public function test_plan_comment_created(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -1261,7 +1261,7 @@ class events_test extends \advanced_testcase { /** * Test plan comment deleted event. */ - public function test_plan_comment_deleted() { + public function test_plan_comment_deleted(): void { $this->resetAfterTest(true); $this->setAdminUser(); $dg = $this->getDataGenerator(); @@ -1297,7 +1297,7 @@ class events_test extends \advanced_testcase { /** * Test evidence_created event. */ - public function test_evidence_created() { + public function test_evidence_created(): void { global $USER; $this->resetAfterTest(true); @@ -1356,7 +1356,7 @@ class events_test extends \advanced_testcase { /** * Test evidence_created event by linking an invalid user competency to an evidence. */ - public function test_evidence_created_with_invalid_user_competency() { + public function test_evidence_created_with_invalid_user_competency(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $syscontext = \context_system::instance(); @@ -1390,7 +1390,7 @@ class events_test extends \advanced_testcase { * * These data are validated by \core_competency\evidence_created::validate_data(). */ - public function test_evidence_created_with_missing_data() { + public function test_evidence_created_with_missing_data(): void { $eventdata = [ 'contextid' => 1, 'objectid' => 1, @@ -1455,7 +1455,7 @@ class events_test extends \advanced_testcase { * Test the user competency grade rated event. * */ - public function test_user_competency_rated() { + public function test_user_competency_rated(): void { $this->resetAfterTest(true); $this->setAdminUser(); $dg = $this->getDataGenerator(); @@ -1504,7 +1504,7 @@ class events_test extends \advanced_testcase { * Test the user competency grade rated in course event. * */ - public function test_user_competency_rated_in_course() { + public function test_user_competency_rated_in_course(): void { $this->resetAfterTest(true); $this->setAdminUser(); $dg = $this->getDataGenerator(); @@ -1561,7 +1561,7 @@ class events_test extends \advanced_testcase { * Test the user competency grade rated in plan event. * */ - public function test_user_competency_rated_in_plan() { + public function test_user_competency_rated_in_plan(): void { $this->resetAfterTest(true); $this->setAdminUser(); $dg = $this->getDataGenerator(); @@ -1611,7 +1611,7 @@ class events_test extends \advanced_testcase { /** * Test user competency comment created event. */ - public function test_user_competency_comment_created() { + public function test_user_competency_comment_created(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); @@ -1653,7 +1653,7 @@ class events_test extends \advanced_testcase { /** * Test plan comment deleted event. */ - public function test_user_competency_comment_deleted() { + public function test_user_competency_comment_deleted(): void { $this->resetAfterTest(true); $this->setAdminUser(); $dg = $this->getDataGenerator(); diff --git a/competency/tests/external/external_test.php b/competency/tests/external/external_test.php index 982ba040814..2cfc7119146 100644 --- a/competency/tests/external/external_test.php +++ b/competency/tests/external/external_test.php @@ -307,7 +307,7 @@ class external_test extends externallib_advanced_testcase { /** * Test we can't create a competency framework with only read permissions. */ - public function test_create_competency_frameworks_with_read_permissions() { + public function test_create_competency_frameworks_with_read_permissions(): void { $this->setUser($this->user); $this->expectException(\required_capability_exception::class); @@ -317,7 +317,7 @@ class external_test extends externallib_advanced_testcase { /** * Test we can't create a competency framework with only read permissions. */ - public function test_create_competency_frameworks_with_read_permissions_in_category() { + public function test_create_competency_frameworks_with_read_permissions_in_category(): void { $this->setUser($this->catuser); $this->expectException(\required_capability_exception::class); $result = $this->create_competency_framework(1, false); @@ -326,7 +326,7 @@ class external_test extends externallib_advanced_testcase { /** * Test we can create a competency framework with manage permissions. */ - public function test_create_competency_frameworks_with_manage_permissions() { + public function test_create_competency_frameworks_with_manage_permissions(): void { $this->setUser($this->creator); $result = $this->create_competency_framework(1, true); @@ -345,7 +345,7 @@ class external_test extends externallib_advanced_testcase { /** * Test we can create a competency framework with manage permissions. */ - public function test_create_competency_frameworks_with_manage_permissions_in_category() { + public function test_create_competency_frameworks_with_manage_permissions_in_category(): void { $this->setUser($this->catcreator); $result = $this->create_competency_framework(1, false); @@ -371,7 +371,7 @@ class external_test extends externallib_advanced_testcase { /** * Test we cannot create a competency framework with nasty data. */ - public function test_create_competency_frameworks_with_nasty_data() { + public function test_create_competency_frameworks_with_nasty_data(): void { $this->setUser($this->creator); $framework = array( 'shortname' => 'short', @@ -390,7 +390,7 @@ class external_test extends externallib_advanced_testcase { /** * Test we can read a competency framework with manage permissions. */ - public function test_read_competency_frameworks_with_manage_permissions() { + public function test_read_competency_frameworks_with_manage_permissions(): void { $this->setUser($this->creator); $result = $this->create_competency_framework(1, true); @@ -413,7 +413,7 @@ class external_test extends externallib_advanced_testcase { /** * Test we can read a competency framework with manage permissions. */ - public function test_read_competency_frameworks_with_manage_permissions_in_category() { + public function test_read_competency_frameworks_with_manage_permissions_in_category(): void { $this->setUser($this->creator); $insystem = $this->create_competency_framework(1, true); @@ -448,7 +448,7 @@ class external_test extends externallib_advanced_testcase { /** * Test we can read a competency framework with read permissions. */ - public function test_read_competency_frameworks_with_read_permissions() { + public function test_read_competency_frameworks_with_read_permissions(): void { $this->setUser($this->creator); $result = $this->create_competency_framework(1, true); @@ -472,7 +472,7 @@ class external_test extends externallib_advanced_testcase { /** * Test we can read a competency framework with read permissions. */ - public function test_read_competency_frameworks_with_read_permissions_in_category() { + public function test_read_competency_frameworks_with_read_permissions_in_category(): void { $this->setUser($this->creator); $insystem = $this->create_competency_framework(1, true); @@ -507,7 +507,7 @@ class external_test extends externallib_advanced_testcase { /** * Test we can delete a competency framework with manage permissions. */ - public function test_delete_competency_frameworks_with_manage_permissions() { + public function test_delete_competency_frameworks_with_manage_permissions(): void { $this->setUser($this->creator); $result = $this->create_competency_framework(1, true); @@ -521,7 +521,7 @@ class external_test extends externallib_advanced_testcase { /** * Test we can delete a competency framework with manage permissions. */ - public function test_delete_competency_frameworks_with_manage_permissions_in_category() { + public function test_delete_competency_frameworks_with_manage_permissions_in_category(): void { $this->setUser($this->creator); $insystem = $this->create_competency_framework(1, true); @@ -547,7 +547,7 @@ class external_test extends externallib_advanced_testcase { /** * Test we can delete a competency framework with read permissions. */ - public function test_delete_competency_frameworks_with_read_permissions() { + public function test_delete_competency_frameworks_with_read_permissions(): void { $this->setUser($this->creator); $result = $this->create_competency_framework(1, true); @@ -561,7 +561,7 @@ class external_test extends externallib_advanced_testcase { /** * Test we can update a competency framework with manage permissions. */ - public function test_update_competency_frameworks_with_manage_permissions() { + public function test_update_competency_frameworks_with_manage_permissions(): void { $this->setUser($this->creator); $result = $this->create_competency_framework(1, true); @@ -573,7 +573,7 @@ class external_test extends externallib_advanced_testcase { /** * Test we can update a competency framework with manage permissions. */ - public function test_update_competency_frameworks_with_manage_permissions_in_category() { + public function test_update_competency_frameworks_with_manage_permissions_in_category(): void { $this->setUser($this->creator); $insystem = $this->create_competency_framework(1, true); @@ -594,7 +594,7 @@ class external_test extends externallib_advanced_testcase { } } - public function test_update_framework_scale() { + public function test_update_framework_scale(): void { $this->setUser($this->creator); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -628,7 +628,7 @@ class external_test extends externallib_advanced_testcase { /** * Test we can update a competency framework with read permissions. */ - public function test_update_competency_frameworks_with_read_permissions() { + public function test_update_competency_frameworks_with_read_permissions(): void { $this->setUser($this->creator); $result = $this->create_competency_framework(1, true); @@ -640,7 +640,7 @@ class external_test extends externallib_advanced_testcase { /** * Test we can list and count competency frameworks with manage permissions. */ - public function test_list_and_count_competency_frameworks_with_manage_permissions() { + public function test_list_and_count_competency_frameworks_with_manage_permissions(): void { $this->setUser($this->creator); $result = $this->create_competency_framework(1, true); $result = $this->create_competency_framework(2, true); @@ -671,7 +671,7 @@ class external_test extends externallib_advanced_testcase { $this->assertEquals(true, $result->visible); } - public function test_list_competency_frameworks_with_query() { + public function test_list_competency_frameworks_with_query(): void { $this->setUser($this->creator); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); $framework1 = $lpg->create_framework(array( @@ -727,7 +727,7 @@ class external_test extends externallib_advanced_testcase { /** * Test we can list and count competency frameworks with read permissions. */ - public function test_list_and_count_competency_frameworks_with_read_permissions() { + public function test_list_and_count_competency_frameworks_with_read_permissions(): void { $this->setUser($this->creator); $result = $this->create_competency_framework(1, true); $result = $this->create_competency_framework(2, true); @@ -761,7 +761,7 @@ class external_test extends externallib_advanced_testcase { /** * Test we can't create a competency with only read permissions. */ - public function test_create_competency_with_read_permissions() { + public function test_create_competency_with_read_permissions(): void { $framework = $this->getDataGenerator()->get_plugin_generator('core_competency')->create_framework(); $this->setUser($this->user); $this->expectException(\required_capability_exception::class); @@ -771,7 +771,7 @@ class external_test extends externallib_advanced_testcase { /** * Test we can create a competency with manage permissions. */ - public function test_create_competency_with_manage_permissions() { + public function test_create_competency_with_manage_permissions(): void { $this->setUser($this->creator); $framework = $this->create_competency_framework(1, true); $competency = $this->create_competency(1, $framework->id); @@ -791,7 +791,7 @@ class external_test extends externallib_advanced_testcase { /** * Test we can create a competency with manage permissions. */ - public function test_create_competency_with_manage_permissions_in_category() { + public function test_create_competency_with_manage_permissions_in_category(): void { $this->setUser($this->creator); $insystem = $this->create_competency_framework(1, true); @@ -822,7 +822,7 @@ class external_test extends externallib_advanced_testcase { /** * Test we cannot create a competency with nasty data. */ - public function test_create_competency_with_nasty_data() { + public function test_create_competency_with_nasty_data(): void { $this->setUser($this->creator); $framework = $this->create_competency_framework(1, true); $competency = array( @@ -842,7 +842,7 @@ class external_test extends externallib_advanced_testcase { /** * Test we can read a competency with manage permissions. */ - public function test_read_competencies_with_manage_permissions() { + public function test_read_competencies_with_manage_permissions(): void { $this->setUser($this->creator); $framework = $this->create_competency_framework(1, true); $competency = $this->create_competency(1, $framework->id); @@ -865,7 +865,7 @@ class external_test extends externallib_advanced_testcase { /** * Test we can read a competency with manage permissions. */ - public function test_read_competencies_with_manage_permissions_in_category() { + public function test_read_competencies_with_manage_permissions_in_category(): void { $this->setUser($this->creator); $sysframework = $this->create_competency_framework(1, true); @@ -900,7 +900,7 @@ class external_test extends externallib_advanced_testcase { /** * Test we can read a competency with read permissions. */ - public function test_read_competencies_with_read_permissions() { + public function test_read_competencies_with_read_permissions(): void { $this->setUser($this->creator); $framework = $this->create_competency_framework(1, true); $competency = $this->create_competency(1, $framework->id); @@ -925,7 +925,7 @@ class external_test extends externallib_advanced_testcase { /** * Test we can read a competency with read permissions. */ - public function test_read_competencies_with_read_permissions_in_category() { + public function test_read_competencies_with_read_permissions_in_category(): void { $this->setUser($this->creator); $sysframework = $this->create_competency_framework(1, true); $insystem = $this->create_competency(1, $sysframework->id); @@ -959,7 +959,7 @@ class external_test extends externallib_advanced_testcase { /** * Test we can delete a competency with manage permissions. */ - public function test_delete_competency_with_manage_permissions() { + public function test_delete_competency_with_manage_permissions(): void { $this->setUser($this->creator); $framework = $this->create_competency_framework(1, true); $result = $this->create_competency(1, $framework->id); @@ -974,7 +974,7 @@ class external_test extends externallib_advanced_testcase { /** * Test we can delete a competency with manage permissions. */ - public function test_delete_competency_with_manage_permissions_in_category() { + public function test_delete_competency_with_manage_permissions_in_category(): void { $this->setUser($this->creator); $sysframework = $this->create_competency_framework(1, true); @@ -1000,7 +1000,7 @@ class external_test extends externallib_advanced_testcase { /** * Test we can delete a competency with read permissions. */ - public function test_delete_competency_with_read_permissions() { + public function test_delete_competency_with_read_permissions(): void { $this->setUser($this->creator); $framework = $this->create_competency_framework(1, true); $result = $this->create_competency(1, $framework->id); @@ -1015,7 +1015,7 @@ class external_test extends externallib_advanced_testcase { /** * Test we can update a competency with manage permissions. */ - public function test_update_competency_with_manage_permissions() { + public function test_update_competency_with_manage_permissions(): void { $this->setUser($this->creator); $framework = $this->create_competency_framework(1, true); $result = $this->create_competency(1, $framework->id); @@ -1028,7 +1028,7 @@ class external_test extends externallib_advanced_testcase { /** * Test we can update a competency with manage permissions. */ - public function test_update_competency_with_manage_permissions_in_category() { + public function test_update_competency_with_manage_permissions_in_category(): void { $this->setUser($this->creator); $sysframework = $this->create_competency_framework(1, true); @@ -1053,7 +1053,7 @@ class external_test extends externallib_advanced_testcase { /** * Test we can update a competency with read permissions. */ - public function test_update_competency_with_read_permissions() { + public function test_update_competency_with_read_permissions(): void { $this->setUser($this->creator); $framework = $this->create_competency_framework(1, true); $result = $this->create_competency(1, $framework->id); @@ -1066,7 +1066,7 @@ class external_test extends externallib_advanced_testcase { /** * Test count competencies with filters. */ - public function test_count_competencies_with_filters() { + public function test_count_competencies_with_filters(): void { $this->setUser($this->creator); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -1094,7 +1094,7 @@ class external_test extends externallib_advanced_testcase { /** * Test we can list and count competencies with manage permissions. */ - public function test_list_and_count_competencies_with_manage_permissions() { + public function test_list_and_count_competencies_with_manage_permissions(): void { $this->setUser($this->creator); $framework = $this->create_competency_framework(1, true); $result = $this->create_competency(1, $framework->id); @@ -1123,7 +1123,7 @@ class external_test extends externallib_advanced_testcase { /** * Test we can list and count competencies with read permissions. */ - public function test_list_and_count_competencies_with_read_permissions() { + public function test_list_and_count_competencies_with_read_permissions(): void { $this->setUser($this->creator); $framework = $this->create_competency_framework(1, true); $result = $this->create_competency(1, $framework->id); @@ -1154,7 +1154,7 @@ class external_test extends externallib_advanced_testcase { /** * Test we can search for competencies. */ - public function test_search_competencies_with_read_permissions() { + public function test_search_competencies_with_read_permissions(): void { $this->setUser($this->creator); $framework = $this->create_competency_framework(1, true); $result = $this->create_competency(1, $framework->id); @@ -1180,7 +1180,7 @@ class external_test extends externallib_advanced_testcase { /** * Test plans creation and updates. */ - public function test_create_and_update_plans() { + public function test_create_and_update_plans(): void { $syscontext = \context_system::instance(); $this->setUser($this->creator); @@ -1253,7 +1253,7 @@ class external_test extends externallib_advanced_testcase { /** * Test complete plan. */ - public function test_complete_plan() { + public function test_complete_plan(): void { $syscontext = \context_system::instance(); $this->setUser($this->creator); @@ -1275,7 +1275,7 @@ class external_test extends externallib_advanced_testcase { /** * Test reopen plan. */ - public function test_reopen_plan() { + public function test_reopen_plan(): void { $syscontext = \context_system::instance(); $this->setUser($this->creator); @@ -1298,7 +1298,7 @@ class external_test extends externallib_advanced_testcase { /** * Test that we can read plans. */ - public function test_read_plans() { + public function test_read_plans(): void { global $OUTPUT; $this->setUser($this->creator); @@ -1442,7 +1442,7 @@ class external_test extends externallib_advanced_testcase { $this->assertEquals((array)$plan3, external::read_plan($plan3->id)); } - public function test_delete_plans() { + public function test_delete_plans(): void { $this->setUser($this->creator); $syscontext = \context_system::instance(); @@ -1490,7 +1490,7 @@ class external_test extends externallib_advanced_testcase { $this->assertTrue(external::delete_plan($plan4->id)); } - public function test_delete_plan_removes_relations() { + public function test_delete_plan_removes_relations(): void { $this->setAdminUser(); $dg = $this->getDataGenerator(); $lpg = $dg->get_plugin_generator('core_competency'); @@ -1518,7 +1518,7 @@ class external_test extends externallib_advanced_testcase { $this->assertEquals(0, user_competency_plan::count_records(array('planid' => $plan->get('id'), 'userid' => $user->id))); } - public function test_list_plan_competencies() { + public function test_list_plan_competencies(): void { $this->setUser($this->creator); $dg = $this->getDataGenerator(); @@ -1596,7 +1596,7 @@ class external_test extends externallib_advanced_testcase { $this->assertEquals(1, $result[2]['usercompetencyplan']['proficiency']); } - public function test_add_competency_to_template() { + public function test_add_competency_to_template(): void { $this->setUser($this->creator); $syscontext = \context_system::instance(); @@ -1627,7 +1627,7 @@ class external_test extends externallib_advanced_testcase { } } - public function test_remove_competency_from_template() { + public function test_remove_competency_from_template(): void { $syscontext = \context_system::instance(); $this->setUser($this->creator); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -1667,7 +1667,7 @@ class external_test extends externallib_advanced_testcase { /** * Test we can re-order competency frameworks. */ - public function test_reorder_template_competencies() { + public function test_reorder_template_competencies(): void { $this->setUser($this->creator); $syscontext = \context_system::instance(); @@ -1734,7 +1734,7 @@ class external_test extends externallib_advanced_testcase { /** * Test we can duplicate learning plan template. */ - public function test_duplicate_learning_plan_template() { + public function test_duplicate_learning_plan_template(): void { $this->setUser($this->creator); $syscontext = \context_system::instance(); @@ -1772,7 +1772,7 @@ class external_test extends externallib_advanced_testcase { /** * Test that we can return scale values for a scale with the scale ID. */ - public function test_get_scale_values() { + public function test_get_scale_values(): void { global $DB; $this->setUser($this->creator); @@ -1813,7 +1813,7 @@ class external_test extends externallib_advanced_testcase { /** * Create a template. */ - public function test_create_template() { + public function test_create_template(): void { $syscontextid = \context_system::instance()->id; $catcontextid = \context_coursecat::instance($this->category->id)->id; @@ -1865,7 +1865,7 @@ class external_test extends externallib_advanced_testcase { /** * Read a template. */ - public function test_read_template() { + public function test_read_template(): void { $syscontextid = \context_system::instance()->id; $catcontextid = \context_coursecat::instance($this->category->id)->id; @@ -1948,7 +1948,7 @@ class external_test extends externallib_advanced_testcase { /** * Update a template. */ - public function test_update_template() { + public function test_update_template(): void { $syscontextid = \context_system::instance()->id; $catcontextid = \context_coursecat::instance($this->category->id)->id; @@ -2029,7 +2029,7 @@ class external_test extends externallib_advanced_testcase { /** * Delete a template. */ - public function test_delete_template() { + public function test_delete_template(): void { global $DB; $syscontextid = \context_system::instance()->id; $catcontextid = \context_coursecat::instance($this->category->id)->id; @@ -2087,7 +2087,7 @@ class external_test extends externallib_advanced_testcase { /** * List templates. */ - public function test_list_templates() { + public function test_list_templates(): void { $syscontextid = \context_system::instance()->id; $catcontextid = \context_coursecat::instance($this->category->id)->id; @@ -2133,7 +2133,7 @@ class external_test extends externallib_advanced_testcase { /** * List templates using competency. */ - public function test_list_templates_using_competency() { + public function test_list_templates_using_competency(): void { $this->setUser($this->creator); // Create a template. @@ -2177,7 +2177,7 @@ class external_test extends externallib_advanced_testcase { $this->assertEquals($template4->id, $comptemp4->id); } - public function test_count_templates() { + public function test_count_templates(): void { $syscontextid = \context_system::instance()->id; $catcontextid = \context_coursecat::instance($this->category->id)->id; @@ -2221,7 +2221,7 @@ class external_test extends externallib_advanced_testcase { * * @return void */ - public function test_add_related_competency() { + public function test_add_related_competency(): void { global $DB; $this->setUser($this->creator); @@ -2313,7 +2313,7 @@ class external_test extends externallib_advanced_testcase { * * @return void */ - public function test_remove_related_competency() { + public function test_remove_related_competency(): void { $this->setUser($this->creator); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -2349,7 +2349,7 @@ class external_test extends externallib_advanced_testcase { * * @return void */ - public function test_search_competencies_including_related() { + public function test_search_competencies_including_related(): void { $this->setUser($this->creator); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -2377,7 +2377,7 @@ class external_test extends externallib_advanced_testcase { * * @return void */ - public function test_add_competency_to_plan() { + public function test_add_competency_to_plan(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -2439,7 +2439,7 @@ class external_test extends externallib_advanced_testcase { * * @return void */ - public function test_remove_competency_from_plan() { + public function test_remove_competency_from_plan(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -2484,7 +2484,7 @@ class external_test extends externallib_advanced_testcase { * * @return void */ - public function test_reorder_plan_competency() { + public function test_reorder_plan_competency(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -2549,7 +2549,7 @@ class external_test extends externallib_advanced_testcase { /** * Test resolving sortorder when we creating competency. */ - public function test_fix_sortorder_when_creating_competency() { + public function test_fix_sortorder_when_creating_competency(): void { $this->resetAfterTest(true); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); $framework = $lpg->create_framework(); @@ -2566,7 +2566,7 @@ class external_test extends externallib_advanced_testcase { /** * Test resolving sortorder when we delete competency. */ - public function test_fix_sortorder_when_delete_competency() { + public function test_fix_sortorder_when_delete_competency(): void { $this->resetAfterTest(true); $this->setUser($this->creator); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -2619,7 +2619,7 @@ class external_test extends externallib_advanced_testcase { /** * Test resolving sortorder when moving a competency. */ - public function test_fix_sortorder_when_moving_competency() { + public function test_fix_sortorder_when_moving_competency(): void { $this->resetAfterTest(true); $this->setUser($this->creator); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -2676,7 +2676,7 @@ class external_test extends externallib_advanced_testcase { $this->assertEquals(2, $c2a->get('sortorder')); } - public function test_grade_competency() { + public function test_grade_competency(): void { global $CFG; $this->setUser($this->creator); @@ -2697,7 +2697,7 @@ class external_test extends externallib_advanced_testcase { $evidence = external::grade_competency($this->user->id, $c1->get('id'), 1); } - public function test_grade_competency_in_course() { + public function test_grade_competency_in_course(): void { global $CFG; $this->setUser($this->creator); @@ -2723,7 +2723,7 @@ class external_test extends externallib_advanced_testcase { $evidence = external::grade_competency_in_course($course->id, $this->user->id, $c1->get('id'), 1); } - public function test_grade_competency_in_plan() { + public function test_grade_competency_in_plan(): void { global $CFG; $this->setUser($this->creator); @@ -2757,7 +2757,7 @@ class external_test extends externallib_advanced_testcase { /** * Test update course competency settings. */ - public function test_update_course_competency_settings() { + public function test_update_course_competency_settings(): void { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); @@ -2803,7 +2803,7 @@ class external_test extends externallib_advanced_testcase { * * @return void */ - public function test_list_competencies_with_filter() { + public function test_list_competencies_with_filter(): void { $this->resetAfterTest(true); $this->setAdminUser(); $dg = $this->getDataGenerator(); @@ -2842,7 +2842,7 @@ class external_test extends externallib_advanced_testcase { * * @return void */ - public function test_list_competencies_with_course_module() { + public function test_list_competencies_with_course_module(): void { $this->resetAfterTest(true); $this->setAdminUser(); $dg = $this->getDataGenerator(); diff --git a/competency/tests/generator_test.php b/competency/tests/generator_test.php index d520dc147c6..25d4e6ee732 100644 --- a/competency/tests/generator_test.php +++ b/competency/tests/generator_test.php @@ -26,7 +26,7 @@ namespace core_competency; */ class generator_test extends \advanced_testcase { - public function test_create_framework() { + public function test_create_framework(): void { $this->resetAfterTest(true); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -37,7 +37,7 @@ class generator_test extends \advanced_testcase { $this->assertInstanceOf('\core_competency\competency_framework', $framework); } - public function test_create_competency() { + public function test_create_competency(): void { $this->resetAfterTest(true); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -49,7 +49,7 @@ class generator_test extends \advanced_testcase { $this->assertInstanceOf('\core_competency\competency', $competency); } - public function test_create_related_competency() { + public function test_create_related_competency(): void { $this->resetAfterTest(true); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -64,7 +64,7 @@ class generator_test extends \advanced_testcase { $this->assertInstanceOf('\core_competency\related_competency', $rc); } - public function test_create_plan() { + public function test_create_plan(): void { $this->resetAfterTest(true); $user = $this->getDataGenerator()->create_user(); @@ -75,7 +75,7 @@ class generator_test extends \advanced_testcase { $this->assertInstanceOf('\core_competency\plan', $plan); } - public function test_create_user_competency() { + public function test_create_user_competency(): void { $this->resetAfterTest(true); $user = $this->getDataGenerator()->create_user(); @@ -91,7 +91,7 @@ class generator_test extends \advanced_testcase { $this->assertInstanceOf('\core_competency\user_competency', $rc); } - public function test_create_user_competency_plan() { + public function test_create_user_competency_plan(): void { $this->resetAfterTest(true); $user = $this->getDataGenerator()->create_user(); @@ -115,7 +115,7 @@ class generator_test extends \advanced_testcase { $this->assertInstanceOf('\core_competency\user_competency_plan', $ucp); } - public function test_create_template() { + public function test_create_template(): void { $this->resetAfterTest(true); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -126,7 +126,7 @@ class generator_test extends \advanced_testcase { $this->assertInstanceOf('\core_competency\template', $template); } - public function test_create_template_competency() { + public function test_create_template_competency(): void { $this->resetAfterTest(true); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -141,7 +141,7 @@ class generator_test extends \advanced_testcase { $this->assertInstanceOf('\core_competency\template_competency', $relation); } - public function test_create_plan_competency() { + public function test_create_plan_competency(): void { $this->resetAfterTest(true); $user = $this->getDataGenerator()->create_user(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -161,7 +161,7 @@ class generator_test extends \advanced_testcase { $this->assertEquals($plan->get('id'), $pc1->get('planid')); } - public function test_create_template_cohort() { + public function test_create_template_cohort(): void { $this->resetAfterTest(true); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -176,7 +176,7 @@ class generator_test extends \advanced_testcase { $this->assertInstanceOf('\core_competency\template_cohort', $tc); } - public function test_create_evidence() { + public function test_create_evidence(): void { $this->resetAfterTest(true); $user = $this->getDataGenerator()->create_user(); @@ -192,7 +192,7 @@ class generator_test extends \advanced_testcase { $this->assertInstanceOf('\core_competency\evidence', $e); } - public function test_create_course_competency() { + public function test_create_course_competency(): void { $this->resetAfterTest(true); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); @@ -212,7 +212,7 @@ class generator_test extends \advanced_testcase { $this->assertInstanceOf('\core_competency\course_competency', $rc); } - public function test_create_course_module_competency() { + public function test_create_course_module_competency(): void { $this->resetAfterTest(true); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); diff --git a/competency/tests/hooks_test.php b/competency/tests/hooks_test.php index 595d31c17c3..7d525a5b998 100644 --- a/competency/tests/hooks_test.php +++ b/competency/tests/hooks_test.php @@ -25,7 +25,7 @@ namespace core_competency; */ class hooks_test extends \advanced_testcase { - public function test_hook_course_deleted() { + public function test_hook_course_deleted(): void { $this->resetAfterTest(); $dg = $this->getDataGenerator(); $ccg = $dg->get_plugin_generator('core_competency'); @@ -72,7 +72,7 @@ class hooks_test extends \advanced_testcase { $this->assertEquals(2, user_competency_course::count_records(['courseid' => $c2->id, 'userid' => $u1->id])); } - public function test_hook_course_module_deleted() { + public function test_hook_course_module_deleted(): void { $this->resetAfterTest(); $dg = $this->getDataGenerator(); $ccg = $dg->get_plugin_generator('core_competency'); @@ -120,7 +120,7 @@ class hooks_test extends \advanced_testcase { $this->assertEquals(2, user_competency_course::count_records(['courseid' => $c2->id, 'userid' => $u1->id])); } - public function test_hook_course_reset_competency_ratings() { + public function test_hook_course_reset_competency_ratings(): void { $this->resetAfterTest(); $dg = $this->getDataGenerator(); $ccg = $dg->get_plugin_generator('core_competency'); @@ -167,7 +167,7 @@ class hooks_test extends \advanced_testcase { $this->assertEquals(2, user_competency_course::count_records(['courseid' => $c2->id, 'userid' => $u1->id])); } - public function test_hook_cohort_deleted() { + public function test_hook_cohort_deleted(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -196,7 +196,7 @@ class hooks_test extends \advanced_testcase { $this->assertEquals(0, \core_competency\template_cohort::count_records(array('templateid' => $t2->get('id')))); } - public function test_hook_user_deleted() { + public function test_hook_user_deleted(): void { $this->resetAfterTest(); $dg = $this->getDataGenerator(); $ccg = $dg->get_plugin_generator('core_competency'); diff --git a/competency/tests/lib_test.php b/competency/tests/lib_test.php index 2d29a0c4134..ce74c6835a6 100644 --- a/competency/tests/lib_test.php +++ b/competency/tests/lib_test.php @@ -40,7 +40,7 @@ global $CFG; */ class lib_test extends \advanced_testcase { - public function test_comment_add_user_competency() { + public function test_comment_add_user_competency(): void { global $DB, $PAGE; $this->resetAfterTest(); $dg = $this->getDataGenerator(); @@ -185,7 +185,7 @@ class lib_test extends \advanced_testcase { /** * Commenting on a plan. */ - public function test_comment_add_plan() { + public function test_comment_add_plan(): void { $this->resetAfterTest(); $dg = $this->getDataGenerator(); $lpg = $dg->get_plugin_generator('core_competency'); diff --git a/competency/tests/performance_helper_test.php b/competency/tests/performance_helper_test.php index ae9477da573..7038f87f440 100644 --- a/competency/tests/performance_helper_test.php +++ b/competency/tests/performance_helper_test.php @@ -27,7 +27,7 @@ use core_competency\external\performance_helper; */ class performance_helper_test extends \advanced_testcase { - public function test_get_context_from_competency() { + public function test_get_context_from_competency(): void { global $DB; $this->resetAfterTest(true); @@ -62,7 +62,7 @@ class performance_helper_test extends \advanced_testcase { $this->assertEquals($DB->perf_get_queries(), $dbqueries); } - public function test_get_framework_from_competency() { + public function test_get_framework_from_competency(): void { global $DB; $this->resetAfterTest(true); @@ -110,7 +110,7 @@ class performance_helper_test extends \advanced_testcase { $this->assertSame($fourthrunframework, $fifthrunframework); } - public function test_get_scale_from_competency() { + public function test_get_scale_from_competency(): void { global $DB; $this->resetAfterTest(true); diff --git a/competency/tests/plan_test.php b/competency/tests/plan_test.php index b71e0d9d826..4b0b2abd4e5 100644 --- a/competency/tests/plan_test.php +++ b/competency/tests/plan_test.php @@ -25,7 +25,7 @@ namespace core_competency; */ class plan_test extends \advanced_testcase { - public function test_can_manage_user() { + public function test_can_manage_user(): void { $this->resetAfterTest(true); $manage = create_role('Manage', 'manage', 'Plan manager'); @@ -64,7 +64,7 @@ class plan_test extends \advanced_testcase { $this->assertFalse(plan::can_manage_user($u3->id)); } - public function test_can_manage_user_draft() { + public function test_can_manage_user_draft(): void { $this->resetAfterTest(true); $manage = create_role('Manage', 'manage', 'Plan manager'); @@ -133,7 +133,7 @@ class plan_test extends \advanced_testcase { $this->assertTrue(plan::can_manage_user_draft($u5->id)); } - public function test_can_read_user() { + public function test_can_read_user(): void { $this->resetAfterTest(true); $read = create_role('Read', 'read', 'Plan reader'); @@ -172,7 +172,7 @@ class plan_test extends \advanced_testcase { $this->assertTrue(plan::can_read_user($u3->id)); // Due to the default capability. } - public function test_can_read_user_draft() { + public function test_can_read_user_draft(): void { $this->resetAfterTest(true); $read = create_role('Read', 'read', 'Plan readr'); @@ -242,7 +242,7 @@ class plan_test extends \advanced_testcase { $this->assertTrue(plan::can_read_user_draft($u5->id)); } - public function test_validate_duedate() { + public function test_validate_duedate(): void { global $DB; $this->resetAfterTest(true); $this->setAdminUser(); @@ -430,7 +430,7 @@ class plan_test extends \advanced_testcase { $this->assertEquals($duedate, $plan->get('duedate')); } - public function test_get_by_user_and_competency() { + public function test_get_by_user_and_competency(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -514,7 +514,7 @@ class plan_test extends \advanced_testcase { $this->assertCount(0, $plans); } - public function test_get_competency() { + public function test_get_competency(): void { $this->resetAfterTest(); $this->setAdminUser(); diff --git a/competency/tests/privacy/provider_test.php b/competency/tests/privacy/provider_test.php index 8ec02a78e05..2e8f39aa8ea 100644 --- a/competency/tests/privacy/provider_test.php +++ b/competency/tests/privacy/provider_test.php @@ -58,7 +58,7 @@ class provider_test extends provider_testcase { $PAGE->get_renderer('core'); } - public function test_get_contexts_for_userid_with_usermodified_for_framework() { + public function test_get_contexts_for_userid_with_usermodified_for_framework(): void { $dg = $this->getDataGenerator(); $ccg = $dg->get_plugin_generator('core_competency'); @@ -115,7 +115,7 @@ class provider_test extends provider_testcase { $this->assert_contextlist($contextlist, [$sysctx, $cat1ctx]); } - public function test_get_users_in_context_with_usermodified_for_framework() { + public function test_get_users_in_context_with_usermodified_for_framework(): void { $dg = $this->getDataGenerator(); $ccg = $dg->get_plugin_generator('core_competency'); @@ -171,7 +171,7 @@ class provider_test extends provider_testcase { $this->assert_array_match($expected, $userlist->get_userids()); } - public function test_get_contexts_for_userid_with_usermodified_for_template() { + public function test_get_contexts_for_userid_with_usermodified_for_template(): void { $dg = $this->getDataGenerator(); $ccg = $dg->get_plugin_generator('core_competency'); @@ -234,7 +234,7 @@ class provider_test extends provider_testcase { $this->assert_contextlist($contextlist, [$sysctx, $cat1ctx]); } - public function test_get_users_in_context_with_usermodified_for_template() { + public function test_get_users_in_context_with_usermodified_for_template(): void { $dg = $this->getDataGenerator(); $ccg = $dg->get_plugin_generator('core_competency'); @@ -297,7 +297,7 @@ class provider_test extends provider_testcase { $this->assert_array_match($expected, $userlist->get_userids()); } - public function test_get_contexts_for_userid_with_usermodified_for_course() { + public function test_get_contexts_for_userid_with_usermodified_for_course(): void { $dg = $this->getDataGenerator(); $ccg = $dg->get_plugin_generator('core_competency'); $c1 = $dg->create_course(); @@ -348,7 +348,7 @@ class provider_test extends provider_testcase { $this->assert_contextlist(provider::get_contexts_for_userid($u4->id), [$c2ctx]); } - public function test_get_users_in_context_with_usermodified_for_course() { + public function test_get_users_in_context_with_usermodified_for_course(): void { $dg = $this->getDataGenerator(); $ccg = $dg->get_plugin_generator('core_competency'); $c1 = $dg->create_course(); @@ -393,7 +393,7 @@ class provider_test extends provider_testcase { $this->assert_array_match($expected, $userlist->get_userids()); } - public function test_get_contexts_for_userid_with_usermodified_for_module() { + public function test_get_contexts_for_userid_with_usermodified_for_module(): void { $dg = $this->getDataGenerator(); $ccg = $dg->get_plugin_generator('core_competency'); $c1 = $dg->create_course(); @@ -426,7 +426,7 @@ class provider_test extends provider_testcase { $this->assert_contextlist(provider::get_contexts_for_userid($u2->id), [$m1ctx, $m2ctx]); } - public function test_get_users_in_context_with_usermodified_for_module() { + public function test_get_users_in_context_with_usermodified_for_module(): void { $dg = $this->getDataGenerator(); $ccg = $dg->get_plugin_generator('core_competency'); $c1 = $dg->create_course(); @@ -462,7 +462,7 @@ class provider_test extends provider_testcase { $this->assert_array_match($expected, $userlist->get_userids()); } - public function test_get_contexts_for_userid_with_usermodified_for_plan() { + public function test_get_contexts_for_userid_with_usermodified_for_plan(): void { $dg = $this->getDataGenerator(); $ccg = $dg->get_plugin_generator('core_competency'); $u0 = $dg->create_user(); @@ -498,7 +498,7 @@ class provider_test extends provider_testcase { $this->assert_contextlist(provider::get_contexts_for_userid($u3->id), [$u0ctx]); } - public function test_get_users_in_context_with_usermodified_for_plan() { + public function test_get_users_in_context_with_usermodified_for_plan(): void { $dg = $this->getDataGenerator(); $ccg = $dg->get_plugin_generator('core_competency'); $u0 = $dg->create_user(); @@ -530,7 +530,7 @@ class provider_test extends provider_testcase { $this->assert_array_match($expected, $userlist->get_userids()); } - public function test_get_contexts_for_userid_with_usermodified_for_competency_data() { + public function test_get_contexts_for_userid_with_usermodified_for_competency_data(): void { $dg = $this->getDataGenerator(); $ccg = $dg->get_plugin_generator('core_competency'); $u0 = $dg->create_user(); @@ -608,7 +608,7 @@ class provider_test extends provider_testcase { $this->assert_contextlist(provider::get_contexts_for_userid($u8->id), [$u0ctx]); } - public function test_get_users_in_context_with_usermodified_for_competency_data() { + public function test_get_users_in_context_with_usermodified_for_competency_data(): void { $dg = $this->getDataGenerator(); $ccg = $dg->get_plugin_generator('core_competency'); $u0 = $dg->create_user(); @@ -659,7 +659,7 @@ class provider_test extends provider_testcase { $this->assert_array_match($expected, $userlist->get_userids()); } - public function test_get_contexts_for_userid_with_actual_data_and_actual_data_is_goooood() { + public function test_get_contexts_for_userid_with_actual_data_and_actual_data_is_goooood(): void { $dg = $this->getDataGenerator(); $ccg = $dg->get_plugin_generator('core_competency'); $c1 = $dg->create_course(); @@ -724,7 +724,7 @@ class provider_test extends provider_testcase { $this->assert_contextlist(provider::get_contexts_for_userid($u5->id), [$u4ctx]); } - public function test_get_users_in_context_with_actual_data_and_actual_data_is_goooood() { + public function test_get_users_in_context_with_actual_data_and_actual_data_is_goooood(): void { $dg = $this->getDataGenerator(); $ccg = $dg->get_plugin_generator('core_competency'); $c1 = $dg->create_course(); @@ -771,7 +771,7 @@ class provider_test extends provider_testcase { $this->assert_array_match([$u4->id], $userlist->get_userids()); } - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { $dg = $this->getDataGenerator(); $ccg = $dg->get_plugin_generator('core_competency'); @@ -944,7 +944,7 @@ class provider_test extends provider_testcase { $this->assertTrue(\core_competency\user_competency_course::record_exists($ucc2->get('id'))); } - public function test_delete_data_for_user_with_other_user_context() { + public function test_delete_data_for_user_with_other_user_context(): void { $dg = $this->getDataGenerator(); $ccg = $dg->get_plugin_generator('core_competency'); @@ -1037,7 +1037,7 @@ class provider_test extends provider_testcase { $this->assertEquals(1, $this->get_comments_count($uc1a->get_comment_object(), $u2->id)); } - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { $dg = $this->getDataGenerator(); $ccg = $dg->get_plugin_generator('core_competency'); @@ -1209,7 +1209,7 @@ class provider_test extends provider_testcase { $this->assertTrue(\core_competency\user_competency_course::record_exists($ucc2->get('id'))); } - public function test_delete_data_for_users_with_other_user_context() { + public function test_delete_data_for_users_with_other_user_context(): void { $dg = $this->getDataGenerator(); $ccg = $dg->get_plugin_generator('core_competency'); @@ -1304,7 +1304,7 @@ class provider_test extends provider_testcase { $this->assertEquals(1, $this->get_comments_count($uc1a->get_comment_object(), $u2->id)); } - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { $dg = $this->getDataGenerator(); $ccg = $dg->get_plugin_generator('core_competency'); @@ -1440,7 +1440,7 @@ class provider_test extends provider_testcase { $this->assertTrue(\core_competency\user_competency_course::record_exists($ucc1b->get('id'))); } - public function test_export_data_for_user_in_module_context_where_usermodified_matches() { + public function test_export_data_for_user_in_module_context_where_usermodified_matches(): void { $dg = $this->getDataGenerator(); $ccg = $dg->get_plugin_generator('core_competency'); @@ -1495,7 +1495,7 @@ class provider_test extends provider_testcase { $this->assertEquals(transform::yesno(true), $data->associations[0]['created_or_modified_by_you']); } - public function test_export_data_for_user_in_course_context_where_usermodified_matches() { + public function test_export_data_for_user_in_course_context_where_usermodified_matches(): void { $dg = $this->getDataGenerator(); $ccg = $dg->get_plugin_generator('core_competency'); @@ -1589,7 +1589,7 @@ class provider_test extends provider_testcase { $this->assertEquals($comp2->get('shortname'), $data->ratings[0]['name']); } - public function test_export_data_for_user_in_course_context_with_real_data() { + public function test_export_data_for_user_in_course_context_with_real_data(): void { $dg = $this->getDataGenerator(); $ccg = $dg->get_plugin_generator('core_competency'); @@ -1647,7 +1647,7 @@ class provider_test extends provider_testcase { $this->assertEquals('-', $data->ratings[1]['rating']['proficient']); } - public function test_export_data_for_user_in_system_and_category_contexts() { + public function test_export_data_for_user_in_system_and_category_contexts(): void { $dg = $this->getDataGenerator(); $ccg = $dg->get_plugin_generator('core_competency'); @@ -1821,7 +1821,7 @@ class provider_test extends provider_testcase { $this->assertEquals(transform::yesno(true), $competency['created_or_modified_by_you']); } - public function test_export_data_for_user_with_related_learning_plans() { + public function test_export_data_for_user_with_related_learning_plans(): void { global $DB; $path = [ @@ -2159,7 +2159,7 @@ class provider_test extends provider_testcase { $this->assert_exported_comments(['Hello!', 'It\'s me...'], $data->comments); } - public function test_export_data_for_user_with_related_user_evidence() { + public function test_export_data_for_user_with_related_user_evidence(): void { $path = [ get_string('competencies', 'core_competency'), get_string('privacy:path:relatedtome', 'core_competency'), @@ -2242,7 +2242,7 @@ class provider_test extends provider_testcase { $this->assertEquals($yes, $competency['created_or_modified_by_you']); } - public function test_export_data_for_user_about_their_learning_plans() { + public function test_export_data_for_user_about_their_learning_plans(): void { $this->setAdminUser(); $dg = $this->getDataGenerator(); $ccg = $dg->get_plugin_generator('core_competency'); @@ -2405,7 +2405,7 @@ class provider_test extends provider_testcase { $this->assertEmpty($data); } - public function test_export_data_for_user_about_their_competencies() { + public function test_export_data_for_user_about_their_competencies(): void { $dg = $this->getDataGenerator(); $ccg = $dg->get_plugin_generator('core_competency'); $path = [get_string('competencies', 'core_competency'), get_string('competencies', 'core_competency')]; @@ -2511,7 +2511,7 @@ class provider_test extends provider_testcase { $this->assertEmpty($data); } - public function test_export_data_for_user_about_their_user_evidence() { + public function test_export_data_for_user_about_their_user_evidence(): void { $dg = $this->getDataGenerator(); $ccg = $dg->get_plugin_generator('core_competency'); $path = [get_string('competencies', 'core_competency'), get_string('privacy:path:userevidence', 'core_competency')]; diff --git a/competency/tests/task/task_test.php b/competency/tests/task/task_test.php index cbca259d5a9..ec74d041e22 100644 --- a/competency/tests/task/task_test.php +++ b/competency/tests/task/task_test.php @@ -29,7 +29,7 @@ use core_competency\template; */ class task_test extends \advanced_testcase { - public function test_sync_plans_from_cohorts_task() { + public function test_sync_plans_from_cohorts_task(): void { global $DB; $this->resetAfterTest(true); @@ -149,7 +149,7 @@ class task_test extends \advanced_testcase { $this->assertEquals(3, plan::count_records(array('templateid' => $tpl->get('id')))); } - public function test_sync_plans_from_cohorts_with_templateduedate_task() { + public function test_sync_plans_from_cohorts_with_templateduedate_task(): void { $this->resetAfterTest(true); $this->setAdminUser(); $dg = $this->getDataGenerator(); @@ -228,7 +228,7 @@ class task_test extends \advanced_testcase { $this->assertEquals(4, plan::count_records(array('templateid' => $tpl->get('id')))); } - public function test_sync_plans_from_cohorts_with_passed_duedate() { + public function test_sync_plans_from_cohorts_with_passed_duedate(): void { global $DB; $this->resetAfterTest(true); @@ -266,7 +266,7 @@ class task_test extends \advanced_testcase { $this->assertEquals(2, plan::count_records()); // Now there is two. } - public function test_complete_plans_task() { + public function test_complete_plans_task(): void { global $DB; $this->resetAfterTest(true); $this->setAdminUser(); diff --git a/competency/tests/template_test.php b/competency/tests/template_test.php index 6087ca7fb25..1d5ec86ab30 100644 --- a/competency/tests/template_test.php +++ b/competency/tests/template_test.php @@ -25,7 +25,7 @@ namespace core_competency; */ class template_test extends \advanced_testcase { - public function test_validate_duedate() { + public function test_validate_duedate(): void { global $DB; $this->resetAfterTest(); diff --git a/competency/tests/user_evidence_competency_test.php b/competency/tests/user_evidence_competency_test.php index 60090b43233..125ae216139 100644 --- a/competency/tests/user_evidence_competency_test.php +++ b/competency/tests/user_evidence_competency_test.php @@ -25,7 +25,7 @@ namespace core_competency; */ class user_evidence_competency_test extends \advanced_testcase { - public function test_get_user_competencies_by_userevidenceid() { + public function test_get_user_competencies_by_userevidenceid(): void { global $CFG, $DB; $this->resetAfterTest(true); diff --git a/completion/tests/activity_custom_completion_test.php b/completion/tests/activity_custom_completion_test.php index 54cb1cc91bf..07ed75a3fe8 100644 --- a/completion/tests/activity_custom_completion_test.php +++ b/completion/tests/activity_custom_completion_test.php @@ -100,7 +100,7 @@ class activity_custom_completion_test extends advanced_testcase { * @param int $invokecount Expected invoke count of get_state(). * @param int $state The expected overall completion state */ - public function test_get_overall_completion_state(array $rules, array $rulestates, int $invokecount, int $state) { + public function test_get_overall_completion_state(array $rules, array $rulestates, int $invokecount, int $state): void { $stub = $this->setup_mock([ 'get_available_custom_rules', 'get_state', @@ -155,7 +155,7 @@ class activity_custom_completion_test extends advanced_testcase { * @param bool $available is_available()'s mocked return value. * @param string|null $expectedexception Expected expectation class name. */ - public function test_validate_rule(bool $defined, bool $available, ?string $expectedexception) { + public function test_validate_rule(bool $defined, bool $available, ?string $expectedexception): void { $stub = $this->setup_mock([ 'is_defined', 'is_available' @@ -180,7 +180,7 @@ class activity_custom_completion_test extends advanced_testcase { /** * Test for is_available(). */ - public function test_is_available() { + public function test_is_available(): void { $stub = $this->setup_mock([ 'get_available_custom_rules', ]); diff --git a/completion/tests/api_test.php b/completion/tests/api_test.php index 5a92d85e59d..4e9d5b510fd 100644 --- a/completion/tests/api_test.php +++ b/completion/tests/api_test.php @@ -33,7 +33,7 @@ class api_test extends \advanced_testcase { $this->resetAfterTest(); } - public function test_update_completion_date_event() { + public function test_update_completion_date_event(): void { global $CFG, $DB; $this->setAdminUser(); @@ -72,7 +72,7 @@ class api_test extends \advanced_testcase { \core_completion\api::update_completion_date_event($assign->cmid, 'assign', null, $time); } - public function test_update_completion_date_event_update() { + public function test_update_completion_date_event_update(): void { global $CFG, $DB; $this->setAdminUser(); @@ -107,7 +107,7 @@ class api_test extends \advanced_testcase { $this->assertEquals($time + DAYSECS, $event->timesort); } - public function test_update_completion_date_event_delete() { + public function test_update_completion_date_event_delete(): void { global $CFG, $DB; $this->setAdminUser(); @@ -130,7 +130,7 @@ class api_test extends \advanced_testcase { $this->assertEquals(0, $DB->count_records('event')); } - public function test_update_completion_date_event_completion_disabled() { + public function test_update_completion_date_event_completion_disabled(): void { global $CFG, $DB; $this->setAdminUser(); @@ -150,7 +150,7 @@ class api_test extends \advanced_testcase { $this->assertEquals(0, $DB->count_records('event')); } - public function test_update_completion_date_event_update_completion_disabled() { + public function test_update_completion_date_event_update_completion_disabled(): void { global $CFG, $DB; $this->setAdminUser(); @@ -188,7 +188,7 @@ class api_test extends \advanced_testcase { $this->assertEquals($time, $event->timesort); } - public function test_update_completion_date_event_delete_completion_disabled() { + public function test_update_completion_date_event_delete_completion_disabled(): void { global $CFG, $DB; $this->setAdminUser(); @@ -217,7 +217,7 @@ class api_test extends \advanced_testcase { /** * Test for mark_course_completions_activity_criteria(). */ - public function test_mark_course_completions_activity_criteria() { + public function test_mark_course_completions_activity_criteria(): void { global $DB, $CFG; require_once($CFG->dirroot.'/completion/criteria/completion_criteria_activity.php'); $this->resetAfterTest(true); @@ -293,7 +293,7 @@ class api_test extends \advanced_testcase { * Test for mark_course_completions_activity_criteria() with different completionpassgrade settings. * @covers ::mark_course_completions_activity_criteria */ - public function test_mark_course_completions_activity_criteria_completion_states() { + public function test_mark_course_completions_activity_criteria_completion_states(): void { global $DB, $CFG; require_once($CFG->dirroot . '/completion/criteria/completion_criteria_activity.php'); $this->resetAfterTest(true); diff --git a/completion/tests/bulk_update_test.php b/completion/tests/bulk_update_test.php index f378e3770f8..b6b2db80fb5 100644 --- a/completion/tests/bulk_update_test.php +++ b/completion/tests/bulk_update_test.php @@ -113,7 +113,7 @@ class bulk_update_test extends \advanced_testcase { * @param array $submitdata data to use in mock form submit * @param array|null $validatedata data to validate the */ - public function test_bulk_form_submit_single($modname, $submitdata, $validatedata = null) { + public function test_bulk_form_submit_single($modname, $submitdata, $validatedata = null): void { global $DB; if ($validatedata === null) { @@ -231,7 +231,7 @@ class bulk_update_test extends \advanced_testcase { * @dataProvider bulk_form_submit_multiple_provider * @param array $providerdata */ - public function test_bulk_form_submit_multiple($providerdata) { + public function test_bulk_form_submit_multiple($providerdata): void { global $DB; $modulenames = $providerdata['modulenames']; diff --git a/completion/tests/capabilities_test.php b/completion/tests/capabilities_test.php index cf6e58383b4..9b6d43ed446 100644 --- a/completion/tests/capabilities_test.php +++ b/completion/tests/capabilities_test.php @@ -28,7 +28,7 @@ class capabilities_test extends \advanced_testcase { /** * A user who does not have capabilities to add events to the calendar should be able to create activities. */ - public function test_creation_with_no_calendar_capabilities() { + public function test_creation_with_no_calendar_capabilities(): void { $this->resetAfterTest(); $course = self::getDataGenerator()->create_course(['enablecompletion' => 1]); $context = \context_course::instance($course->id); diff --git a/completion/tests/cm_completion_details_test.php b/completion/tests/cm_completion_details_test.php index 5fca54e8ee8..faede9eafda 100644 --- a/completion/tests/cm_completion_details_test.php +++ b/completion/tests/cm_completion_details_test.php @@ -127,7 +127,7 @@ class cm_completion_details_test extends advanced_testcase { * @param int $completion The completion tracking mode. * @param bool $expectedresult Expected result. */ - public function test_has_completion(int $completion, bool $expectedresult) { + public function test_has_completion(int $completion, bool $expectedresult): void { $cmcompletion = $this->setup_data($completion); $this->assertEquals($expectedresult, $cmcompletion->has_completion()); @@ -160,7 +160,7 @@ class cm_completion_details_test extends advanced_testcase { * @param int $completion The completion tracking mode. * @param bool $expectedresult Expected result. */ - public function test_is_automatic(int $completion, bool $expectedresult) { + public function test_is_automatic(int $completion, bool $expectedresult): void { $cmcompletion = $this->setup_data($completion); $this->assertEquals($expectedresult, $cmcompletion->is_automatic()); @@ -193,7 +193,7 @@ class cm_completion_details_test extends advanced_testcase { * @param int $completion The completion tracking mode. * @param bool $expectedresult Expected result. */ - public function test_is_manual(int $completion, bool $expectedresult) { + public function test_is_manual(int $completion, bool $expectedresult): void { $cmcompletion = $this->setup_data($completion); $this->assertEquals($expectedresult, $cmcompletion->is_manual()); @@ -217,7 +217,7 @@ class cm_completion_details_test extends advanced_testcase { * @dataProvider overall_completion_provider * @param int $state */ - public function test_get_overall_completion(int $state) { + public function test_get_overall_completion(int $state): void { $completiondata = (object)['completionstate' => $state]; $cmcompletion = $this->setup_data(COMPLETION_TRACKING_AUTOMATIC, [], $completiondata); $this->assertEquals($state, $cmcompletion->get_overall_completion()); @@ -497,7 +497,7 @@ class cm_completion_details_test extends advanced_testcase { * @param array $expecteddetails Expected completion details returned by get_details(). */ public function test_get_details(int $completion, ?int $completionview, - ?int $completiongrade, ?int $completionpassgrade, array $expecteddetails) { + ?int $completiongrade, ?int $completionpassgrade, array $expecteddetails): void { $options = []; $getdatareturn = (object)[ 'viewed' => $completionview, @@ -597,7 +597,7 @@ class cm_completion_details_test extends advanced_testcase { * @param array $expectedorder The expected order of completion conditions returned about the module. */ public function test_get_details_custom_order(bool $completionview, bool $completiongrade, array $customcompletionrules, - string $modname, array $expectedorder) { + string $modname, array $expectedorder): void { $options['customcompletion'] = []; $customcompletiondata = []; diff --git a/completion/tests/externallib_test.php b/completion/tests/externallib_test.php index 06fe5c7dbd5..3893b82b23d 100644 --- a/completion/tests/externallib_test.php +++ b/completion/tests/externallib_test.php @@ -41,7 +41,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test update_activity_completion_status_manually */ - public function test_update_activity_completion_status_manually() { + public function test_update_activity_completion_status_manually(): void { global $DB, $CFG; $this->resetAfterTest(true); @@ -88,7 +88,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test update_activity_completion_status */ - public function test_get_activities_completion_status() { + public function test_get_activities_completion_status(): void { global $DB, $CFG, $PAGE; $this->resetAfterTest(true); @@ -317,7 +317,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test override_activity_completion_status */ - public function test_override_activity_completion_status() { + public function test_override_activity_completion_status(): void { global $DB, $CFG; $this->resetAfterTest(true); @@ -380,7 +380,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test overriding the activity completion status as a user without the capability to do so. */ - public function test_override_status_user_without_capability() { + public function test_override_status_user_without_capability(): void { global $DB, $CFG; $this->resetAfterTest(true); @@ -409,7 +409,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_course_completion_status */ - public function test_get_course_completion_status() { + public function test_get_course_completion_status(): void { global $DB, $CFG, $COMPLETION_CRITERIA_TYPES; require_once($CFG->dirroot.'/completion/criteria/completion_criteria_self.php'); require_once($CFG->dirroot.'/completion/criteria/completion_criteria_date.php'); @@ -540,7 +540,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test mark_course_self_completed */ - public function test_mark_course_self_completed() { + public function test_mark_course_self_completed(): void { global $DB, $CFG; require_once($CFG->dirroot.'/completion/criteria/completion_criteria_self.php'); diff --git a/completion/tests/generator_test.php b/completion/tests/generator_test.php index 7c5f6826bcc..b10de8bdfbf 100644 --- a/completion/tests/generator_test.php +++ b/completion/tests/generator_test.php @@ -40,7 +40,7 @@ class generator_test extends \advanced_testcase { * * @covers ::create_default_completion */ - public function test_create_default_completion($course, $module, bool $exception, int $count, int $completion = 0) { + public function test_create_default_completion($course, $module, bool $exception, int $count, int $completion = 0): void { global $DB; $this->resetAfterTest(true); diff --git a/completion/tests/privacy/provider_test.php b/completion/tests/privacy/provider_test.php index 6d1d81948a6..80a43220138 100644 --- a/completion/tests/privacy/provider_test.php +++ b/completion/tests/privacy/provider_test.php @@ -43,7 +43,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test joining course completion data to an sql statement. */ - public function test_get_course_completion_join_sql() { + public function test_get_course_completion_join_sql(): void { global $DB; $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); @@ -63,7 +63,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test fetching users' course completion by context and adding to a userlist. */ - public function test_add_course_completion_users_to_userlist() { + public function test_add_course_completion_users_to_userlist(): void { $this->resetAfterTest(); $user1 = $this->getDataGenerator()->create_user(); @@ -93,7 +93,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test getting course completion information. */ - public function test_get_course_completion_info() { + public function test_get_course_completion_info(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); $this->create_course_completion(); @@ -106,7 +106,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test getting activity completion information. */ - public function test_get_activity_completion_info() { + public function test_get_activity_completion_info(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); $this->create_course_completion(); @@ -121,7 +121,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test deleting activity completion information for a user. */ - public function test_delete_completion_activity_user() { + public function test_delete_completion_activity_user(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); $this->create_course_completion(); @@ -135,7 +135,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test deleting course completion information. */ - public function test_delete_completion_course() { + public function test_delete_completion_course(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); $this->create_course_completion(); @@ -150,7 +150,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test deleting course completion information by approved userlist. */ - public function test_delete_completion_by_approved_userlist() { + public function test_delete_completion_by_approved_userlist(): void { $this->resetAfterTest(); $user1 = $this->getDataGenerator()->create_user(); $user2 = $this->getDataGenerator()->create_user(); @@ -207,7 +207,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test getting course completion information with completion disabled. */ - public function test_get_course_completion_info_completion_disabled() { + public function test_get_course_completion_info_completion_disabled(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); diff --git a/completion/tests/progress_test.php b/completion/tests/progress_test.php index 51a6b576678..c46341723ef 100644 --- a/completion/tests/progress_test.php +++ b/completion/tests/progress_test.php @@ -41,7 +41,7 @@ class progress_test extends \advanced_testcase { /** * Tests that the course progress percentage is returned correctly when we have only activity completion. */ - public function test_course_progress_percentage_with_just_activities() { + public function test_course_progress_percentage_with_just_activities(): void { global $DB; // Add a course that supports completion. @@ -80,7 +80,7 @@ class progress_test extends \advanced_testcase { /** * Tests that the course progress percentage is returned correctly when we have a course and activity completion. */ - public function test_course_progress_percentage_with_activities_and_course() { + public function test_course_progress_percentage_with_activities_and_course(): void { global $DB; // Add a course that supports completion. @@ -125,7 +125,7 @@ class progress_test extends \advanced_testcase { * * @covers \core_completion\progress::get_course_progress_percentage. */ - public function test_course_progress_percentage_completion_state() { + public function test_course_progress_percentage_completion_state(): void { global $DB, $CFG; require_once("{$CFG->dirroot}/completion/criteria/completion_criteria_activity.php"); @@ -233,7 +233,7 @@ class progress_test extends \advanced_testcase { /** * Tests that the course progress returns null when the course does not support it. */ - public function test_course_progress_course_not_using_completion() { + public function test_course_progress_course_not_using_completion(): void { // Create a course that does not use completion. $course = $this->getDataGenerator()->create_course(); @@ -244,7 +244,7 @@ class progress_test extends \advanced_testcase { /** * Tests that the course progress returns null when there are no activities that support it. */ - public function test_course_progress_no_activities_using_completion() { + public function test_course_progress_no_activities_using_completion(): void { // Create a course that does support completion. $course = $this->getDataGenerator()->create_course(array('enablecompletion' => 1)); @@ -258,7 +258,7 @@ class progress_test extends \advanced_testcase { /** * Tests that the course progress returns null for a not tracked for completion user in a course. */ - public function test_course_progress_not_tracked_user() { + public function test_course_progress_not_tracked_user(): void { global $DB; // Add a course that supports completion. diff --git a/contentbank/contenttype/h5p/tests/content_h5p_test.php b/contentbank/contenttype/h5p/tests/content_h5p_test.php index 4c145c21244..a1b982f88ee 100644 --- a/contentbank/contenttype/h5p/tests/content_h5p_test.php +++ b/contentbank/contenttype/h5p/tests/content_h5p_test.php @@ -32,7 +32,7 @@ class content_h5p_test extends \advanced_testcase { * * @covers ::get_file */ - public function test_upload_file() { + public function test_upload_file(): void { $this->resetAfterTest(); // Create content. diff --git a/contentbank/contenttype/h5p/tests/contenttype_h5p_test.php b/contentbank/contenttype/h5p/tests/contenttype_h5p_test.php index 592072817ba..1d9a4424245 100644 --- a/contentbank/contenttype/h5p/tests/contenttype_h5p_test.php +++ b/contentbank/contenttype/h5p/tests/contenttype_h5p_test.php @@ -30,7 +30,7 @@ class contenttype_h5p_test extends \advanced_testcase { /** * Test the behaviour of delete_content(). */ - public function test_delete_content() { + public function test_delete_content(): void { global $CFG, $USER, $DB; $this->resetAfterTest(); @@ -73,7 +73,7 @@ class contenttype_h5p_test extends \advanced_testcase { * * @covers ::can_upload */ - public function test_can_upload() { + public function test_can_upload(): void { $this->resetAfterTest(); $systemcontext = \context_system::instance(); @@ -104,7 +104,7 @@ class contenttype_h5p_test extends \advanced_testcase { * * @covers ::get_icon */ - public function test_get_icon() { + public function test_get_icon(): void { global $CFG; $this->resetAfterTest(); @@ -146,7 +146,7 @@ class contenttype_h5p_test extends \advanced_testcase { * * @covers ::get_download_url */ - public function test_get_download_url() { + public function test_get_download_url(): void { global $CFG; $this->resetAfterTest(); diff --git a/contentbank/tests/content_test.php b/contentbank/tests/content_test.php index 9161c1d8729..a0dac533b6f 100644 --- a/contentbank/tests/content_test.php +++ b/contentbank/tests/content_test.php @@ -56,7 +56,7 @@ class content_test extends \advanced_testcase { * * @covers ::get_name */ - public function test_get_name() { + public function test_get_name(): void { $this->resetAfterTest(); // Create content. @@ -96,7 +96,7 @@ class content_test extends \advanced_testcase { * * @covers ::set_name */ - public function test_set_name(string $newname, string $expected) { + public function test_set_name(string $newname, string $expected): void { global $DB; $this->resetAfterTest(); @@ -125,7 +125,7 @@ class content_test extends \advanced_testcase { * * @covers ::get_content_type */ - public function test_get_content_type() { + public function test_get_content_type(): void { $this->resetAfterTest(); // Create content. @@ -143,7 +143,7 @@ class content_test extends \advanced_testcase { * * @covers ::set_configdata */ - public function test_configdata_changes() { + public function test_configdata_changes(): void { $this->resetAfterTest(); $configdata = "{img: 'icon.svg'}"; @@ -166,7 +166,7 @@ class content_test extends \advanced_testcase { * * @covers ::set_contextid */ - public function test_set_contextid() { + public function test_set_contextid(): void { $this->resetAfterTest(); $this->setAdminUser(); $context = context_system::instance(); @@ -197,7 +197,7 @@ class content_test extends \advanced_testcase { * * @covers ::set_visibility */ - public function test_set_visibility() { + public function test_set_visibility(): void { $this->resetAfterTest(); $this->setAdminUser(); $context = context_system::instance(); @@ -333,7 +333,7 @@ class content_test extends \advanced_testcase { * * @covers ::is_view_allowed */ - public function test_is_view_allowed() { + public function test_is_view_allowed(): void { $this->resetAfterTest(); $this->setAdminUser(); $context = context_system::instance(); @@ -371,7 +371,7 @@ class content_test extends \advanced_testcase { * * @covers ::get_uses */ - public function test_get_uses() { + public function test_get_uses(): void { $this->resetAfterTest(); $this->setAdminUser(); $context = context_system::instance(); diff --git a/contentbank/tests/contentbank_test.php b/contentbank/tests/contentbank_test.php index 6291c2ae70e..2efb13eef28 100644 --- a/contentbank/tests/contentbank_test.php +++ b/contentbank/tests/contentbank_test.php @@ -81,7 +81,7 @@ class contentbank_test extends advanced_testcase { * * @covers ::get_extension */ - public function test_get_extension(string $filename, string $expected) { + public function test_get_extension(string $filename, string $expected): void { $this->resetAfterTest(); $cb = new contentbank(); @@ -112,7 +112,7 @@ class contentbank_test extends advanced_testcase { * * @covers ::load_context_supported_extensions */ - public function test_get_extension_supporter_for_admins(array $supporters, string $extension, string $expected) { + public function test_get_extension_supporter_for_admins(array $supporters, string $extension, string $expected): void { $this->resetAfterTest(); $cb = new contentbank(); @@ -136,7 +136,7 @@ class contentbank_test extends advanced_testcase { * * @covers ::load_context_supported_extensions */ - public function test_get_extension_supporter_for_users(array $supporters, string $extension, string $expected) { + public function test_get_extension_supporter_for_users(array $supporters, string $extension, string $expected): void { $this->resetAfterTest(); $cb = new contentbank(); @@ -161,7 +161,7 @@ class contentbank_test extends advanced_testcase { * * @covers ::load_context_supported_extensions */ - public function test_get_extension_supporter_for_teachers(array $supporters, string $extension, string $expected) { + public function test_get_extension_supporter_for_teachers(array $supporters, string $extension, string $expected): void { $this->resetAfterTest(); $cb = new contentbank(); @@ -187,7 +187,7 @@ class contentbank_test extends advanced_testcase { * * @covers ::get_extension_supporter */ - public function test_get_extension_supporter(array $supporters, string $extension, string $expected) { + public function test_get_extension_supporter(array $supporters, string $extension, string $expected): void { $this->resetAfterTest(); $cb = new contentbank(); @@ -361,7 +361,7 @@ class contentbank_test extends advanced_testcase { * * @covers ::create_content_from_file */ - public function test_create_content_from_file() { + public function test_create_content_from_file(): void { global $USER, $CFG; $this->resetAfterTest(); @@ -395,7 +395,7 @@ class contentbank_test extends advanced_testcase { * * @covers ::delete_contents */ - public function test_delete_contents() { + public function test_delete_contents(): void { global $DB; $this->resetAfterTest(); @@ -444,7 +444,7 @@ class contentbank_test extends advanced_testcase { * * @covers ::delete_contents */ - public function test_delete_contents_for_empty_contentbank() { + public function test_delete_contents_for_empty_contentbank(): void { $this->resetAfterTest(); $cb = new \core_contentbank\contentbank(); @@ -467,7 +467,7 @@ class contentbank_test extends advanced_testcase { * * @covers ::move_contents */ - public function test_move_contents() { + public function test_move_contents(): void { global $DB; $this->resetAfterTest(); @@ -500,7 +500,7 @@ class contentbank_test extends advanced_testcase { * * @covers ::move_contents */ - public function test_move_contents_for_empty_contentbank() { + public function test_move_contents_for_empty_contentbank(): void { $this->resetAfterTest(); $cb = new \core_contentbank\contentbank(); @@ -613,7 +613,7 @@ class contentbank_test extends advanced_testcase { * * @covers ::get_content_from_id */ - public function test_get_content_from_id() { + public function test_get_content_from_id(): void { $this->resetAfterTest(); $cb = new \core_contentbank\contentbank(); diff --git a/contentbank/tests/contenttype_test.php b/contentbank/tests/contenttype_test.php index ec53ef67f4a..5ef8ebf1c4d 100644 --- a/contentbank/tests/contenttype_test.php +++ b/contentbank/tests/contenttype_test.php @@ -66,7 +66,7 @@ class contenttype_test extends \advanced_testcase { * * @covers ::get_contenttype_name */ - public function test_get_contenttype_name() { + public function test_get_contenttype_name(): void { $this->resetAfterTest(); $systemcontext = \context_system::instance(); @@ -80,7 +80,7 @@ class contenttype_test extends \advanced_testcase { * * @covers ::get_plugin_name */ - public function test_get_plugin_name() { + public function test_get_plugin_name(): void { $this->resetAfterTest(); $systemcontext = \context_system::instance(); @@ -94,7 +94,7 @@ class contenttype_test extends \advanced_testcase { * * @covers ::get_icon */ - public function test_get_icon() { + public function test_get_icon(): void { global $CFG; $this->resetAfterTest(); @@ -115,7 +115,7 @@ class contenttype_test extends \advanced_testcase { * * @covers ::is_feature_supported */ - public function test_is_feature_supported() { + public function test_is_feature_supported(): void { $this->resetAfterTest(); $systemcontext = \context_system::instance(); @@ -130,7 +130,7 @@ class contenttype_test extends \advanced_testcase { * * @covers ::can_upload */ - public function test_no_upload_feature_supported() { + public function test_no_upload_feature_supported(): void { $this->resetAfterTest(); $systemcontext = \context_system::instance(); @@ -146,7 +146,7 @@ class contenttype_test extends \advanced_testcase { * * @covers ::create_content */ - public function test_create_empty_content() { + public function test_create_empty_content(): void { $this->resetAfterTest(); // Create empty content. @@ -164,7 +164,7 @@ class contenttype_test extends \advanced_testcase { * * @covers ::create_content */ - public function test_create_content() { + public function test_create_content(): void { $this->resetAfterTest(); // Create content. @@ -366,7 +366,7 @@ class contenttype_test extends \advanced_testcase { /** * Test the behaviour of can_delete(). */ - public function test_can_delete() { + public function test_can_delete(): void { global $DB; $this->resetAfterTest(); @@ -401,7 +401,7 @@ class contenttype_test extends \advanced_testcase { /** * Test the behaviour of delete_content(). */ - public function test_delete_content() { + public function test_delete_content(): void { global $DB; $this->resetAfterTest(); @@ -473,7 +473,7 @@ class contenttype_test extends \advanced_testcase { * * @covers ::rename_content */ - public function test_rename_content(string $newname, string $expected, bool $result) { + public function test_rename_content(string $newname, string $expected, bool $result): void { global $DB; $this->resetAfterTest(); @@ -502,7 +502,7 @@ class contenttype_test extends \advanced_testcase { /** * Test the behaviour of move_content(). */ - public function test_move_content() { + public function test_move_content(): void { global $DB; $this->resetAfterTest(); @@ -544,7 +544,7 @@ class contenttype_test extends \advanced_testcase { * * @covers ::can_manage */ - public function test_can_manage() { + public function test_can_manage(): void { global $DB, $USER; $this->resetAfterTest(); @@ -593,7 +593,7 @@ class contenttype_test extends \advanced_testcase { * * @covers ::can_download */ - public function test_can_download() { + public function test_can_download(): void { global $DB; $this->resetAfterTest(); @@ -627,7 +627,7 @@ class contenttype_test extends \advanced_testcase { * * @covers ::get_download_url */ - public function test_get_download_url() { + public function test_get_download_url(): void { global $CFG; $this->resetAfterTest(); @@ -659,7 +659,7 @@ class contenttype_test extends \advanced_testcase { * * @covers ::pluginfile */ - public function test_pluginfile() { + public function test_pluginfile(): void { $this->resetAfterTest(); $this->setAdminUser(); $systemcontext = context_system::instance(); diff --git a/contentbank/tests/external/copy_content_test.php b/contentbank/tests/external/copy_content_test.php index 7929e09d647..df9134abea2 100644 --- a/contentbank/tests/external/copy_content_test.php +++ b/contentbank/tests/external/copy_content_test.php @@ -40,7 +40,7 @@ class copy_content_test extends \externallib_advanced_testcase { * * @covers ::execute */ - public function test_copy_content_with_permission() { + public function test_copy_content_with_permission(): void { global $CFG, $DB; $this->resetAfterTest(); @@ -84,7 +84,7 @@ class copy_content_test extends \externallib_advanced_testcase { * * @covers ::execute */ - public function test_copy_content() { + public function test_copy_content(): void { global $CFG, $DB; $this->resetAfterTest(); diff --git a/contentbank/tests/external/delete_content_test.php b/contentbank/tests/external/delete_content_test.php index 5a0a890d141..f136d297eaf 100644 --- a/contentbank/tests/external/delete_content_test.php +++ b/contentbank/tests/external/delete_content_test.php @@ -48,7 +48,7 @@ class delete_content_test extends externallib_advanced_testcase { /** * Test the behaviour of delete_content(). */ - public function test_delete_content() { + public function test_delete_content(): void { global $DB; $this->resetAfterTest(); $records = []; diff --git a/contentbank/tests/external/rename_content_test.php b/contentbank/tests/external/rename_content_test.php index 2668b3f2e9c..45463c68e27 100644 --- a/contentbank/tests/external/rename_content_test.php +++ b/contentbank/tests/external/rename_content_test.php @@ -74,7 +74,7 @@ class rename_content_test extends \externallib_advanced_testcase { * * @covers ::execute */ - public function test_rename_content_with_permission(string $newname, string $expectedname, bool $expectedresult) { + public function test_rename_content_with_permission(string $newname, string $expectedname, bool $expectedresult): void { global $DB; $this->resetAfterTest(); @@ -111,7 +111,7 @@ class rename_content_test extends \externallib_advanced_testcase { * * @covers ::execute */ - public function test_rename_content_without_permission() { + public function test_rename_content_without_permission(): void { global $DB; $this->resetAfterTest(); diff --git a/contentbank/tests/privacy/provider_test.php b/contentbank/tests/privacy/provider_test.php index 61e31e93d3d..4464978af6d 100644 --- a/contentbank/tests/privacy/provider_test.php +++ b/contentbank/tests/privacy/provider_test.php @@ -56,7 +56,7 @@ class provider_test extends provider_testcase { /** * Test for provider::get_contexts_for_userid(). */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { $this->resetAfterTest(); // Setup scenario. @@ -88,7 +88,7 @@ class provider_test extends provider_testcase { /** * Test for provider::get_users_in_context(). */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { $this->resetAfterTest(); // Setup scenario. @@ -115,7 +115,7 @@ class provider_test extends provider_testcase { /** * Test for provider::test_export_user_data(). */ - public function test_export_user_data() { + public function test_export_user_data(): void { $this->resetAfterTest(); // Setup scenario. @@ -165,7 +165,7 @@ class provider_test extends provider_testcase { /** * Test for provider::delete_data_for_all_users_in_context(). */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; $this->resetAfterTest(); @@ -202,7 +202,7 @@ class provider_test extends provider_testcase { /** * Test for provider::test_delete_data_for_users(). */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { global $DB; $this->resetAfterTest(); @@ -265,7 +265,7 @@ class provider_test extends provider_testcase { /** * Test for provider::delete_data_for_user(). */ - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; $this->resetAfterTest(); @@ -366,7 +366,7 @@ class provider_test extends provider_testcase { /** * Ensure that export_user_preferences returns no data if the user has not visited any content bank. */ - public function test_export_user_preferences_no_pref() { + public function test_export_user_preferences_no_pref(): void { global $DB; $this->resetAfterTest(); @@ -382,7 +382,7 @@ class provider_test extends provider_testcase { /** * Test for provider::test_export_user_preferences(). */ - public function test_export_user_preferences() { + public function test_export_user_preferences(): void { global $DB; // Test setup. diff --git a/course/format/tests/base_test.php b/course/format/tests/base_test.php index 356db997aed..de5b7a5f253 100644 --- a/course/format/tests/base_test.php +++ b/course/format/tests/base_test.php @@ -42,7 +42,7 @@ class base_test extends advanced_testcase { * @author Jason den Dulk * @covers \core_courseformat */ - public function test_courseformat_saveandload() { + public function test_courseformat_saveandload(): void { $this->resetAfterTest(); $courseformatoptiondata = (object) [ @@ -65,7 +65,7 @@ class base_test extends advanced_testcase { $this->assertEqualsCanonicalizing($courseformatoptiondata, (object) $savedcourseformatoptiondata); } - public function test_available_hook() { + public function test_available_hook(): void { global $DB; $this->resetAfterTest(); @@ -184,7 +184,7 @@ class base_test extends advanced_testcase { /** * Test for supports_news() with a course format plugin that doesn't define 'news_items' in default blocks. */ - public function test_supports_news() { + public function test_supports_news(): void { $this->resetAfterTest(); $format = course_get_format((object)['format' => 'testformat']); $this->assertFalse($format->supports_news()); @@ -193,7 +193,7 @@ class base_test extends advanced_testcase { /** * Test for supports_news() for old course format plugins that defines 'news_items' in default blocks. */ - public function test_supports_news_legacy() { + public function test_supports_news_legacy(): void { $this->resetAfterTest(); $format = course_get_format((object)['format' => 'testlegacy']); $this->assertTrue($format->supports_news()); @@ -263,7 +263,7 @@ class base_test extends advanced_testcase { * @param string $result the expected result classname * @param bool $exception if the method will raise an exception */ - public function test_get_output_classname($find, $result, $exception) { + public function test_get_output_classname($find, $result, $exception): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(['format' => 'theunittest']); @@ -307,7 +307,7 @@ class base_test extends advanced_testcase { * * @covers ::get_sections_preferences */ - public function test_get_sections_preferences() { + public function test_get_sections_preferences(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator(); $course = $generator->create_course(); @@ -341,7 +341,7 @@ class base_test extends advanced_testcase { * * @covers ::set_sections_preference */ - public function test_set_sections_preference() { + public function test_set_sections_preference(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator(); $course = $generator->create_course(); @@ -466,7 +466,7 @@ class base_test extends advanced_testcase { * @dataProvider delete_format_data_provider * @param bool $usehook if it should use course_delete to trigger $format->delete_format_data as a hook */ - public function test_delete_format_data(bool $usehook) { + public function test_delete_format_data(bool $usehook): void { global $DB; $this->resetAfterTest(); @@ -532,7 +532,7 @@ class base_test extends advanced_testcase { * Test duplicate_section() * @covers ::duplicate_section */ - public function test_duplicate_section() { + public function test_duplicate_section(): void { global $DB; $this->setAdminUser(); @@ -645,7 +645,7 @@ class base_test extends advanced_testcase { * @param string $destination the reference of the destination section * @param string[] $order the references of the final section order */ - public function test_move_section_after(string $movesection, string $destination, array $order) { + public function test_move_section_after(string $movesection, string $destination, array $order): void { global $DB; $this->resetAfterTest(); @@ -770,7 +770,7 @@ class base_test extends advanced_testcase { * @param string $expectedparam the expected param to check * @param string $exception if an exception is expected */ - public function test_get_non_ajax_cm_action_url(string $action, string $expectedparam, bool $exception) { + public function test_get_non_ajax_cm_action_url(string $action, string $expectedparam, bool $exception): void { global $DB; $this->resetAfterTest(); diff --git a/course/format/tests/external/update_course_test.php b/course/format/tests/external/update_course_test.php index 754b355cafb..31150bbe90f 100644 --- a/course/format/tests/external/update_course_test.php +++ b/course/format/tests/external/update_course_test.php @@ -64,7 +64,7 @@ class update_course_test extends \externallib_advanced_testcase { array $expected, bool $expectexception, bool $assertdebug - ) { + ): void { $this->resetAfterTest(); @@ -184,7 +184,7 @@ class update_course_test extends \externallib_advanced_testcase { * @covers ::execute * */ - public function test_execute_wrong_courseid() { + public function test_execute_wrong_courseid(): void { $this->resetAfterTest(); @@ -206,7 +206,7 @@ class update_course_test extends \externallib_advanced_testcase { * * @covers ::execute */ - public function test_execute_target_params() { + public function test_execute_target_params(): void { $this->resetAfterTest(); diff --git a/course/format/tests/output/activitybadge_test.php b/course/format/tests/output/activitybadge_test.php index b20e955b24b..7ea2910d848 100644 --- a/course/format/tests/output/activitybadge_test.php +++ b/course/format/tests/output/activitybadge_test.php @@ -35,7 +35,7 @@ class activitybadge_test extends \advanced_testcase { * @covers ::export_for_template * @covers ::create_instance */ - public function test_activitybadge_export_for_template() { + public function test_activitybadge_export_for_template(): void { $this->resetAfterTest(); $this->setAdminUser(); diff --git a/course/format/tests/output/local/state/cm_test.php b/course/format/tests/output/local/state/cm_test.php index 7c4a99d9e12..ddf82e28a92 100644 --- a/course/format/tests/output/local/state/cm_test.php +++ b/course/format/tests/output/local/state/cm_test.php @@ -58,7 +58,7 @@ class cm_test extends \advanced_testcase { bool $hasavailability = false, bool $available = false, bool $expected = false - ) { + ): void { $data = $this->setup_hasrestrictions_scenario($format, $rolename, $hasavailability, $available); // Get the cm state. diff --git a/course/format/tests/output/local/state/section_test.php b/course/format/tests/output/local/state/section_test.php index 3cbc0e33946..2cd0566a898 100644 --- a/course/format/tests/output/local/state/section_test.php +++ b/course/format/tests/output/local/state/section_test.php @@ -58,7 +58,7 @@ class section_test extends \advanced_testcase { bool $hasavailability = false, bool $available = false, bool $expected = false - ) { + ): void { $data = $this->setup_hasrestrictions_scenario($format, $rolename, $hasavailability, $available); // Get the cm state. diff --git a/course/format/tests/output/local/state/state_test.php b/course/format/tests/output/local/state/state_test.php index fb6df56c108..c364f7cbe53 100644 --- a/course/format/tests/output/local/state/state_test.php +++ b/course/format/tests/output/local/state/state_test.php @@ -45,7 +45,7 @@ class state_test extends \advanced_testcase { * * @param string $format The course format of the course where the method will be executed. */ - public function test_state(string $format = 'topics') { + public function test_state(string $format = 'topics'): void { global $PAGE; $this->resetAfterTest(); diff --git a/course/format/tests/privacy/provider_test.php b/course/format/tests/privacy/provider_test.php index ada7676399e..1aba69e6af1 100644 --- a/course/format/tests/privacy/provider_test.php +++ b/course/format/tests/privacy/provider_test.php @@ -32,7 +32,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::test_export_user_preferences(). */ - public function test_export_user_preferences() { + public function test_export_user_preferences(): void { $this->resetAfterTest(); // Test setup. diff --git a/course/format/tests/stateactions_test.php b/course/format/tests/stateactions_test.php index bf79fb09a41..1479592d28c 100644 --- a/course/format/tests/stateactions_test.php +++ b/course/format/tests/stateactions_test.php @@ -897,7 +897,7 @@ class stateactions_test extends \advanced_testcase { bool $validcms = true, string $role = 'admin', bool $expectedexception = false - ) { + ): void { $this->resetAfterTest(); // Create a course with 3 sections. diff --git a/course/format/topics/tests/format_topics_test.php b/course/format/topics/tests/format_topics_test.php index 0d10c4346c7..0d0ff0b6edf 100644 --- a/course/format/topics/tests/format_topics_test.php +++ b/course/format/topics/tests/format_topics_test.php @@ -38,7 +38,7 @@ class format_topics_test extends \advanced_testcase { * * @return void */ - public function test_get_section_name() { + public function test_get_section_name(): void { global $DB; $this->resetAfterTest(true); @@ -64,7 +64,7 @@ class format_topics_test extends \advanced_testcase { * * @return void */ - public function test_get_section_name_customised() { + public function test_get_section_name_customised(): void { global $DB; $this->resetAfterTest(true); @@ -98,7 +98,7 @@ class format_topics_test extends \advanced_testcase { * * @return void */ - public function test_get_default_section_name() { + public function test_get_default_section_name(): void { global $DB; $this->resetAfterTest(true); @@ -129,7 +129,7 @@ class format_topics_test extends \advanced_testcase { * * @return void */ - public function test_update_inplace_editable() { + public function test_update_inplace_editable(): void { global $CFG, $DB, $PAGE; require_once($CFG->dirroot . '/lib/external/externallib.php'); @@ -164,7 +164,7 @@ class format_topics_test extends \advanced_testcase { * * @return void */ - public function test_inplace_editable() { + public function test_inplace_editable(): void { global $DB, $PAGE; $this->resetAfterTest(); @@ -198,7 +198,7 @@ class format_topics_test extends \advanced_testcase { * * @return void */ - public function test_default_course_enddate() { + public function test_default_course_enddate(): void { global $CFG, $DB; $this->resetAfterTest(true); diff --git a/course/format/weeks/tests/format_weeks_test.php b/course/format/weeks/tests/format_weeks_test.php index 49979ce6959..9110482f340 100644 --- a/course/format/weeks/tests/format_weeks_test.php +++ b/course/format/weeks/tests/format_weeks_test.php @@ -36,7 +36,7 @@ class format_weeks_test extends \advanced_testcase { /** * Tests for format_weeks::get_section_name method with default section names. */ - public function test_get_section_name() { + public function test_get_section_name(): void { global $DB; $this->resetAfterTest(true); @@ -60,7 +60,7 @@ class format_weeks_test extends \advanced_testcase { /** * Tests for format_weeks::get_section_name method with modified section names. */ - public function test_get_section_name_customised() { + public function test_get_section_name_customised(): void { global $DB; $this->resetAfterTest(true); @@ -92,7 +92,7 @@ class format_weeks_test extends \advanced_testcase { /** * Tests for format_weeks::get_default_section_name. */ - public function test_get_default_section_name() { + public function test_get_default_section_name(): void { global $DB; $this->resetAfterTest(true); @@ -127,7 +127,7 @@ class format_weeks_test extends \advanced_testcase { /** * Test web service updating section name */ - public function test_update_inplace_editable() { + public function test_update_inplace_editable(): void { global $CFG, $DB, $PAGE; require_once($CFG->dirroot . '/lib/external/externallib.php'); @@ -160,7 +160,7 @@ class format_weeks_test extends \advanced_testcase { /** * Test callback updating section name */ - public function test_inplace_editable() { + public function test_inplace_editable(): void { global $CFG, $DB, $PAGE; $this->resetAfterTest(); @@ -194,7 +194,7 @@ class format_weeks_test extends \advanced_testcase { * * @return void */ - public function test_default_course_enddate() { + public function test_default_course_enddate(): void { global $CFG, $DB, $PAGE; $this->resetAfterTest(true); diff --git a/course/format/weeks/tests/observer_test.php b/course/format/weeks/tests/observer_test.php index 4ab42703a63..ada26d82c15 100644 --- a/course/format/weeks/tests/observer_test.php +++ b/course/format/weeks/tests/observer_test.php @@ -35,7 +35,7 @@ class observer_test extends \advanced_testcase { /** * Tests when we update a course with automatic end date set. */ - public function test_course_updated_with_automatic_end_date() { + public function test_course_updated_with_automatic_end_date(): void { global $DB; // Generate a course with some sections. @@ -64,7 +64,7 @@ class observer_test extends \advanced_testcase { /** * Tests when we update a course with automatic end date set but no actual change is made. */ - public function test_course_updated_with_automatic_end_date_no_change() { + public function test_course_updated_with_automatic_end_date_no_change(): void { global $DB; // Generate a course with some sections. @@ -90,7 +90,7 @@ class observer_test extends \advanced_testcase { /** * Tests when we update a course without automatic end date set. */ - public function test_course_updated_without_automatic_end_date() { + public function test_course_updated_without_automatic_end_date(): void { global $DB; // Generate a course with some sections. @@ -117,7 +117,7 @@ class observer_test extends \advanced_testcase { /** * Tests when we adding a course section with automatic end date set. */ - public function test_course_section_created_with_automatic_end_date() { + public function test_course_section_created_with_automatic_end_date(): void { global $DB; $numsections = 6; @@ -143,7 +143,7 @@ class observer_test extends \advanced_testcase { /** * Tests when we update a course without automatic end date set. */ - public function test_create_section_without_automatic_end_date() { + public function test_create_section_without_automatic_end_date(): void { global $DB; // Generate a course with some sections. @@ -175,7 +175,7 @@ class observer_test extends \advanced_testcase { /** * Tests when we deleting a course section with automatic end date set. */ - public function test_course_section_deleted_with_automatic_end_date() { + public function test_course_section_deleted_with_automatic_end_date(): void { global $DB; // Generate a course with some sections. diff --git a/course/tests/analytics/indicators_test.php b/course/tests/analytics/indicators_test.php index 7a1baab8bf1..b80a13f9663 100644 --- a/course/tests/analytics/indicators_test.php +++ b/course/tests/analytics/indicators_test.php @@ -38,7 +38,7 @@ class indicators_test extends \advanced_testcase { * * @return void */ - public function test_no_teacher() { + public function test_no_teacher(): void { global $DB; $this->resetAfterTest(true); @@ -77,7 +77,7 @@ class indicators_test extends \advanced_testcase { * * @return void */ - public function test_completion_enabled() { + public function test_completion_enabled(): void { global $DB; $this->resetAfterTest(true); @@ -145,7 +145,7 @@ class indicators_test extends \advanced_testcase { * * @return void */ - public function test_potential_cognitive() { + public function test_potential_cognitive(): void { global $DB; $this->resetAfterTest(true); @@ -230,7 +230,7 @@ class indicators_test extends \advanced_testcase { * * @return void */ - public function test_potential_social() { + public function test_potential_social(): void { global $DB; $this->resetAfterTest(true); @@ -313,7 +313,7 @@ class indicators_test extends \advanced_testcase { * * @return void */ - public function test_activities_due() { + public function test_activities_due(): void { global $DB; $this->resetAfterTest(true); diff --git a/course/tests/backup/restore_test.php b/course/tests/backup/restore_test.php index e364957740c..26ebb90dc31 100644 --- a/course/tests/backup/restore_test.php +++ b/course/tests/backup/restore_test.php @@ -202,7 +202,7 @@ class restore_test extends \advanced_testcase { return $this->async_restore_course($backupid, 0, $userid, 0); } - public function test_async_restore_existing_idnumber_in_new_course() { + public function test_async_restore_existing_idnumber_in_new_course(): void { $this->resetAfterTest(); $dg = $this->getDataGenerator(); @@ -214,7 +214,7 @@ class restore_test extends \advanced_testcase { $this->assertEquals('', $c2->idnumber); } - public function test_async_restore_course_info_in_existing_course() { + public function test_async_restore_course_info_in_existing_course(): void { global $DB; $this->resetAfterTest(); $dg = $this->getDataGenerator(); @@ -250,7 +250,7 @@ class restore_test extends \advanced_testcase { $this->assertEquals($chat2->chattime, $restoredchat2->chattime); } - public function test_async_restore_course_info_in_existing_course_delete_first() { + public function test_async_restore_course_info_in_existing_course_delete_first(): void { global $DB; $this->resetAfterTest(); $dg = $this->getDataGenerator(); @@ -281,7 +281,7 @@ class restore_test extends \advanced_testcase { $this->assertEmpty($restoredchat2); } - public function test_restore_existing_idnumber_in_new_course() { + public function test_restore_existing_idnumber_in_new_course(): void { $this->resetAfterTest(); $dg = $this->getDataGenerator(); @@ -293,7 +293,7 @@ class restore_test extends \advanced_testcase { $this->assertEquals('', $c2->idnumber); } - public function test_restore_non_existing_idnumber_in_new_course() { + public function test_restore_non_existing_idnumber_in_new_course(): void { global $DB; $this->resetAfterTest(); @@ -309,7 +309,7 @@ class restore_test extends \advanced_testcase { $this->assertEquals('ABC', $c2->idnumber); } - public function test_restore_existing_idnumber_in_existing_course() { + public function test_restore_existing_idnumber_in_existing_course(): void { global $DB; $this->resetAfterTest(); @@ -326,7 +326,7 @@ class restore_test extends \advanced_testcase { $this->assertEquals('ABC', $c1->idnumber); } - public function test_restore_non_existing_idnumber_in_existing_course() { + public function test_restore_non_existing_idnumber_in_existing_course(): void { global $DB; $this->resetAfterTest(); @@ -343,7 +343,7 @@ class restore_test extends \advanced_testcase { $this->assertEquals('ABC', $c2->idnumber); } - public function test_restore_idnumber_in_existing_course_without_permissions() { + public function test_restore_idnumber_in_existing_course_without_permissions(): void { global $DB; $this->resetAfterTest(); $dg = $this->getDataGenerator(); @@ -367,7 +367,7 @@ class restore_test extends \advanced_testcase { $this->assertEquals('DEF', $c2->idnumber); } - public function test_restore_course_info_in_new_course() { + public function test_restore_course_info_in_new_course(): void { global $DB; $this->resetAfterTest(); $dg = $this->getDataGenerator(); @@ -423,7 +423,7 @@ class restore_test extends \advanced_testcase { $events[0]->get_description()); } - public function test_restore_course_info_in_existing_course() { + public function test_restore_course_info_in_existing_course(): void { global $DB; $this->resetAfterTest(); $dg = $this->getDataGenerator(); @@ -459,7 +459,7 @@ class restore_test extends \advanced_testcase { $this->assertEquals($chat2->chattime, $restoredchat2->chattime); } - public function test_restore_course_shortname_in_existing_course_without_permissions() { + public function test_restore_course_shortname_in_existing_course_without_permissions(): void { global $DB; $this->resetAfterTest(); $dg = $this->getDataGenerator(); @@ -483,7 +483,7 @@ class restore_test extends \advanced_testcase { $this->assertEquals(FORMAT_MOODLE, $restored->summaryformat); } - public function test_restore_course_fullname_in_existing_course_without_permissions() { + public function test_restore_course_fullname_in_existing_course_without_permissions(): void { global $DB; $this->resetAfterTest(); $dg = $this->getDataGenerator(); @@ -507,7 +507,7 @@ class restore_test extends \advanced_testcase { $this->assertEquals(FORMAT_MOODLE, $restored->summaryformat); } - public function test_restore_course_summary_in_existing_course_without_permissions() { + public function test_restore_course_summary_in_existing_course_without_permissions(): void { global $DB; $this->resetAfterTest(); $dg = $this->getDataGenerator(); @@ -531,7 +531,7 @@ class restore_test extends \advanced_testcase { $this->assertEquals($c2->summaryformat, $restored->summaryformat); } - public function test_restore_course_startdate_in_existing_course_without_permissions() { + public function test_restore_course_startdate_in_existing_course_without_permissions(): void { global $DB; $this->resetAfterTest(); $dg = $this->getDataGenerator(); @@ -577,7 +577,7 @@ class restore_test extends \advanced_testcase { * @author Matthew Hilton * @covers \core_courseformat */ - public function test_restore_editor_courseformat() { + public function test_restore_editor_courseformat(): void { $this->resetAfterTest(); // Setup user with restore permissions. diff --git a/course/tests/backup_restore_activity_test.php b/course/tests/backup_restore_activity_test.php index 9759649927e..8ccae92b447 100644 --- a/course/tests/backup_restore_activity_test.php +++ b/course/tests/backup_restore_activity_test.php @@ -39,7 +39,7 @@ class backup_restore_activity_test extends \advanced_testcase { /** * Test that duplicating a page preserves the lang setting. */ - public function test_duplicating_page_preserves_lang() { + public function test_duplicating_page_preserves_lang(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -57,7 +57,7 @@ class backup_restore_activity_test extends \advanced_testcase { $this->assertEquals('en', $newpagecm->lang); } - public function test_activity_forced_lang_not_restored_without_capability() { + public function test_activity_forced_lang_not_restored_without_capability(): void { global $DB; $this->resetAfterTest(); $this->setAdminUser(); diff --git a/course/tests/category_hooks_test.php b/course/tests/category_hooks_test.php index b68de7a7eeb..ae80fa283c7 100644 --- a/course/tests/category_hooks_test.php +++ b/course/tests/category_hooks_test.php @@ -77,7 +77,7 @@ class category_hooks_test extends \advanced_testcase { return $mockcategory; } - public function test_can_course_category_delete_hook() { + public function test_can_course_category_delete_hook(): void { $category1 = \core_course_category::create(array('name' => 'Cat1')); $category2 = \core_course_category::create(array('name' => 'Cat2', 'parent' => $category1->id)); $category3 = \core_course_category::create(array('name' => 'Cat3')); @@ -104,7 +104,7 @@ class category_hooks_test extends \advanced_testcase { $this->assertSame($mockcategory2, $argument); } - public function test_can_course_category_delete_move_hook() { + public function test_can_course_category_delete_move_hook(): void { $category1 = \core_course_category::create(array('name' => 'Cat1')); $category2 = \core_course_category::create(array('name' => 'Cat2', 'parent' => $category1->id)); $category3 = \core_course_category::create(array('name' => 'Cat3')); @@ -136,7 +136,7 @@ class category_hooks_test extends \advanced_testcase { $this->assertEquals($category3->id, $argument->id); } - public function test_pre_course_category_delete_hook() { + public function test_pre_course_category_delete_hook(): void { $category1 = \core_course_category::create(array('name' => 'Cat1')); $category2 = \core_course_category::create(array('name' => 'Cat2', 'parent' => $category1->id)); @@ -152,7 +152,7 @@ class category_hooks_test extends \advanced_testcase { $this->assertEquals($mockcategory2->get_db_record(), $argument); } - public function test_pre_course_category_delete_move_hook() { + public function test_pre_course_category_delete_move_hook(): void { $category1 = \core_course_category::create(array('name' => 'Cat1')); $category2 = \core_course_category::create(array('name' => 'Cat2', 'parent' => $category1->id)); $category3 = \core_course_category::create(array('name' => 'Cat3')); @@ -178,7 +178,7 @@ class category_hooks_test extends \advanced_testcase { $this->assertEquals($category3->id, $argument->id); } - public function test_get_course_category_contents_hook() { + public function test_get_course_category_contents_hook(): void { $category1 = \core_course_category::create(array('name' => 'Cat1')); $category2 = \core_course_category::create(array('name' => 'Cat2', 'parent' => $category1->id)); diff --git a/course/tests/category_test.php b/course/tests/category_test.php index 85443ba9d84..c1ec14a6997 100644 --- a/course/tests/category_test.php +++ b/course/tests/category_test.php @@ -69,7 +69,7 @@ class category_test extends \advanced_testcase { accesslib_clear_all_caches_for_unit_testing(); } - public function test_create_coursecat() { + public function test_create_coursecat(): void { // Create the category. $data = new \stdClass(); $data->name = 'aaa'; @@ -96,7 +96,7 @@ class category_test extends \advanced_testcase { $this->assertGreaterThan($category2->sortorder, $category3->sortorder); } - public function test_name_idnumber_exceptions() { + public function test_name_idnumber_exceptions(): void { try { core_course_category::create(array('name' => '')); $this->fail('Missing category name exception expected in core_course_category::create'); @@ -140,7 +140,7 @@ class category_test extends \advanced_testcase { } } - public function test_visibility() { + public function test_visibility(): void { $this->assign_capability('moodle/category:viewhiddencategories'); $this->assign_capability('moodle/category:manage'); @@ -208,7 +208,7 @@ class category_test extends \advanced_testcase { $this->assertEquals(1, $category5->visibleold); } - public function test_hierarchy() { + public function test_hierarchy(): void { $this->assign_capability('moodle/category:viewhiddencategories'); $this->assign_capability('moodle/category:manage'); @@ -241,7 +241,7 @@ class category_test extends \advanced_testcase { $this->assertEquals(array(), array_keys($category2->get_children())); } - public function test_update() { + public function test_update(): void { $category1 = core_course_category::create(array('name' => 'Cat1')); $timecreated = $category1->timemodified; $this->assertSame('Cat1', $category1->name); @@ -259,7 +259,7 @@ class category_test extends \advanced_testcase { $this->assertGreaterThan($timecreated, $category1->timemodified); } - public function test_delete() { + public function test_delete(): void { global $DB; $this->assign_capability('moodle/category:manage'); @@ -336,7 +336,7 @@ class category_test extends \advanced_testcase { (array)$DB->get_record_sql('SELECT id, category from {course} where id <> ?', array(SITEID))); } - public function test_get_children() { + public function test_get_children(): void { $category1 = core_course_category::create(array('name' => 'Cat1')); $category2 = core_course_category::create(array('name' => 'Cat2', 'parent' => $category1->id)); $category3 = core_course_category::create(array('name' => 'Cat3', 'parent' => $category1->id, 'visible' => 0)); @@ -380,7 +380,7 @@ class category_test extends \advanced_testcase { /** * Test the get_all_children_ids function. */ - public function test_get_all_children_ids() { + public function test_get_all_children_ids(): void { $category1 = core_course_category::create(array('name' => 'Cat1')); $category2 = core_course_category::create(array('name' => 'Cat2')); $category11 = core_course_category::create(array('name' => 'Cat11', 'parent' => $category1->id)); @@ -411,7 +411,7 @@ class category_test extends \advanced_testcase { /** * Test the countall function */ - public function test_count_all() { + public function test_count_all(): void { global $DB; // Dont assume there is just one. An add-on might create a category as part of the install. $numcategories = $DB->count_records('course_categories'); @@ -435,7 +435,7 @@ class category_test extends \advanced_testcase { /** * Test the is_simple_site function */ - public function test_is_simple_site() { + public function test_is_simple_site(): void { // By default site has one category and is considered simple. $this->assertEquals(true, core_course_category::is_simple_site()); $default = core_course_category::get_default(); @@ -452,7 +452,7 @@ class category_test extends \advanced_testcase { /** * Test a categories ability to resort courses. */ - public function test_resort_courses() { + public function test_resort_courses(): void { $this->resetAfterTest(true); $generator = $this->getDataGenerator(); $category = $generator->create_category(); @@ -512,7 +512,7 @@ class category_test extends \advanced_testcase { $this->assertSame($expected, array_keys($coursecat->get_courses())); } - public function test_get_search_courses() { + public function test_get_search_courses(): void { global $DB; $cat1 = core_course_category::create(array('name' => 'Cat1')); @@ -622,7 +622,7 @@ class category_test extends \advanced_testcase { ])); } - public function test_course_contacts() { + public function test_course_contacts(): void { global $DB, $CFG; set_config('coursecontactduplicates', false); @@ -907,7 +907,7 @@ class category_test extends \advanced_testcase { $CFG->coursecontact = $oldcoursecontact; } - public function test_overview_files() { + public function test_overview_files(): void { global $CFG; $this->setAdminUser(); $cat1 = core_course_category::create(array('name' => 'Cat1')); @@ -998,7 +998,7 @@ class category_test extends \advanced_testcase { $this->assertEquals(1, count($courses[$c5->id]->get_course_overviewfiles())); } - public function test_get_nested_name() { + public function test_get_nested_name(): void { $cat1name = 'Cat1'; $cat2name = 'Cat2'; $cat3name = 'Cat3'; @@ -1014,7 +1014,7 @@ class category_test extends \advanced_testcase { $this->assertEquals("{$cat1name} / {$cat2name} / {$cat4name}", $category4->get_nested_name(false)); } - public function test_coursecat_is_uservisible() { + public function test_coursecat_is_uservisible(): void { global $USER; // Create category 1 as visible. @@ -1044,7 +1044,7 @@ class category_test extends \advanced_testcase { $this->assertFalse($category2->is_uservisible()); } - public function test_current_user_coursecat_get() { + public function test_current_user_coursecat_get(): void { $this->assign_capability('moodle/category:viewhiddencategories'); // Create category 1 as visible. @@ -1065,7 +1065,7 @@ class category_test extends \advanced_testcase { core_course_category::get($category2->id); } - public function test_another_user_coursecat_get() { + public function test_another_user_coursecat_get(): void { global $USER; $this->assign_capability('moodle/category:viewhiddencategories'); @@ -1115,7 +1115,7 @@ class category_test extends \advanced_testcase { /** * This test ensures that is the list of courses in a category can be retrieved while a course is being deleted. */ - public function test_get_courses_during_delete() { + public function test_get_courses_during_delete(): void { global $DB; $category = self::getDataGenerator()->create_category(); $course = self::getDataGenerator()->create_course(['category' => $category->id]); @@ -1383,7 +1383,7 @@ class category_test extends \advanced_testcase { * * @coversNothing */ - public function test_make_category_list_context() { + public function test_make_category_list_context(): void { global $DB; // Ensure that the category list is empty. $DB->delete_records('course_categories'); diff --git a/course/tests/content_item_readonly_repository_test.php b/course/tests/content_item_readonly_repository_test.php index 681851bd5ce..84406076c09 100644 --- a/course/tests/content_item_readonly_repository_test.php +++ b/course/tests/content_item_readonly_repository_test.php @@ -39,7 +39,7 @@ class content_item_readonly_repository_test extends \advanced_testcase { /** * Test the repository method, find_all_for_course(). */ - public function test_find_all_for_course() { + public function test_find_all_for_course(): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -57,7 +57,7 @@ class content_item_readonly_repository_test extends \advanced_testcase { /** * Test verifying that content items for hidden modules are not returned. */ - public function test_find_all_for_course_hidden_module() { + public function test_find_all_for_course_hidden_module(): void { $this->resetAfterTest(); global $DB; diff --git a/course/tests/content_item_test.php b/course/tests/content_item_test.php index 3a86bc3488c..95db8b36bfa 100644 --- a/course/tests/content_item_test.php +++ b/course/tests/content_item_test.php @@ -36,7 +36,7 @@ class content_item_test extends \advanced_testcase { /** * Test the content_item class. */ - public function test_content_item() { + public function test_content_item(): void { $this->resetAfterTest(); $contentitem = new content_item(22, 'Item name', new lang_string_title('modulename', 'mod_assign'), @@ -58,7 +58,7 @@ class content_item_test extends \advanced_testcase { /** * Test confirming that plugins can return custom titles for a content item. */ - public function test_content_item_custom_string_title() { + public function test_content_item_custom_string_title(): void { $this->resetAfterTest(); $contentitem = new content_item(22, 'Item name', new string_title('My custom string'), diff --git a/course/tests/course_delete_modules_test.php b/course/tests/course_delete_modules_test.php index 28e241f6cf8..1164f0964fe 100644 --- a/course/tests/course_delete_modules_test.php +++ b/course/tests/course_delete_modules_test.php @@ -37,7 +37,7 @@ class course_delete_modules_test extends \advanced_testcase { /** * Test to have a no message for usual process. */ - public function test_delete_module_execution() { + public function test_delete_module_execution(): void { $this->resetAfterTest(); // Generate test data. diff --git a/course/tests/course_format_function_test.php b/course/tests/course_format_function_test.php index 6e89eca9786..7be6e7c5b89 100644 --- a/course/tests/course_format_function_test.php +++ b/course/tests/course_format_function_test.php @@ -37,7 +37,7 @@ class course_format_function_test extends \basic_testcase { * Tests clean_param_if_not_null function * @covers ::clean_param_if_not_null */ - public function test_clean_param_if_not_null() { + public function test_clean_param_if_not_null(): void { $this->assertNull(clean_param_if_not_null(null)); $n = '3x'; $this->assertEquals(clean_param($n, PARAM_INT), clean_param_if_not_null($n, PARAM_INT)); @@ -53,7 +53,7 @@ class course_format_function_test extends \basic_testcase { * Tests contract_value function * @covers ::contract_value */ - public function test_contract_value() { + public function test_contract_value(): void { $input = [ 'abc' => '

All together Now

', 'abcformat' => '1', @@ -80,7 +80,7 @@ class course_format_function_test extends \basic_testcase { * Tests expand_value function * @covers ::expand_value */ - public function test_expand_value() { + public function test_expand_value(): void { $input = [ 'abc_editor' => [ 'text' => '

All together Now

', 'format' => '1' ], 'jolly' => 'Roger', diff --git a/course/tests/course_image_cache_test.php b/course/tests/course_image_cache_test.php index 59b697a5b97..2a825e7dad0 100644 --- a/course/tests/course_image_cache_test.php +++ b/course/tests/course_image_cache_test.php @@ -86,7 +86,7 @@ class course_image_cache_test extends \advanced_testcase { /** * Test exception if try to get an image for non existing course. */ - public function test_getting_data_if_course_is_not_exist() { + public function test_getting_data_if_course_is_not_exist(): void { $this->expectException('dml_missing_record_exception'); $this->expectExceptionMessageMatches("/Can't find data record in database table course./"); $this->assertFalse(\cache::make('core', 'course_image')->get(999)); @@ -95,7 +95,7 @@ class course_image_cache_test extends \advanced_testcase { /** * Test get_image_url_from_overview_files when no summary files in the course. */ - public function test_get_image_url_from_overview_files_return_null_if_no_summary_files_in_the_course() { + public function test_get_image_url_from_overview_files_return_null_if_no_summary_files_in_the_course(): void { $method = new ReflectionMethod(course_image::class, 'get_image_url_from_overview_files'); $cache = course_image::get_instance_for_cache(new cache_definition()); @@ -107,7 +107,7 @@ class course_image_cache_test extends \advanced_testcase { /** * Test get_image_url_from_overview_files when no summary images in the course. */ - public function test_get_image_url_from_overview_files_returns_null_if_no_summary_images_in_the_course() { + public function test_get_image_url_from_overview_files_returns_null_if_no_summary_images_in_the_course(): void { $method = new ReflectionMethod(course_image::class, 'get_image_url_from_overview_files'); $cache = course_image::get_instance_for_cache(new cache_definition()); @@ -120,7 +120,7 @@ class course_image_cache_test extends \advanced_testcase { /** * Test get_image_url_from_overview_files when no summary images in the course. */ - public function test_get_image_url_from_overview_files_returns_url_if_there_is_a_summary_image() { + public function test_get_image_url_from_overview_files_returns_url_if_there_is_a_summary_image(): void { $method = new ReflectionMethod(course_image::class, 'get_image_url_from_overview_files'); $cache = course_image::get_instance_for_cache(new cache_definition()); @@ -134,7 +134,7 @@ class course_image_cache_test extends \advanced_testcase { /** * Test get_image_url_from_overview_files when several summary images in the course. */ - public function test_get_image_url_from_overview_files_returns_url_of_the_first_image_if_there_are_many_summary_images() { + public function test_get_image_url_from_overview_files_returns_url_of_the_first_image_if_there_are_many_summary_images(): void { $method = new ReflectionMethod(course_image::class, 'get_image_url_from_overview_files'); $cache = course_image::get_instance_for_cache(new cache_definition()); @@ -152,7 +152,7 @@ class course_image_cache_test extends \advanced_testcase { /** * Test get_image_url_from_overview_files when several summary files in the course. */ - public function test_get_image_url_from_overview_files_returns_url_of_the_first_image_if_there_are_many_summary_files() { + public function test_get_image_url_from_overview_files_returns_url_of_the_first_image_if_there_are_many_summary_files(): void { $method = new ReflectionMethod(course_image::class, 'get_image_url_from_overview_files'); $cache = course_image::get_instance_for_cache(new cache_definition()); diff --git a/course/tests/course_summary_exporter_test.php b/course/tests/course_summary_exporter_test.php index b9fb8f120d0..e95c7a77783 100644 --- a/course/tests/course_summary_exporter_test.php +++ b/course/tests/course_summary_exporter_test.php @@ -34,7 +34,7 @@ class course_summary_exporter_test extends \advanced_testcase { /** * Test that if no course overview images uploaded get_course_image returns false. */ - public function test_get_course_image_when_no_overview_images_uploaded() { + public function test_get_course_image_when_no_overview_images_uploaded(): void { $this->resetAfterTest(true); $this->setAdminUser(); $course = $this->getDataGenerator()->create_course(); @@ -45,7 +45,7 @@ class course_summary_exporter_test extends \advanced_testcase { /** * Test that if course overview images uploaded get_course_image returns an image URL. */ - public function test_get_course_image_when_overview_images_are_uploaded() { + public function test_get_course_image_when_overview_images_are_uploaded(): void { global $USER; $this->resetAfterTest(true); diff --git a/course/tests/courselib_test.php b/course/tests/courselib_test.php index a03babf7a4f..7fdaf62202f 100644 --- a/course/tests/courselib_test.php +++ b/course/tests/courselib_test.php @@ -399,7 +399,7 @@ class courselib_test extends advanced_testcase { /** * Test create_module() for multiple modules defined in the $modules array (first declaration of the function). */ - public function test_create_module() { + public function test_create_module(): void { // Add the module name you want to test here. // Create the match MODULENAME_create_set_values() and MODULENAME_create_run_asserts(). $modules = array('forum', 'assign'); @@ -412,7 +412,7 @@ class courselib_test extends advanced_testcase { /** * Test update_module() for multiple modules defined in the $modules array (first declaration of the function). */ - public function test_update_module() { + public function test_update_module(): void { // Add the module name you want to test here. // Create the match MODULENAME_update_set_values() and MODULENAME_update_run_asserts(). $modules = array('forum'); @@ -649,7 +649,7 @@ class courselib_test extends advanced_testcase { /** * Test the create_course function */ - public function test_create_course() { + public function test_create_course(): void { global $DB; $this->resetAfterTest(true); $defaultcategory = $DB->get_field_select('course_categories', "MIN(id)", "parent=0"); @@ -693,7 +693,7 @@ class courselib_test extends advanced_testcase { } } - public function test_create_course_with_generator() { + public function test_create_course_with_generator(): void { global $DB; $this->resetAfterTest(true); $course = $this->getDataGenerator()->create_course(); @@ -703,7 +703,7 @@ class courselib_test extends advanced_testcase { $this->assertTrue($sectioncreated); } - public function test_create_course_sections() { + public function test_create_course_sections(): void { global $DB; $this->resetAfterTest(true); @@ -729,7 +729,7 @@ class courselib_test extends advanced_testcase { $this->assertEquals(range(0, $numsections + 1), $sectionscreated); } - public function test_update_course() { + public function test_update_course(): void { global $DB; $this->resetAfterTest(); @@ -776,7 +776,7 @@ class courselib_test extends advanced_testcase { } } - public function test_update_course_section_time_modified() { + public function test_update_course_section_time_modified(): void { global $DB; $this->resetAfterTest(); @@ -827,7 +827,7 @@ class courselib_test extends advanced_testcase { * @param int $mode The value for the course's 'relativedatesmode' field. * @param int $expectedvalue The expected value of the 'relativedatesmode' field after course creation. */ - public function test_relative_dates_mode_for_course_creation($setting, $mode, $expectedvalue) { + public function test_relative_dates_mode_for_course_creation($setting, $mode, $expectedvalue): void { global $DB; $this->resetAfterTest(); @@ -845,7 +845,7 @@ class courselib_test extends advanced_testcase { /** * Test update_course by attempting to change the relative dates mode. */ - public function test_relative_dates_mode_for_course_update() { + public function test_relative_dates_mode_for_course_update(): void { global $DB; $this->resetAfterTest(); @@ -864,7 +864,7 @@ class courselib_test extends advanced_testcase { $this->assertEquals(1, $relativedatesmode); } - public function test_course_add_cm_to_section() { + public function test_course_add_cm_to_section(): void { global $DB; $this->resetAfterTest(true); @@ -915,7 +915,7 @@ class courselib_test extends advanced_testcase { $this->assertEquals($cmids[3] . ',' . $cmids[2], $sequence); } - public function test_reorder_sections() { + public function test_reorder_sections(): void { global $DB; $this->resetAfterTest(true); @@ -953,7 +953,7 @@ class courselib_test extends advanced_testcase { $this->assertFalse($neworder); } - public function test_move_section_down() { + public function test_move_section_down(): void { global $DB; $this->resetAfterTest(true); @@ -982,7 +982,7 @@ class courselib_test extends advanced_testcase { $this->assertEquals($oldsections[6], $sections[6]); } - public function test_move_section_up() { + public function test_move_section_up(): void { global $DB; $this->resetAfterTest(true); @@ -1011,7 +1011,7 @@ class courselib_test extends advanced_testcase { $this->assertEquals($oldsections[6], $sections[4]); } - public function test_move_section_marker() { + public function test_move_section_marker(): void { global $DB; $this->resetAfterTest(true); @@ -1129,7 +1129,7 @@ class courselib_test extends advanced_testcase { $this->assertEquals(4, $sectionmovequerycount); } - public function test_course_can_delete_section() { + public function test_course_can_delete_section(): void { global $DB; $this->resetAfterTest(true); @@ -1191,7 +1191,7 @@ class courselib_test extends advanced_testcase { $this->assertFalse(course_can_delete_section($coursesingleactivity, 1)); } - public function test_course_delete_section() { + public function test_course_delete_section(): void { global $DB; $this->resetAfterTest(true); @@ -1245,7 +1245,7 @@ class courselib_test extends advanced_testcase { $this->assertFalse(course_get_format($course)->is_section_current(1)); } - public function test_get_course_display_name_for_list() { + public function test_get_course_display_name_for_list(): void { global $CFG; $this->resetAfterTest(true); @@ -1258,7 +1258,7 @@ class courselib_test extends advanced_testcase { $this->assertEquals('FROG101 Introduction to pond life', get_course_display_name_for_list($course)); } - public function test_move_module_in_course() { + public function test_move_module_in_course(): void { global $DB; $this->resetAfterTest(true); @@ -1321,7 +1321,7 @@ class courselib_test extends advanced_testcase { $this->assertTrue(in_array($cm->id, $newsequences)); } - public function test_module_visibility() { + public function test_module_visibility(): void { $this->setAdminUser(); $this->resetAfterTest(true); @@ -1391,7 +1391,7 @@ class courselib_test extends advanced_testcase { } } - public function test_section_visibility_events() { + public function test_section_visibility_events(): void { $this->setAdminUser(); $this->resetAfterTest(true); @@ -1417,7 +1417,7 @@ class courselib_test extends advanced_testcase { $sink->close(); } - public function test_section_visibility() { + public function test_section_visibility(): void { $this->setAdminUser(); $this->resetAfterTest(true); @@ -1521,7 +1521,7 @@ class courselib_test extends advanced_testcase { } } - public function test_course_page_type_list() { + public function test_course_page_type_list(): void { global $DB; $this->resetAfterTest(true); @@ -1573,7 +1573,7 @@ class courselib_test extends advanced_testcase { $this->assertEquals($pagetypelist, $testpagetypelist1); } - public function test_compare_activities_by_time_desc() { + public function test_compare_activities_by_time_desc(): void { // Let's create some test data. $activitiesivities = array(); @@ -1617,7 +1617,7 @@ class courselib_test extends advanced_testcase { } } - public function test_compare_activities_by_time_asc() { + public function test_compare_activities_by_time_asc(): void { // Let's create some test data. $activities = array(); @@ -1666,7 +1666,7 @@ class courselib_test extends advanced_testcase { * verifies that the course/module visiblity seettings are * retained. */ - public function test_moveto_module_between_hidden_sections() { + public function test_moveto_module_between_hidden_sections(): void { global $DB; $this->resetAfterTest(true); @@ -1748,7 +1748,7 @@ class courselib_test extends advanced_testcase { * Tests moving a module around in the same section. moveto_module() * is called this way in modduplicate. */ - public function test_moveto_module_in_same_section() { + public function test_moveto_module_in_same_section(): void { global $DB; $this->resetAfterTest(true); @@ -1792,7 +1792,7 @@ class courselib_test extends advanced_testcase { * @param array $options The options for the module creation * @dataProvider provider_course_delete_module */ - public function test_course_delete_module($type, $options) { + public function test_course_delete_module($type, $options): void { global $DB; $this->resetAfterTest(true); @@ -1899,7 +1899,7 @@ class courselib_test extends advanced_testcase { /** * Test that triggering a course_created event works as expected. */ - public function test_course_created_event() { + public function test_course_created_event(): void { global $DB; $this->resetAfterTest(); @@ -1964,7 +1964,7 @@ class courselib_test extends advanced_testcase { /** * Test that triggering a course_updated event works as expected. */ - public function test_course_updated_event() { + public function test_course_updated_event(): void { global $DB; $this->resetAfterTest(); @@ -2033,7 +2033,7 @@ class courselib_test extends advanced_testcase { /** * Test that triggering a course_updated event logs changes. */ - public function test_course_updated_event_with_changes() { + public function test_course_updated_event_with_changes(): void { global $DB; $this->resetAfterTest(); @@ -2066,7 +2066,7 @@ class courselib_test extends advanced_testcase { /** * Test that triggering a course_deleted event works as expected. */ - public function test_course_deleted_event() { + public function test_course_deleted_event(): void { $this->resetAfterTest(); // Create the course. @@ -2107,7 +2107,7 @@ class courselib_test extends advanced_testcase { /** * Test that triggering a course_content_deleted event works as expected. */ - public function test_course_content_deleted_event() { + public function test_course_content_deleted_event(): void { global $DB; $this->resetAfterTest(); @@ -2144,7 +2144,7 @@ class courselib_test extends advanced_testcase { /** * Test that triggering a course_category_deleted event works as expected. */ - public function test_course_category_deleted_event() { + public function test_course_category_deleted_event(): void { $this->resetAfterTest(); // Create a category. @@ -2211,7 +2211,7 @@ class courselib_test extends advanced_testcase { /** * Test that triggering a course_backup_created event works as expected. */ - public function test_course_backup_created_event() { + public function test_course_backup_created_event(): void { global $CFG; // Get the necessary files to perform backup and restore. @@ -2257,7 +2257,7 @@ class courselib_test extends advanced_testcase { /** * Test that triggering a course_restored event works as expected. */ - public function test_course_restored_event() { + public function test_course_restored_event(): void { global $CFG; // Get the necessary files to perform backup and restore. @@ -2314,7 +2314,7 @@ class courselib_test extends advanced_testcase { /** * Test that triggering a course_section_updated event works as expected. */ - public function test_course_section_updated_event() { + public function test_course_section_updated_event(): void { global $DB; $this->resetAfterTest(); @@ -2369,7 +2369,7 @@ class courselib_test extends advanced_testcase { /** * Test that triggering a course_section_deleted event works as expected. */ - public function test_course_section_deleted_event() { + public function test_course_section_deleted_event(): void { global $USER, $DB; $this->resetAfterTest(); $sink = $this->redirectEvents(); @@ -2399,7 +2399,7 @@ class courselib_test extends advanced_testcase { $this->assertEventContextNotUsed($event); } - public function test_course_integrity_check() { + public function test_course_integrity_check(): void { global $DB; $this->resetAfterTest(true); @@ -2522,7 +2522,7 @@ class courselib_test extends advanced_testcase { /** * Tests for event related to course module creation. */ - public function test_course_module_created_event() { + public function test_course_module_created_event(): void { global $USER; $this->resetAfterTest(); @@ -2580,7 +2580,7 @@ class courselib_test extends advanced_testcase { /** * Tests for event validations related to course module creation. */ - public function test_course_module_created_event_exceptions() { + public function test_course_module_created_event_exceptions(): void { $this->resetAfterTest(); @@ -2645,7 +2645,7 @@ class courselib_test extends advanced_testcase { /** * Tests for event related to course module updates. */ - public function test_course_module_updated_event() { + public function test_course_module_updated_event(): void { global $USER, $DB; $this->resetAfterTest(); @@ -2680,7 +2680,7 @@ class courselib_test extends advanced_testcase { /** * Tests for create_from_cm method. */ - public function test_course_module_create_from_cm() { + public function test_course_module_create_from_cm(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -2718,7 +2718,7 @@ class courselib_test extends advanced_testcase { /** * Tests for event validations related to course module update. */ - public function test_course_module_updated_event_exceptions() { + public function test_course_module_updated_event_exceptions(): void { $this->resetAfterTest(); @@ -2783,7 +2783,7 @@ class courselib_test extends advanced_testcase { /** * Tests for event related to course module delete. */ - public function test_course_module_deleted_event() { + public function test_course_module_deleted_event(): void { global $USER, $DB; $this->resetAfterTest(); @@ -2808,7 +2808,7 @@ class courselib_test extends advanced_testcase { /** * Tests for event validations related to course module deletion. */ - public function test_course_module_deleted_event_exceptions() { + public function test_course_module_deleted_event_exceptions(): void { $this->resetAfterTest(); @@ -2878,7 +2878,7 @@ class courselib_test extends advanced_testcase { /** * Test course move after course. */ - public function test_course_change_sortorder_after_course() { + public function test_course_change_sortorder_after_course(): void { global $DB; $this->resetAfterTest(true); @@ -2927,7 +2927,7 @@ class courselib_test extends advanced_testcase { /** * Tests changing the visibility of a course. */ - public function test_course_change_visibility() { + public function test_course_change_visibility(): void { global $DB; $this->resetAfterTest(true); @@ -2953,7 +2953,7 @@ class courselib_test extends advanced_testcase { /** * Tests moving the course up and down by one. */ - public function test_course_change_sortorder_by_one() { + public function test_course_change_sortorder_by_one(): void { global $DB; $this->resetAfterTest(true); @@ -3009,7 +3009,7 @@ class courselib_test extends advanced_testcase { $this->assertEquals(array_keys($dbcourses), array_keys($courses)); } - public function test_view_resources_list() { + public function test_view_resources_list(): void { $this->resetAfterTest(); $course = self::getDataGenerator()->create_course(); @@ -3034,7 +3034,7 @@ class courselib_test extends advanced_testcase { /** * Test duplicate_module() */ - public function test_duplicate_module() { + public function test_duplicate_module(): void { $this->setAdminUser(); $this->resetAfterTest(); $course = self::getDataGenerator()->create_course(); @@ -3062,7 +3062,7 @@ class courselib_test extends advanced_testcase { * are present but set to an empty tree, availability is set to null in * database. */ - public function test_empty_availability_settings() { + public function test_empty_availability_settings(): void { global $DB; $this->setAdminUser(); $this->resetAfterTest(); @@ -3099,7 +3099,7 @@ class courselib_test extends advanced_testcase { /** * Test update_inplace_editable() */ - public function test_update_module_name_inplace() { + public function test_update_module_name_inplace(): void { global $CFG, $DB, $PAGE; require_once($CFG->dirroot . '/lib/external/externallib.php'); @@ -3129,7 +3129,7 @@ class courselib_test extends advanced_testcase { /** * Testing function course_get_tagged_course_modules - search tagged course modules */ - public function test_course_get_tagged_course_modules() { + public function test_course_get_tagged_course_modules(): void { global $DB; $this->resetAfterTest(); $course3 = $this->getDataGenerator()->create_course(); @@ -3242,7 +3242,7 @@ class courselib_test extends advanced_testcase { /** * Test course_get_user_navigation_options for frontpage. */ - public function test_course_get_user_navigation_options_for_frontpage() { + public function test_course_get_user_navigation_options_for_frontpage(): void { global $CFG, $SITE, $DB; $this->resetAfterTest(); $context = context_system::instance(); @@ -3285,7 +3285,7 @@ class courselib_test extends advanced_testcase { /** * Test course_get_user_navigation_options for managers in a normal course. */ - public function test_course_get_user_navigation_options_for_managers() { + public function test_course_get_user_navigation_options_for_managers(): void { global $CFG; $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -3302,7 +3302,7 @@ class courselib_test extends advanced_testcase { /** * Test course_get_user_navigation_options for students in a normal course. */ - public function test_course_get_user_navigation_options_for_students() { + public function test_course_get_user_navigation_options_for_students(): void { global $DB, $CFG; $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -3343,7 +3343,7 @@ class courselib_test extends advanced_testcase { /** * Test course_get_user_administration_options for frontpage. */ - public function test_course_get_user_administration_options_for_frontpage() { + public function test_course_get_user_administration_options_for_frontpage(): void { global $CFG, $SITE; $this->resetAfterTest(); $course = clone $SITE; @@ -3376,7 +3376,7 @@ class courselib_test extends advanced_testcase { /** * Test course_get_user_administration_options for managers in a normal course. */ - public function test_course_get_user_administration_options_for_managers() { + public function test_course_get_user_administration_options_for_managers(): void { global $CFG; $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -3402,7 +3402,7 @@ class courselib_test extends advanced_testcase { /** * Test course_get_user_administration_options for students in a normal course. */ - public function test_course_get_user_administration_options_for_students() { + public function test_course_get_user_administration_options_for_students(): void { global $DB, $CFG; $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -3437,7 +3437,7 @@ class courselib_test extends advanced_testcase { /** * Test test_update_course_frontpage_category. */ - public function test_update_course_frontpage_category() { + public function test_update_course_frontpage_category(): void { // Fetch front page course. $course = get_course(SITEID); // Test update information on front page course. @@ -3455,7 +3455,7 @@ class courselib_test extends advanced_testcase { * @param int $enddate * @param string $errorcode */ - public function test_course_enddate($startdate, $enddate, $errorcode) { + public function test_course_enddate($startdate, $enddate, $errorcode): void { $this->resetAfterTest(true); @@ -3519,7 +3519,7 @@ class courselib_test extends advanced_testcase { * @param int $resultingstartdate * @param int $resultingenddate */ - public function test_course_dates_reset($startdate, $enddate, $resetstartdate, $resetenddate, $resultingstartdate, $resultingenddate) { + public function test_course_dates_reset($startdate, $enddate, $resetstartdate, $resetenddate, $resultingstartdate, $resultingenddate): void { global $CFG, $DB; require_once($CFG->dirroot.'/completion/criteria/completion_criteria_date.php'); @@ -3630,7 +3630,7 @@ class courselib_test extends advanced_testcase { * - with reset_roles_overrides enabled * - with selective role unenrolments */ - public function test_course_roles_reset() { + public function test_course_roles_reset(): void { global $DB; $this->resetAfterTest(true); @@ -3694,7 +3694,7 @@ class courselib_test extends advanced_testcase { $this->assertEmpty($usersroles); } - public function test_course_check_module_updates_since() { + public function test_course_check_module_updates_since(): void { global $CFG, $DB, $USER; require_once($CFG->dirroot . '/mod/glossary/lib.php'); require_once($CFG->dirroot . '/rating/lib.php'); @@ -3782,7 +3782,7 @@ class courselib_test extends advanced_testcase { $this->assertFalse($updates->outcomes->updated); } - public function test_async_module_deletion_hook_implemented() { + public function test_async_module_deletion_hook_implemented(): void { // Async module deletion depends on the 'true' being returned by at least one plugin implementing the hook, // 'course_module_adhoc_deletion_recommended'. In core, is implemented by the course recyclebin, which will only return // true if the recyclebin plugin is enabled. To make sure async deletion occurs, this test force-enables the recyclebin. @@ -3849,7 +3849,7 @@ class courselib_test extends advanced_testcase { $this->assertEmpty($cmcount); } - public function test_async_module_deletion_hook_not_implemented() { + public function test_async_module_deletion_hook_not_implemented(): void { // Only proceed if we are sure that no plugin is going to advocate async removal of a module. I.e. no plugin returns // 'true' from the 'course_module_adhoc_deletion_recommended' hook. // In the case of core, only recyclebin implements this hook, and it will only return true if enabled, so disable it. @@ -3904,7 +3904,7 @@ class courselib_test extends advanced_testcase { $this->assertEmpty($cmcount); } - public function test_async_section_deletion_hook_implemented() { + public function test_async_section_deletion_hook_implemented(): void { // Async section deletion (provided section contains modules), depends on the 'true' being returned by at least one plugin // implementing the 'course_module_adhoc_deletion_recommended' hook. In core, is implemented by the course recyclebin, // which will only return true if the plugin is enabled. To make sure async deletion occurs, this test enables recyclebin. @@ -3992,7 +3992,7 @@ class courselib_test extends advanced_testcase { $this->assertEquals(3, $count); } - public function test_async_section_deletion_hook_not_implemented() { + public function test_async_section_deletion_hook_not_implemented(): void { // If no plugins advocate async removal, then normal synchronous removal will take place. // Only proceed if we are sure that no plugin is going to advocate async removal of a module. I.e. no plugin returns // 'true' from the 'course_module_adhoc_deletion_recommended' hook. @@ -4068,7 +4068,7 @@ class courselib_test extends advanced_testcase { $this->assertEquals(2, $count); } - public function test_classify_course_for_timeline() { + public function test_classify_course_for_timeline(): void { global $DB, $CFG; require_once($CFG->dirroot.'/completion/criteria/completion_criteria_self.php'); @@ -4129,7 +4129,7 @@ class courselib_test extends advanced_testcase { /** * Test the main function for updating all calendar events for a module. */ - public function test_course_module_calendar_event_update_process() { + public function test_course_module_calendar_event_update_process(): void { global $DB; $this->resetAfterTest(); @@ -4190,7 +4190,7 @@ class courselib_test extends advanced_testcase { /** * Test the higher level checks for updating calendar events for an instance. */ - public function test_course_module_update_calendar_events() { + public function test_course_module_update_calendar_events(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -4219,7 +4219,7 @@ class courselib_test extends advanced_testcase { /** * Test the higher level checks for updating calendar events for a module. */ - public function test_course_module_bulk_update_calendar_events() { + public function test_course_module_bulk_update_calendar_events(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -4247,7 +4247,7 @@ class courselib_test extends advanced_testcase { /** * Test that a student can view participants in a course they are enrolled in. */ - public function test_course_can_view_participants_as_student() { + public function test_course_can_view_participants_as_student(): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -4264,7 +4264,7 @@ class courselib_test extends advanced_testcase { /** * Test that a student in a course can not view participants on the site. */ - public function test_course_can_view_participants_as_student_on_site() { + public function test_course_can_view_participants_as_student_on_site(): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -4280,7 +4280,7 @@ class courselib_test extends advanced_testcase { /** * Test that an admin can view participants on the site. */ - public function test_course_can_view_participants_as_admin_on_site() { + public function test_course_can_view_participants_as_admin_on_site(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -4291,7 +4291,7 @@ class courselib_test extends advanced_testcase { /** * Test teachers can view participants in a course they are enrolled in. */ - public function test_course_can_view_participants_as_teacher() { + public function test_course_can_view_participants_as_teacher(): void { global $DB; $this->resetAfterTest(); @@ -4311,7 +4311,7 @@ class courselib_test extends advanced_testcase { /** * Check the teacher can still view the participants page without the 'viewparticipants' cap. */ - public function test_course_can_view_participants_as_teacher_without_view_participants_cap() { + public function test_course_can_view_participants_as_teacher_without_view_participants_cap(): void { global $DB; $this->resetAfterTest(); @@ -4335,7 +4335,7 @@ class courselib_test extends advanced_testcase { /** * Check the teacher can still view the participants page without the 'moodle/course:enrolreview' cap. */ - public function test_course_can_view_participants_as_teacher_without_enrol_review_cap() { + public function test_course_can_view_participants_as_teacher_without_enrol_review_cap(): void { global $DB; $this->resetAfterTest(); @@ -4359,7 +4359,7 @@ class courselib_test extends advanced_testcase { /** * Check the teacher can not view the participants page without the required caps. */ - public function test_course_can_view_participants_as_teacher_without_required_caps() { + public function test_course_can_view_participants_as_teacher_without_required_caps(): void { global $DB; $this->resetAfterTest(); @@ -4383,7 +4383,7 @@ class courselib_test extends advanced_testcase { /** * Check that an exception is not thrown if we can view the participants page. */ - public function test_course_require_view_participants() { + public function test_course_require_view_participants(): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -4400,7 +4400,7 @@ class courselib_test extends advanced_testcase { /** * Check that an exception is thrown if we can't view the participants page. */ - public function test_course_require_view_participants_as_student_on_site() { + public function test_course_require_view_participants_as_student_on_site(): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -4417,7 +4417,7 @@ class courselib_test extends advanced_testcase { /** * Testing the can_download_from_backup_filearea fn. */ - public function test_can_download_from_backup_filearea() { + public function test_can_download_from_backup_filearea(): void { global $DB; $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -5524,7 +5524,7 @@ class courselib_test extends advanced_testcase { /** * Testing core_course_core_calendar_get_valid_event_timestart_range when the course has no end date. */ - public function test_core_course_core_calendar_get_valid_event_timestart_range_no_enddate() { + public function test_core_course_core_calendar_get_valid_event_timestart_range_no_enddate(): void { global $CFG; require_once($CFG->dirroot . "/calendar/lib.php"); @@ -5549,7 +5549,7 @@ class courselib_test extends advanced_testcase { /** * Testing core_course_core_calendar_get_valid_event_timestart_range when the course has end date. */ - public function test_core_course_core_calendar_get_valid_event_timestart_range_with_enddate() { + public function test_core_course_core_calendar_get_valid_event_timestart_range_with_enddate(): void { global $CFG; require_once($CFG->dirroot . "/calendar/lib.php"); @@ -5574,7 +5574,7 @@ class courselib_test extends advanced_testcase { /** * Test the course_get_recent_courses function. */ - public function test_course_get_recent_courses() { + public function test_course_get_recent_courses(): void { global $DB; $this->resetAfterTest(); @@ -5663,7 +5663,7 @@ class courselib_test extends advanced_testcase { * @param string $sort The sort value * @param string $expectedexceptionmsg The expected exception message */ - public function test_course_get_recent_courses_sort_validation(string $sort, string $expectedexceptionmsg) { + public function test_course_get_recent_courses_sort_validation(string $sort, string $expectedexceptionmsg): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); @@ -5710,7 +5710,7 @@ class courselib_test extends advanced_testcase { /** * Test the course_get_recent_courses function. */ - public function test_course_get_recent_courses_with_guest() { + public function test_course_get_recent_courses_with_guest(): void { global $DB; $this->resetAfterTest(true); @@ -7029,7 +7029,7 @@ class courselib_test extends advanced_testcase { * Test that calling course_get_course_dates_for_user_ids multiple times in the * same request fill fetch the correct data for the user. */ - public function test_course_get_course_dates_for_user_ids_multiple_calls() { + public function test_course_get_course_dates_for_user_ids_multiple_calls(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator(); @@ -7083,7 +7083,7 @@ class courselib_test extends advanced_testcase { * @param bool $expected The expected result * @dataProvider provider_course_modules_pending_deletion */ - public function test_course_modules_pending_deletion(array $modules, int $indextodelete, bool $gradable, bool $expected) { + public function test_course_modules_pending_deletion(array $modules, int $indextodelete, bool $gradable, bool $expected): void { $this->resetAfterTest(); // Ensure recyclebin is enabled. @@ -7105,7 +7105,7 @@ class courselib_test extends advanced_testcase { /** * Tests for the course_request::can_request */ - public function test_can_request_course() { + public function test_can_request_course(): void { global $CFG, $DB; $this->resetAfterTest(); @@ -7169,7 +7169,7 @@ class courselib_test extends advanced_testcase { /** * Tests for the course_request::can_approve */ - public function test_can_approve_course_request() { + public function test_can_approve_course_request(): void { global $CFG; $this->resetAfterTest(); @@ -7211,7 +7211,7 @@ class courselib_test extends advanced_testcase { /** * Test the course allowed module method. */ - public function test_course_allowed_module() { + public function test_course_allowed_module(): void { $this->resetAfterTest(); global $DB; @@ -7233,7 +7233,7 @@ class courselib_test extends advanced_testcase { /** * Test the {@link average_number_of_participants()} function. */ - public function test_average_number_of_participants() { + public function test_average_number_of_participants(): void { global $DB; $this->resetAfterTest(true); @@ -7306,7 +7306,7 @@ class courselib_test extends advanced_testcase { /** * Test the set_downloadcontent() function. */ - public function test_set_downloadcontent() { + public function test_set_downloadcontent(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator(); diff --git a/course/tests/courserequest_test.php b/course/tests/courserequest_test.php index 6a8086b1bb3..b8130e83c58 100644 --- a/course/tests/courserequest_test.php +++ b/course/tests/courserequest_test.php @@ -33,7 +33,7 @@ require_once($CFG->dirroot.'/course/lib.php'); */ class courserequest_test extends \advanced_testcase { - public function test_create_request() { + public function test_create_request(): void { global $DB, $USER; $this->resetAfterTest(true); @@ -78,7 +78,7 @@ class courserequest_test extends \advanced_testcase { $this->assertEquals($cat1->id, $cr->category); } - public function test_approve_request() { + public function test_approve_request(): void { global $DB; $this->resetAfterTest(true); $this->preventResetByRollback(); @@ -139,7 +139,7 @@ class courserequest_test extends \advanced_testcase { $this->assertEquals($data->category, $course->category); } - public function test_reject_request() { + public function test_reject_request(): void { global $DB; $this->resetAfterTest(true); $this->preventResetByRollback(); diff --git a/course/tests/customfield_test.php b/course/tests/customfield_test.php index ff0f5cb85cc..454dd32cda7 100644 --- a/course/tests/customfield_test.php +++ b/course/tests/customfield_test.php @@ -53,7 +53,7 @@ class customfield_test extends \advanced_testcase { /** * Test creating course with customfields and retrieving them */ - public function test_create_course() { + public function test_create_course(): void { global $DB; $dg = $this->getDataGenerator(); @@ -135,7 +135,7 @@ class customfield_test extends \advanced_testcase { /** * Test backup and restore of custom fields */ - public function test_restore_customfields() { + public function test_restore_customfields(): void { global $USER; $dg = $this->getDataGenerator(); @@ -155,7 +155,7 @@ class customfield_test extends \advanced_testcase { /** * Delete a category that has fields and the fields have data. */ - public function test_delete_category() { + public function test_delete_category(): void { global $DB; $dg = $this->getDataGenerator(); diff --git a/course/tests/event/events_test.php b/course/tests/event/events_test.php index 49dd6ebc038..ea373a9943b 100644 --- a/course/tests/event/events_test.php +++ b/course/tests/event/events_test.php @@ -48,7 +48,7 @@ class events_test extends \advanced_testcase { * There is no external API for viewing a category, so the unit test will simply * create and trigger the event and ensure data is returned as expected. */ - public function test_course_category_viewed_event() { + public function test_course_category_viewed_event(): void { // Create a category. $category = $this->getDataGenerator()->create_category(); @@ -80,7 +80,7 @@ class events_test extends \advanced_testcase { * There is no external API for viewing course information so the unit test will simply * create and trigger the event and ensure data is returned as expected. */ - public function test_course_information_viewed_event() { + public function test_course_information_viewed_event(): void { // Create a course. $data = new \stdClass(); @@ -113,7 +113,7 @@ class events_test extends \advanced_testcase { * There is no external API for viewing course information so the unit test will simply * create and trigger the event and ensure data is returned as expected. */ - public function test_courses_searched_event() { + public function test_courses_searched_event(): void { // Trigger an event: courses searched. $search = 'mysearch'; diff --git a/course/tests/exporters_content_item_test.php b/course/tests/exporters_content_item_test.php index 307a2e7ec36..084f37df45f 100644 --- a/course/tests/exporters_content_item_test.php +++ b/course/tests/exporters_content_item_test.php @@ -40,7 +40,7 @@ class exporters_content_item_test extends \advanced_testcase { /** * Test confirming a content_item can be exported for a course. */ - public function test_export_course_content_item() { + public function test_export_course_content_item(): void { $this->resetAfterTest(); global $PAGE; @@ -79,7 +79,7 @@ class exporters_content_item_test extends \advanced_testcase { /** * Test that legacy items (with id of -1) are exported correctly. */ - public function test_export_course_content_item_legacy() { + public function test_export_course_content_item_legacy(): void { $this->resetAfterTest(); global $PAGE; diff --git a/course/tests/exporters_content_items_test.php b/course/tests/exporters_content_items_test.php index 9563a7e587f..65e1c6e7927 100644 --- a/course/tests/exporters_content_items_test.php +++ b/course/tests/exporters_content_items_test.php @@ -40,7 +40,7 @@ class exporters_content_items_test extends \advanced_testcase { /** * Test confirming the collection of content_items can be exported for a course. */ - public function test_export_course_content_items() { + public function test_export_course_content_items(): void { $this->resetAfterTest(); global $PAGE; diff --git a/course/tests/externallib_test.php b/course/tests/externallib_test.php index 167204aec47..a560bf98674 100644 --- a/course/tests/externallib_test.php +++ b/course/tests/externallib_test.php @@ -53,7 +53,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test create_categories */ - public function test_create_categories() { + public function test_create_categories(): void { global $DB; @@ -131,7 +131,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test delete categories */ - public function test_delete_categories() { + public function test_delete_categories(): void { global $DB; $this->resetAfterTest(true); @@ -174,7 +174,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get categories */ - public function test_get_categories() { + public function test_get_categories(): void { global $DB; $this->resetAfterTest(true); @@ -305,7 +305,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test update_categories */ - public function test_update_categories() { + public function test_update_categories(): void { global $DB; $this->resetAfterTest(true); @@ -368,7 +368,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test update_categories method for moving categories */ - public function test_update_categories_moving() { + public function test_update_categories_moving(): void { $this->resetAfterTest(); // Create data. @@ -406,7 +406,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test create_courses numsections */ - public function test_create_course_numsections() { + public function test_create_course_numsections(): void { global $DB; $this->resetAfterTest(true); @@ -440,7 +440,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test create_courses */ - public function test_create_courses() { + public function test_create_courses(): void { global $DB; $this->resetAfterTest(true); @@ -677,7 +677,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test delete_courses */ - public function test_delete_courses() { + public function test_delete_courses(): void { global $DB, $USER; $this->resetAfterTest(true); @@ -737,7 +737,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_courses */ - public function test_get_courses() { + public function test_get_courses(): void { global $DB; $this->resetAfterTest(true); @@ -897,7 +897,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_courses without capability */ - public function test_get_courses_without_capability() { + public function test_get_courses_without_capability(): void { $this->resetAfterTest(true); $course1 = $this->getDataGenerator()->create_course(); @@ -923,7 +923,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test search_courses */ - public function test_search_courses() { + public function test_search_courses(): void { global $DB; @@ -1149,7 +1149,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_course_contents */ - public function test_get_course_contents() { + public function test_get_course_contents(): void { global $CFG; $this->resetAfterTest(true); @@ -1299,7 +1299,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_course_contents as student */ - public function test_get_course_contents_student() { + public function test_get_course_contents_student(): void { global $DB; $this->resetAfterTest(true); @@ -1347,7 +1347,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_course_contents excluding modules */ - public function test_get_course_contents_excluding_modules() { + public function test_get_course_contents_excluding_modules(): void { $this->resetAfterTest(true); list($course, $forumcm, $datacm, $pagecm, $labelcm, $urlcm) = $this->prepare_get_course_contents_test(); @@ -1365,7 +1365,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_course_contents excluding contents */ - public function test_get_course_contents_excluding_contents() { + public function test_get_course_contents_excluding_contents(): void { $this->resetAfterTest(true); list($course, $forumcm, $datacm, $pagecm, $labelcm, $urlcm) = $this->prepare_get_course_contents_test(); @@ -1389,7 +1389,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_course_contents filtering by section number */ - public function test_get_course_contents_section_number() { + public function test_get_course_contents_section_number(): void { $this->resetAfterTest(true); list($course, $forumcm, $datacm, $pagecm, $labelcm, $urlcm) = $this->prepare_get_course_contents_test(); @@ -1407,7 +1407,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_course_contents filtering by cmid */ - public function test_get_course_contents_cmid() { + public function test_get_course_contents_cmid(): void { $this->resetAfterTest(true); list($course, $forumcm, $datacm, $pagecm, $labelcm, $urlcm) = $this->prepare_get_course_contents_test(); @@ -1427,7 +1427,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_course_contents filtering by cmid and section */ - public function test_get_course_contents_section_cmid() { + public function test_get_course_contents_section_cmid(): void { $this->resetAfterTest(true); list($course, $forumcm, $datacm, $pagecm, $labelcm, $urlcm) = $this->prepare_get_course_contents_test(); @@ -1449,7 +1449,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_course_contents filtering by modname */ - public function test_get_course_contents_modname() { + public function test_get_course_contents_modname(): void { $this->resetAfterTest(true); list($course, $forumcm, $datacm, $pagecm, $labelcm, $urlcm) = $this->prepare_get_course_contents_test(); @@ -1468,7 +1468,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_course_contents filtering by modname */ - public function test_get_course_contents_modid() { + public function test_get_course_contents_modid(): void { $this->resetAfterTest(true); list($course, $forumcm, $datacm, $pagecm, $labelcm, $urlcm) = $this->prepare_get_course_contents_test(); @@ -1491,7 +1491,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_course_contents returns downloadcontent value. */ - public function test_get_course_contents_downloadcontent() { + public function test_get_course_contents_downloadcontent(): void { $this->resetAfterTest(); list($course, $forumcm, $datacm, $pagecm, $labelcm, $urlcm) = $this->prepare_get_course_contents_test(); @@ -1513,7 +1513,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get course contents completion manual */ - public function test_get_course_contents_completion_manual() { + public function test_get_course_contents_completion_manual(): void { global $CFG; $this->resetAfterTest(true); @@ -1587,7 +1587,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get course contents completion auto */ - public function test_get_course_contents_completion_auto() { + public function test_get_course_contents_completion_auto(): void { global $CFG; $this->resetAfterTest(true); @@ -1629,7 +1629,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test mimetype is returned for resources with showtype set. */ - public function test_get_course_contents_including_mimetype() { + public function test_get_course_contents_including_mimetype(): void { $this->resetAfterTest(true); $this->setAdminUser(); @@ -1651,7 +1651,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test contents info is returned. */ - public function test_get_course_contents_contentsinfo() { + public function test_get_course_contents_contentsinfo(): void { global $USER; $this->resetAfterTest(true); @@ -1729,7 +1729,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_course_contents when hidden sections are displayed. */ - public function test_get_course_contents_hiddensections() { + public function test_get_course_contents_hiddensections(): void { global $DB; $this->resetAfterTest(true); @@ -1782,7 +1782,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get course contents dates. */ - public function test_get_course_contents_dates() { + public function test_get_course_contents_dates(): void { $this->resetAfterTest(true); $this->setAdminUser(); @@ -1835,7 +1835,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_course_contents for courses with invalid course format. */ - public function test_get_course_contents_invalid_format() { + public function test_get_course_contents_invalid_format(): void { global $DB; $this->resetAfterTest(); @@ -1852,7 +1852,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test duplicate_course */ - public function test_duplicate_course() { + public function test_duplicate_course(): void { $this->resetAfterTest(true); // Create one course with three modules. @@ -1898,7 +1898,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test update_courses */ - public function test_update_courses() { + public function test_update_courses(): void { global $DB, $CFG, $USER, $COURSE; // Get current $COURSE to be able to restore it later (defaults to $SITE). We need this @@ -2200,7 +2200,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test delete course_module. */ - public function test_delete_modules() { + public function test_delete_modules(): void { global $DB; // Ensure we reset the data after this test. @@ -2300,7 +2300,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test import_course into an empty course */ - public function test_import_course_empty() { + public function test_import_course_empty(): void { global $USER; $this->resetAfterTest(true); @@ -2347,7 +2347,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test import_course into an filled course */ - public function test_import_course_filled() { + public function test_import_course_filled(): void { global $USER; $this->resetAfterTest(true); @@ -2398,7 +2398,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test import_course with only blocks set to backup */ - public function test_import_course_blocksonly() { + public function test_import_course_blocksonly(): void { global $USER, $DB; $this->resetAfterTest(true); @@ -2439,7 +2439,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test import_course into an filled course, deleting content. */ - public function test_import_course_deletecontent() { + public function test_import_course_deletecontent(): void { global $USER; $this->resetAfterTest(true); @@ -2487,7 +2487,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Ensure import_course handles incorrect deletecontent option correctly. */ - public function test_import_course_invalid_deletecontent_option() { + public function test_import_course_invalid_deletecontent_option(): void { $this->resetAfterTest(true); $course1 = self::getDataGenerator()->create_course(); @@ -2502,7 +2502,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test view_course function */ - public function test_view_course() { + public function test_view_course(): void { $this->resetAfterTest(); @@ -2539,7 +2539,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_course_module */ - public function test_get_course_module() { + public function test_get_course_module(): void { global $DB; $this->resetAfterTest(true); @@ -2656,7 +2656,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_course_module_by_instance */ - public function test_get_course_module_by_instance() { + public function test_get_course_module_by_instance(): void { global $DB; $this->resetAfterTest(true); @@ -2729,7 +2729,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_user_navigation_options */ - public function test_get_user_navigation_options() { + public function test_get_user_navigation_options(): void { global $USER; $this->resetAfterTest(); @@ -2783,7 +2783,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_user_administration_options */ - public function test_get_user_administration_options() { + public function test_get_user_administration_options(): void { global $USER; $this->resetAfterTest(); @@ -2850,7 +2850,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_courses_by_fields */ - public function test_get_courses_by_field() { + public function test_get_courses_by_field(): void { global $DB, $USER; $this->resetAfterTest(true); @@ -3157,12 +3157,12 @@ class externallib_test extends externallib_advanced_testcase { $this->assertNotContains('communicationroomurl', $course); } - public function test_get_courses_by_field_invalid_field() { + public function test_get_courses_by_field_invalid_field(): void { $this->expectException('invalid_parameter_exception'); $result = core_course_external::get_courses_by_field('zyx', 'x'); } - public function test_get_courses_by_field_invalid_courses() { + public function test_get_courses_by_field_invalid_courses(): void { $result = core_course_external::get_courses_by_field('id', '-1'); $result = external_api::clean_returnvalue(core_course_external::get_courses_by_field_returns(), $result); $this->assertCount(0, $result['courses']); @@ -3171,7 +3171,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_courses_by_field_invalid_theme_and_lang */ - public function test_get_courses_by_field_invalid_theme_and_lang() { + public function test_get_courses_by_field_invalid_theme_and_lang(): void { $this->resetAfterTest(true); $this->setAdminUser(); @@ -3183,7 +3183,7 @@ class externallib_test extends externallib_advanced_testcase { } - public function test_check_updates() { + public function test_check_updates(): void { global $DB; $this->resetAfterTest(true); $this->setAdminUser(); @@ -3797,7 +3797,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test the get_recent_courses function. */ - public function test_get_recent_courses() { + public function test_get_recent_courses(): void { global $USER, $DB; $this->resetAfterTest(); @@ -3879,7 +3879,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get enrolled users by cmid function. */ - public function test_get_enrolled_users_by_cmid() { + public function test_get_enrolled_users_by_cmid(): void { global $PAGE; $this->resetAfterTest(true); @@ -4083,7 +4083,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test the web service returning course content items, specifically in case where the user can't manage activities. */ - public function test_get_course_content_items_no_permission_to_manage() { + public function test_get_course_content_items_no_permission_to_manage(): void { $this->resetAfterTest(); $course = self::getDataGenerator()->create_course(); @@ -4100,7 +4100,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test toggling the recommendation of an activity. */ - public function test_toggle_activity_recommendation() { + public function test_toggle_activity_recommendation(): void { global $CFG; $this->resetAfterTest(); diff --git a/course/tests/management_helper_test.php b/course/tests/management_helper_test.php index 66cd892a125..87a74ad5c5f 100644 --- a/course/tests/management_helper_test.php +++ b/course/tests/management_helper_test.php @@ -76,7 +76,7 @@ class management_helper_test extends \advanced_testcase { * In order to show/hide the user must have moodle/category:manage on the parent context. * In order to view hidden categories the user must have moodle/category:viewhiddencategories */ - public function test_action_category_hide_and_show() { + public function test_action_category_hide_and_show(): void { global $DB; $this->resetAfterTest(true); @@ -234,7 +234,7 @@ class management_helper_test extends \advanced_testcase { * * This mimics the logic of {@link test_action_category_hide_and_show()} */ - public function test_action_category_hide_and_show_by_id() { + public function test_action_category_hide_and_show_by_id(): void { global $DB; $this->resetAfterTest(true); @@ -389,7 +389,7 @@ class management_helper_test extends \advanced_testcase { /** * Test moving courses between categories. */ - public function test_action_category_move_courses_into() { + public function test_action_category_move_courses_into(): void { global $DB, $CFG; $this->resetAfterTest(true); @@ -524,7 +524,7 @@ class management_helper_test extends \advanced_testcase { /** * Test moving a categories up and down. */ - public function test_action_category_movedown_and_moveup() { + public function test_action_category_movedown_and_moveup(): void { global $DB; $this->resetAfterTest(true); @@ -659,7 +659,7 @@ class management_helper_test extends \advanced_testcase { * * \core_course\management\helper::action_category_resort_courses */ - public function test_action_category_resort_courses() { + public function test_action_category_resort_courses(): void { global $DB; $this->resetAfterTest(true); @@ -761,7 +761,7 @@ class management_helper_test extends \advanced_testcase { * * \core_course\management\helper::action_category_resort_courses */ - public function test_action_category_resort_subcategories() { + public function test_action_category_resort_subcategories(): void { global $DB; $this->resetAfterTest(true); @@ -857,7 +857,7 @@ class management_helper_test extends \advanced_testcase { * @see \core_course\management\helper::action_course_hide * @see \core_course\management\helper::action_course_show */ - public function test_action_course_hide_show() { + public function test_action_course_hide_show(): void { $this->resetAfterTest(true); $generator = $this->getDataGenerator(); @@ -921,7 +921,7 @@ class management_helper_test extends \advanced_testcase { * @see \core_course\management\helper::action_course_hide_by_record * @see \core_course\management\helper::action_course_show_by_record */ - public function test_action_course_hide_show_by_record() { + public function test_action_course_hide_show_by_record(): void { $this->resetAfterTest(true); $generator = $this->getDataGenerator(); @@ -982,7 +982,7 @@ class management_helper_test extends \advanced_testcase { /** * Tests moving a course up and down by one. */ - public function test_action_course_movedown_and_moveup() { + public function test_action_course_movedown_and_moveup(): void { global $DB; $this->resetAfterTest(true); @@ -1092,7 +1092,7 @@ class management_helper_test extends \advanced_testcase { /** * Tests the fetching of actions for a category. */ - public function test_get_category_listitem_actions() { + public function test_get_category_listitem_actions(): void { global $PAGE; $this->resetAfterTest(true); @@ -1126,7 +1126,7 @@ class management_helper_test extends \advanced_testcase { /** * Tests fetching the course actions. */ - public function test_get_course_detail_actions() { + public function test_get_course_detail_actions(): void { $this->resetAfterTest(true); $generator = $this->getDataGenerator(); @@ -1159,7 +1159,7 @@ class management_helper_test extends \advanced_testcase { /** * Test fetching course details. */ - public function test_get_course_detail_array() { + public function test_get_course_detail_array(): void { $this->resetAfterTest(true); $generator = $this->getDataGenerator(); @@ -1194,7 +1194,7 @@ class management_helper_test extends \advanced_testcase { $this->assertArrayHasKey('modulesused', $details); } - public function test_move_courses_into_category() { + public function test_move_courses_into_category(): void { global $DB, $CFG; $this->resetAfterTest(true); diff --git a/course/tests/modlib_test.php b/course/tests/modlib_test.php index 199c1a513ee..065033999fd 100644 --- a/course/tests/modlib_test.php +++ b/course/tests/modlib_test.php @@ -37,7 +37,7 @@ class modlib_test extends \advanced_testcase { /** * Test prepare_new_moduleinfo_data */ - public function test_prepare_new_moduleinfo_data() { + public function test_prepare_new_moduleinfo_data(): void { global $DB; $this->resetAfterTest(true); @@ -86,7 +86,7 @@ class modlib_test extends \advanced_testcase { * Test prepare_new_moduleinfo_data with suffix (which is currently only used by the completion rules). * @covers ::prepare_new_moduleinfo_data */ - public function test_prepare_new_moduleinfo_data_with_suffix() { + public function test_prepare_new_moduleinfo_data_with_suffix(): void { global $DB; $this->resetAfterTest(true); @@ -129,7 +129,7 @@ class modlib_test extends \advanced_testcase { /** * Test get_moduleinfo_data */ - public function test_get_moduleinfo_data() { + public function test_get_moduleinfo_data(): void { global $DB; $this->resetAfterTest(true); $this->setAdminUser(); @@ -212,7 +212,7 @@ class modlib_test extends \advanced_testcase { * * @covers \add_moduleinfo */ - public function test_add_moduleinfo() { + public function test_add_moduleinfo(): void { global $DB; $this->resetAfterTest(true); diff --git a/course/tests/privacy/provider_test.php b/course/tests/privacy/provider_test.php index 81fd442c946..da9e57b306d 100644 --- a/course/tests/privacy/provider_test.php +++ b/course/tests/privacy/provider_test.php @@ -44,7 +44,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { * Test getting the appropriate context for the userid. This should only ever * return the user context for the user id supplied. */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { $this->resetAfterTest(); $user1 = $this->getDataGenerator()->create_user(); @@ -90,7 +90,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test fetching users within a context. */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { $this->resetAfterTest(); $component = 'core_course'; @@ -138,7 +138,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test that user data is exported. */ - public function test_export_user_data() { + public function test_export_user_data(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); @@ -173,7 +173,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { * Verify that if a module context is included in the contextlist_collection and its parent course is not, the * export_context_data() call picks this up, and that the contextual course information is included. */ - public function test_export_context_data_module_context_only() { + public function test_export_context_data_module_context_only(): void { $this->resetAfterTest(); // Create a course and a single module. @@ -203,7 +203,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { * Verify that if a module context and its parent course context are both included in the contextlist_collection, that course * contextual information is present in the export. */ - public function test_export_context_data_course_and_module_contexts() { + public function test_export_context_data_course_and_module_contexts(): void { $this->resetAfterTest(); // Create a course and a single module. @@ -235,7 +235,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test deleting all user data for one context. */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; $this->resetAfterTest(); @@ -303,7 +303,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test deleting data for only one user. */ - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { $this->resetAfterTest(); $user1 = $this->getDataGenerator()->create_user(); @@ -399,7 +399,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test deleting data within a context for an approved userlist. */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { $this->resetAfterTest(); $component = 'core_course'; diff --git a/course/tests/search/search_test.php b/course/tests/search/search_test.php index 7498ad1a7fd..5149f5c6ee3 100644 --- a/course/tests/search/search_test.php +++ b/course/tests/search/search_test.php @@ -72,7 +72,7 @@ class search_test extends \advanced_testcase { * * @return void */ - public function test_courses_indexing() { + public function test_courses_indexing(): void { // Returns the instance as long as the area is supported. $searcharea = \core_search\manager::get_search_area($this->coursesareaid); @@ -115,7 +115,7 @@ class search_test extends \advanced_testcase { /** * Tests course indexing support for contexts. */ - public function test_courses_indexing_contexts() { + public function test_courses_indexing_contexts(): void { global $DB, $USER, $SITE; $searcharea = \core_search\manager::get_search_area($this->coursesareaid); @@ -196,7 +196,7 @@ class search_test extends \advanced_testcase { * * @return void */ - public function test_courses_document() { + public function test_courses_document(): void { // Returns the instance as long as the area is supported. $searcharea = \core_search\manager::get_search_area($this->coursesareaid); @@ -226,7 +226,7 @@ class search_test extends \advanced_testcase { * * @return void */ - public function test_courses_access() { + public function test_courses_access(): void { $this->resetAfterTest(); // Returns the instance as long as the area is supported. @@ -259,7 +259,7 @@ class search_test extends \advanced_testcase { /** * Indexing section contents. */ - public function test_section_indexing() { + public function test_section_indexing(): void { global $DB, $USER; // Returns the instance as long as the area is supported. @@ -352,7 +352,7 @@ class search_test extends \advanced_testcase { /** * Document contents for sections. */ - public function test_section_document() { + public function test_section_document(): void { global $DB; $searcharea = \core_search\manager::get_search_area($this->sectionareaid); @@ -386,7 +386,7 @@ class search_test extends \advanced_testcase { /** * Document access for sections. */ - public function test_section_access() { + public function test_section_access(): void { global $DB; $searcharea = \core_search\manager::get_search_area($this->sectionareaid); @@ -461,7 +461,7 @@ class search_test extends \advanced_testcase { * * @return void */ - public function test_customfield_indexing() { + public function test_customfield_indexing(): void { // Returns the instance as long as the area is supported. $searcharea = \core_search\manager::get_search_area($this->customfieldareaid); $this->assertInstanceOf('\core_course\search\customfield', $searcharea); @@ -508,7 +508,7 @@ class search_test extends \advanced_testcase { * * @return void */ - public function test_customfield_document() { + public function test_customfield_document(): void { global $DB; // Returns the instance as long as the area is supported. $searcharea = \core_search\manager::get_search_area($this->customfieldareaid); @@ -543,7 +543,7 @@ class search_test extends \advanced_testcase { /** * Document accesses for customfield area. */ - public function test_customfield_access() { + public function test_customfield_access(): void { global $DB; $this->resetAfterTest(); @@ -615,7 +615,7 @@ class search_test extends \advanced_testcase { /** * Test document icon for course area. */ - public function test_get_doc_icon_for_course_area() { + public function test_get_doc_icon_for_course_area(): void { $searcharea = \core_search\manager::get_search_area($this->coursesareaid); $document = $this->getMockBuilder('\core_search\document') @@ -631,7 +631,7 @@ class search_test extends \advanced_testcase { /** * Test document icon for section area. */ - public function test_get_doc_icon_for_section_area() { + public function test_get_doc_icon_for_section_area(): void { $searcharea = \core_search\manager::get_search_area($this->sectionareaid); $document = $this->getMockBuilder('\core_search\document') @@ -647,7 +647,7 @@ class search_test extends \advanced_testcase { /** * Test assigned search categories. */ - public function test_get_category_names() { + public function test_get_category_names(): void { $coursessearcharea = \core_search\manager::get_search_area($this->coursesareaid); $sectionsearcharea = \core_search\manager::get_search_area($this->sectionareaid); $customfieldssearcharea = \core_search\manager::get_search_area($this->customfieldareaid); diff --git a/course/tests/services_content_item_service_test.php b/course/tests/services_content_item_service_test.php index acdb662c592..2abe98d47f4 100644 --- a/course/tests/services_content_item_service_test.php +++ b/course/tests/services_content_item_service_test.php @@ -40,7 +40,7 @@ class services_content_item_service_test extends \advanced_testcase { /** * Test confirming that content items are returned by the service. */ - public function test_get_content_items_for_user_in_course_basic() { + public function test_get_content_items_for_user_in_course_basic(): void { $this->resetAfterTest(); // Create a user in a course. @@ -65,7 +65,7 @@ class services_content_item_service_test extends \advanced_testcase { /** * Test confirming that access control is performed when asking the service to return content items for a user in a course. */ - public function test_get_content_items_for_user_in_course_permissions() { + public function test_get_content_items_for_user_in_course_permissions(): void { $this->resetAfterTest(); global $DB; @@ -89,7 +89,7 @@ class services_content_item_service_test extends \advanced_testcase { /** * Test confirming that params can be added to the content item's link. */ - public function test_get_content_item_for_user_in_course_link_params() { + public function test_get_content_item_for_user_in_course_link_params(): void { $this->resetAfterTest(); // Create a user in a course. @@ -107,7 +107,7 @@ class services_content_item_service_test extends \advanced_testcase { /** * Test confirming that all content items can be fetched irrespective of permissions. */ - public function test_get_all_content_items() { + public function test_get_all_content_items(): void { $this->resetAfterTest(); global $DB; @@ -147,7 +147,7 @@ class services_content_item_service_test extends \advanced_testcase { /** * Test confirming that content items which title match a certain pattern can be fetched irrespective of permissions. */ - public function test_get_content_items_by_name_pattern() { + public function test_get_content_items_by_name_pattern(): void { $this->resetAfterTest(); // Create a user in a course. @@ -176,7 +176,7 @@ class services_content_item_service_test extends \advanced_testcase { /** * Test confirming that a content item can be added to a user's favourites. */ - public function test_add_to_user_favourites() { + public function test_add_to_user_favourites(): void { $this->resetAfterTest(); // Create a user in a course. @@ -206,7 +206,7 @@ class services_content_item_service_test extends \advanced_testcase { /** * Test verifying that content items can be removed from a user's favourites. */ - public function test_remove_from_user_favourites() { + public function test_remove_from_user_favourites(): void { $this->resetAfterTest(); // Create a user in a course. @@ -238,7 +238,7 @@ class services_content_item_service_test extends \advanced_testcase { /** * Test that toggling a recommendation works as anticipated. */ - public function test_toggle_recommendation() { + public function test_toggle_recommendation(): void { $this->resetAfterTest(); // Create a user in a course. diff --git a/course/tests/targets_test.php b/course/tests/targets_test.php index 6dc0ad89a5d..ec4e9f8f022 100644 --- a/course/tests/targets_test.php +++ b/course/tests/targets_test.php @@ -338,7 +338,7 @@ class targets_test extends \advanced_testcase { * @param true|string $isvalid True when analysable is valid, string when it is not * @param boolean $fortraining True if the course is for training the model */ - public function test_core_target_course_completion_analysable($courseparams, $isvalid, $fortraining = true) { + public function test_core_target_course_completion_analysable($courseparams, $isvalid, $fortraining = true): void { global $DB; $this->resetAfterTest(true); @@ -395,7 +395,7 @@ class targets_test extends \advanced_testcase { * @param boolean $isvalidforprediction True when sample is valid for prediction, false when it is not */ public function test_core_target_course_completion_samples($coursestart, $courseend, $timestart, $timeend, - $isvalidfortraining, $isvalidforprediction) { + $isvalidfortraining, $isvalidforprediction): void { $this->resetAfterTest(true); @@ -433,7 +433,7 @@ class targets_test extends \advanced_testcase { * @param boolean $nullcalculation Whether the calculation should be null or not */ public function test_core_target_course_completion_active_during_analysis_time($starttime, $endtime, $timestart, $timeend, - $nullcalculation) { + $nullcalculation): void { $this->resetAfterTest(true); @@ -503,7 +503,7 @@ class targets_test extends \advanced_testcase { /** * Test the specific conditions of a valid analysable for the course_competencies target. */ - public function test_core_target_course_competencies_analysable() { + public function test_core_target_course_competencies_analysable(): void { $data = $this->setup_competencies_environment(); @@ -519,7 +519,7 @@ class targets_test extends \advanced_testcase { /** * Test the target value calculation. */ - public function test_core_target_course_competencies_calculate() { + public function test_core_target_course_competencies_calculate(): void { $data = $this->setup_competencies_environment(); @@ -552,7 +552,7 @@ class targets_test extends \advanced_testcase { /** * Test the specific conditions of a valid analysable for the course_gradetopass target. */ - public function test_core_target_course_gradetopass_analysable() { + public function test_core_target_course_gradetopass_analysable(): void { global $DB; $this->resetAfterTest(true); @@ -583,7 +583,7 @@ class targets_test extends \advanced_testcase { /** * Test the target value calculation of the course_gradetopass target. */ - public function test_core_target_course_gradetopass_calculate() { + public function test_core_target_course_gradetopass_calculate(): void { global $DB; $this->resetAfterTest(true); diff --git a/customfield/field/checkbox/tests/plugin_test.php b/customfield/field/checkbox/tests/plugin_test.php index 5453eded900..aa4d79c5f52 100644 --- a/customfield/field/checkbox/tests/plugin_test.php +++ b/customfield/field/checkbox/tests/plugin_test.php @@ -75,7 +75,7 @@ class plugin_test extends \advanced_testcase { /** * Test for initialising field and data controllers */ - public function test_initialise() { + public function test_initialise(): void { $f = \core_customfield\field_controller::create($this->cfields[1]->get('id')); $this->assertTrue($f instanceof field_controller); @@ -94,7 +94,7 @@ class plugin_test extends \advanced_testcase { * * Create a configuration form and submit it with the same values as in the field */ - public function test_config_form() { + public function test_config_form(): void { $this->setAdminUser(); $submitdata = (array)$this->cfields[1]->to_record(); $submitdata['configdata'] = $this->cfields[1]->get('configdata'); @@ -119,7 +119,7 @@ class plugin_test extends \advanced_testcase { /** * Test for instance form functions */ - public function test_instance_form() { + public function test_instance_form(): void { global $CFG; require_once($CFG->dirroot . '/customfield/tests/fixtures/test_instance_form.php'); $this->setAdminUser(); @@ -148,7 +148,7 @@ class plugin_test extends \advanced_testcase { /** * Test for data_controller::get_value and export_value */ - public function test_get_export_value() { + public function test_get_export_value(): void { $this->assertEquals(1, $this->cfdata[1]->get_value()); $this->assertEquals('Yes', $this->cfdata[1]->export_value()); @@ -166,7 +166,7 @@ class plugin_test extends \advanced_testcase { /** * Deleting fields and data */ - public function test_delete() { + public function test_delete(): void { $this->cfcat->get_handler()->delete_all(); } } diff --git a/customfield/field/date/tests/plugin_test.php b/customfield/field/date/tests/plugin_test.php index 8b15fb8825d..cf01a554a7b 100644 --- a/customfield/field/date/tests/plugin_test.php +++ b/customfield/field/date/tests/plugin_test.php @@ -72,7 +72,7 @@ class plugin_test extends \advanced_testcase { /** * Test for initialising field and data controllers */ - public function test_initialise() { + public function test_initialise(): void { $f = \core_customfield\field_controller::create($this->cfields[1]->get('id')); $this->assertTrue($f instanceof field_controller); @@ -91,7 +91,7 @@ class plugin_test extends \advanced_testcase { * * Create a configuration form and submit it with the same values as in the field */ - public function test_config_form() { + public function test_config_form(): void { $this->setAdminUser(); $submitdata = (array)$this->cfields[1]->to_record(); $submitdata['configdata'] = $this->cfields[1]->get('configdata'); @@ -107,7 +107,7 @@ class plugin_test extends \advanced_testcase { /** * Test for instance form functions */ - public function test_instance_form() { + public function test_instance_form(): void { global $CFG; require_once($CFG->dirroot . '/customfield/tests/fixtures/test_instance_form.php'); $this->setAdminUser(); @@ -136,7 +136,7 @@ class plugin_test extends \advanced_testcase { /** * Test for min/max date validation */ - public function test_instance_form_validation() { + public function test_instance_form_validation(): void { $this->setAdminUser(); $handler = $this->cfcat->get_handler(); $submitdata = (array)$this->courses[1]; @@ -154,7 +154,7 @@ class plugin_test extends \advanced_testcase { /** * Test for data_controller::get_value and export_value */ - public function test_get_export_value() { + public function test_get_export_value(): void { $this->assertEquals(1546300800, $this->cfdata[1]->get_value()); $this->assertStringMatchesFormat('%a 1 January 2019%a', $this->cfdata[1]->export_value()); @@ -189,14 +189,14 @@ class plugin_test extends \advanced_testcase { * * @dataProvider parse_value_provider */ - public function test_parse_value(string $value, int $expected) { + public function test_parse_value(string $value, int $expected): void { $this->assertSame($expected, $this->cfields[1]->parse_value($value)); } /** * Deleting fields and data */ - public function test_delete() { + public function test_delete(): void { $this->cfcat->get_handler()->delete_all(); } } diff --git a/customfield/field/select/tests/plugin_test.php b/customfield/field/select/tests/plugin_test.php index 77fdf2950af..337d9410b52 100644 --- a/customfield/field/select/tests/plugin_test.php +++ b/customfield/field/select/tests/plugin_test.php @@ -76,7 +76,7 @@ class plugin_test extends \advanced_testcase { /** * Test for initialising field and data controllers */ - public function test_initialise() { + public function test_initialise(): void { $f = \core_customfield\field_controller::create($this->cfields[1]->get('id')); $this->assertTrue($f instanceof field_controller); @@ -95,7 +95,7 @@ class plugin_test extends \advanced_testcase { * * Create a configuration form and submit it with the same values as in the field */ - public function test_config_form() { + public function test_config_form(): void { $this->setAdminUser(); $submitdata = (array)$this->cfields[1]->to_record(); $submitdata['configdata'] = $this->cfields[1]->get('configdata'); @@ -111,7 +111,7 @@ class plugin_test extends \advanced_testcase { /** * Test for instance form functions */ - public function test_instance_form() { + public function test_instance_form(): void { global $CFG; require_once($CFG->dirroot . '/customfield/tests/fixtures/test_instance_form.php'); $this->setAdminUser(); @@ -140,7 +140,7 @@ class plugin_test extends \advanced_testcase { /** * Test for data_controller::get_value and export_value */ - public function test_get_export_value() { + public function test_get_export_value(): void { $this->assertEquals(1, $this->cfdata[1]->get_value()); $this->assertEquals('a', $this->cfdata[1]->export_value()); @@ -173,7 +173,7 @@ class plugin_test extends \advanced_testcase { * * @dataProvider parse_value_provider */ - public function test_parse_value(string $value, int $expected) { + public function test_parse_value(string $value, int $expected): void { $field = $this->get_generator()->create_field([ 'categoryid' => $this->cfcat->get('id'), 'type' => 'select', @@ -189,7 +189,7 @@ class plugin_test extends \advanced_testcase { /** * Deleting fields and data */ - public function test_delete() { + public function test_delete(): void { $this->cfcat->get_handler()->delete_all(); } } diff --git a/customfield/field/text/tests/plugin_test.php b/customfield/field/text/tests/plugin_test.php index 837c23da7b6..a26406b645f 100644 --- a/customfield/field/text/tests/plugin_test.php +++ b/customfield/field/text/tests/plugin_test.php @@ -81,7 +81,7 @@ class plugin_test extends \advanced_testcase { /** * Test for initialising field and data controllers */ - public function test_initialise() { + public function test_initialise(): void { $f = \core_customfield\field_controller::create($this->cfields[1]->get('id')); $this->assertTrue($f instanceof field_controller); @@ -100,7 +100,7 @@ class plugin_test extends \advanced_testcase { * * Create a configuration form and submit it with the same values as in the field */ - public function test_config_form() { + public function test_config_form(): void { $this->setAdminUser(); $submitdata = (array)$this->cfields[1]->to_record(); $submitdata['configdata'] = $this->cfields[1]->get('configdata'); @@ -116,7 +116,7 @@ class plugin_test extends \advanced_testcase { /** * Test for instance form functions */ - public function test_instance_form() { + public function test_instance_form(): void { global $CFG; require_once($CFG->dirroot . '/customfield/tests/fixtures/test_instance_form.php'); $this->setAdminUser(); @@ -145,7 +145,7 @@ class plugin_test extends \advanced_testcase { /** * Test for data_controller::get_value and export_value */ - public function test_get_export_value() { + public function test_get_export_value(): void { $this->assertEquals('Value1', $this->cfdata[1]->get_value()); $this->assertEquals('Value1', $this->cfdata[1]->export_value()); @@ -163,7 +163,7 @@ class plugin_test extends \advanced_testcase { /** * Deleting fields and data */ - public function test_delete() { + public function test_delete(): void { $this->cfcat->get_handler()->delete_all(); } } diff --git a/customfield/field/textarea/tests/plugin_test.php b/customfield/field/textarea/tests/plugin_test.php index d24e24ec344..8565791a318 100644 --- a/customfield/field/textarea/tests/plugin_test.php +++ b/customfield/field/textarea/tests/plugin_test.php @@ -82,7 +82,7 @@ class plugin_test extends \advanced_testcase { /** * Test for initialising field and data controllers */ - public function test_initialise() { + public function test_initialise(): void { $f = \core_customfield\field_controller::create($this->cfields[1]->get('id')); $this->assertTrue($f instanceof field_controller); @@ -101,7 +101,7 @@ class plugin_test extends \advanced_testcase { * * Create a configuration form and submit it with the same values as in the field */ - public function test_config_form() { + public function test_config_form(): void { $this->setAdminUser(); $submitdata = (array)$this->cfields[3]->to_record(); $submitdata['configdata'] = $this->cfields[3]->get('configdata'); @@ -117,7 +117,7 @@ class plugin_test extends \advanced_testcase { /** * Test for instance form functions */ - public function test_instance_form() { + public function test_instance_form(): void { global $CFG; require_once($CFG->dirroot . '/customfield/tests/fixtures/test_instance_form.php'); $this->setAdminUser(); @@ -181,7 +181,7 @@ class plugin_test extends \advanced_testcase { /** * Test for data_controller::get_value and export_value */ - public function test_get_export_value() { + public function test_get_export_value(): void { $this->assertEquals('Value1', $this->cfdata[1]->get_value()); $this->assertEquals('
Value1
', $this->cfdata[1]->export_value()); @@ -197,7 +197,7 @@ class plugin_test extends \advanced_testcase { /** * Deleting fields and data */ - public function test_delete() { + public function test_delete(): void { $this->cfcat->get_handler()->delete_all(); } diff --git a/customfield/tests/api_test.php b/customfield/tests/api_test.php index c3e4e2aa4b1..112a98ac027 100644 --- a/customfield/tests/api_test.php +++ b/customfield/tests/api_test.php @@ -54,7 +54,7 @@ class api_test extends \advanced_testcase { * This replicates what is happening when categories are moved * in the interface using drag-drop. */ - public function test_move_category() { + public function test_move_category(): void { $this->resetAfterTest(); // Create the categories. @@ -105,7 +105,7 @@ class api_test extends \advanced_testcase { /** * Tests for \core_customfield\api::get_categories_with_fields() behaviour. */ - public function test_get_categories_with_fields() { + public function test_get_categories_with_fields(): void { $this->resetAfterTest(); // Create the categories. @@ -141,7 +141,7 @@ class api_test extends \advanced_testcase { /** * Test for functions api::save_category() and rename_category) */ - public function test_save_category() { + public function test_save_category(): void { $this->resetAfterTest(); $params = ['component' => 'core_course', 'area' => 'course', 'itemid' => 0, 'name' => 'Cat1', @@ -176,7 +176,7 @@ class api_test extends \advanced_testcase { /** * Test for function handler::create_category */ - public function test_create_category() { + public function test_create_category(): void { $this->resetAfterTest(); $handler = \core_course\customfield\course_handler::create(); @@ -200,7 +200,7 @@ class api_test extends \advanced_testcase { /** * Tests for \core_customfield\api::delete_category() behaviour. */ - public function test_delete_category_with_fields() { + public function test_delete_category_with_fields(): void { $this->resetAfterTest(); global $DB; diff --git a/customfield/tests/category_controller_test.php b/customfield/tests/category_controller_test.php index 5179a4135ff..49876bcbd49 100644 --- a/customfield/tests/category_controller_test.php +++ b/customfield/tests/category_controller_test.php @@ -40,7 +40,7 @@ class category_controller_test extends \advanced_testcase { /** * Test for the field_controller::__construct function. */ - public function test_constructor() { + public function test_constructor(): void { $this->resetAfterTest(); $c = category_controller::create(0, (object)['component' => 'core_course', 'area' => 'course', 'itemid' => 0]); @@ -64,7 +64,7 @@ class category_controller_test extends \advanced_testcase { /** * Test for function \core_customfield\field_controller::create() in case of wrong parameters */ - public function test_constructor_errors() { + public function test_constructor_errors(): void { global $DB; $this->resetAfterTest(); @@ -165,7 +165,7 @@ class category_controller_test extends \advanced_testcase { * \core_customfield\category_controller::save() * \core_customfield\category_controller::get() */ - public function test_create_category() { + public function test_create_category(): void { $this->resetAfterTest(); // Create the category. @@ -194,7 +194,7 @@ class category_controller_test extends \advanced_testcase { /** * Tests for \core_customfield\category_controller::set() behaviour. */ - public function test_rename_category() { + public function test_rename_category(): void { $this->resetAfterTest(); // Create the category. @@ -219,7 +219,7 @@ class category_controller_test extends \advanced_testcase { /** * Tests for \core_customfield\category_controller::delete() behaviour. */ - public function test_delete_category() { + public function test_delete_category(): void { $this->resetAfterTest(); // Create the category. diff --git a/customfield/tests/data_controller_test.php b/customfield/tests/data_controller_test.php index 56b86c2e4d7..c01d00248ad 100644 --- a/customfield/tests/data_controller_test.php +++ b/customfield/tests/data_controller_test.php @@ -45,7 +45,7 @@ class data_controller_test extends \advanced_testcase { /** * Test for function data_controller::create() */ - public function test_constructor() { + public function test_constructor(): void { global $DB; $this->resetAfterTest(); @@ -115,7 +115,7 @@ class data_controller_test extends \advanced_testcase { /** * Test for function \core_customfield\field_controller::create() in case of wrong parameters */ - public function test_constructor_errors() { + public function test_constructor_errors(): void { global $DB; $this->resetAfterTest(); diff --git a/customfield/tests/field_controller_test.php b/customfield/tests/field_controller_test.php index 1600310d067..8de20746ec0 100644 --- a/customfield/tests/field_controller_test.php +++ b/customfield/tests/field_controller_test.php @@ -45,7 +45,7 @@ class field_controller_test extends \advanced_testcase { /** * Test for function \core_customfield\field_controller::create() */ - public function test_constructor() { + public function test_constructor(): void { global $DB; $this->resetAfterTest(); @@ -92,7 +92,7 @@ class field_controller_test extends \advanced_testcase { /** * Test for function \core_customfield\field_controller::create() in case of wrong parameters */ - public function test_constructor_errors() { + public function test_constructor_errors(): void { global $DB; $this->resetAfterTest(); @@ -166,7 +166,7 @@ class field_controller_test extends \advanced_testcase { * \core_customfield\field_controller::get() * \core_customfield\field_controller::get_category() */ - public function test_create_field() { + public function test_create_field(): void { global $DB; $this->resetAfterTest(); @@ -196,7 +196,7 @@ class field_controller_test extends \advanced_testcase { /** * Tests for \core_customfield\field_controller::delete() behaviour. */ - public function test_delete_field() { + public function test_delete_field(): void { global $DB; $this->resetAfterTest(); @@ -225,7 +225,7 @@ class field_controller_test extends \advanced_testcase { /** * Tests for \core_customfield\field_controller::get_configdata_property() behaviour. */ - public function test_get_configdata_property() { + public function test_get_configdata_property(): void { $this->resetAfterTest(); $lpg = $this->get_generator(); diff --git a/customfield/tests/generator_test.php b/customfield/tests/generator_test.php index 20f17b078f7..d749be1cd62 100644 --- a/customfield/tests/generator_test.php +++ b/customfield/tests/generator_test.php @@ -37,7 +37,7 @@ class generator_test extends \advanced_testcase { /** * Test creating category */ - public function test_create_category() { + public function test_create_category(): void { $this->resetAfterTest(true); $lpg = $this->get_generator(); @@ -50,7 +50,7 @@ class generator_test extends \advanced_testcase { /** * Test creating field */ - public function test_create_field() { + public function test_create_field(): void { $this->resetAfterTest(true); $lpg = $this->get_generator(); @@ -69,7 +69,7 @@ class generator_test extends \advanced_testcase { /** * Test for function add_instance_data() */ - public function test_add_instance_data() { + public function test_add_instance_data(): void { $this->resetAfterTest(true); $lpg = $this->get_generator(); diff --git a/customfield/tests/privacy/provider_test.php b/customfield/tests/privacy/provider_test.php index 8ee9c414ada..96bc820994d 100644 --- a/customfield/tests/privacy/provider_test.php +++ b/customfield/tests/privacy/provider_test.php @@ -97,7 +97,7 @@ class provider_test extends provider_testcase { /** * Test for provider::get_metadata() */ - public function test_get_metadata() { + public function test_get_metadata(): void { $collection = new \core_privacy\local\metadata\collection('core_customfield'); $collection = provider::get_metadata($collection); $this->assertNotEmpty($collection); @@ -106,7 +106,7 @@ class provider_test extends provider_testcase { /** * Test for provider::get_customfields_data_contexts */ - public function test_get_customfields_data_contexts() { + public function test_get_customfields_data_contexts(): void { global $DB; [ 'cffields' => $cffields, @@ -125,7 +125,7 @@ class provider_test extends provider_testcase { /** * Test for provider::get_customfields_configuration_contexts() */ - public function test_get_customfields_configuration_contexts() { + public function test_get_customfields_configuration_contexts(): void { $this->generate_test_data(); $r = provider::get_customfields_configuration_contexts('core_course', 'course'); @@ -135,7 +135,7 @@ class provider_test extends provider_testcase { /** * Test for provider::export_customfields_data() */ - public function test_export_customfields_data() { + public function test_export_customfields_data(): void { global $USER, $DB; $this->resetAfterTest(); [ @@ -177,7 +177,7 @@ class provider_test extends provider_testcase { /** * Test for provider::delete_customfields_data() */ - public function test_delete_customfields_data() { + public function test_delete_customfields_data(): void { global $USER, $DB; $this->resetAfterTest(); [ @@ -195,7 +195,7 @@ class provider_test extends provider_testcase { /** * Test for provider::delete_customfields_configuration() */ - public function test_delete_customfields_configuration() { + public function test_delete_customfields_configuration(): void { global $USER, $DB; $this->resetAfterTest(); [ @@ -232,7 +232,7 @@ class provider_test extends provider_testcase { /** * Test for provider::delete_customfields_configuration_for_context() */ - public function test_delete_customfields_configuration_for_context() { + public function test_delete_customfields_configuration_for_context(): void { global $USER, $DB; $this->resetAfterTest(); [ @@ -269,7 +269,7 @@ class provider_test extends provider_testcase { /** * Test for provider::delete_customfields_data_for_context() */ - public function test_delete_customfields_data_for_context() { + public function test_delete_customfields_data_for_context(): void { global $DB; $this->resetAfterTest(); [ diff --git a/enrol/category/tests/plugin_test.php b/enrol/category/tests/plugin_test.php index aae6632f131..e9e688a8e1a 100644 --- a/enrol/category/tests/plugin_test.php +++ b/enrol/category/tests/plugin_test.php @@ -57,7 +57,7 @@ class plugin_test extends \advanced_testcase { * in core accesslib was changed, but it is possible that only this test * is affected, nto the plugin itself... */ - public function test_utils() { + public function test_utils(): void { global $DB; $this->resetAfterTest(); @@ -84,7 +84,7 @@ class plugin_test extends \advanced_testcase { $this->assertEmpty($roles); } - public function test_handler_sync() { + public function test_handler_sync(): void { global $DB, $CFG; require_once($CFG->dirroot.'/enrol/category/locallib.php'); @@ -157,7 +157,7 @@ class plugin_test extends \advanced_testcase { } - public function test_sync_course() { + public function test_sync_course(): void { global $DB, $CFG; require_once($CFG->dirroot.'/enrol/category/locallib.php'); @@ -251,7 +251,7 @@ class plugin_test extends \advanced_testcase { $this->assertEquals(0, $DB->count_records('enrol', array('enrol'=>'category'))); } - public function test_sync_full() { + public function test_sync_full(): void { global $DB, $CFG; require_once($CFG->dirroot.'/enrol/category/locallib.php'); diff --git a/enrol/cohort/tests/lib_test.php b/enrol/cohort/tests/lib_test.php index 47e805d705a..e22085e0da7 100644 --- a/enrol/cohort/tests/lib_test.php +++ b/enrol/cohort/tests/lib_test.php @@ -37,7 +37,7 @@ class lib_test extends \advanced_testcase { /** * Test that a new group with the name of the cohort is created. */ - public function test_enrol_cohort_create_new_group() { + public function test_enrol_cohort_create_new_group(): void { global $DB; $this->resetAfterTest(); // Create a category. @@ -83,7 +83,7 @@ class lib_test extends \advanced_testcase { /** * Test for getting user enrolment actions. */ - public function test_get_user_enrolment_actions() { + public function test_get_user_enrolment_actions(): void { global $CFG, $PAGE; $this->resetAfterTest(); @@ -132,7 +132,7 @@ class lib_test extends \advanced_testcase { $this->assertCount(1, $actions); } - public function test_enrol_cohort_unenrolaction_suspend_only() { + public function test_enrol_cohort_unenrolaction_suspend_only(): void { global $CFG, $DB, $PAGE; $this->resetAfterTest(); @@ -215,7 +215,7 @@ class lib_test extends \advanced_testcase { * * @covers ::validate_plugin_data_context */ - public function test_validate_plugin_data_context() { + public function test_validate_plugin_data_context(): void { $this->resetAfterTest(); $cohortplugin = enrol_get_plugin('cohort'); @@ -260,7 +260,7 @@ class lib_test extends \advanced_testcase { * * @covers ::fill_enrol_custom_fields */ - public function test_fill_enrol_custom_fields() { + public function test_fill_enrol_custom_fields(): void { $this->resetAfterTest(); $cohortplugin = enrol_get_plugin('cohort'); @@ -315,7 +315,7 @@ class lib_test extends \advanced_testcase { * * @covers ::validate_enrol_plugin_data */ - public function test_validate_enrol_plugin_data() { + public function test_validate_enrol_plugin_data(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -407,7 +407,7 @@ class lib_test extends \advanced_testcase { * * @covers ::find_instance */ - public function test_find_instance() { + public function test_find_instance(): void { global $DB; $this->resetAfterTest(); diff --git a/enrol/cohort/tests/privacy/provider_test.php b/enrol/cohort/tests/privacy/provider_test.php index d6296134042..95b4ad6f4db 100644 --- a/enrol/cohort/tests/privacy/provider_test.php +++ b/enrol/cohort/tests/privacy/provider_test.php @@ -41,7 +41,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test getting the context for the user ID related to this plugin. */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { global $DB; $this->resetAfterTest(); @@ -79,7 +79,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test that user data is exported correctly. */ - public function test_export_user_data() { + public function test_export_user_data(): void { global $DB; $this->resetAfterTest(); @@ -134,7 +134,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::delete_data_for_all_users_in_context(). */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; $this->resetAfterTest(); @@ -182,7 +182,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::delete_data_for_user(). */ - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; $this->resetAfterTest(); @@ -262,7 +262,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::delete_data_for_users(). */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { global $DB; $this->resetAfterTest(); @@ -351,7 +351,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::get_users_in_context(). */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { global $DB; $this->resetAfterTest(); diff --git a/enrol/cohort/tests/sync_test.php b/enrol/cohort/tests/sync_test.php index 2064379a4fb..1654aa50f81 100644 --- a/enrol/cohort/tests/sync_test.php +++ b/enrol/cohort/tests/sync_test.php @@ -47,7 +47,7 @@ class sync_test extends \advanced_testcase { set_config('enrol_plugins_enabled', implode(',', $enabled)); } - public function test_handler_sync() { + public function test_handler_sync(): void { global $DB; $this->resetAfterTest(); @@ -323,7 +323,7 @@ class sync_test extends \advanced_testcase { $this->assertEquals(0, $DB->count_records('groups_members', array('component'=>'enrol_cohort', 'itemid'=>$cohortinstance1->id))); } - public function test_sync_course() { + public function test_sync_course(): void { global $DB; $this->resetAfterTest(); @@ -535,7 +535,7 @@ class sync_test extends \advanced_testcase { $this->assertTrue(groups_is_member($group2->id, $user4->id)); } - public function test_sync_all_courses() { + public function test_sync_all_courses(): void { global $DB; $this->resetAfterTest(); diff --git a/enrol/database/tests/lib_test.php b/enrol/database/tests/lib_test.php index d9f1b439fab..94c1467d65a 100644 --- a/enrol/database/tests/lib_test.php +++ b/enrol/database/tests/lib_test.php @@ -51,7 +51,7 @@ class lib_test extends \advanced_testcase { /** * Test for getting user enrolment actions. */ - public function test_get_user_enrolment_actions() { + public function test_get_user_enrolment_actions(): void { global $CFG, $PAGE; $this->resetAfterTest(); diff --git a/enrol/database/tests/sync_test.php b/enrol/database/tests/sync_test.php index 061c29b8d71..dc80e55eae1 100644 --- a/enrol/database/tests/sync_test.php +++ b/enrol/database/tests/sync_test.php @@ -237,7 +237,7 @@ class sync_test extends \advanced_testcase { $this->assertFalse($DB->record_exists('user_enrolments', array('enrolid' => $dbinstance->id, 'userid' => self::$users[$userindex]->id))); } - public function test_sync_user_enrolments() { + public function test_sync_user_enrolments(): void { global $DB; $this->init_enrol_database(); @@ -427,7 +427,7 @@ class sync_test extends \advanced_testcase { /** * @depends test_sync_user_enrolments */ - public function test_sync_users() { + public function test_sync_users(): void { global $DB; $this->resetAfterTest(false); @@ -699,7 +699,7 @@ class sync_test extends \advanced_testcase { /** * @depends test_sync_users */ - public function test_sync_courses() { + public function test_sync_courses(): void { global $DB; $this->resetAfterTest(true); diff --git a/enrol/fee/tests/payment/service_provider_test.php b/enrol/fee/tests/payment/service_provider_test.php index a59af4884e4..abff86496eb 100644 --- a/enrol/fee/tests/payment/service_provider_test.php +++ b/enrol/fee/tests/payment/service_provider_test.php @@ -37,7 +37,7 @@ class service_provider_test extends \advanced_testcase { * * @covers ::get_payable */ - public function test_get_payable() { + public function test_get_payable(): void { global $DB; $this->resetAfterTest(); @@ -68,7 +68,7 @@ class service_provider_test extends \advanced_testcase { * * @covers ::get_success_url */ - public function test_get_success_url() { + public function test_get_success_url(): void { global $CFG, $DB; $this->resetAfterTest(); @@ -99,7 +99,7 @@ class service_provider_test extends \advanced_testcase { * * @covers ::deliver_order */ - public function test_deliver_order() { + public function test_deliver_order(): void { global $DB; $this->resetAfterTest(); diff --git a/enrol/flatfile/tests/flatfile_test.php b/enrol/flatfile/tests/flatfile_test.php index d72993a96e8..c0fc14681d1 100644 --- a/enrol/flatfile/tests/flatfile_test.php +++ b/enrol/flatfile/tests/flatfile_test.php @@ -51,14 +51,14 @@ class flatfile_test extends \advanced_testcase { set_config('enrol_plugins_enabled', implode(',', $enabled)); } - public function test_basics() { + public function test_basics(): void { $this->assertFalse(enrol_is_enabled('flatfile')); $plugin = enrol_get_plugin('flatfile'); $this->assertInstanceOf('enrol_flatfile_plugin', $plugin); $this->assertEquals(ENROL_EXT_REMOVED_SUSPENDNOROLES, get_config('enrol_flatfile', 'expiredaction')); } - public function test_sync_nothing() { + public function test_sync_nothing(): void { $this->resetAfterTest(); $this->disable_plugin(); @@ -70,7 +70,7 @@ class flatfile_test extends \advanced_testcase { $flatfileplugin->sync(new \null_progress_trace()); } - public function test_sync() { + public function test_sync(): void { global $CFG, $DB; $this->resetAfterTest(); @@ -277,7 +277,7 @@ class flatfile_test extends \advanced_testcase { $this->assertTrue($DB->record_exists('user_enrolments', array('userid'=>$user1->id, 'enrolid'=>$maninstance1->id))); } - public function test_notification() { + public function test_notification(): void { global $CFG, $DB; $this->resetAfterTest(); @@ -364,7 +364,7 @@ class flatfile_test extends \advanced_testcase { $this->assertEquals($admin->id, $messages[4]->useridfrom); } - public function test_expired() { + public function test_expired(): void { global $DB; $this->resetAfterTest(); @@ -480,7 +480,7 @@ class flatfile_test extends \advanced_testcase { /** * Flatfile enrolment sync task test. */ - public function test_flatfile_sync_task() { + public function test_flatfile_sync_task(): void { global $CFG, $DB; $this->resetAfterTest(); @@ -511,7 +511,7 @@ class flatfile_test extends \advanced_testcase { /** * Test for getting user enrolment actions. */ - public function test_get_user_enrolment_actions() { + public function test_get_user_enrolment_actions(): void { global $CFG, $PAGE; $this->resetAfterTest(); diff --git a/enrol/flatfile/tests/privacy/provider_test.php b/enrol/flatfile/tests/privacy/provider_test.php index c574c37f43c..4908c2f4703 100644 --- a/enrol/flatfile/tests/privacy/provider_test.php +++ b/enrol/flatfile/tests/privacy/provider_test.php @@ -71,7 +71,7 @@ class provider_test extends provider_testcase { /** * Verify that get_metadata returns the database table mapping. */ - public function test_get_metadata() { + public function test_get_metadata(): void { $collection = new collection('enrol_flatfile'); $collection = provider::get_metadata($collection); $collectiondata = $collection->get_collection(); @@ -82,7 +82,7 @@ class provider_test extends provider_testcase { /** * Verify that the relevant course contexts are returned for users with pending enrolment records. */ - public function test_get_contexts_for_user() { + public function test_get_contexts_for_user(): void { global $DB; // Create, via flatfile syncing, the future enrolments entries in the enrol_flatfile table. $this->create_future_enrolments(); @@ -106,7 +106,7 @@ class provider_test extends provider_testcase { /** * Verify the export includes any future enrolment records for the user. */ - public function test_export_user_data() { + public function test_export_user_data(): void { // Create, via flatfile syncing, the future enrolments entries in the enrol_flatfile table. $this->create_future_enrolments(); @@ -140,7 +140,7 @@ class provider_test extends provider_testcase { /** * Verify export will limit any future enrolment records to only those contextids provided. */ - public function test_export_user_data_restricted_context_subset() { + public function test_export_user_data_restricted_context_subset(): void { // Create, via flatfile syncing, the future enrolments entries in the enrol_flatfile table. $this->create_future_enrolments(); @@ -168,7 +168,7 @@ class provider_test extends provider_testcase { /** * Verify that records can be deleted by context. */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; // Create, via flatfile syncing, the future enrolments entries in the enrol_flatfile table. $this->create_future_enrolments(); @@ -181,7 +181,7 @@ class provider_test extends provider_testcase { $this->assertEquals(0, $DB->count_records('enrol_flatfile', ['courseid' => $this->coursecontext1->instanceid])); } - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; // Create, via flatfile syncing, the future enrolments entries in the enrol_flatfile table. $this->create_future_enrolments(); @@ -209,7 +209,7 @@ class provider_test extends provider_testcase { /** * Test for provider::get_users_in_context(). */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { global $DB; // Create, via flatfile syncing, the future enrolments entries in the enrol_flatfile table. $this->create_future_enrolments(); @@ -237,7 +237,7 @@ class provider_test extends provider_testcase { /** * Test for provider::delete_data_for_users(). */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { global $DB; // Create, via flatfile syncing, the future enrolments entries in the enrol_flatfile table. diff --git a/enrol/guest/tests/external/external_test.php b/enrol/guest/tests/external/external_test.php index 5cd6a66cb04..0b0e7c2e985 100644 --- a/enrol/guest/tests/external/external_test.php +++ b/enrol/guest/tests/external/external_test.php @@ -49,7 +49,7 @@ class external_test extends externallib_advanced_testcase { /** * Test get_instance_info */ - public function test_get_instance_info() { + public function test_get_instance_info(): void { global $DB; $this->resetAfterTest(true); diff --git a/enrol/guest/tests/lib_test.php b/enrol/guest/tests/lib_test.php index 2003a065238..435e52f8234 100644 --- a/enrol/guest/tests/lib_test.php +++ b/enrol/guest/tests/lib_test.php @@ -102,7 +102,7 @@ class lib_test extends \advanced_testcase { * * @covers ::find_instance */ - public function test_find_instance() { + public function test_find_instance(): void { global $DB; $this->resetAfterTest(); diff --git a/enrol/imsenterprise/tests/imsenterprise_test.php b/enrol/imsenterprise/tests/imsenterprise_test.php index e0056a89c4e..9b72944073d 100644 --- a/enrol/imsenterprise/tests/imsenterprise_test.php +++ b/enrol/imsenterprise/tests/imsenterprise_test.php @@ -52,7 +52,7 @@ class imsenterprise_test extends \advanced_testcase { /** * With an empty IMS enterprise file */ - public function test_emptyfile() { + public function test_emptyfile(): void { global $DB; $prevncourses = $DB->count_records('course'); @@ -68,7 +68,7 @@ class imsenterprise_test extends \advanced_testcase { /** * Existing users are not created again */ - public function test_users_existing() { + public function test_users_existing(): void { global $DB; $user1 = $this->getDataGenerator()->create_user(); @@ -86,7 +86,7 @@ class imsenterprise_test extends \advanced_testcase { /** * Add new users */ - public function test_users_add() { + public function test_users_add(): void { global $DB; $prevnusers = $DB->count_records('user'); @@ -108,7 +108,7 @@ class imsenterprise_test extends \advanced_testcase { /** * Add new users and set an auth type */ - public function test_users_add_with_auth() { + public function test_users_add_with_auth(): void { global $DB; $prevnusers = $DB->count_records('user'); @@ -138,7 +138,7 @@ class imsenterprise_test extends \advanced_testcase { /** * Update user */ - public function test_user_update() { + public function test_user_update(): void { global $DB; $user = $this->getDataGenerator()->create_user(array('idnumber' => 'test-update-user')); @@ -159,7 +159,7 @@ class imsenterprise_test extends \advanced_testcase { $this->assertEquals($imsuser->lastname, $dbuser->lastname); } - public function test_user_update_disabled() { + public function test_user_update_disabled(): void { global $DB; $this->imsplugin->set_config('imsupdateusers', false); @@ -187,7 +187,7 @@ class imsenterprise_test extends \advanced_testcase { /** * Delete user */ - public function test_user_delete() { + public function test_user_delete(): void { global $DB; $this->imsplugin->set_config('imsdeleteusers', true); @@ -208,7 +208,7 @@ class imsenterprise_test extends \advanced_testcase { /** * Delete user disabled */ - public function test_user_delete_disabled() { + public function test_user_delete_disabled(): void { global $DB; $this->imsplugin->set_config('imsdeleteusers', false); @@ -229,7 +229,7 @@ class imsenterprise_test extends \advanced_testcase { /** * Existing courses are not created again */ - public function test_courses_existing() { + public function test_courses_existing(): void { global $DB; $course1 = $this->getDataGenerator()->create_course(array('idnumber' => 'id1')); @@ -253,7 +253,7 @@ class imsenterprise_test extends \advanced_testcase { /** * Add new courses */ - public function test_courses_add() { + public function test_courses_add(): void { global $DB; $prevncourses = $DB->count_records('course'); @@ -283,7 +283,7 @@ class imsenterprise_test extends \advanced_testcase { * Verify that courses are not created when createnewcourses * option is diabled. */ - public function test_courses_add_createnewcourses_disabled() { + public function test_courses_add_createnewcourses_disabled(): void { global $DB; $this->imsplugin->set_config('createnewcourses', false); @@ -318,7 +318,7 @@ class imsenterprise_test extends \advanced_testcase { /** * Test adding a course with no idnumber. */ - public function test_courses_no_idnumber() { + public function test_courses_no_idnumber(): void { global $DB; $prevncourses = $DB->count_records('course'); @@ -339,7 +339,7 @@ class imsenterprise_test extends \advanced_testcase { /** * Add new course with the truncateidnumber setting. */ - public function test_courses_add_truncate_idnumber() { + public function test_courses_add_truncate_idnumber(): void { global $DB; $truncatelength = 4; @@ -367,7 +367,7 @@ class imsenterprise_test extends \advanced_testcase { /** * Add new course without a category. */ - public function test_course_add_default_category() { + public function test_course_add_default_category(): void { global $DB; $this->imsplugin->set_config('createnewcategories', false); @@ -393,7 +393,7 @@ class imsenterprise_test extends \advanced_testcase { /** * Course attributes mapping to IMS enterprise group description tags */ - public function test_courses_attrmapping() { + public function test_courses_attrmapping(): void { global $DB; // Setting a all = coursecode (idnumber) mapping. @@ -465,7 +465,7 @@ class imsenterprise_test extends \advanced_testcase { /** * Course updates */ - public function test_course_update() { + public function test_course_update(): void { global $DB; $course4 = new \stdClass(); @@ -497,7 +497,7 @@ class imsenterprise_test extends \advanced_testcase { /** * Course delete. Make it hidden. */ - public function test_course_delete() { + public function test_course_delete(): void { global $DB; $course8 = new \stdClass(); @@ -528,7 +528,7 @@ class imsenterprise_test extends \advanced_testcase { /** * Nested categories with name during course creation */ - public function test_nested_categories() { + public function test_nested_categories(): void { global $DB; $this->imsplugin->set_config('nestedcategories', true); @@ -582,7 +582,7 @@ class imsenterprise_test extends \advanced_testcase { /** * Test that duplicate nested categories with name are not created */ - public function test_nested_categories_for_dups() { + public function test_nested_categories_for_dups(): void { global $DB; $this->imsplugin->set_config('nestedcategories', true); @@ -622,7 +622,7 @@ class imsenterprise_test extends \advanced_testcase { /** * Nested categories with idnumber during course creation */ - public function test_nested_categories_idnumber() { + public function test_nested_categories_idnumber(): void { global $DB; $this->imsplugin->set_config('nestedcategories', true); @@ -692,7 +692,7 @@ class imsenterprise_test extends \advanced_testcase { /** * Test that duplicate nested categories with idnumber are not created */ - public function test_nested_categories_idnumber_for_dups() { + public function test_nested_categories_idnumber_for_dups(): void { global $DB; $this->imsplugin->set_config('nestedcategories', true); @@ -741,7 +741,7 @@ class imsenterprise_test extends \advanced_testcase { /** * Test that nested categories with idnumber is not created if name is missing */ - public function test_categories_idnumber_missing_name() { + public function test_categories_idnumber_missing_name(): void { global $DB, $CFG; $this->imsplugin->set_config('nestedcategories', true); @@ -785,7 +785,7 @@ class imsenterprise_test extends \advanced_testcase { /** * Create category with name (nested categories not activated). */ - public function test_create_category_name_no_nested() { + public function test_create_category_name_no_nested(): void { global $DB; $course = new \stdClass(); @@ -812,7 +812,7 @@ class imsenterprise_test extends \advanced_testcase { /** * Find a category with name (nested categories not activated). */ - public function test_find_category_name_no_nested() { + public function test_find_category_name_no_nested(): void { global $DB; $cattop = $this->getDataGenerator()->create_category(array('name' => 'CAT-TOP')); @@ -845,7 +845,7 @@ class imsenterprise_test extends \advanced_testcase { /** * Create category with idnumber (nested categories not activated). */ - public function test_create_category_idnumber_no_nested() { + public function test_create_category_idnumber_no_nested(): void { global $DB; $this->imsplugin->set_config('categoryidnumber', true); @@ -877,7 +877,7 @@ class imsenterprise_test extends \advanced_testcase { /** * Find a category with idnumber (nested categories not activated). */ - public function test_find_category_idnumber_no_nested() { + public function test_find_category_idnumber_no_nested(): void { global $DB; $this->imsplugin->set_config('categoryidnumber', true); @@ -919,7 +919,7 @@ class imsenterprise_test extends \advanced_testcase { /** * Test that category with idnumber is not created if name is missing (nested categories not activated). */ - public function test_category_idnumber_missing_name_no_nested() { + public function test_category_idnumber_missing_name_no_nested(): void { global $DB; $this->imsplugin->set_config('categoryidnumber', true); @@ -1084,7 +1084,7 @@ class imsenterprise_test extends \advanced_testcase { /** * IMS Enterprise enrolment task test. */ - public function test_imsenterprise_cron_task() { + public function test_imsenterprise_cron_task(): void { global $DB; $prevnusers = $DB->count_records('user'); diff --git a/enrol/imsenterprise/tests/imsenterprise_unenrol_test.php b/enrol/imsenterprise/tests/imsenterprise_unenrol_test.php index 4c41962822d..33d4760bd0e 100644 --- a/enrol/imsenterprise/tests/imsenterprise_unenrol_test.php +++ b/enrol/imsenterprise/tests/imsenterprise_unenrol_test.php @@ -273,7 +273,7 @@ class imsenterprise_unenrol_test extends \advanced_testcase { /** * Add new users, courses and enrolments */ - public function test_users_are_enroled_on_courses() { + public function test_users_are_enroled_on_courses(): void { global $DB; $prevnuserenrolments = $DB->count_records('user_enrolments'); @@ -301,7 +301,7 @@ class imsenterprise_unenrol_test extends \advanced_testcase { /** * Check that the unenrol actions are completely ignored when "unenrol" setting is disabled */ - public function test_no_action_when_unenrol_disabled() { + public function test_no_action_when_unenrol_disabled(): void { global $DB; $prevnuserenrolments = $DB->count_records('user_enrolments'); @@ -360,7 +360,7 @@ class imsenterprise_unenrol_test extends \advanced_testcase { /** * When a user has existing roles and enrolments, they are unaffected by IMS instructions for other courses */ - public function test_existing_roles_and_enrolments_unaffected() { + public function test_existing_roles_and_enrolments_unaffected(): void { global $DB; @@ -445,7 +445,7 @@ class imsenterprise_unenrol_test extends \advanced_testcase { /** * Enrolments alone are disabled */ - public function test_disable_enrolments_only() { + public function test_disable_enrolments_only(): void { global $DB; @@ -522,7 +522,7 @@ class imsenterprise_unenrol_test extends \advanced_testcase { /** * Enrolments are disabled but retained) and roles removed */ - public function test_disable_enrolments_and_remove_roles() { + public function test_disable_enrolments_and_remove_roles(): void { global $DB; @@ -600,7 +600,7 @@ class imsenterprise_unenrol_test extends \advanced_testcase { /** * Enrolments and roles are deleted for specified user */ - public function test_delete_roles_and_enrolments() { + public function test_delete_roles_and_enrolments(): void { global $DB; diff --git a/enrol/ldap/tests/ldap_test.php b/enrol/ldap/tests/ldap_test.php index 7f93d763593..55035fad01f 100644 --- a/enrol/ldap/tests/ldap_test.php +++ b/enrol/ldap/tests/ldap_test.php @@ -64,7 +64,7 @@ class ldap_test extends \advanced_testcase { * @param int $pagesize Value to be configured in settings controlling page size. * @param int $subcontext Value to be configured in settings controlling searching in subcontexts. */ - public function test_enrol_ldap(int $pagesize, int $subcontext) { + public function test_enrol_ldap(int $pagesize, int $subcontext): void { global $CFG, $DB; if (!extension_loaded('ldap')) { @@ -502,7 +502,7 @@ class ldap_test extends \advanced_testcase { * @param string $usertype The supported user type * @param string $expected The expected filter value */ - public function test_objectclass_fetch($usertype, $expected) { + public function test_objectclass_fetch($usertype, $expected): void { $this->resetAfterTest(); // Set the user type - this must be performed before the plugin is instantiated. set_config('user_type', $usertype, 'enrol_ldap'); diff --git a/enrol/lti/tests/data_connector_test.php b/enrol/lti/tests/data_connector_test.php index d2e812fecd4..5707a22a434 100644 --- a/enrol/lti/tests/data_connector_test.php +++ b/enrol/lti/tests/data_connector_test.php @@ -51,7 +51,7 @@ class data_connector_test extends \advanced_testcase { /** * Test for data_connector::loadToolConsumer(). */ - public function test_load_consumer() { + public function test_load_consumer(): void { $consumer = new ToolConsumer(); $dc = new data_connector(); @@ -114,7 +114,7 @@ class data_connector_test extends \advanced_testcase { /** * Test for data_connector::saveToolConsumer(). */ - public function test_save_consumer() { + public function test_save_consumer(): void { $dc = new data_connector(); $time = time(); @@ -211,7 +211,7 @@ class data_connector_test extends \advanced_testcase { /** * Test for data_connector::deleteToolConsumer(). */ - public function test_delete_tool_consumer() { + public function test_delete_tool_consumer(): void { $dc = new data_connector(); $data = [ 'name' => 'TestName', @@ -290,7 +290,7 @@ class data_connector_test extends \advanced_testcase { /** * Test for data_connector::getToolConsumers(). */ - public function test_get_tool_consumers() { + public function test_get_tool_consumers(): void { $dc = new data_connector(); $consumers = $dc->getToolConsumers(); @@ -331,7 +331,7 @@ class data_connector_test extends \advanced_testcase { /** * Test for data_connector::loadToolProxy(). */ - public function test_get_tool_proxy() { + public function test_get_tool_proxy(): void { $dc = new data_connector(); $toolproxy = new ToolProxy($dc); $this->assertFalse($dc->loadToolProxy($toolproxy)); @@ -340,7 +340,7 @@ class data_connector_test extends \advanced_testcase { /** * Test for data_connector::saveToolProxy(). */ - public function test_save_tool_proxy() { + public function test_save_tool_proxy(): void { $dc = new data_connector(); $toolproxy = new ToolProxy($dc); $this->assertFalse($dc->saveToolProxy($toolproxy)); @@ -349,7 +349,7 @@ class data_connector_test extends \advanced_testcase { /** * Test for data_connector::deleteToolProxy(). */ - public function test_delete_tool_proxy() { + public function test_delete_tool_proxy(): void { $dc = new data_connector(); $toolproxy = new ToolProxy($dc); $this->assertFalse($dc->deleteToolProxy($toolproxy)); @@ -358,7 +358,7 @@ class data_connector_test extends \advanced_testcase { /** * Test for data_connector::loadContext(). */ - public function test_load_context() { + public function test_load_context(): void { $dc = new data_connector(); $consumer = new ToolConsumer(null, $dc); $consumer->name = 'testconsumername'; @@ -394,7 +394,7 @@ class data_connector_test extends \advanced_testcase { /** * Test for data_connector::saveContext(). */ - public function test_save_context() { + public function test_save_context(): void { $dc = new data_connector(); $consumer = new ToolConsumer(null, $dc); $consumer->name = 'testconsumername'; @@ -446,7 +446,7 @@ class data_connector_test extends \advanced_testcase { /** * Test for data_connector::deleteContext(). */ - public function test_delete_context() { + public function test_delete_context(): void { $dc = new data_connector(); $consumer = new ToolConsumer(null, $dc); $consumer->name = 'testconsumername'; @@ -523,7 +523,7 @@ class data_connector_test extends \advanced_testcase { /** * Test for data_connector::loadResourceLink(). */ - public function test_load_resource_link() { + public function test_load_resource_link(): void { $dc = new data_connector(); // Consumer for the resource link. @@ -582,7 +582,7 @@ class data_connector_test extends \advanced_testcase { /** * Test for data_connector::saveResourceLink(). */ - public function test_save_resource_link() { + public function test_save_resource_link(): void { $dc = new data_connector(); // Consumer for the resource link. @@ -648,7 +648,7 @@ class data_connector_test extends \advanced_testcase { /** * Test for data_connector::deleteResourceLink(). */ - public function test_delete_resource_link() { + public function test_delete_resource_link(): void { $dc = new data_connector(); $consumer = new ToolConsumer(null, $dc); $consumer->name = 'testconsumername'; @@ -707,7 +707,7 @@ class data_connector_test extends \advanced_testcase { /** * Test for data_connector::getUserResultSourcedIDsResourceLink(). */ - public function test_get_user_result_sourced_ids_resource_link() { + public function test_get_user_result_sourced_ids_resource_link(): void { $dc = new data_connector(); $consumer = new ToolConsumer(null, $dc); $consumer->name = 'testconsumername'; @@ -764,7 +764,7 @@ class data_connector_test extends \advanced_testcase { /** * Test for data_connector::getSharesResourceLink(). */ - public function test_get_shares_resource_link() { + public function test_get_shares_resource_link(): void { $dc = new data_connector(); $consumer = new ToolConsumer(null, $dc); $consumer->name = 'testconsumername'; @@ -814,7 +814,7 @@ class data_connector_test extends \advanced_testcase { /** * Test for data_connector::loadConsumerNonce(). */ - public function test_load_consumer_nonce() { + public function test_load_consumer_nonce(): void { $dc = new data_connector(); $consumer = new ToolConsumer(null, $dc); @@ -835,7 +835,7 @@ class data_connector_test extends \advanced_testcase { /** * Test for data_connector::loadConsumerNonce() for a nonce that has expired. */ - public function test_load_consumer_nonce_expired() { + public function test_load_consumer_nonce_expired(): void { $dc = new data_connector(); $consumer = new ToolConsumer(null, $dc); @@ -855,7 +855,7 @@ class data_connector_test extends \advanced_testcase { /** * Test for data_connector::saveConsumerNonce(). */ - public function test_save_consumer_nonce() { + public function test_save_consumer_nonce(): void { $dc = new data_connector(); $consumer = new ToolConsumer(null, $dc); @@ -873,7 +873,7 @@ class data_connector_test extends \advanced_testcase { /** * Test for data_connector::loadResourceLinkShareKey(). */ - public function test_load_resource_link_share_key() { + public function test_load_resource_link_share_key(): void { $dc = new data_connector(); $consumer = new ToolConsumer(null, $dc); @@ -903,7 +903,7 @@ class data_connector_test extends \advanced_testcase { /** * Test for data_connector::loadResourceLinkShareKey() with an expired share key. */ - public function test_load_resource_link_share_key_expired() { + public function test_load_resource_link_share_key_expired(): void { $dc = new data_connector(); $consumer = new ToolConsumer(null, $dc); @@ -927,7 +927,7 @@ class data_connector_test extends \advanced_testcase { /** * Test for data_connector::saveResourceLinkShareKey(). */ - public function test_save_resource_link_share_key() { + public function test_save_resource_link_share_key(): void { $dc = new data_connector(); $consumer = new ToolConsumer(null, $dc); @@ -956,7 +956,7 @@ class data_connector_test extends \advanced_testcase { /** * Test for data_connector::deleteResourceLinkShareKey(). */ - public function test_delete_resource_link_share_key() { + public function test_delete_resource_link_share_key(): void { $dc = new data_connector(); $consumer = new ToolConsumer(null, $dc); @@ -984,7 +984,7 @@ class data_connector_test extends \advanced_testcase { /** * Test for data_connector::loadUser(). */ - public function test_load_user() { + public function test_load_user(): void { $dc = new data_connector(); $consumer = new ToolConsumer(null, $dc); $consumer->name = 'TestName'; @@ -1019,7 +1019,7 @@ class data_connector_test extends \advanced_testcase { /** * Test for data_connector::saveUser(). */ - public function test_save_user() { + public function test_save_user(): void { $dc = new data_connector(); $consumer = new ToolConsumer(null, $dc); $consumer->name = 'TestName'; @@ -1058,7 +1058,7 @@ class data_connector_test extends \advanced_testcase { /** * Test for data_connector::deleteUser(). */ - public function test_delete_user() { + public function test_delete_user(): void { $dc = new data_connector(); $consumer = new ToolConsumer(null, $dc); $consumer->name = 'TestName'; @@ -1100,7 +1100,7 @@ class data_connector_test extends \advanced_testcase { /** * Test for data_connector::get_contexts_from_consumer(). */ - public function test_get_contexts_from_consumer() { + public function test_get_contexts_from_consumer(): void { $dc = new data_connector(); $consumer = new ToolConsumer(null, $dc); $consumer->name = 'testconsumername'; @@ -1133,7 +1133,7 @@ class data_connector_test extends \advanced_testcase { /** * Test for data_connector::get_consumers_mapped_to_tool(). */ - public function test_get_consumers_mapped_to_tool() { + public function test_get_consumers_mapped_to_tool(): void { $generator = $this->getDataGenerator(); // Create two tools belonging to the same course. $course1 = $generator->create_course(); @@ -1173,7 +1173,7 @@ class data_connector_test extends \advanced_testcase { /** * Test for data_connector::get_resourcelink_from_consumer() */ - public function test_get_resourcelink_from_consumer() { + public function test_get_resourcelink_from_consumer(): void { $dc = new data_connector(); $consumer = new ToolConsumer(null, $dc); @@ -1197,7 +1197,7 @@ class data_connector_test extends \advanced_testcase { /** * Test for data_connector::get_resourcelink_from_context() */ - public function test_get_resourcelink_from_context() { + public function test_get_resourcelink_from_context(): void { $dc = new data_connector(); $consumer = new ToolConsumer(null, $dc); diff --git a/enrol/lti/tests/helper_test.php b/enrol/lti/tests/helper_test.php index a3553183415..e1e99fdb6c6 100644 --- a/enrol/lti/tests/helper_test.php +++ b/enrol/lti/tests/helper_test.php @@ -54,7 +54,7 @@ class helper_test extends \advanced_testcase { /** * Test the update user profile image function. */ - public function test_update_user_profile_image() { + public function test_update_user_profile_image(): void { global $DB, $CFG; // Set the profile image. @@ -79,7 +79,7 @@ class helper_test extends \advanced_testcase { /** * Test that we can not enrol past the maximum number of users allowed. */ - public function test_enrol_user_max_enrolled() { + public function test_enrol_user_max_enrolled(): void { global $DB; // Set up the LTI enrolment tool. @@ -108,7 +108,7 @@ class helper_test extends \advanced_testcase { /** * Test that we can not enrol when the enrolment has not started. */ - public function test_enrol_user_enrolment_not_started() { + public function test_enrol_user_enrolment_not_started(): void { global $DB; // Set up the LTI enrolment tool. @@ -130,7 +130,7 @@ class helper_test extends \advanced_testcase { /** * Test that we can not enrol when the enrolment has finished. */ - public function test_enrol_user_enrolment_finished() { + public function test_enrol_user_enrolment_finished(): void { global $DB; // Set up the LTI enrolment tool. @@ -152,7 +152,7 @@ class helper_test extends \advanced_testcase { /** * Test returning the number of available tools. */ - public function test_count_lti_tools() { + public function test_count_lti_tools(): void { $generator = $this->getDataGenerator(); // Create two tools belonging to the same course. $course1 = $generator->create_course(); @@ -191,7 +191,7 @@ class helper_test extends \advanced_testcase { /** * Test returning the list of available tools. */ - public function test_get_lti_tools() { + public function test_get_lti_tools(): void { $generator = $this->getDataGenerator(); // Create two tools belonging to the same course. $course1 = $generator->create_course(); @@ -244,7 +244,7 @@ class helper_test extends \advanced_testcase { /** * Test getting the launch url of a tool. */ - public function test_get_launch_url() { + public function test_get_launch_url(): void { $course1 = $this->getDataGenerator()->create_course(); $data = new \stdClass(); $data->courseid = $course1->id; @@ -258,7 +258,7 @@ class helper_test extends \advanced_testcase { /** * Test getting the cartridge url of a tool. */ - public function test_get_cartridge_url() { + public function test_get_cartridge_url(): void { global $CFG; $slasharguments = $CFG->slasharguments; @@ -288,7 +288,7 @@ class helper_test extends \advanced_testcase { /** * Test getting the cartridge url of a tool. */ - public function test_get_proxy_url() { + public function test_get_proxy_url(): void { global $CFG; $slasharguments = $CFG->slasharguments; @@ -318,7 +318,7 @@ class helper_test extends \advanced_testcase { /** * Test getting the name of a tool. */ - public function test_get_name() { + public function test_get_name(): void { $course1 = $this->getDataGenerator()->create_course(); $data = new \stdClass(); $data->courseid = $course1->id; @@ -335,7 +335,7 @@ class helper_test extends \advanced_testcase { /** * Test getting the description of a tool. */ - public function test_get_description() { + public function test_get_description(): void { $generator = $this->getDataGenerator(); $course1 = $generator->create_course(); $data = new \stdClass(); @@ -358,7 +358,7 @@ class helper_test extends \advanced_testcase { /** * Test getting the icon of a tool. */ - public function test_get_icon() { + public function test_get_icon(): void { global $CFG; $course1 = $this->getDataGenerator()->create_course(); @@ -376,7 +376,7 @@ class helper_test extends \advanced_testcase { /** * Test verifying a cartridge token. */ - public function test_verify_cartridge_token() { + public function test_verify_cartridge_token(): void { $course1 = $this->getDataGenerator()->create_course(); $data = new \stdClass(); $data->courseid = $course1->id; @@ -390,7 +390,7 @@ class helper_test extends \advanced_testcase { /** * Test verifying a proxy token. */ - public function test_verify_proxy_token() { + public function test_verify_proxy_token(): void { $course1 = $this->getDataGenerator()->create_course(); $data = new \stdClass(); $data->courseid = $course1->id; @@ -474,7 +474,7 @@ class helper_test extends \advanced_testcase { * @param array $parameters A hash of parameters represented by a heirarchy of xpath expressions * @param string $expected The name of the fixture file containing the expected result. */ - public function test_set_xpath($parameters, $expected) { + public function test_set_xpath($parameters, $expected): void { $helper = new \ReflectionClass('enrol_lti\\helper'); $function = $helper->getMethod('set_xpath'); @@ -490,7 +490,7 @@ class helper_test extends \advanced_testcase { /** * Test set_xpath when an incorrect xpath expression is given. */ - public function test_set_xpath_incorrect_xpath() { + public function test_set_xpath_incorrect_xpath(): void { $parameters = [ "/root" => [ "/firstnode" => null, @@ -513,7 +513,7 @@ class helper_test extends \advanced_testcase { /** * Test create cartridge. */ - public function test_create_cartridge() { + public function test_create_cartridge(): void { global $CFG; $course1 = $this->getDataGenerator()->create_course(); diff --git a/enrol/lti/tests/lib_test.php b/enrol/lti/tests/lib_test.php index 9698d5e818b..ef378a0f87d 100644 --- a/enrol/lti/tests/lib_test.php +++ b/enrol/lti/tests/lib_test.php @@ -56,7 +56,7 @@ class lib_test extends \lti_advantage_testcase { /** * Test for enrol_lti_plugin::delete_instance(). */ - public function test_delete_instance() { + public function test_delete_instance(): void { global $DB; // Create tool enrolment instance. @@ -126,7 +126,7 @@ class lib_test extends \lti_advantage_testcase { * * @covers \enrol_lti_plugin::delete_instance */ - public function test_delete_instance_lti_advantage() { + public function test_delete_instance_lti_advantage(): void { global $DB; // Setup. [ @@ -171,7 +171,7 @@ class lib_test extends \lti_advantage_testcase { /** * Test for getting user enrolment actions. */ - public function test_get_user_enrolment_actions() { + public function test_get_user_enrolment_actions(): void { global $CFG, $DB, $PAGE; $this->resetAfterTest(); @@ -222,7 +222,7 @@ class lib_test extends \lti_advantage_testcase { * * @covers \enrol_lti_pre_course_module_delete */ - public function test_course_module_deletion() { + public function test_course_module_deletion(): void { // Create two modules and publish them. $course = $this->getDataGenerator()->create_course(); $mod = $this->getDataGenerator()->create_module('assign', ['course' => $course->id]); diff --git a/enrol/lti/tests/local/ltiadvantage/entity/ags_info_test.php b/enrol/lti/tests/local/ltiadvantage/entity/ags_info_test.php index 87d0bba422c..538d7a4a031 100644 --- a/enrol/lti/tests/local/ltiadvantage/entity/ags_info_test.php +++ b/enrol/lti/tests/local/ltiadvantage/entity/ags_info_test.php @@ -33,7 +33,7 @@ class ags_info_test extends \advanced_testcase { * @param array $expectations various expectations for the test cases. * @covers ::create */ - public function test_creation(array $args, array $expectations) { + public function test_creation(array $args, array $expectations): void { if (!$expectations['valid']) { $this->expectException($expectations['exception']); $this->expectExceptionMessage($expectations['exceptionmessage']); diff --git a/enrol/lti/tests/local/ltiadvantage/entity/application_registration_test.php b/enrol/lti/tests/local/ltiadvantage/entity/application_registration_test.php index 5937136af6e..727c2f2a001 100644 --- a/enrol/lti/tests/local/ltiadvantage/entity/application_registration_test.php +++ b/enrol/lti/tests/local/ltiadvantage/entity/application_registration_test.php @@ -34,7 +34,7 @@ class application_registration_test extends \advanced_testcase { * @param array $expectations various expectations for the test cases. * @covers ::create */ - public function test_creation(array $args, array $expectations) { + public function test_creation(array $args, array $expectations): void { if ($expectations['valid']) { $reg = application_registration::create(...array_values($args)); $this->assertEquals($args['name'], $reg->get_name()); @@ -149,7 +149,7 @@ class application_registration_test extends \advanced_testcase { * @param array $expectations various expectations for the test cases. * @covers ::create_draft */ - public function test_create_draft(array $args, array $expectations) { + public function test_create_draft(array $args, array $expectations): void { if ($expectations['valid']) { $reg = application_registration::create_draft(...array_values($args)); $this->assertEquals($args['name'], $reg->get_name()); @@ -174,7 +174,7 @@ class application_registration_test extends \advanced_testcase { * * @covers ::complete_registration */ - public function test_complete_registration() { + public function test_complete_registration(): void { // Create a draft registration which should initially be incomplete. $draft = application_registration::create_draft('Test platform name', '1234bfda'); $this->assertFalse($draft->is_complete()); @@ -246,7 +246,7 @@ class application_registration_test extends \advanced_testcase { * @param array $expectations various expectations for the test cases. * @covers ::add_tool_deployment */ - public function test_add_tool_deployment(array $args, array $expectations) { + public function test_add_tool_deployment(array $args, array $expectations): void { if ($expectations['valid']) { $reg = application_registration::create(...array_values($args['registration'])); diff --git a/enrol/lti/tests/local/ltiadvantage/entity/context_test.php b/enrol/lti/tests/local/ltiadvantage/entity/context_test.php index b9f5d4d631b..0898222013d 100644 --- a/enrol/lti/tests/local/ltiadvantage/entity/context_test.php +++ b/enrol/lti/tests/local/ltiadvantage/entity/context_test.php @@ -34,7 +34,7 @@ class context_test extends \advanced_testcase { * @param array $expectations various expectations for the test cases. * @covers ::create */ - public function test_creation(array $args, array $expectations) { + public function test_creation(array $args, array $expectations): void { if (!$expectations['valid']) { $this->expectException($expectations['exception']); $this->expectExceptionMessage($expectations['exceptionmessage']); diff --git a/enrol/lti/tests/local/ltiadvantage/entity/deployment_test.php b/enrol/lti/tests/local/ltiadvantage/entity/deployment_test.php index 81f252161c5..4adb64b18aa 100644 --- a/enrol/lti/tests/local/ltiadvantage/entity/deployment_test.php +++ b/enrol/lti/tests/local/ltiadvantage/entity/deployment_test.php @@ -34,7 +34,7 @@ class deployment_test extends \advanced_testcase { * @param array $expectations various expectations for the test cases. * @covers ::create */ - public function test_creation(array $args, array $expectations) { + public function test_creation(array $args, array $expectations): void { if (!$expectations['valid']) { $this->expectException($expectations['exception']); $this->expectExceptionMessage($expectations['exceptionmessage']); @@ -141,7 +141,7 @@ class deployment_test extends \advanced_testcase { * * @covers ::add_context */ - public function test_add_context() { + public function test_add_context(): void { $deploymentwithid = deployment::create(123, 'deploymentid123', 'Global tool deployment', 55); $context = $deploymentwithid->add_context('context-id-123', ['CourseSection']); $this->assertInstanceOf(context::class, $context); @@ -158,7 +158,7 @@ class deployment_test extends \advanced_testcase { * * @covers ::add_resource_link */ - public function test_add_resource_link() { + public function test_add_resource_link(): void { $deploymentwithid = deployment::create(123, 'deploymentid123', 'Global tool deployment', 55); $resourcelink = $deploymentwithid->add_resource_link('res-link-id-123', 45); $this->assertInstanceOf(resource_link::class, $resourcelink); @@ -178,7 +178,7 @@ class deployment_test extends \advanced_testcase { * * @covers ::set_legacy_consumer_key */ - public function test_set_legacy_consumer_key() { + public function test_set_legacy_consumer_key(): void { $deployment = deployment::create(12, 'deploy-id-123', 'Global tool deployment'); $deployment->set_legacy_consumer_key(str_repeat('a', 255)); $this->assertEquals(str_repeat('a', 255), $deployment->get_legacy_consumer_key()); diff --git a/enrol/lti/tests/local/ltiadvantage/entity/migration_claim_test.php b/enrol/lti/tests/local/ltiadvantage/entity/migration_claim_test.php index 6900408a513..e04f55e9559 100644 --- a/enrol/lti/tests/local/ltiadvantage/entity/migration_claim_test.php +++ b/enrol/lti/tests/local/ltiadvantage/entity/migration_claim_test.php @@ -60,7 +60,7 @@ class migration_claim_test extends \advanced_testcase { */ public function test_migration_claim(array $migrationclaimdata, string $deploymentid, string $platform, string $clientid, string $exp, string $nonce, legacy_consumer_repository $legacyconsumerrepo, - array $expected) { + array $expected): void { if (!empty($expected['exception'])) { $this->expectException($expected['exception']); diff --git a/enrol/lti/tests/local/ltiadvantage/entity/nrps_info_test.php b/enrol/lti/tests/local/ltiadvantage/entity/nrps_info_test.php index 7e23fe90b90..cc6c58ea974 100644 --- a/enrol/lti/tests/local/ltiadvantage/entity/nrps_info_test.php +++ b/enrol/lti/tests/local/ltiadvantage/entity/nrps_info_test.php @@ -34,7 +34,7 @@ class nrps_info_test extends \advanced_testcase { * @param array $expectations various expectations for the test cases. * @covers ::create */ - public function test_create(array $args, array $expectations) { + public function test_create(array $args, array $expectations): void { if (!$expectations['valid']) { $this->expectException($expectations['exception']); $this->expectExceptionMessage($expectations['exceptionmessage']); diff --git a/enrol/lti/tests/local/ltiadvantage/entity/resource_link_test.php b/enrol/lti/tests/local/ltiadvantage/entity/resource_link_test.php index 04f35d0b01c..e1726f3d0c6 100644 --- a/enrol/lti/tests/local/ltiadvantage/entity/resource_link_test.php +++ b/enrol/lti/tests/local/ltiadvantage/entity/resource_link_test.php @@ -33,7 +33,7 @@ class resource_link_test extends \advanced_testcase { * @param array $expectations various expectations for the test cases. * @covers ::create */ - public function test_create(array $args, array $expectations) { + public function test_create(array $args, array $expectations): void { if (!$expectations['valid']) { $this->expectException($expectations['exception']); $this->expectExceptionMessage($expectations['exceptionmessage']); @@ -120,7 +120,7 @@ class resource_link_test extends \advanced_testcase { * @dataProvider add_grade_service_provider * @covers ::add_grade_service */ - public function test_add_grade_service(array $args, array $expected) { + public function test_add_grade_service(array $args, array $expected): void { $reslink = resource_link::create('res-link-id-123', 24, 44); $this->assertNull($reslink->get_grade_service()); @@ -212,7 +212,7 @@ class resource_link_test extends \advanced_testcase { * * @covers ::add_names_and_roles_service */ - public function test_add_names_and_roles_service() { + public function test_add_names_and_roles_service(): void { $reslink = resource_link::create('res-link-id-123', 24, 44); $this->assertNull($reslink->get_names_and_roles_service()); $reslink->add_names_and_roles_service(new \moodle_url('https://lms.example.com/10/memberships'), ['2.0']); @@ -228,7 +228,7 @@ class resource_link_test extends \advanced_testcase { * * @covers ::add_user */ - public function test_add_user() { + public function test_add_user(): void { global $CFG; $reslinkwithid = resource_link::create('res-link-id-123', 24, 44, 66, 33); $user = $reslinkwithid->add_user(2, 'platform-user-id-123', $CFG->lang, 'Sydney', 'AU', 'Test university', '99'); @@ -246,7 +246,7 @@ class resource_link_test extends \advanced_testcase { * * @covers ::set_resourceid */ - public function test_set_resource_id() { + public function test_set_resource_id(): void { $reslink = resource_link::create('res-link-id-123', 24, 44); $this->assertEquals(44, $reslink->get_resourceid()); $reslink->set_resourceid(333); @@ -261,7 +261,7 @@ class resource_link_test extends \advanced_testcase { * * @covers ::set_contextid */ - public function test_set_context_id() { + public function test_set_context_id(): void { $reslink = resource_link::create('res-link-id-123', 24, 44); $this->assertEquals(null, $reslink->get_contextid()); $reslink->set_contextid(333); diff --git a/enrol/lti/tests/local/ltiadvantage/entity/user_test.php b/enrol/lti/tests/local/ltiadvantage/entity/user_test.php index ae594f9c8ce..69aa28e77a6 100644 --- a/enrol/lti/tests/local/ltiadvantage/entity/user_test.php +++ b/enrol/lti/tests/local/ltiadvantage/entity/user_test.php @@ -34,7 +34,7 @@ class user_test extends \advanced_testcase { * @param array $expectations various expectations for the test cases. * @covers ::create */ - public function test_create(array $args, array $expectations) { + public function test_create(array $args, array $expectations): void { if ($expectations['valid']) { $user = user::create(...array_values($args)); $this->assertInstanceOf(user::class, $user); @@ -242,7 +242,7 @@ class user_test extends \advanced_testcase { * @param array $expectations various expectations for the test cases. * @covers ::create_from_resource_link */ - public function test_create_from_resource_link(array $args, array $expectations) { + public function test_create_from_resource_link(array $args, array $expectations): void { if ($expectations['valid']) { $user = user::create_from_resource_link(...array_values($args)); $this->assertInstanceOf(user::class, $user); @@ -487,7 +487,7 @@ class user_test extends \advanced_testcase { * @param array $expectations the array of expectations * @covers ::__construct */ - public function test_setters_and_getters(string $methodname, $arg, array $expectations) { + public function test_setters_and_getters(string $methodname, $arg, array $expectations): void { $user = $this->create_test_user(); $setter = 'set_'.$methodname; $getter = 'get_'.$methodname; diff --git a/enrol/lti/tests/local/ltiadvantage/lib/issuer_database_test.php b/enrol/lti/tests/local/ltiadvantage/lib/issuer_database_test.php index b8aef36e239..9798326f1cc 100644 --- a/enrol/lti/tests/local/ltiadvantage/lib/issuer_database_test.php +++ b/enrol/lti/tests/local/ltiadvantage/lib/issuer_database_test.php @@ -37,7 +37,7 @@ class issuer_database_test extends \advanced_testcase { * * @covers ::findRegistrationByIssuer */ - public function test_find_registration_by_issuer() { + public function test_find_registration_by_issuer(): void { $this->resetAfterTest(); $appregrepo = new application_registration_repository(); $appreg = application_registration::create( @@ -72,7 +72,7 @@ class issuer_database_test extends \advanced_testcase { * * @covers ::findDeployment */ - public function test_find_deployment() { + public function test_find_deployment(): void { $this->resetAfterTest(); $appregrepo = new application_registration_repository(); $appreg = application_registration::create( diff --git a/enrol/lti/tests/local/ltiadvantage/lib/launch_cache_session_test.php b/enrol/lti/tests/local/ltiadvantage/lib/launch_cache_session_test.php index a1bf00ad92b..aeaa14610bc 100644 --- a/enrol/lti/tests/local/ltiadvantage/lib/launch_cache_session_test.php +++ b/enrol/lti/tests/local/ltiadvantage/lib/launch_cache_session_test.php @@ -33,7 +33,7 @@ class launch_cache_session_test extends \advanced_testcase { * * @covers ::cacheLaunchData */ - public function test_cache_launch_data() { + public function test_cache_launch_data(): void { $lcs = new launch_cache_session(); $lcs->cacheLaunchData('TestKey', ['JWT body' => 'xxx']); @@ -49,7 +49,7 @@ class launch_cache_session_test extends \advanced_testcase { * * @covers ::cacheNonce */ - public function test_cache_and_check_nonce() { + public function test_cache_and_check_nonce(): void { $lcs = new launch_cache_session(); $lcs->cacheNonce('my_nonce_123', 'my_state_234'); @@ -66,7 +66,7 @@ class launch_cache_session_test extends \advanced_testcase { * * @covers ::purge */ - public function test_purge() { + public function test_purge(): void { $lcs = new launch_cache_session(); $lcs->cacheLaunchData('TestKey', ['JWT body' => 'xxx']); diff --git a/enrol/lti/tests/local/ltiadvantage/repository/application_registration_repository_test.php b/enrol/lti/tests/local/ltiadvantage/repository/application_registration_repository_test.php index cef5b0bbbdf..c04fc2aaa21 100644 --- a/enrol/lti/tests/local/ltiadvantage/repository/application_registration_repository_test.php +++ b/enrol/lti/tests/local/ltiadvantage/repository/application_registration_repository_test.php @@ -100,7 +100,7 @@ class application_registration_repository_test extends \advanced_testcase { * @covers ::save * @param array $regdata the registration data */ - public function test_save_new(array $regdata) { + public function test_save_new(array $regdata): void { $this->resetAfterTest(); $reg = application_registration::create_draft($regdata['name'], $regdata['uniqueid']); @@ -182,7 +182,7 @@ class application_registration_repository_test extends \advanced_testcase { * * @covers ::save */ - public function test_save_existing() { + public function test_save_existing(): void { $this->resetAfterTest(); $repository = new application_registration_repository(); @@ -227,7 +227,7 @@ class application_registration_repository_test extends \advanced_testcase { * * @covers ::save */ - public function test_save_duplicate_unique_constraints() { + public function test_save_duplicate_unique_constraints(): void { $this->resetAfterTest(); $testregistration = $this->generate_application_registration(); $testregistration2 = $this->generate_application_registration(); @@ -243,7 +243,7 @@ class application_registration_repository_test extends \advanced_testcase { * * @covers ::find */ - public function test_find() { + public function test_find(): void { $this->resetAfterTest(); $testregistration = $this->generate_application_registration(); $repository = new application_registration_repository(); @@ -260,7 +260,7 @@ class application_registration_repository_test extends \advanced_testcase { * * @covers ::find_by_uniqueid */ - public function test_find_by_uniqueid() { + public function test_find_by_uniqueid(): void { $this->resetAfterTest(); $testregistration = $this->generate_application_registration('https://lms.example.org', 'abc12345'); $repository = new application_registration_repository(); @@ -277,7 +277,7 @@ class application_registration_repository_test extends \advanced_testcase { * * @covers ::find_by_platform_uniqueid */ - public function test_find_by_platform_uniqueid() { + public function test_find_by_platform_uniqueid(): void { $this->resetAfterTest(); $repository = new application_registration_repository(); @@ -307,7 +307,7 @@ class application_registration_repository_test extends \advanced_testcase { * * @covers ::find_all */ - public function test_find_all() { + public function test_find_all(): void { $this->resetAfterTest(); // None to begin with. $repository = new application_registration_repository(); @@ -335,7 +335,7 @@ class application_registration_repository_test extends \advanced_testcase { * * @covers ::find_by_platform */ - public function test_find_by_platform() { + public function test_find_by_platform(): void { $this->resetAfterTest(); // None to begin with. $repository = new application_registration_repository(); @@ -359,7 +359,7 @@ class application_registration_repository_test extends \advanced_testcase { * * @covers ::exists */ - public function test_exists() { + public function test_exists(): void { $this->resetAfterTest(); $testregistration = $this->generate_application_registration(); $repository = new application_registration_repository(); @@ -374,7 +374,7 @@ class application_registration_repository_test extends \advanced_testcase { * * @covers ::delete */ - public function test_delete() { + public function test_delete(): void { $this->resetAfterTest(); global $DB; $reg = $this->generate_application_registration(); @@ -394,7 +394,7 @@ class application_registration_repository_test extends \advanced_testcase { * * @covers ::find_by_deployment */ - public function test_find_by_deployment() { + public function test_find_by_deployment(): void { $this->resetAfterTest(); $appregrepo = new application_registration_repository(); $deploymentrepo = new deployment_repository(); diff --git a/enrol/lti/tests/local/ltiadvantage/repository/context_repository_test.php b/enrol/lti/tests/local/ltiadvantage/repository/context_repository_test.php index a8ea6867ce4..d122baeaf9e 100644 --- a/enrol/lti/tests/local/ltiadvantage/repository/context_repository_test.php +++ b/enrol/lti/tests/local/ltiadvantage/repository/context_repository_test.php @@ -85,7 +85,7 @@ class context_repository_test extends \advanced_testcase { * * @covers ::save */ - public function test_save_new() { + public function test_save_new(): void { $this->resetAfterTest(); $context = $this->create_test_context(); $contextrepo = new context_repository(); @@ -101,7 +101,7 @@ class context_repository_test extends \advanced_testcase { * * @covers ::save */ - public function test_save_existing() { + public function test_save_existing(): void { $this->resetAfterTest(); $context = $this->create_test_context(); $contextrepo = new context_repository(); @@ -125,7 +125,7 @@ class context_repository_test extends \advanced_testcase { * * @covers ::save */ - public function test_save_unique_constraints_not_met() { + public function test_save_unique_constraints_not_met(): void { $this->resetAfterTest(); $context = $this->create_test_context(); $context2 = clone $context; @@ -143,7 +143,7 @@ class context_repository_test extends \advanced_testcase { * * @covers ::exists */ - public function test_exists() { + public function test_exists(): void { $this->resetAfterTest(); $contextrepo = new context_repository(); $context = $this->create_test_context(); @@ -158,7 +158,7 @@ class context_repository_test extends \advanced_testcase { * * @covers ::find */ - public function test_find() { + public function test_find(): void { $this->resetAfterTest(); $context = $this->create_test_context(); $contextrepo = new context_repository(); @@ -175,7 +175,7 @@ class context_repository_test extends \advanced_testcase { * * @covers ::find_by_contextid */ - public function test_find_by_contextid() { + public function test_find_by_contextid(): void { $this->resetAfterTest(); $context = $this->create_test_context(); $contextrepo = new context_repository(); @@ -193,7 +193,7 @@ class context_repository_test extends \advanced_testcase { * * @covers ::delete */ - public function test_delete() { + public function test_delete(): void { $this->resetAfterTest(); $context = $this->create_test_context(); $contextrepo = new context_repository(); @@ -211,7 +211,7 @@ class context_repository_test extends \advanced_testcase { * * @covers ::delete_by_deployment */ - public function test_delete_by_deployment() { + public function test_delete_by_deployment(): void { $this->resetAfterTest(); $context = $this->create_test_context(); $contextrepo = new context_repository(); diff --git a/enrol/lti/tests/local/ltiadvantage/repository/deployment_repository_test.php b/enrol/lti/tests/local/ltiadvantage/repository/deployment_repository_test.php index e6217b3d6f6..ee19b9f8f4a 100644 --- a/enrol/lti/tests/local/ltiadvantage/repository/deployment_repository_test.php +++ b/enrol/lti/tests/local/ltiadvantage/repository/deployment_repository_test.php @@ -93,7 +93,7 @@ class deployment_repository_test extends \advanced_testcase { * * @covers ::save */ - public function test_save_new() { + public function test_save_new(): void { $this->resetAfterTest(); $deploymentrepo = new deployment_repository(); $deployment = $this->create_test_deployment(); @@ -110,7 +110,7 @@ class deployment_repository_test extends \advanced_testcase { * * @covers ::save */ - public function test_save_existing() { + public function test_save_existing(): void { $this->resetAfterTest(); $deploymentrepo = new deployment_repository(); $deployment = $this->create_test_deployment(); @@ -129,7 +129,7 @@ class deployment_repository_test extends \advanced_testcase { * * @covers ::save */ - public function test_save_unique_constraints_not_met() { + public function test_save_unique_constraints_not_met(): void { $this->resetAfterTest(); $deployment1 = $this->create_test_deployment('Deploy_ID_123'); $deployment2 = $this->create_test_deployment('Deploy_ID_123', $deployment1->get_registrationid()); @@ -145,7 +145,7 @@ class deployment_repository_test extends \advanced_testcase { * * @covers ::exists */ - public function test_exists() { + public function test_exists(): void { $this->resetAfterTest(); $deploymentrepo = new deployment_repository(); $deployment = $this->create_test_deployment(); @@ -160,7 +160,7 @@ class deployment_repository_test extends \advanced_testcase { * * @covers ::find */ - public function test_find() { + public function test_find(): void { $this->resetAfterTest(); $deployment = $this->create_test_deployment(); $deploymentrepo = new deployment_repository(); @@ -177,7 +177,7 @@ class deployment_repository_test extends \advanced_testcase { * * @covers ::delete */ - public function test_delete() { + public function test_delete(): void { $this->resetAfterTest(); $deployment = $this->create_test_deployment(); $deploymentrepo = new deployment_repository(); @@ -195,7 +195,7 @@ class deployment_repository_test extends \advanced_testcase { * * @covers ::delete_by_registration */ - public function test_delete_by_registration() { + public function test_delete_by_registration(): void { $this->resetAfterTest(); $deployment = $this->create_test_deployment(); $deploymentrepo = new deployment_repository(); @@ -223,7 +223,7 @@ class deployment_repository_test extends \advanced_testcase { * * @covers ::count_by_registration */ - public function test_count_by_registration() { + public function test_count_by_registration(): void { $this->resetAfterTest(); $deployment = $this->create_test_deployment(); $deploymentrepo = new deployment_repository(); @@ -245,7 +245,7 @@ class deployment_repository_test extends \advanced_testcase { * * @covers ::find_by_registration */ - public function test_find_by_registration() { + public function test_find_by_registration(): void { $this->resetAfterTest(); $deployment = $this->create_test_deployment(); $deploymentrepo = new deployment_repository(); @@ -265,7 +265,7 @@ class deployment_repository_test extends \advanced_testcase { * * @covers ::find_all_by_registration */ - public function test_find_all_by_registration() { + public function test_find_all_by_registration(): void { $this->resetAfterTest(); $registration1 = application_registration::create( 'Test', diff --git a/enrol/lti/tests/local/ltiadvantage/repository/legacy_consumer_repository_test.php b/enrol/lti/tests/local/ltiadvantage/repository/legacy_consumer_repository_test.php index 16f23fda3ed..10b22381bdf 100644 --- a/enrol/lti/tests/local/ltiadvantage/repository/legacy_consumer_repository_test.php +++ b/enrol/lti/tests/local/ltiadvantage/repository/legacy_consumer_repository_test.php @@ -34,7 +34,7 @@ class legacy_consumer_repository_test extends \lti_advantage_testcase { * * @covers ::get_consumer_secrets */ - public function test_get_consumer_secrets() { + public function test_get_consumer_secrets(): void { $this->resetAfterTest(); // Set up legacy consumer information. $course = $this->getDataGenerator()->create_course(); diff --git a/enrol/lti/tests/local/ltiadvantage/repository/published_resource_repository_test.php b/enrol/lti/tests/local/ltiadvantage/repository/published_resource_repository_test.php index f862e6be6f1..58bc5635d68 100644 --- a/enrol/lti/tests/local/ltiadvantage/repository/published_resource_repository_test.php +++ b/enrol/lti/tests/local/ltiadvantage/repository/published_resource_repository_test.php @@ -164,7 +164,7 @@ class published_resource_repository_test extends \advanced_testcase { * * @covers ::find_all_for_user */ - public function test_find_all_for_user_no_permissions() { + public function test_find_all_for_user_no_permissions(): void { $this->resetAfterTest(); global $DB; [$user, $user2, $user3, $course, $course2, $mod, $mod2, $mod3, $mod4, $coursetool, $modtool, $mod2tool] diff --git a/enrol/lti/tests/local/ltiadvantage/repository/resource_link_repository_test.php b/enrol/lti/tests/local/ltiadvantage/repository/resource_link_repository_test.php index a9ff411f17c..4526cb3ab3f 100644 --- a/enrol/lti/tests/local/ltiadvantage/repository/resource_link_repository_test.php +++ b/enrol/lti/tests/local/ltiadvantage/repository/resource_link_repository_test.php @@ -118,7 +118,7 @@ class resource_link_repository_test extends \advanced_testcase { * * @covers ::save */ - public function test_save_new() { + public function test_save_new(): void { $this->resetAfterTest(); $resourcelink = $this->generate_resource_link(); $repository = new resource_link_repository(); @@ -134,7 +134,7 @@ class resource_link_repository_test extends \advanced_testcase { * * @covers ::save */ - public function test_add_uniqueness_constraints() { + public function test_add_uniqueness_constraints(): void { $this->resetAfterTest(); $reslink1 = $this->generate_resource_link(); $reslink2 = clone $reslink1; @@ -150,7 +150,7 @@ class resource_link_repository_test extends \advanced_testcase { * * @covers ::find */ - public function test_find() { + public function test_find(): void { $this->resetAfterTest(); $resourcelink = $this->generate_resource_link(); $repository = new resource_link_repository(); @@ -255,7 +255,7 @@ class resource_link_repository_test extends \advanced_testcase { * * @covers ::delete */ - public function test_delete() { + public function test_delete(): void { global $CFG; $this->resetAfterTest(); $resourcelink = $this->generate_resource_link(); @@ -294,7 +294,7 @@ class resource_link_repository_test extends \advanced_testcase { * * @covers ::delete_by_resource */ - public function test_delete_by_resource() { + public function test_delete_by_resource(): void { global $CFG; $this->resetAfterTest(); $resourcelink = $this->generate_resource_link(); @@ -339,7 +339,7 @@ class resource_link_repository_test extends \advanced_testcase { * * @covers ::delete_by_deployment */ - public function test_delete_by_deployment() { + public function test_delete_by_deployment(): void { global $CFG; $this->resetAfterTest(); $resourcelink = $this->generate_resource_link(); @@ -378,7 +378,7 @@ class resource_link_repository_test extends \advanced_testcase { * * @covers ::exists */ - public function test_exists() { + public function test_exists(): void { $this->resetAfterTest(); $resourcelink = $this->generate_resource_link(); $repository = new resource_link_repository(); @@ -393,7 +393,7 @@ class resource_link_repository_test extends \advanced_testcase { * * @covers ::save */ - public function test_save_existing() { + public function test_save_existing(): void { $this->resetAfterTest(); $resourcelink = $this->generate_resource_link(); $repository = new resource_link_repository(); @@ -411,7 +411,7 @@ class resource_link_repository_test extends \advanced_testcase { * * @covers ::save */ - public function test_update_stale() { + public function test_update_stale(): void { $this->resetAfterTest(); $resourcelink = $this->generate_resource_link(); $repository = new resource_link_repository(); diff --git a/enrol/lti/tests/local/ltiadvantage/repository/user_repository_test.php b/enrol/lti/tests/local/ltiadvantage/repository/user_repository_test.php index e1c5526b53b..c1df1757248 100644 --- a/enrol/lti/tests/local/ltiadvantage/repository/user_repository_test.php +++ b/enrol/lti/tests/local/ltiadvantage/repository/user_repository_test.php @@ -165,7 +165,7 @@ class user_repository_test extends \advanced_testcase { * * @covers ::save */ - public function test_save_new_unchanged_user_defaults() { + public function test_save_new_unchanged_user_defaults(): void { $this->resetAfterTest(); $user = $this->generate_user(); $userrepo = new user_repository(); @@ -186,7 +186,7 @@ class user_repository_test extends \advanced_testcase { * * @covers ::save */ - public function test_save_new_changed_user_defaults() { + public function test_save_new_changed_user_defaults(): void { $this->resetAfterTest(); $user = $this->generate_user(1, ['city' => 'Perth']); $userrepo = new user_repository(); @@ -207,7 +207,7 @@ class user_repository_test extends \advanced_testcase { * * @covers ::save */ - public function test_save_existing() { + public function test_save_existing(): void { $this->resetAfterTest(); $user = $this->generate_user(); $userrepo = new user_repository(); @@ -237,7 +237,7 @@ class user_repository_test extends \advanced_testcase { * * @covers ::save */ - public function test_save_existing_localid_mismatch() { + public function test_save_existing_localid_mismatch(): void { $this->resetAfterTest(); $user = $this->generate_user(); $userrepo = new user_repository(); @@ -270,7 +270,7 @@ class user_repository_test extends \advanced_testcase { * * @covers ::save */ - public function test_save_stale_id() { + public function test_save_stale_id(): void { global $CFG; $this->resetAfterTest(); $instructoruser = $this->getDataGenerator()->create_user(); @@ -302,7 +302,7 @@ class user_repository_test extends \advanced_testcase { * * @covers ::save */ - public function test_save_uniqueness_constraint() { + public function test_save_uniqueness_constraint(): void { $this->resetAfterTest(); $user = $this->generate_user(); $userrepo = new user_repository(); @@ -318,7 +318,7 @@ class user_repository_test extends \advanced_testcase { * * @covers ::find */ - public function test_find() { + public function test_find(): void { $this->resetAfterTest(); $user = $this->generate_user(); $userrepo = new user_repository(); @@ -336,7 +336,7 @@ class user_repository_test extends \advanced_testcase { * * @covers ::find_by_resource */ - public function test_find_by_resource() { + public function test_find_by_resource(): void { global $CFG; $this->resetAfterTest(); $user = $this->generate_user(); @@ -371,7 +371,7 @@ class user_repository_test extends \advanced_testcase { * * @covers ::find_by_resource_link */ - public function test_find_by_resource_link() { + public function test_find_by_resource_link(): void { global $CFG; $this->resetAfterTest(); $user = $this->generate_user(); @@ -410,7 +410,7 @@ class user_repository_test extends \advanced_testcase { * * @covers ::exists */ - public function test_exists() { + public function test_exists(): void { $this->resetAfterTest(); $user = $this->generate_user(); $userrepo = new user_repository(); @@ -425,7 +425,7 @@ class user_repository_test extends \advanced_testcase { * * @covers ::delete */ - public function test_delete() { + public function test_delete(): void { $this->resetAfterTest(); $user = $this->generate_user(); $userrepo = new user_repository(); @@ -448,7 +448,7 @@ class user_repository_test extends \advanced_testcase { * * @covers ::delete_by_deployment */ - public function test_delete_by_deployment() { + public function test_delete_by_deployment(): void { global $CFG; $this->resetAfterTest(); $user = $this->generate_user(); @@ -497,7 +497,7 @@ class user_repository_test extends \advanced_testcase { * * @covers ::save */ - public function test_save_deleted() { + public function test_save_deleted(): void { $this->resetAfterTest(); $user = $this->generate_user(); $userrepo = new user_repository(); diff --git a/enrol/lti/tests/local/ltiadvantage/service/application_registration_service_test.php b/enrol/lti/tests/local/ltiadvantage/service/application_registration_service_test.php index b55ddb64b8e..eee2b7fd903 100644 --- a/enrol/lti/tests/local/ltiadvantage/service/application_registration_service_test.php +++ b/enrol/lti/tests/local/ltiadvantage/service/application_registration_service_test.php @@ -55,7 +55,7 @@ class application_registration_service_test extends \lti_advantage_testcase { * * @covers ::create_draft_application_registration */ - public function test_create_draft_application() { + public function test_create_draft_application(): void { $this->resetAfterTest(); $service = $this->get_application_registration_service(); @@ -79,7 +79,7 @@ class application_registration_service_test extends \lti_advantage_testcase { * * @covers ::update_application_registration */ - public function test_update_application_registration() { + public function test_update_application_registration(): void { $this->resetAfterTest(); // Create a registration in the draft state. @@ -141,7 +141,7 @@ class application_registration_service_test extends \lti_advantage_testcase { * * @covers ::delete_application_registration */ - public function test_delete_application_registration() { + public function test_delete_application_registration(): void { $this->resetAfterTest(); // Setup. $registrationrepo = new application_registration_repository(); diff --git a/enrol/lti/tests/local/ltiadvantage/service/tool_deployment_service_test.php b/enrol/lti/tests/local/ltiadvantage/service/tool_deployment_service_test.php index 20ab51762a0..9f0f8d3b496 100644 --- a/enrol/lti/tests/local/ltiadvantage/service/tool_deployment_service_test.php +++ b/enrol/lti/tests/local/ltiadvantage/service/tool_deployment_service_test.php @@ -78,7 +78,7 @@ class tool_deployment_service_test extends \lti_advantage_testcase { * * @covers ::add_tool_deployment */ - public function test_add_tool_deployment() { + public function test_add_tool_deployment(): void { $this->resetAfterTest(); $testreg = $this->generate_application_registration(); $deploymentrepo = new deployment_repository(); @@ -101,7 +101,7 @@ class tool_deployment_service_test extends \lti_advantage_testcase { * * @covers ::add_tool_deployment */ - public function test_add_tool_deployment_registration_missing() { + public function test_add_tool_deployment_registration_missing(): void { $this->resetAfterTest(); $service = $this->get_tool_deployment_service(); @@ -121,7 +121,7 @@ class tool_deployment_service_test extends \lti_advantage_testcase { * * @covers ::delete_tool_deployment */ - public function test_delete_deployment() { + public function test_delete_deployment(): void { $this->resetAfterTest(); // Setup. $registrationrepo = new application_registration_repository(); diff --git a/enrol/lti/tests/local/ltiadvantage/service/tool_launch_service_test.php b/enrol/lti/tests/local/ltiadvantage/service/tool_launch_service_test.php index c2239b20c01..16be61fcfd8 100644 --- a/enrol/lti/tests/local/ltiadvantage/service/tool_launch_service_test.php +++ b/enrol/lti/tests/local/ltiadvantage/service/tool_launch_service_test.php @@ -49,7 +49,7 @@ class tool_launch_service_test extends \lti_advantage_testcase { * @param array $expected the array detailing expectations. * @covers ::user_launches_tool */ - public function test_user_launches_tool(?array $legacydata, ?array $launchdata, array $expected) { + public function test_user_launches_tool(?array $legacydata, ?array $launchdata, array $expected): void { $this->resetAfterTest(); // Setup. $contextrepo = new context_repository(); @@ -272,7 +272,7 @@ class tool_launch_service_test extends \lti_advantage_testcase { * * @covers ::user_launches_tool */ - public function test_user_launches_tool_missing_custom_id() { + public function test_user_launches_tool_missing_custom_id(): void { $this->resetAfterTest(); [$course, $modresource] = $this->create_test_environment(); $instructoruser = $this->getDataGenerator()->create_user(); @@ -290,7 +290,7 @@ class tool_launch_service_test extends \lti_advantage_testcase { * * @covers ::user_launches_tool */ - public function test_user_launches_tool_invalid_custom_id() { + public function test_user_launches_tool_invalid_custom_id(): void { $this->resetAfterTest(); [$course, $modresource] = $this->create_test_environment(); $instructoruser = $this->getDataGenerator()->create_user(); @@ -308,7 +308,7 @@ class tool_launch_service_test extends \lti_advantage_testcase { * * @covers ::user_launches_tool */ - public function test_user_launches_tool_missing_registration() { + public function test_user_launches_tool_missing_registration(): void { $this->resetAfterTest(); // Setup. [ @@ -341,7 +341,7 @@ class tool_launch_service_test extends \lti_advantage_testcase { * * @covers ::user_launches_tool */ - public function test_user_launches_tool_missing_deployment() { + public function test_user_launches_tool_missing_deployment(): void { $this->resetAfterTest(); // Setup. [ @@ -374,7 +374,7 @@ class tool_launch_service_test extends \lti_advantage_testcase { * * @covers ::user_launches_tool */ - public function test_user_launches_tool_role_mapping() { + public function test_user_launches_tool_role_mapping(): void { $this->resetAfterTest(); // Create mock launches for 3 different user types: instructor, admin, learner. [$course, $modresource] = $this->create_test_environment(); @@ -429,7 +429,7 @@ class tool_launch_service_test extends \lti_advantage_testcase { * * @covers ::user_launches_tool */ - public function test_user_launches_tool_user_fields_updated() { + public function test_user_launches_tool_user_fields_updated(): void { $this->resetAfterTest(); [$course, $modresource] = $this->create_test_environment(); $user = $this->getDataGenerator()->create_user(); @@ -476,7 +476,7 @@ class tool_launch_service_test extends \lti_advantage_testcase { * * @covers ::user_launches_tool */ - public function test_user_launches_tool_max_enrolment_start_restriction() { + public function test_user_launches_tool_max_enrolment_start_restriction(): void { $this->resetAfterTest(); [$course, $modresource] = $this->create_test_environment(true, true, false, \enrol_lti\helper::MEMBER_SYNC_ENROL_NEW, false, false, time() + DAYSECS); @@ -494,7 +494,7 @@ class tool_launch_service_test extends \lti_advantage_testcase { * * @covers ::user_launches_tool */ - public function test_user_launches_tool_force_embedding_custom_param() { + public function test_user_launches_tool_force_embedding_custom_param(): void { $this->resetAfterTest(); [$course, $modresource] = $this->create_test_environment(); $instructoruser = $this->getDataGenerator()->create_user(); @@ -529,7 +529,7 @@ class tool_launch_service_test extends \lti_advantage_testcase { * @dataProvider aud_data_provider * @covers ::user_launches_tool */ - public function test_user_launches_tool_aud_variations($aud, array $expected) { + public function test_user_launches_tool_aud_variations($aud, array $expected): void { $this->resetAfterTest(); [$course, $modresource] = $this->create_test_environment(); $instructoruser = $this->getDataGenerator()->create_user(); @@ -618,7 +618,7 @@ class tool_launch_service_test extends \lti_advantage_testcase { * @dataProvider ags_claim_provider * @covers ::user_launches_tool */ - public function test_user_launches_tool_ags_claim_handling(array $agsclaim1, array $agsclaim2, array $expected) { + public function test_user_launches_tool_ags_claim_handling(array $agsclaim1, array $agsclaim2, array $expected): void { $this->resetAfterTest(); [$course, $modresource] = $this->create_test_environment(); $instructoruser = $this->getDataGenerator()->create_user(); diff --git a/enrol/lti/tests/local/ltiadvantage/task/sync_grades_test.php b/enrol/lti/tests/local/ltiadvantage/task/sync_grades_test.php index 7040f10b6d9..2e30f0815a8 100644 --- a/enrol/lti/tests/local/ltiadvantage/task/sync_grades_test.php +++ b/enrol/lti/tests/local/ltiadvantage/task/sync_grades_test.php @@ -40,7 +40,7 @@ class sync_grades_test extends \lti_advantage_testcase { * * @covers ::get_name */ - public function test_get_name() { + public function test_get_name(): void { $this->assertEquals(get_string('tasksyncgrades', 'enrol_lti'), (new sync_grades())->get_name()); } @@ -49,7 +49,7 @@ class sync_grades_test extends \lti_advantage_testcase { * * @covers ::execute */ - public function test_sync_grades_gradesync_disabled() { + public function test_sync_grades_gradesync_disabled(): void { $this->resetAfterTest(); [$course, $resource] = $this->create_test_environment(true, true, true, helper::MEMBER_SYNC_ENROL_AND_UNENROL, false); @@ -70,7 +70,7 @@ class sync_grades_test extends \lti_advantage_testcase { * * @covers ::execute */ - public function test_sync_grades_auth_plugin_disabled() { + public function test_sync_grades_auth_plugin_disabled(): void { $this->resetAfterTest(); [$course, $resource] = $this->create_test_environment(false); $launchservice = $this->get_tool_launch_service(); @@ -91,7 +91,7 @@ class sync_grades_test extends \lti_advantage_testcase { * * @covers ::execute */ - public function test_sync_grades_enrol_plugin_disabled() { + public function test_sync_grades_enrol_plugin_disabled(): void { $this->resetAfterTest(); [$course, $resource] = $this->create_test_environment(true, false); $launchservice = $this->get_tool_launch_service(); diff --git a/enrol/lti/tests/local/ltiadvantage/task/sync_members_test.php b/enrol/lti/tests/local/ltiadvantage/task/sync_members_test.php index ec265de1b91..3db54e83d4a 100644 --- a/enrol/lti/tests/local/ltiadvantage/task/sync_members_test.php +++ b/enrol/lti/tests/local/ltiadvantage/task/sync_members_test.php @@ -215,7 +215,7 @@ class sync_members_test extends \lti_advantage_testcase { * * @covers ::get_name */ - public function test_get_name() { + public function test_get_name(): void { $this->assertEquals(get_string('tasksyncmembers', 'enrol_lti'), (new sync_members())->get_name()); } @@ -224,7 +224,7 @@ class sync_members_test extends \lti_advantage_testcase { * * @covers ::execute */ - public function test_resource_link_level_sync() { + public function test_resource_link_level_sync(): void { $this->resetAfterTest(); [$course, $resource] = $this->create_test_environment(); @@ -254,7 +254,7 @@ class sync_members_test extends \lti_advantage_testcase { * * @covers ::execute */ - public function test_resource_link_level_sync_multiple_resource_links() { + public function test_resource_link_level_sync_multiple_resource_links(): void { $this->resetAfterTest(); [$course, $resource] = $this->create_test_environment(); @@ -300,7 +300,7 @@ class sync_members_test extends \lti_advantage_testcase { * * @covers ::execute */ - public function test_user_profile_image_sync() { + public function test_user_profile_image_sync(): void { $this->resetAfterTest(); [$course, $resource] = $this->create_test_environment(); @@ -331,7 +331,7 @@ class sync_members_test extends \lti_advantage_testcase { * * @covers ::execute */ - public function test_context_level_sync() { + public function test_context_level_sync(): void { $this->resetAfterTest(); [$course, $resource] = $this->create_test_environment(); @@ -359,7 +359,7 @@ class sync_members_test extends \lti_advantage_testcase { * * @covers ::execute */ - public function test_sync_user_data() { + public function test_sync_user_data(): void { $this->resetAfterTest(); [$course, $resource, $resource2, $resource3, $appreg] = $this->create_test_environment(); $userrepo = new user_repository(); @@ -424,7 +424,7 @@ class sync_members_test extends \lti_advantage_testcase { * * @covers ::execute */ - public function test_membership_sync_disabled() { + public function test_membership_sync_disabled(): void { $this->resetAfterTest(); [$course, $resource] = $this->create_test_environment(true, true, false); @@ -455,7 +455,7 @@ class sync_members_test extends \lti_advantage_testcase { * * @covers ::execute */ - public function test_sync_mode_enrol_and_unenrol() { + public function test_sync_mode_enrol_and_unenrol(): void { $this->resetAfterTest(); [$course, $resource] = $this->create_test_environment(); $userrepo = new user_repository(); @@ -503,7 +503,7 @@ class sync_members_test extends \lti_advantage_testcase { * * @covers ::execute */ - public function test_sync_mode_unenrol_missing() { + public function test_sync_mode_unenrol_missing(): void { $this->resetAfterTest(); [$course, $resource] = $this->create_test_environment(true, true, true, helper::MEMBER_SYNC_UNENROL_MISSING); $userrepo = new user_repository(); @@ -532,7 +532,7 @@ class sync_members_test extends \lti_advantage_testcase { * * @covers ::execute */ - public function test_sync_mode_enrol_new() { + public function test_sync_mode_enrol_new(): void { $this->resetAfterTest(); [$course, $resource] = $this->create_test_environment(true, true, true, helper::MEMBER_SYNC_ENROL_NEW); $userrepo = new user_repository(); @@ -562,7 +562,7 @@ class sync_members_test extends \lti_advantage_testcase { * * @covers ::execute */ - public function test_sync_auth_disabled() { + public function test_sync_auth_disabled(): void { $this->resetAfterTest(); [$course, $resource] = $this->create_test_environment(false); $userrepo = new user_repository(); @@ -588,7 +588,7 @@ class sync_members_test extends \lti_advantage_testcase { * * @covers ::execute */ - public function test_sync_enrol_disabled() { + public function test_sync_enrol_disabled(): void { $this->resetAfterTest(); [$course, $resource] = $this->create_test_environment(true, false); $userrepo = new user_repository(); @@ -614,7 +614,7 @@ class sync_members_test extends \lti_advantage_testcase { * * @covers ::execute */ - public function test_sync_members_disabled_instance() { + public function test_sync_members_disabled_instance(): void { $this->resetAfterTest(); global $DB; @@ -646,7 +646,7 @@ class sync_members_test extends \lti_advantage_testcase { * * @covers ::execute */ - public function test_sync_no_nrps_support() { + public function test_sync_no_nrps_support(): void { $this->resetAfterTest(); [$course, $resource] = $this->create_test_environment(); $userrepo = new user_repository(); @@ -679,7 +679,7 @@ class sync_members_test extends \lti_advantage_testcase { * * @covers ::execute */ - public function test_sync_non_lti_linked_user() { + public function test_sync_non_lti_linked_user(): void { $this->resetAfterTest(); // Set up the environment. diff --git a/enrol/lti/tests/local/ltiadvantage/task/sync_tool_grades_test.php b/enrol/lti/tests/local/ltiadvantage/task/sync_tool_grades_test.php index f39cd753785..f661e03ab08 100644 --- a/enrol/lti/tests/local/ltiadvantage/task/sync_tool_grades_test.php +++ b/enrol/lti/tests/local/ltiadvantage/task/sync_tool_grades_test.php @@ -217,7 +217,7 @@ class sync_tool_grades_test extends \lti_advantage_testcase { * * @covers ::execute */ - public function test_grade_sync_chronological_syncs() { + public function test_grade_sync_chronological_syncs(): void { $this->resetAfterTest(); [$course, $resource] = $this->create_test_environment(); @@ -316,7 +316,7 @@ class sync_tool_grades_test extends \lti_advantage_testcase { * * @covers ::execute */ - public function test_grade_sync_multiple_resource_links() { + public function test_grade_sync_multiple_resource_links(): void { $this->resetAfterTest(); [$course, $resource] = $this->create_test_environment(); @@ -389,7 +389,7 @@ class sync_tool_grades_test extends \lti_advantage_testcase { * * @covers ::execute */ - public function test_sync_grades_no_service_endpoint() { + public function test_sync_grades_no_service_endpoint(): void { $this->resetAfterTest(); [$course, $resource] = $this->create_test_environment(); $launchservice = $this->get_tool_launch_service(); @@ -420,7 +420,7 @@ class sync_tool_grades_test extends \lti_advantage_testcase { * * @covers ::execute */ - public function test_sync_grades_disabled_instance() { + public function test_sync_grades_disabled_instance(): void { $this->resetAfterTest(); global $DB; @@ -450,7 +450,7 @@ class sync_tool_grades_test extends \lti_advantage_testcase { * * @covers ::execute */ - public function test_sync_grades_deleted_context() { + public function test_sync_grades_deleted_context(): void { $this->resetAfterTest(); global $DB; @@ -487,7 +487,7 @@ class sync_tool_grades_test extends \lti_advantage_testcase { * * @covers ::execute */ - public function test_sync_grades_completion_required() { + public function test_sync_grades_completion_required(): void { $this->resetAfterTest(); global $CFG; require_once($CFG->libdir . '/completionlib.php'); @@ -681,7 +681,7 @@ class sync_tool_grades_test extends \lti_advantage_testcase { * * @covers ::execute */ - public function test_sync_grades_failed_service_call() { + public function test_sync_grades_failed_service_call(): void { $this->resetAfterTest(); [$course, $resource] = $this->create_test_environment(); $launchservice = $this->get_tool_launch_service(); diff --git a/enrol/lti/tests/local/ltiadvantage/utility/message_helper_test.php b/enrol/lti/tests/local/ltiadvantage/utility/message_helper_test.php index ccaf1d9047a..af1240f6614 100644 --- a/enrol/lti/tests/local/ltiadvantage/utility/message_helper_test.php +++ b/enrol/lti/tests/local/ltiadvantage/utility/message_helper_test.php @@ -34,7 +34,7 @@ class message_helper_test extends \base_testcase { * @param bool $expected the expected return of is_instructor_launch() given the JWT data. * @covers ::is_instructor_launch */ - public function test_is_instructor_launch(array $jwtdata, bool $expected) { + public function test_is_instructor_launch(array $jwtdata, bool $expected): void { $this->assertEquals($expected, message_helper::is_instructor_launch($jwtdata)); } diff --git a/enrol/lti/tests/local/ltiadvantage/viewobject/published_resource_test.php b/enrol/lti/tests/local/ltiadvantage/viewobject/published_resource_test.php index 17506334c63..61ac8c27bd0 100644 --- a/enrol/lti/tests/local/ltiadvantage/viewobject/published_resource_test.php +++ b/enrol/lti/tests/local/ltiadvantage/viewobject/published_resource_test.php @@ -31,7 +31,7 @@ class published_resource_test extends \advanced_testcase { * * @covers ::__construct */ - public function test_create() { + public function test_create(): void { $pr = new published_resource( 'Assignment one', 'Course 1', diff --git a/enrol/lti/tests/privacy/provider_test.php b/enrol/lti/tests/privacy/provider_test.php index 1d832501cb8..2b79eac69e0 100644 --- a/enrol/lti/tests/privacy/provider_test.php +++ b/enrol/lti/tests/privacy/provider_test.php @@ -84,7 +84,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test getting the context for the user ID related to this plugin. */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { $contextlist = provider::get_contexts_for_userid($this->user->id); $this->assertCount(2, $contextlist); @@ -100,7 +100,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::export_user_data(). */ - public function test_export_for_context() { + public function test_export_for_context(): void { $coursecontext = \context_course::instance($this->course->id); $cmcontext = \context_module::instance($this->activity->cmid); @@ -134,7 +134,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::delete_data_for_all_users_in_context(). */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; $count = $DB->count_records('enrol_lti_users'); @@ -154,7 +154,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::delete_data_for_user(). */ - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; $cmcontext = \context_module::instance($this->activity->cmid); @@ -208,7 +208,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::get_users_in_context() when the context is a course. */ - public function test_get_users_in_context_course() { + public function test_get_users_in_context_course(): void { $coursecontext = \context_course::instance($this->course->id); $userlist = new \core_privacy\local\request\userlist($coursecontext, 'enrol_paypal'); provider::get_users_in_context($userlist); @@ -221,7 +221,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::get_users_in_context() when the context is an activity. */ - public function test_get_users_in_context_activity() { + public function test_get_users_in_context_activity(): void { $activityctx = \context_module::instance($this->activity->cmid); $userlist = new \core_privacy\local\request\userlist($activityctx, 'enrol_paypal'); provider::get_users_in_context($userlist); @@ -234,7 +234,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::delete_data_for_users() when the context is a course. */ - public function test_delete_data_for_users_course() { + public function test_delete_data_for_users_course(): void { global $DB; $coursecontext = \context_course::instance($this->course->id); @@ -264,7 +264,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::delete_data_for_users() when the context is an activity. */ - public function test_delete_data_for_users_activity() { + public function test_delete_data_for_users_activity(): void { global $DB; $cmcontext = \context_module::instance($this->activity->cmid); diff --git a/enrol/lti/tests/sync_members_test.php b/enrol/lti/tests/sync_members_test.php index fc086ef4f2f..6705efe88aa 100644 --- a/enrol/lti/tests/sync_members_test.php +++ b/enrol/lti/tests/sync_members_test.php @@ -111,7 +111,7 @@ class sync_members_test extends \advanced_testcase { /** * Test for sync_members::do_context_membership_request(). */ - public function test_do_context_membership_request() { + public function test_do_context_membership_request(): void { // Suppress output. ob_start(); $members = $this->task->do_context_membership_request($this->context); @@ -122,7 +122,7 @@ class sync_members_test extends \advanced_testcase { /** * Test for sync_members::do_resourcelink_membership_request(). */ - public function test_do_resourcelink_membership_request() { + public function test_do_resourcelink_membership_request(): void { $members = $this->task->do_resourcelink_membership_request($this->resourcelink); $this->assertFalse($members); } @@ -130,7 +130,7 @@ class sync_members_test extends \advanced_testcase { /** * Test for sync_members::execute() when auth_lti is disabled. */ - public function test_execute_authdisabled() { + public function test_execute_authdisabled(): void { ob_start(); $this->task->execute(); $output = ob_get_clean(); @@ -141,7 +141,7 @@ class sync_members_test extends \advanced_testcase { /** * Test for sync_members::execute() when enrol_lti is disabled. */ - public function test_execute_enroldisabled() { + public function test_execute_enroldisabled(): void { // Enable auth_lti. $this->enable_auth(); @@ -155,7 +155,7 @@ class sync_members_test extends \advanced_testcase { /** * Test for sync_members::execute(). */ - public function test_execute() { + public function test_execute(): void { // Enable auth_lti. $this->enable_auth(); @@ -176,7 +176,7 @@ class sync_members_test extends \advanced_testcase { /** * Test for sync_members::fetch_members_from_consumer() with no resource link nor context associated with the consumer. */ - public function test_fetch_members_from_consumer_noresourcelink_nocontext() { + public function test_fetch_members_from_consumer_noresourcelink_nocontext(): void { // Suppress output. ob_start(); $members = $this->task->fetch_members_from_consumer($this->consumer); @@ -187,14 +187,14 @@ class sync_members_test extends \advanced_testcase { /** * Test for sync_members::get_name(). */ - public function test_get_name() { + public function test_get_name(): void { $this->assertEquals(get_string('tasksyncmembers', 'enrol_lti'), $this->task->get_name()); } /** * Test for sync_members::should_sync_enrol(). */ - public function test_should_sync_enrol() { + public function test_should_sync_enrol(): void { $this->assertTrue($this->task->should_sync_enrol(helper::MEMBER_SYNC_ENROL_AND_UNENROL)); $this->assertTrue($this->task->should_sync_enrol(helper::MEMBER_SYNC_ENROL_NEW)); $this->assertFalse($this->task->should_sync_enrol(helper::MEMBER_SYNC_UNENROL_MISSING)); @@ -203,7 +203,7 @@ class sync_members_test extends \advanced_testcase { /** * Test for sync_members::should_sync_unenrol(). */ - public function test_should_sync_unenrol() { + public function test_should_sync_unenrol(): void { $this->assertTrue($this->task->should_sync_unenrol(helper::MEMBER_SYNC_ENROL_AND_UNENROL)); $this->assertFalse($this->task->should_sync_unenrol(helper::MEMBER_SYNC_ENROL_NEW)); $this->assertTrue($this->task->should_sync_unenrol(helper::MEMBER_SYNC_UNENROL_MISSING)); @@ -212,7 +212,7 @@ class sync_members_test extends \advanced_testcase { /** * Test for sync_members::sync_member_information(). */ - public function test_sync_member_information() { + public function test_sync_member_information(): void { list($users, $enrolledcount) = $this->task->sync_member_information($this->tool, $this->consumer, $this->members); $membercount = count($this->members); $this->assertCount(10, $this->members); @@ -223,7 +223,7 @@ class sync_members_test extends \advanced_testcase { /** * Test for sync_members::sync_profile_images(). */ - public function test_sync_profile_images() { + public function test_sync_profile_images(): void { $task = $this->task; list($users, $enrolledcount) = $task->sync_member_information($this->tool, $this->consumer, $this->members); $membercount = count($this->members); @@ -240,7 +240,7 @@ class sync_members_test extends \advanced_testcase { /** * Test for sync_members::sync_unenrol(). */ - public function test_sync_unenrol() { + public function test_sync_unenrol(): void { $tool = $this->tool; $task = $this->task; diff --git a/enrol/lti/tests/tool_provider_test.php b/enrol/lti/tests/tool_provider_test.php index 50073da97a2..7d8754614a0 100644 --- a/enrol/lti/tests/tool_provider_test.php +++ b/enrol/lti/tests/tool_provider_test.php @@ -72,7 +72,7 @@ class tool_provider_test extends \advanced_testcase { /** * Passing non-existent tool ID. */ - public function test_constructor_with_non_existent_tool() { + public function test_constructor_with_non_existent_tool(): void { $this->expectException('dml_exception'); new tool_provider(-1); } @@ -80,7 +80,7 @@ class tool_provider_test extends \advanced_testcase { /** * Constructor test. */ - public function test_constructor() { + public function test_constructor(): void { global $CFG, $SITE; $tool = $this->tool; @@ -121,7 +121,7 @@ class tool_provider_test extends \advanced_testcase { /** * Test for handle request. */ - public function test_handle_request_no_request_data() { + public function test_handle_request_no_request_data(): void { $tool = $this->tool; $tp = new tool_provider($tool->id); @@ -140,7 +140,7 @@ class tool_provider_test extends \advanced_testcase { /** * Test for tool_provider::onError(). */ - public function test_on_error() { + public function test_on_error(): void { $tool = $this->tool; $tp = new dummy_tool_provider($tool->id); $message = "THIS IS AN ERROR!"; @@ -153,7 +153,7 @@ class tool_provider_test extends \advanced_testcase { /** * Test for tool_provider::onRegister() with no tool consumer set. */ - public function test_on_register_no_consumer() { + public function test_on_register_no_consumer(): void { $tool = $this->tool; $tp = new dummy_tool_provider($tool->id); @@ -166,7 +166,7 @@ class tool_provider_test extends \advanced_testcase { /** * Test for tool_provider::onRegister() without return URL. */ - public function test_on_register_no_return_url() { + public function test_on_register_no_return_url(): void { $tool = $this->tool; $dataconnector = new data_connector(); @@ -192,7 +192,7 @@ class tool_provider_test extends \advanced_testcase { /** * Test for tool_provider::onRegister() when registration fails. */ - public function test_on_register_failed() { + public function test_on_register_failed(): void { global $CFG; $tool = $this->tool; @@ -225,7 +225,7 @@ class tool_provider_test extends \advanced_testcase { /** * Test for tool_provider::onRegister() when registration succeeds. */ - public function test_on_register() { + public function test_on_register(): void { global $CFG, $DB; $tool = $this->tool; @@ -275,7 +275,7 @@ class tool_provider_test extends \advanced_testcase { /** * Test for tool_provider::onLaunch(). */ - public function test_on_launch_no_frame_embedding() { + public function test_on_launch_no_frame_embedding(): void { $tp = $this->build_dummy_tp(); // Capture output of onLaunch() method and save it as a string. @@ -290,7 +290,7 @@ class tool_provider_test extends \advanced_testcase { /** * Test for tool_provider::onLaunch(). */ - public function test_on_launch_with_frame_embedding() { + public function test_on_launch_with_frame_embedding(): void { global $CFG; $CFG->allowframembedding = true; @@ -307,7 +307,7 @@ class tool_provider_test extends \advanced_testcase { /** * Test for tool_provider::onLaunch() with invalid secret and no tool proxy (for LTI 1 launches). */ - public function test_on_launch_with_invalid_secret_and_no_proxy() { + public function test_on_launch_with_invalid_secret_and_no_proxy(): void { $tp = $this->build_dummy_tp('badsecret'); // Suppress session header errors. @@ -319,7 +319,7 @@ class tool_provider_test extends \advanced_testcase { /** * Test for tool_provider::onLaunch() with invalid launch URL. */ - public function test_on_launch_proxy_with_invalid_launch_url() { + public function test_on_launch_proxy_with_invalid_launch_url(): void { $proxy = [ 'tool_profile' => [ 'resource_handler' => [ @@ -345,7 +345,7 @@ class tool_provider_test extends \advanced_testcase { /** * Test for tool_provider::onLaunch() with invalid launch URL. */ - public function test_on_launch_proxy_with_valid_launch_url() { + public function test_on_launch_proxy_with_valid_launch_url(): void { $tool = $this->tool; $proxy = [ @@ -378,7 +378,7 @@ class tool_provider_test extends \advanced_testcase { /** * Test for tool_provider::onLaunch() for a request with message type other than basic-lti-launch-request. */ - public function test_on_launch_proxy_with_invalid_message_type() { + public function test_on_launch_proxy_with_invalid_message_type(): void { $tool = $this->tool; $proxy = [ @@ -407,7 +407,7 @@ class tool_provider_test extends \advanced_testcase { /** * Test for tool_provider::onLaunch() to verify that a user image can be set from the resource link's custom_user_image setting. */ - public function test_on_launch_with_user_image_from_resource_link() { + public function test_on_launch_with_user_image_from_resource_link(): void { global $DB; $userimageurl = $this->getExternalTestFileUrl('test.jpg'); @@ -434,7 +434,7 @@ class tool_provider_test extends \advanced_testcase { /** * Test for tool_provider::onLaunch() to verify that a LTI user has been enrolled. */ - public function test_on_launch_user_enrolment() { + public function test_on_launch_user_enrolment(): void { global $DB; $tp = $this->build_dummy_tp($this->tool->secret); @@ -459,7 +459,7 @@ class tool_provider_test extends \advanced_testcase { /** * Test for tool_provider::onLaunch() when the consumer object has not been set. */ - public function test_on_launch_no_consumer() { + public function test_on_launch_no_consumer(): void { global $DB; $tool = $this->tool; @@ -479,7 +479,7 @@ class tool_provider_test extends \advanced_testcase { /** * Test for tool_provider::onLaunch() when we have a non-existent consumer data. */ - public function test_on_launch_invalid_consumer() { + public function test_on_launch_invalid_consumer(): void { $tool = $this->tool; $dataconnector = new data_connector(); @@ -496,7 +496,7 @@ class tool_provider_test extends \advanced_testcase { /** * Test for tool_provider::map_tool_to_consumer(). */ - public function test_map_tool_to_consumer() { + public function test_map_tool_to_consumer(): void { global $DB; $tp = $this->build_dummy_tp(); @@ -513,7 +513,7 @@ class tool_provider_test extends \advanced_testcase { /** * Test for tool_provider::map_tool_to_consumer(). */ - public function test_map_tool_to_consumer_no_consumer() { + public function test_map_tool_to_consumer_no_consumer(): void { $tp = new dummy_tool_provider($this->tool->id); $this->expectException('moodle_exception'); $tp->map_tool_to_consumer(); diff --git a/enrol/manual/tests/externallib_test.php b/enrol/manual/tests/externallib_test.php index 5a2054f765c..159b6481d59 100644 --- a/enrol/manual/tests/externallib_test.php +++ b/enrol/manual/tests/externallib_test.php @@ -40,7 +40,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_enrolled_users */ - public function test_enrol_users() { + public function test_enrol_users(): void { global $DB; $this->resetAfterTest(true); @@ -129,7 +129,7 @@ class externallib_test extends externallib_advanced_testcase { * @throws invalid_parameter_exception * @throws moodle_exception */ - public function test_unenrol_user_single() { + public function test_unenrol_user_single(): void { global $CFG, $DB; require_once($CFG->libdir . '/enrollib.php'); $this->resetAfterTest(true); @@ -163,7 +163,7 @@ class externallib_test extends externallib_advanced_testcase { * @throws invalid_parameter_exception * @throws moodle_exception */ - public function test_unenrol_user_multiple() { + public function test_unenrol_user_multiple(): void { global $CFG, $DB; require_once($CFG->libdir . '/enrollib.php'); $this->resetAfterTest(true); @@ -202,7 +202,7 @@ class externallib_test extends externallib_advanced_testcase { * @throws invalid_parameter_exception * @throws moodle_exception */ - public function test_unenrol_user_error_no_capability() { + public function test_unenrol_user_error_no_capability(): void { global $CFG, $DB; require_once($CFG->libdir . '/enrollib.php'); $this->resetAfterTest(true); @@ -249,7 +249,7 @@ class externallib_test extends externallib_advanced_testcase { * Test for unenrol if user does not exist. * @throws coding_exception */ - public function test_unenrol_user_error_not_exist() { + public function test_unenrol_user_error_not_exist(): void { global $CFG, $DB; require_once($CFG->libdir . '/enrollib.php'); $this->resetAfterTest(true); diff --git a/enrol/manual/tests/lib_test.php b/enrol/manual/tests/lib_test.php index 28258e8d7f8..f5e1acb3bf2 100644 --- a/enrol/manual/tests/lib_test.php +++ b/enrol/manual/tests/lib_test.php @@ -42,7 +42,7 @@ class lib_test extends \advanced_testcase { /** * Test enrol migration function used when uninstalling enrol plugins. */ - public function test_migrate_plugin_enrolments() { + public function test_migrate_plugin_enrolments(): void { global $DB, $CFG; require_once($CFG->dirroot.'/enrol/manual/locallib.php'); @@ -207,7 +207,7 @@ class lib_test extends \advanced_testcase { enrol_manual_migrate_plugin_enrolments('yyyy'); } - public function test_expired() { + public function test_expired(): void { global $DB; $this->resetAfterTest(); @@ -334,7 +334,7 @@ class lib_test extends \advanced_testcase { $this->assertTrue($DB->record_exists('user_enrolments', array('enrolid'=>$maninstance2->id, 'userid'=>$user3->id, 'status'=>ENROL_USER_SUSPENDED))); } - public function test_send_expiry_notifications() { + public function test_send_expiry_notifications(): void { global $DB, $CFG; $this->resetAfterTest(); $this->preventResetByRollback(); // Messaging does not like transactions... @@ -501,7 +501,7 @@ class lib_test extends \advanced_testcase { /** * Test for getting user enrolment actions. */ - public function test_get_user_enrolment_actions() { + public function test_get_user_enrolment_actions(): void { global $CFG, $PAGE; $this->resetAfterTest(); @@ -553,7 +553,7 @@ class lib_test extends \advanced_testcase { * @param stdClass $globalsettings * @covers \enrol_manual::add_default_instance */ - public function test_default_enrolment_instance_acquires_correct_settings(stdClass $expectation, stdClass $globalsettings) { + public function test_default_enrolment_instance_acquires_correct_settings(stdClass $expectation, stdClass $globalsettings): void { global $DB; $this->resetAfterTest(); @@ -767,7 +767,7 @@ class lib_test extends \advanced_testcase { * * @covers ::find_instance */ - public function test_find_instance() { + public function test_find_instance(): void { global $DB; $this->resetAfterTest(); diff --git a/enrol/meta/tests/external/add_instances_test.php b/enrol/meta/tests/external/add_instances_test.php index 4481718ab7c..4ccb82c4207 100644 --- a/enrol/meta/tests/external/add_instances_test.php +++ b/enrol/meta/tests/external/add_instances_test.php @@ -44,7 +44,7 @@ class add_instances_test extends \externallib_advanced_testcase { /** * Test add_instances no instances. */ - public function test_add_instances_no_instances() { + public function test_add_instances_no_instances(): void { $this->expectException(\invalid_parameter_exception::class); add_instances::execute([]); } @@ -52,7 +52,7 @@ class add_instances_test extends \externallib_advanced_testcase { /** * Test add_instances missing courses. */ - public function test_add_instances_missing_courses() { + public function test_add_instances_missing_courses(): void { $course = self::getDataGenerator()->create_course(); // Missing meta course. @@ -75,7 +75,7 @@ class add_instances_test extends \externallib_advanced_testcase { /** * Test add_instances missing capabilities. */ - public function test_add_instances_missing_capabilities() { + public function test_add_instances_missing_capabilities(): void { $metacourse = self::getDataGenerator()->create_course(); $course = self::getDataGenerator()->create_course(); $user = self::getDataGenerator()->create_user(); @@ -115,7 +115,7 @@ class add_instances_test extends \externallib_advanced_testcase { /** * Test add_instances. */ - public function test_add_instances() { + public function test_add_instances(): void { global $DB; $metacourse = self::getDataGenerator()->create_course(); $course = self::getDataGenerator()->create_course(); diff --git a/enrol/meta/tests/external/delete_instances_test.php b/enrol/meta/tests/external/delete_instances_test.php index 5f3a35a5f83..723c2d74e84 100644 --- a/enrol/meta/tests/external/delete_instances_test.php +++ b/enrol/meta/tests/external/delete_instances_test.php @@ -44,7 +44,7 @@ class delete_instances_test extends \externallib_advanced_testcase { /** * Test delete_instances no instances. */ - public function test_delete_instances_no_instances() { + public function test_delete_instances_no_instances(): void { $this->expectException(\invalid_parameter_exception::class); delete_instances::execute([]); } @@ -52,7 +52,7 @@ class delete_instances_test extends \externallib_advanced_testcase { /** * Test delete_instances missing courses. */ - public function test_delete_instances_missing_courses() { + public function test_delete_instances_missing_courses(): void { $course = self::getDataGenerator()->create_course(); // Missing meta course. @@ -75,7 +75,7 @@ class delete_instances_test extends \externallib_advanced_testcase { /** * Test delete_instances missing capabilities. */ - public function test_delete_instances_missing_capabilities() { + public function test_delete_instances_missing_capabilities(): void { $metacourse = self::getDataGenerator()->create_course(); $course = self::getDataGenerator()->create_course(); $user = self::getDataGenerator()->create_user(); @@ -102,7 +102,7 @@ class delete_instances_test extends \externallib_advanced_testcase { /** * Test delete_instances. */ - public function test_delete_instances() { + public function test_delete_instances(): void { global $DB; $metacourse = self::getDataGenerator()->create_course(); $course = self::getDataGenerator()->create_course(); diff --git a/enrol/meta/tests/plugin_test.php b/enrol/meta/tests/plugin_test.php index 754c2622fd4..2d69805661c 100644 --- a/enrol/meta/tests/plugin_test.php +++ b/enrol/meta/tests/plugin_test.php @@ -74,7 +74,7 @@ class plugin_test extends \advanced_testcase { return true; } - public function test_sync() { + public function test_sync(): void { global $CFG, $DB; $this->resetAfterTest(true); @@ -444,7 +444,7 @@ class plugin_test extends \advanced_testcase { } - public function test_add_to_group() { + public function test_add_to_group(): void { global $CFG, $DB; require_once($CFG->dirroot.'/group/lib.php'); @@ -540,7 +540,7 @@ class plugin_test extends \advanced_testcase { * Enrol users from another course into a course where one of the members is already enrolled * and is a member of the same group. */ - public function test_add_to_group_with_member() { + public function test_add_to_group_with_member(): void { global $CFG, $DB; require_once($CFG->dirroot.'/group/lib.php'); @@ -635,7 +635,7 @@ class plugin_test extends \advanced_testcase { /** * Test user_enrolment_created event. */ - public function test_user_enrolment_created_event() { + public function test_user_enrolment_created_event(): void { global $DB; $this->resetAfterTest(); @@ -667,7 +667,7 @@ class plugin_test extends \advanced_testcase { /** * Test user_enrolment_deleted event. */ - public function test_user_enrolment_deleted_event() { + public function test_user_enrolment_deleted_event(): void { global $DB; $this->resetAfterTest(true); @@ -700,7 +700,7 @@ class plugin_test extends \advanced_testcase { /** * Test user_enrolment_updated event. */ - public function test_user_enrolment_updated_event() { + public function test_user_enrolment_updated_event(): void { global $DB; $this->resetAfterTest(true); @@ -735,7 +735,7 @@ class plugin_test extends \advanced_testcase { /** * Test that a new group with the name of the course is created. */ - public function test_enrol_meta_create_new_group() { + public function test_enrol_meta_create_new_group(): void { global $DB, $CFG; $this->resetAfterTest(); // Create two courses. @@ -775,7 +775,7 @@ class plugin_test extends \advanced_testcase { /** * Test that enrolment timestart-timeend is respected in meta course. */ - public function test_timeend() { + public function test_timeend(): void { global $CFG, $DB; $this->resetAfterTest(true); @@ -899,7 +899,7 @@ class plugin_test extends \advanced_testcase { /** * Test for getting user enrolment actions. */ - public function test_get_user_enrolment_actions() { + public function test_get_user_enrolment_actions(): void { global $CFG, $PAGE; $this->resetAfterTest(); @@ -951,7 +951,7 @@ class plugin_test extends \advanced_testcase { /** * Test how data for instance editing is validated. */ - public function test_edit_instance_validation() { + public function test_edit_instance_validation(): void { global $DB; $this->resetAfterTest(); @@ -1096,7 +1096,7 @@ class plugin_test extends \advanced_testcase { * * @covers ::fill_enrol_custom_fields */ - public function test_fill_enrol_custom_fields() { + public function test_fill_enrol_custom_fields(): void { $this->resetAfterTest(); $metaplugin = enrol_get_plugin('meta'); @@ -1149,7 +1149,7 @@ class plugin_test extends \advanced_testcase { * * @covers ::validate_enrol_plugin_data */ - public function test_validate_enrol_plugin_data() { + public function test_validate_enrol_plugin_data(): void { $this->resetAfterTest(); $cat = $this->getDataGenerator()->create_category(); @@ -1223,7 +1223,7 @@ class plugin_test extends \advanced_testcase { * * @covers ::find_instance */ - public function test_find_instance() { + public function test_find_instance(): void { global $DB; $this->resetAfterTest(); diff --git a/enrol/meta/tests/privacy/provider_test.php b/enrol/meta/tests/privacy/provider_test.php index c7c954a8a15..9b95a2adde8 100644 --- a/enrol/meta/tests/privacy/provider_test.php +++ b/enrol/meta/tests/privacy/provider_test.php @@ -51,7 +51,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test getting the context for the user ID related to this plugin. */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { global $DB; $this->resetAfterTest(); @@ -83,7 +83,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test that user data is exported correctly. */ - public function test_export_user_data() { + public function test_export_user_data(): void { global $DB; $this->resetAfterTest(); @@ -123,7 +123,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::delete_data_for_all_users_in_context(). */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; $this->resetAfterTest(); @@ -163,7 +163,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::delete_data_for_user(). */ - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; $this->resetAfterTest(); @@ -209,7 +209,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::delete_data_for_users(). */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { global $DB; $this->resetAfterTest(); @@ -259,7 +259,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::get_users_in_context(). */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { global $DB; $this->resetAfterTest(); diff --git a/enrol/paypal/tests/paypal_test.php b/enrol/paypal/tests/paypal_test.php index acc8a2fc416..4ad5e9db5da 100644 --- a/enrol/paypal/tests/paypal_test.php +++ b/enrol/paypal/tests/paypal_test.php @@ -40,14 +40,14 @@ class paypal_test extends \advanced_testcase { set_config('enrol_plugins_enabled', implode(',', $enabled)); } - public function test_basics() { + public function test_basics(): void { $this->assertFalse(enrol_is_enabled('paypal')); $plugin = enrol_get_plugin('paypal'); $this->assertInstanceOf('enrol_paypal_plugin', $plugin); $this->assertEquals(ENROL_EXT_REMOVED_SUSPENDNOROLES, get_config('enrol_paypal', 'expiredaction')); } - public function test_sync_nothing() { + public function test_sync_nothing(): void { $this->resetAfterTest(); $this->enable_plugin(); @@ -57,7 +57,7 @@ class paypal_test extends \advanced_testcase { $paypalplugin->sync(new \null_progress_trace()); } - public function test_expired() { + public function test_expired(): void { global $DB; $this->resetAfterTest(); @@ -170,7 +170,7 @@ class paypal_test extends \advanced_testcase { /** * Test for getting user enrolment actions. */ - public function test_get_user_enrolment_actions() { + public function test_get_user_enrolment_actions(): void { global $CFG, $PAGE; $this->resetAfterTest(); diff --git a/enrol/paypal/tests/privacy/provider_test.php b/enrol/paypal/tests/privacy/provider_test.php index 75bfa8cb0e8..107faa0b121 100644 --- a/enrol/paypal/tests/privacy/provider_test.php +++ b/enrol/paypal/tests/privacy/provider_test.php @@ -202,7 +202,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::get_metadata(). */ - public function test_get_metadata() { + public function test_get_metadata(): void { $collection = new collection('enrol_paypal'); $newcollection = provider::get_metadata($collection); $itemcollection = $newcollection->get_collection(); @@ -249,7 +249,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::get_contexts_for_userid(). */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { $coursecontext1 = \context_course::instance($this->course1->id); $coursecontext2 = \context_course::instance($this->course2->id); @@ -272,7 +272,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::get_contexts_for_userid with a user who is a receiver. */ - public function test_get_contexts_for_userid_receiver() { + public function test_get_contexts_for_userid_receiver(): void { $coursecontext1 = \context_course::instance($this->course1->id); $coursecontext2 = \context_course::instance($this->course2->id); @@ -294,7 +294,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::get_contexts_for_userid with a user who is a business. */ - public function test_get_contexts_for_userid_business() { + public function test_get_contexts_for_userid_business(): void { $coursecontext1 = \context_course::instance($this->course1->id); $coursecontext2 = \context_course::instance($this->course2->id); $coursecontext3 = \context_course::instance($this->course3->id); @@ -317,7 +317,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::export_user_data(). */ - public function test_export_user_data() { + public function test_export_user_data(): void { $coursecontext1 = \context_course::instance($this->course1->id); $this->setUser($this->student1); @@ -334,7 +334,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::export_user_data() when user is not enrolled. */ - public function test_export_user_data_not_enrolled() { + public function test_export_user_data_not_enrolled(): void { $coursecontext1 = \context_course::instance($this->course1->id); $this->setUser($this->student2); @@ -348,7 +348,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::export_user_data() when user has no enrolment. */ - public function test_export_user_data_no_enrolment() { + public function test_export_user_data_no_enrolment(): void { $coursecontext1 = \context_course::instance($this->course1->id); $this->setUser($this->student0); @@ -359,7 +359,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { $this->assertFalse($writer->has_any_data()); } - public function test_export_user_data_multiple_paypal_history() { + public function test_export_user_data_multiple_paypal_history(): void { $coursecontext2 = \context_course::instance($this->course2->id); $this->setUser($this->student2); @@ -378,7 +378,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::delete_data_for_all_users_in_context(). */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; $coursecontext1 = \context_course::instance($this->course1->id); @@ -411,7 +411,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::delete_data_for_all_users_in_context() when there is multiple transaction histories for a user. */ - public function test_delete_data_for_all_users_in_context_multiple_transactions() { + public function test_delete_data_for_all_users_in_context_multiple_transactions(): void { global $DB; $coursecontext2 = \context_course::instance($this->course2->id); @@ -444,7 +444,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::delete_data_for_user() when student is enrolled in multiple courses and deleting from one of them. */ - public function test_delete_data_for_user_from_single_context() { + public function test_delete_data_for_user_from_single_context(): void { global $DB; $coursecontext1 = \context_course::instance($this->course1->id); @@ -497,7 +497,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::delete_data_for_user() when student is enrolled in multiple courses and deleting from all of them. */ - public function test_delete_data_for_user_from_multiple_context() { + public function test_delete_data_for_user_from_multiple_context(): void { global $DB; $coursecontext1 = \context_course::instance($this->course1->id); @@ -551,7 +551,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::delete_data_for_user() when user is not enrolled, but is the receiver of the payment. */ - public function test_delete_data_for_user_for_business_user() { + public function test_delete_data_for_user_for_business_user(): void { global $DB; $coursecontext1 = \context_course::instance($this->course1->id); @@ -596,7 +596,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::delete_data_for_user() when user is not enrolled, but is the receiver of the payment. */ - public function test_delete_data_for_user_for_receiver_user() { + public function test_delete_data_for_user_for_receiver_user(): void { global $DB; $coursecontext1 = \context_course::instance($this->course1->id); @@ -667,7 +667,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::get_users_in_context(). */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { $coursecontext1 = \context_course::instance($this->course1->id); $coursecontext2 = \context_course::instance($this->course2->id); $coursecontext3 = \context_course::instance($this->course3->id); @@ -713,7 +713,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::delete_data_for_users(). */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { global $DB; $coursecontext1 = \context_course::instance($this->course1->id); @@ -773,7 +773,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::delete_data_for_users() for business user deletion. */ - public function test_delete_data_for_users_business() { + public function test_delete_data_for_users_business(): void { global $DB; $coursecontext1 = \context_course::instance($this->course1->id); @@ -808,7 +808,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::delete_data_for_users() for receiver user deletion. */ - public function test_delete_data_for_users_receiver() { + public function test_delete_data_for_users_receiver(): void { global $DB; $coursecontext1 = \context_course::instance($this->course1->id); diff --git a/enrol/self/tests/externallib_test.php b/enrol/self/tests/externallib_test.php index 5fae34204a5..2e2bb16ec5e 100644 --- a/enrol/self/tests/externallib_test.php +++ b/enrol/self/tests/externallib_test.php @@ -40,7 +40,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_instance_info */ - public function test_get_instance_info() { + public function test_get_instance_info(): void { global $DB; $this->resetAfterTest(true); @@ -117,7 +117,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test enrol_user */ - public function test_enrol_user() { + public function test_enrol_user(): void { global $DB; self::resetAfterTest(true); diff --git a/enrol/self/tests/self_test.php b/enrol/self/tests/self_test.php index 3cf850b4ba7..78fce0ef94d 100644 --- a/enrol/self/tests/self_test.php +++ b/enrol/self/tests/self_test.php @@ -36,7 +36,7 @@ require_once($CFG->dirroot.'/enrol/self/locallib.php'); */ class self_test extends \advanced_testcase { - public function test_basics() { + public function test_basics(): void { $this->assertTrue(enrol_is_enabled('self')); $plugin = enrol_get_plugin('self'); $this->assertInstanceOf('enrol_self_plugin', $plugin); @@ -44,7 +44,7 @@ class self_test extends \advanced_testcase { $this->assertEquals(ENROL_EXT_REMOVED_KEEP, get_config('enrol_self', 'expiredaction')); } - public function test_sync_nothing() { + public function test_sync_nothing(): void { global $SITE; $selfplugin = enrol_get_plugin('self'); @@ -56,7 +56,7 @@ class self_test extends \advanced_testcase { $selfplugin->sync($trace, $SITE->id); } - public function test_longtimnosee() { + public function test_longtimnosee(): void { global $DB; $this->resetAfterTest(); @@ -316,7 +316,7 @@ class self_test extends \advanced_testcase { $this->assertDebuggingCalled('send_expiry_notifications() in self enrolment plugin needs expirynotifyhour setting'); } - public function test_expired() { + public function test_expired(): void { global $DB; $this->resetAfterTest(); @@ -433,7 +433,7 @@ class self_test extends \advanced_testcase { $this->assertEquals(1, $DB->count_records('role_assignments', array('roleid'=>$teacherrole->id))); } - public function test_send_expiry_notifications() { + public function test_send_expiry_notifications(): void { global $DB, $CFG; $this->resetAfterTest(); $this->preventResetByRollback(); // Messaging does not like transactions... @@ -608,7 +608,7 @@ class self_test extends \advanced_testcase { $this->assertEquals(6, $sink->count()); } - public function test_show_enrolme_link() { + public function test_show_enrolme_link(): void { global $DB, $CFG; $this->resetAfterTest(); $this->preventResetByRollback(); // Messaging does not like transactions... @@ -740,7 +740,7 @@ class self_test extends \advanced_testcase { /** * This will check user enrolment only, rest has been tested in test_show_enrolme_link. */ - public function test_can_self_enrol() { + public function test_can_self_enrol(): void { global $DB, $CFG, $OUTPUT; $this->resetAfterTest(); $this->preventResetByRollback(); @@ -785,7 +785,7 @@ class self_test extends \advanced_testcase { * * @covers ::is_self_enrol_available */ - public function test_is_self_enrol_available() { + public function test_is_self_enrol_available(): void { global $DB, $CFG; $this->resetAfterTest(); @@ -952,7 +952,7 @@ class self_test extends \advanced_testcase { /** * Test enrol_self_check_group_enrolment_key */ - public function test_enrol_self_check_group_enrolment_key() { + public function test_enrol_self_check_group_enrolment_key(): void { global $DB; self::resetAfterTest(true); @@ -989,7 +989,7 @@ class self_test extends \advanced_testcase { /** * Test get_welcome_email_contact(). */ - public function test_get_welcome_email_contact() { + public function test_get_welcome_email_contact(): void { global $DB; self::resetAfterTest(true); @@ -1072,7 +1072,7 @@ class self_test extends \advanced_testcase { /** * Test for getting user enrolment actions. */ - public function test_get_user_enrolment_actions() { + public function test_get_user_enrolment_actions(): void { global $CFG, $DB, $PAGE; $this->resetAfterTest(); @@ -1121,7 +1121,7 @@ class self_test extends \advanced_testcase { * * @covers ::find_instance */ - public function test_find_instance() { + public function test_find_instance(): void { global $DB; $this->resetAfterTest(); diff --git a/enrol/tests/course_enrolment_manager_test.php b/enrol/tests/course_enrolment_manager_test.php index 70c4bf36c7b..9b54fc14e52 100644 --- a/enrol/tests/course_enrolment_manager_test.php +++ b/enrol/tests/course_enrolment_manager_test.php @@ -118,7 +118,7 @@ class course_enrolment_manager_test extends \advanced_testcase { /** * Verify get_total_users() returned number of users expected in every situation. */ - public function test_get_total_users() { + public function test_get_total_users(): void { global $PAGE; $this->resetAfterTest(); @@ -172,7 +172,7 @@ class course_enrolment_manager_test extends \advanced_testcase { /** * Verify get_users() returned number of users expected in every situation. */ - public function test_get_users() { + public function test_get_users(): void { global $PAGE; $this->resetAfterTest(); @@ -270,7 +270,7 @@ class course_enrolment_manager_test extends \advanced_testcase { /** * Checks that the get_users function returns the correct user fields. */ - public function test_get_users_fields() { + public function test_get_users_fields(): void { global $PAGE; $this->resetAfterTest(); @@ -302,7 +302,7 @@ class course_enrolment_manager_test extends \advanced_testcase { /** * Checks that the get_other_users function returns the correct user fields. */ - public function test_get_other_users_fields() { + public function test_get_other_users_fields(): void { global $PAGE, $DB; $this->resetAfterTest(); @@ -336,7 +336,7 @@ class course_enrolment_manager_test extends \advanced_testcase { /** * Checks that the get_potential_users function returns the correct user fields. */ - public function test_get_potential_users_fields() { + public function test_get_potential_users_fields(): void { global $PAGE; $this->resetAfterTest(); @@ -381,7 +381,7 @@ class course_enrolment_manager_test extends \advanced_testcase { * @param int $expectedtotalusers Expected total of users in database. * @param bool $expectedmoreusers Expected for more users return or not. */ - public function test_get_potential_users($perpage, $returnexactcount, $expectedusers, $expectedtotalusers, $expectedmoreusers) { + public function test_get_potential_users($perpage, $returnexactcount, $expectedusers, $expectedtotalusers, $expectedmoreusers): void { global $DB, $PAGE; $this->resetAfterTest(); $this->setAdminUser(); @@ -409,7 +409,7 @@ class course_enrolment_manager_test extends \advanced_testcase { /** * Tests get_potential_users when the search term includes a custom field. */ - public function test_get_potential_users_search_fields() { + public function test_get_potential_users_search_fields(): void { global $PAGE; $this->resetAfterTest(); @@ -475,7 +475,7 @@ class course_enrolment_manager_test extends \advanced_testcase { * @param int $expectedtotalusers Expected total of users in database. * @param bool $expectedmoreusers Expected for more users return or not. */ - public function test_search_other_users($perpage, $returnexactcount, $expectedusers, $expectedtotalusers, $expectedmoreusers) { + public function test_search_other_users($perpage, $returnexactcount, $expectedusers, $expectedtotalusers, $expectedmoreusers): void { global $PAGE; $this->resetAfterTest(); $this->setAdminUser(); @@ -523,7 +523,7 @@ class course_enrolment_manager_test extends \advanced_testcase { * @param int $expectedtotalusers Expected total of users in database. * @param bool $expectedmoreusers Expected for more users return or not. */ - public function test_search_users($perpage, $returnexactcount, $expectedusers, $expectedtotalusers, $expectedmoreusers) { + public function test_search_users($perpage, $returnexactcount, $expectedusers, $expectedtotalusers, $expectedmoreusers): void { global $PAGE; $this->resetAfterTest(); diff --git a/enrol/tests/enrollib_test.php b/enrol/tests/enrollib_test.php index db7efa102a2..2280c144741 100644 --- a/enrol/tests/enrollib_test.php +++ b/enrol/tests/enrollib_test.php @@ -38,7 +38,7 @@ defined('MOODLE_INTERNAL') || die(); */ class enrollib_test extends advanced_testcase { - public function test_enrol_get_all_users_courses() { + public function test_enrol_get_all_users_courses(): void { global $DB, $CFG; $this->resetAfterTest(); @@ -234,7 +234,7 @@ class enrollib_test extends advanced_testcase { * Test enrol_course_delete() without passing a user id. When a value for user id is not present, the method * should delete all enrolment related data in the course. */ - public function test_enrol_course_delete_without_userid() { + public function test_enrol_course_delete_without_userid(): void { global $DB; $this->resetAfterTest(); @@ -297,7 +297,7 @@ class enrollib_test extends advanced_testcase { * @param array $excludedcapabilities The capabilities that should be excluded from the user's role * @param bool $expected The expected results */ - public function test_enrol_course_delete_with_userid($excludedcapabilities, $expected) { + public function test_enrol_course_delete_with_userid($excludedcapabilities, $expected): void { global $DB; $this->resetAfterTest(); @@ -443,7 +443,7 @@ class enrollib_test extends advanced_testcase { } - public function test_enrol_user_sees_own_courses() { + public function test_enrol_user_sees_own_courses(): void { global $DB, $CFG; $this->resetAfterTest(); @@ -542,7 +542,7 @@ class enrollib_test extends advanced_testcase { $this->assertEquals($reads, $DB->perf_get_reads()); } - public function test_enrol_get_shared_courses() { + public function test_enrol_get_shared_courses(): void { $this->resetAfterTest(); $user1 = $this->getDataGenerator()->create_user(); @@ -571,7 +571,7 @@ class enrollib_test extends advanced_testcase { $this->assertEquals($sharedcourse->id, $course1->id); } - public function test_enrol_get_shared_courses_different_methods() { + public function test_enrol_get_shared_courses_different_methods(): void { global $DB, $CFG; require_once($CFG->dirroot . '/enrol/self/externallib.php'); @@ -630,7 +630,7 @@ class enrollib_test extends advanced_testcase { /** * Test user enrolment created event. */ - public function test_user_enrolment_created_event() { + public function test_user_enrolment_created_event(): void { global $DB; $this->resetAfterTest(); @@ -664,7 +664,7 @@ class enrollib_test extends advanced_testcase { /** * Test user_enrolment_deleted event. */ - public function test_user_enrolment_deleted_event() { + public function test_user_enrolment_deleted_event(): void { global $DB; $this->resetAfterTest(true); @@ -698,7 +698,7 @@ class enrollib_test extends advanced_testcase { /** * Test enrol_instance_created, enrol_instance_updated and enrol_instance_deleted events. */ - public function test_instance_events() { + public function test_instance_events(): void { global $DB; $this->resetAfterTest(true); @@ -758,7 +758,7 @@ class enrollib_test extends advanced_testcase { /** * Confirms that timemodified field was updated after modification of user enrollment */ - public function test_enrollment_update_timemodified() { + public function test_enrollment_update_timemodified(): void { global $DB; $this->resetAfterTest(true); @@ -813,7 +813,7 @@ class enrollib_test extends advanced_testcase { * Test to confirm that enrol_get_my_courses only return the courses that * the logged in user is enrolled in. */ - public function test_enrol_get_my_courses_only_enrolled_courses() { + public function test_enrol_get_my_courses_only_enrolled_courses(): void { $user = $this->getDataGenerator()->create_user(); $course1 = $this->getDataGenerator()->create_course(); $course2 = $this->getDataGenerator()->create_course(); @@ -861,7 +861,7 @@ class enrollib_test extends advanced_testcase { * @throws coding_exception * @throws dml_exception */ - public function test_enrol_get_my_courses_include_hidden() { + public function test_enrol_get_my_courses_include_hidden(): void { global $DB, $CFG; $this->resetAfterTest(true); @@ -912,7 +912,7 @@ class enrollib_test extends advanced_testcase { * Tests the enrol_get_my_courses function when using the $allaccessible parameter, which * includes a wider range of courses (enrolled courses + other accessible ones). */ - public function test_enrol_get_my_courses_all_accessible() { + public function test_enrol_get_my_courses_all_accessible(): void { global $DB, $CFG; $this->resetAfterTest(true); @@ -1081,7 +1081,7 @@ class enrollib_test extends advanced_testcase { * * @return void */ - public function test_course_users() { + public function test_course_users(): void { $this->resetAfterTest(); $user1 = $this->getDataGenerator()->create_user(); @@ -1115,7 +1115,7 @@ class enrollib_test extends advanced_testcase { * @covers \enrol_get_course_users() * @return void */ - public function test_course_users_in_groups() { + public function test_course_users_in_groups(): void { $this->resetAfterTest(); $user1 = $this->getDataGenerator()->create_user(); @@ -1151,7 +1151,7 @@ class enrollib_test extends advanced_testcase { * * @return void */ - public function test_count_enrolled_users() { + public function test_count_enrolled_users(): void { global $DB; $this->resetAfterTest(true); @@ -1374,7 +1374,7 @@ class enrollib_test extends advanced_testcase { * * @return void */ - public function test_enrol_get_course_users_roles() { + public function test_enrol_get_course_users_roles(): void { global $DB; $this->resetAfterTest(); @@ -1424,7 +1424,7 @@ class enrollib_test extends advanced_testcase { /** * Test enrol_calculate_duration function */ - public function test_enrol_calculate_duration() { + public function test_enrol_calculate_duration(): void { // Start time 07/01/2019 @ 12:00am (UTC). $timestart = 1561939200; // End time 07/05/2019 @ 12:00am (UTC). @@ -1454,7 +1454,7 @@ class enrollib_test extends advanced_testcase { bool $useprohibit, int $expectedmatch, int $expectedcount - ) { + ): void { global $DB, $CFG; $this->resetAfterTest(); @@ -1517,7 +1517,7 @@ class enrollib_test extends advanced_testcase { * Test last_time_enrolments_synced not recorded with "force" option for enrol_check_plugins. * @covers ::enrol_check_plugins */ - public function test_enrol_check_plugins_with_forced_option() { + public function test_enrol_check_plugins_with_forced_option(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); @@ -1548,7 +1548,7 @@ class enrollib_test extends advanced_testcase { * * @param mixed $config Config value. */ - public function test_enrol_check_plugins_with_empty_config_value($config) { + public function test_enrol_check_plugins_with_empty_config_value($config): void { global $CFG; $this->resetAfterTest(); @@ -1564,7 +1564,7 @@ class enrollib_test extends advanced_testcase { * Test last_time_enrolments_synced is recorded without "force" option for enrol_check_plugins. * @covers ::enrol_check_plugins */ - public function test_last_time_enrolments_synced_is_set_if_not_forced() { + public function test_last_time_enrolments_synced_is_set_if_not_forced(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); @@ -1585,7 +1585,7 @@ class enrollib_test extends advanced_testcase { * Test last_time_enrolments_synced is recorded correctly without "force" option for enrol_check_plugins. * @covers ::enrol_check_plugins */ - public function test_last_time_enrolments_synced_is_set_if_not_forced_if_have_not_passed_interval() { + public function test_last_time_enrolments_synced_is_set_if_not_forced_if_have_not_passed_interval(): void { global $CFG; $this->resetAfterTest(); @@ -1610,7 +1610,7 @@ class enrollib_test extends advanced_testcase { * * @covers ::enrol_selfenrol_available */ - public function test_enrol_selfenrol_available() { + public function test_enrol_selfenrol_available(): void { global $DB, $CFG; $this->resetAfterTest(); diff --git a/enrol/tests/externallib_test.php b/enrol/tests/externallib_test.php index c81ac56a143..17619314301 100644 --- a/enrol/tests/externallib_test.php +++ b/enrol/tests/externallib_test.php @@ -256,7 +256,7 @@ class externallib_test extends externallib_advanced_testcase { * * @dataProvider get_enrolled_users_visibility_provider */ - public function test_get_enrolled_users_visibility($settings, $results) { + public function test_get_enrolled_users_visibility($settings, $results): void { global $USER; @@ -367,7 +367,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Verify get_enrolled_users() returned users according to their status. */ - public function test_get_enrolled_users_active_suspended() { + public function test_get_enrolled_users_active_suspended(): void { global $USER; $this->resetAfterTest(); @@ -456,7 +456,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_users_courses */ - public function test_get_users_courses() { + public function test_get_users_courses(): void { global $CFG, $DB; require_once($CFG->dirroot . '/completion/criteria/completion_criteria_self.php'); @@ -711,7 +711,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_users_courses with mathjax in the name. */ - public function test_get_users_courses_with_mathjax() { + public function test_get_users_courses_with_mathjax(): void { global $DB; $this->resetAfterTest(true); @@ -772,7 +772,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_course_enrolment_methods */ - public function test_get_course_enrolment_methods() { + public function test_get_course_enrolment_methods(): void { global $DB; $this->resetAfterTest(true); @@ -878,7 +878,7 @@ class externallib_test extends externallib_advanced_testcase { * Test get_enrolled_users from core_enrol_external without additional * parameters. */ - public function test_get_enrolled_users_without_parameters() { + public function test_get_enrolled_users_without_parameters(): void { $capability = 'moodle/course:viewparticipants'; $data = $this->get_enrolled_users_setup($capability); @@ -896,7 +896,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_enrolled_users from core_enrol_external with some parameters set. */ - public function test_get_enrolled_users_with_parameters() { + public function test_get_enrolled_users_with_parameters(): void { $capability = 'moodle/course:viewparticipants'; $data = $this->get_enrolled_users_setup($capability); @@ -921,7 +921,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_enrolled_users last course access. */ - public function test_get_enrolled_users_including_lastcourseaccess() { + public function test_get_enrolled_users_including_lastcourseaccess(): void { global $DB; $capability = 'moodle/course:viewparticipants'; $data = $this->get_enrolled_users_setup($capability); @@ -961,7 +961,7 @@ class externallib_test extends externallib_advanced_testcase { * Test get_enrolled_users from core_enrol_external with capability to * viewparticipants removed. */ - public function test_get_enrolled_users_without_capability() { + public function test_get_enrolled_users_without_capability(): void { $capability = 'moodle/course:viewparticipants'; $data = $this->get_enrolled_users_setup($capability); @@ -1013,7 +1013,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_enrolled_users_with_capability without additional paramaters. */ - public function test_get_enrolled_users_with_capability_without_parameters() { + public function test_get_enrolled_users_with_capability_without_parameters(): void { $capability = 'moodle/course:viewparticipants'; $data = $this->get_enrolled_users_with_capability_setup($capability); @@ -1042,7 +1042,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_enrolled_users_with_capability */ - public function test_get_enrolled_users_with_capability_with_parameters() { + public function test_get_enrolled_users_with_capability_with_parameters(): void { $capability = 'moodle/course:viewparticipants'; $data = $this->get_enrolled_users_with_capability_setup($capability); @@ -1075,7 +1075,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_enrolled_users last course access. */ - public function test_get_enrolled_users_with_capability_including_lastcourseaccess() { + public function test_get_enrolled_users_with_capability_including_lastcourseaccess(): void { global $DB; $capability = 'moodle/course:viewparticipants'; $data = $this->get_enrolled_users_with_capability_setup($capability); @@ -1194,7 +1194,7 @@ class externallib_test extends externallib_advanced_testcase { * @param bool $validationerror The validationerror we are expecting to receive from the webservice. * @dataProvider submit_user_enrolment_form_provider */ - public function test_submit_user_enrolment_form($customdata, $expectedresult, $validationerror) { + public function test_submit_user_enrolment_form($customdata, $expectedresult, $validationerror): void { global $CFG, $DB; $this->resetAfterTest(true); @@ -1273,7 +1273,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test for core_enrol_external::unenrol_user_enrolment(). */ - public function test_unenerol_user_enrolment() { + public function test_unenerol_user_enrolment(): void { global $DB; $this->resetAfterTest(true); @@ -1338,7 +1338,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test for core_enrol_external::test_search_users(). */ - public function test_search_users() { + public function test_search_users(): void { global $DB; $this->resetAfterTest(true); @@ -1427,7 +1427,7 @@ class externallib_test extends externallib_advanced_testcase { * Test for core_enrol_external::search_users() when group mode is active. * @covers ::search_users */ - public function test_search_users_groupmode() { + public function test_search_users_groupmode(): void { global $DB; $this->resetAfterTest(); diff --git a/enrol/tests/privacy/provider_test.php b/enrol/tests/privacy/provider_test.php index 6b3ffe46f59..a26a3e86553 100644 --- a/enrol/tests/privacy/provider_test.php +++ b/enrol/tests/privacy/provider_test.php @@ -44,7 +44,7 @@ class provider_test extends provider_testcase { /** * Check that a course context is returned if there is any user data for this user. */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { $this->resetAfterTest(); $user1 = $this->getDataGenerator()->create_user(); $course1 = $this->getDataGenerator()->create_course(); @@ -61,7 +61,7 @@ class provider_test extends provider_testcase { /** * Test that user data is exported correctly. */ - public function test_export_user_data() { + public function test_export_user_data(): void { global $DB; $this->resetAfterTest(); @@ -108,7 +108,7 @@ class provider_test extends provider_testcase { /** * Test deleting all user data for a specific context. */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; $this->resetAfterTest(); @@ -146,7 +146,7 @@ class provider_test extends provider_testcase { /** * This should work identical to the above test. */ - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; $this->resetAfterTest(); @@ -181,7 +181,7 @@ class provider_test extends provider_testcase { /** * Test that only users within a course context are fetched. */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { $this->resetAfterTest(); $component = 'core_enrol'; @@ -214,7 +214,7 @@ class provider_test extends provider_testcase { /** * Test that data for users in approved userlist is deleted. */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { $this->resetAfterTest(); $component = 'core_enrol'; diff --git a/enrol/tests/role_external_test.php b/enrol/tests/role_external_test.php index 9ad70aa34ac..0942a504f19 100644 --- a/enrol/tests/role_external_test.php +++ b/enrol/tests/role_external_test.php @@ -45,7 +45,7 @@ class role_external_test extends \externallib_advanced_testcase { /** * Test assign_roles */ - public function test_assign_roles() { + public function test_assign_roles(): void { global $USER; $this->resetAfterTest(true); @@ -94,7 +94,7 @@ class role_external_test extends \externallib_advanced_testcase { /** * Test unassign_roles */ - public function test_unassign_roles() { + public function test_unassign_roles(): void { global $USER; $this->resetAfterTest(true); diff --git a/favourites/tests/component_favourite_service_test.php b/favourites/tests/component_favourite_service_test.php index a6b3092a255..e95e50bba8d 100644 --- a/favourites/tests/component_favourite_service_test.php +++ b/favourites/tests/component_favourite_service_test.php @@ -177,7 +177,7 @@ class component_favourite_service_test extends \advanced_testcase { /** * Test confirming the deletion of favourites by type and item, but with no optional context filter provided. */ - public function test_delete_favourites_by_type_and_item() { + public function test_delete_favourites_by_type_and_item(): void { list($user1context, $user2context, $course1context, $course2context) = $this->setup_users_and_courses(); // Get a user_favourite_service for each user. @@ -225,7 +225,7 @@ class component_favourite_service_test extends \advanced_testcase { /** * Test confirming the deletion of favourites by type and item and with the optional context filter provided. */ - public function test_delete_favourites_by_type_and_item_with_context() { + public function test_delete_favourites_by_type_and_item_with_context(): void { list($user1context, $user2context, $course1context, $course2context) = $this->setup_users_and_courses(); // Get a user_favourite_service for each user. diff --git a/favourites/tests/privacy/provider_test.php b/favourites/tests/privacy/provider_test.php index 6e8583b4e06..5be0f28793c 100644 --- a/favourites/tests/privacy/provider_test.php +++ b/favourites/tests/privacy/provider_test.php @@ -60,7 +60,7 @@ class provider_test extends provider_testcase { /** * Test confirming that contexts of favourited items can be added to the contextlist. */ - public function test_add_contexts_for_userid() { + public function test_add_contexts_for_userid(): void { list($user1, $user2, $user1context, $user2context, $course1context, $course2context) = $this->set_up_courses_and_users(); // Favourite 2 courses for user1 and 1 course for user2, all at the site context. @@ -92,7 +92,7 @@ class provider_test extends provider_testcase { /** * Test deletion of user favourites based on an approved_contextlist and component area. */ - public function test_delete_favourites_for_user() { + public function test_delete_favourites_for_user(): void { list($user1, $user2, $user1context, $user2context, $course1context, $course2context) = $this->set_up_courses_and_users(); // Favourite 2 courses for user1 and 1 course for user2, all at the user context. @@ -113,7 +113,7 @@ class provider_test extends provider_testcase { $this->assertCount(1, $ufservice2->find_favourites_by_type('core_course', 'courses')); } - public function test_delete_favourites_for_all_users() { + public function test_delete_favourites_for_all_users(): void { list($user1, $user2, $user1context, $user2context, $course1context, $course2context) = $this->set_up_courses_and_users(); // Favourite 2 course modules for user1 and 1 course module for user2 all in course 1 context. @@ -140,7 +140,7 @@ class provider_test extends provider_testcase { /** * Test confirming that user ID's of favourited items can be added to the userlist. */ - public function test_add_userids_for_context() { + public function test_add_userids_for_context(): void { list($user1, $user2, $user1context, $user2context, $course1context, $course2context) = $this->set_up_courses_and_users(); // Favourite 2 courses for user1 and 1 course for user2, all at the site context. @@ -185,7 +185,7 @@ class provider_test extends provider_testcase { /** * Test deletion of user favourites based on an approved_userlist, component area and item type. */ - public function test_delete_favourites_for_userlist() { + public function test_delete_favourites_for_userlist(): void { list($user1, $user2, $user1context, $user2context, $course1context, $course2context) = $this->set_up_courses_and_users(); // Favourite 2 courses for user1 and 1 course for user2. @@ -252,7 +252,7 @@ class provider_test extends provider_testcase { /** * Test fetching the favourites data for a specified user in a specified component, item type and item ID. */ - public function test_get_favourites_info_for_user() { + public function test_get_favourites_info_for_user(): void { list($user1, $user2, $user1context, $user2context, $course1context, $course2context) = $this->set_up_courses_and_users(); // Favourite 2 courses for user1 and 1 course for user2. diff --git a/favourites/tests/repository_test.php b/favourites/tests/repository_test.php index d949822eadf..bf9e603e056 100644 --- a/favourites/tests/repository_test.php +++ b/favourites/tests/repository_test.php @@ -49,7 +49,7 @@ class repository_test extends \advanced_testcase { /** * Verify the basic create operation can create records, and is validated. */ - public function test_add() { + public function test_add(): void { list($user1context, $user2context, $course1context, $course2context) = $this->setup_users_and_courses(); // Create a favourites repository and favourite a course. @@ -84,7 +84,7 @@ class repository_test extends \advanced_testcase { /** * Tests that incomplete favourites cannot be saved. */ - public function test_add_incomplete_favourite() { + public function test_add_incomplete_favourite(): void { list($user1context, $user2context, $course1context, $course2context) = $this->setup_users_and_courses(); // Create a favourites repository and try to favourite a course. @@ -103,7 +103,7 @@ class repository_test extends \advanced_testcase { $favouritesrepo->add($favcourse); } - public function test_add_all_basic() { + public function test_add_all_basic(): void { list($user1context, $user2context, $course1context, $course2context) = $this->setup_users_and_courses(); // Create a favourites repository and favourite several courses. @@ -150,7 +150,7 @@ class repository_test extends \advanced_testcase { /** * Tests reading from the repository by instance id. */ - public function test_find() { + public function test_find(): void { list($user1context, $user2context, $course1context, $course2context) = $this->setup_users_and_courses(); // Create a favourites repository and favourite a course. @@ -178,7 +178,7 @@ class repository_test extends \advanced_testcase { /** * Test verifying that find_all() returns all favourites, or an empty array. */ - public function test_find_all() { + public function test_find_all(): void { list($user1context, $user2context, $course1context, $course2context) = $this->setup_users_and_courses(); $favouritesrepo = new favourite_repository($user1context); @@ -217,7 +217,7 @@ class repository_test extends \advanced_testcase { /** * Testing the pagination of the find_all method. */ - public function test_find_all_pagination() { + public function test_find_all_pagination(): void { list($user1context, $user2context, $course1context, $course2context) = $this->setup_users_and_courses(); $favouritesrepo = new favourite_repository($user1context); @@ -259,7 +259,7 @@ class repository_test extends \advanced_testcase { /** * Test retrieval of a user's favourites for a given criteria, in this case, area. */ - public function test_find_by() { + public function test_find_by(): void { list($user1context, $user2context, $course1context, $course2context) = $this->setup_users_and_courses(); // Create a favourites repository and favourite a course. @@ -307,7 +307,7 @@ class repository_test extends \advanced_testcase { /** * Testing the pagination of the find_by method. */ - public function test_find_by_pagination() { + public function test_find_by_pagination(): void { list($user1context, $user2context, $course1context, $course2context) = $this->setup_users_and_courses(); $favouritesrepo = new favourite_repository($user1context); @@ -353,7 +353,7 @@ class repository_test extends \advanced_testcase { /** * Test the count_by() method. */ - public function test_count_by() { + public function test_count_by(): void { list($user1context, $user2context, $course1context, $course2context) = $this->setup_users_and_courses(); // Create a favourites repository and add 2 favourites in different areas. @@ -387,7 +387,7 @@ class repository_test extends \advanced_testcase { /** * Test the exists() function. */ - public function test_exists() { + public function test_exists(): void { list($user1context, $user2context, $course1context, $course2context) = $this->setup_users_and_courses(); // Create a favourites repository and favourite a course. @@ -411,7 +411,7 @@ class repository_test extends \advanced_testcase { /** * Test the exists_by() method. */ - public function test_exists_by() { + public function test_exists_by(): void { list($user1context, $user2context, $course1context, $course2context) = $this->setup_users_and_courses(); // Create a favourites repository and favourite two courses, in different areas. @@ -468,7 +468,7 @@ class repository_test extends \advanced_testcase { /** * Test the update() method, by simulating a user changing the ordering of a favourite. */ - public function test_update() { + public function test_update(): void { list($user1context, $user2context, $course1context, $course2context) = $this->setup_users_and_courses(); // Create a favourites repository and favourite a course. @@ -490,7 +490,7 @@ class repository_test extends \advanced_testcase { $this->assertEquals('1', $favourite1->ordering); } - public function test_delete() { + public function test_delete(): void { list($user1context, $user2context, $course1context, $course2context) = $this->setup_users_and_courses(); // Create a favourites repository and favourite a course. @@ -515,7 +515,7 @@ class repository_test extends \advanced_testcase { /** * Test the delete_by() method. */ - public function test_delete_by() { + public function test_delete_by(): void { list($user1context, $user2context, $course1context, $course2context) = $this->setup_users_and_courses(); // Create a favourites repository and favourite two courses, in different areas. @@ -576,7 +576,7 @@ class repository_test extends \advanced_testcase { /** * Test the find_favourite() method for an existing favourite. */ - public function test_find_favourite_basic() { + public function test_find_favourite_basic(): void { list($user1context, $user2context, $course1context, $course2context) = $this->setup_users_and_courses(); // Create a favourites repository and favourite two courses, in different areas. @@ -606,7 +606,7 @@ class repository_test extends \advanced_testcase { /** * Test confirming the repository throws an exception in find_favourite if the favourite can't be found. */ - public function test_find_favourite_nonexistent_favourite() { + public function test_find_favourite_nonexistent_favourite(): void { list($user1context, $user2context, $course1context, $course2context) = $this->setup_users_and_courses(); // Confirm we get an exception. diff --git a/favourites/tests/user_favourite_service_test.php b/favourites/tests/user_favourite_service_test.php index 3743a6583c9..9c55d417933 100644 --- a/favourites/tests/user_favourite_service_test.php +++ b/favourites/tests/user_favourite_service_test.php @@ -182,7 +182,7 @@ class user_favourite_service_test extends \advanced_testcase { /** * Test getting a user_favourite_service from the static locator. */ - public function test_get_service_for_user_context() { + public function test_get_service_for_user_context(): void { list($user1context, $user2context, $course1context, $course2context) = $this->setup_users_and_courses(); $userservice = \core_favourites\service_factory::get_service_for_user_context($user1context); $this->assertInstanceOf(\core_favourites\local\service\user_favourite_service::class, $userservice); @@ -191,7 +191,7 @@ class user_favourite_service_test extends \advanced_testcase { /** * Test confirming an item can be favourited only once. */ - public function test_create_favourite_basic() { + public function test_create_favourite_basic(): void { list($user1context, $user2context, $course1context, $course2context) = $this->setup_users_and_courses(); // Get a user_favourite_service for a user. @@ -210,7 +210,7 @@ class user_favourite_service_test extends \advanced_testcase { /** * Test confirming that an exception is thrown if trying to favourite an item for a non-existent component. */ - public function test_create_favourite_nonexistent_component() { + public function test_create_favourite_nonexistent_component(): void { list($user1context, $user2context, $course1context, $course2context) = $this->setup_users_and_courses(); // Get a user_favourite_service for the user. @@ -225,7 +225,7 @@ class user_favourite_service_test extends \advanced_testcase { /** * Test fetching favourites for single user, by area. */ - public function test_find_favourites_by_type_single_user() { + public function test_find_favourites_by_type_single_user(): void { list($user1context, $user2context, $course1context, $course2context) = $this->setup_users_and_courses(); // Get a user_favourite_service for the user. @@ -251,7 +251,7 @@ class user_favourite_service_test extends \advanced_testcase { /** * Test fetching favourites for single user, by area. */ - public function test_find_all_favourites() { + public function test_find_all_favourites(): void { list($user1context, $user2context, $course1context, $course2context) = $this->setup_users_and_courses(); // Get a user_favourite_service for the user. @@ -287,7 +287,7 @@ class user_favourite_service_test extends \advanced_testcase { /** * Make sure the find_favourites_by_type() method only returns favourites for the scoped user. */ - public function test_find_favourites_by_type_multiple_users() { + public function test_find_favourites_by_type_multiple_users(): void { list($user1context, $user2context, $course1context, $course2context) = $this->setup_users_and_courses(); // Get a user_favourite_service for 2 users. @@ -314,7 +314,7 @@ class user_favourite_service_test extends \advanced_testcase { /** * Test confirming that an exception is thrown if trying to get favourites for a non-existent component. */ - public function test_find_favourites_by_type_nonexistent_component() { + public function test_find_favourites_by_type_nonexistent_component(): void { list($user1context, $user2context, $course1context, $course2context) = $this->setup_users_and_courses(); // Get a user_favourite_service for the user. @@ -329,7 +329,7 @@ class user_favourite_service_test extends \advanced_testcase { /** * Test confirming the pagination support for the find_favourites_by_type() method. */ - public function test_find_favourites_by_type_pagination() { + public function test_find_favourites_by_type_pagination(): void { list($user1context, $user2context, $course1context, $course2context) = $this->setup_users_and_courses(); // Get a user_favourite_service for the user. @@ -360,7 +360,7 @@ class user_favourite_service_test extends \advanced_testcase { /** * Test confirming the basic deletion behaviour. */ - public function test_delete_favourite_basic() { + public function test_delete_favourite_basic(): void { list($user1context, $user2context, $course1context, $course2context) = $this->setup_users_and_courses(); // Get a user_favourite_service for the user. @@ -385,7 +385,7 @@ class user_favourite_service_test extends \advanced_testcase { /** * Test confirming the behaviour of the favourite_exists() method. */ - public function test_favourite_exists() { + public function test_favourite_exists(): void { list($user1context, $user2context, $course1context, $course2context) = $this->setup_users_and_courses(); // Get a user_favourite_service for the user. @@ -419,7 +419,7 @@ class user_favourite_service_test extends \advanced_testcase { /** * Test confirming the behaviour of the get_favourite() method. */ - public function test_get_favourite() { + public function test_get_favourite(): void { list($user1context, $user2context, $course1context, $course2context) = $this->setup_users_and_courses(); // Get a user_favourite_service for the user. @@ -452,7 +452,7 @@ class user_favourite_service_test extends \advanced_testcase { /** * Test confirming the behaviour of the count_favourites_by_type() method. */ - public function test_count_favourites_by_type() { + public function test_count_favourites_by_type(): void { list($user1context, $user2context, $course1context, $course2context) = $this->setup_users_and_courses(); // Get a user_favourite_service for the user. @@ -482,7 +482,7 @@ class user_favourite_service_test extends \advanced_testcase { /** * Verify that the join sql generated by get_join_sql_by_type is valid and can be used to include favourite information. */ - public function test_get_join_sql_by_type() { + public function test_get_join_sql_by_type(): void { global $DB; list($user1context, $user2context, $course1context, $course2context) = $this->setup_users_and_courses(); diff --git a/files/converter/googledrive/tests/privacy/provider_test.php b/files/converter/googledrive/tests/privacy/provider_test.php index 664fdf87452..237b5bc40fb 100644 --- a/files/converter/googledrive/tests/privacy/provider_test.php +++ b/files/converter/googledrive/tests/privacy/provider_test.php @@ -38,7 +38,7 @@ class provider_test extends provider_testcase { /** * Test getting the context for the user ID related to this plugin. */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); diff --git a/files/converter/unoconv/tests/converter_test.php b/files/converter/unoconv/tests/converter_test.php index 90df8298b55..a83941f79a4 100644 --- a/files/converter/unoconv/tests/converter_test.php +++ b/files/converter/unoconv/tests/converter_test.php @@ -55,7 +55,7 @@ class converter_test extends \advanced_testcase { /** * Tests for the start_document_conversion function. */ - public function test_start_document_conversion() { + public function test_start_document_conversion(): void { $this->resetAfterTest(); $this->require_unoconv(); @@ -95,7 +95,7 @@ class converter_test extends \advanced_testcase { * @param string $path The path to test * @param int $status The expected status */ - public function test_test_unoconv_path($path, $status) { + public function test_test_unoconv_path($path, $status): void { global $CFG; $this->resetAfterTest(); diff --git a/files/tests/conversion_test.php b/files/tests/conversion_test.php index ced4d29b5bd..bb2955fd741 100644 --- a/files/tests/conversion_test.php +++ b/files/tests/conversion_test.php @@ -53,7 +53,7 @@ class conversion_test extends \advanced_testcase { * Ensure that get_conversions_for_file returns an existing conversion * record with matching sourcefileid and targetformat. */ - public function test_get_conversions_for_file_existing_conversion_incomplete() { + public function test_get_conversions_for_file_existing_conversion_incomplete(): void { $this->resetAfterTest(); $sourcefile = $this->create_stored_file(); @@ -82,7 +82,7 @@ class conversion_test extends \advanced_testcase { * * @covers \core_files\conversion::get_conversions_for_file */ - public function test_get_conversions_for_multiple_files_existing_conversion_incomplete() { + public function test_get_conversions_for_multiple_files_existing_conversion_incomplete(): void { $this->resetAfterTest(); // Create a bunch of files with the same content. @@ -127,7 +127,7 @@ class conversion_test extends \advanced_testcase { * record with matching sourcefileid and targetformat when a second * conversion to a different format exists. */ - public function test_get_conversions_for_file_existing_conversion_multiple_formats_incomplete() { + public function test_get_conversions_for_file_existing_conversion_multiple_formats_incomplete(): void { $this->resetAfterTest(); $sourcefile = $this->create_stored_file(); @@ -159,7 +159,7 @@ class conversion_test extends \advanced_testcase { * Ensure that get_conversions_for_file returns an existing conversion * record with matching sourcefileid and targetformat. */ - public function test_get_conversions_for_file_existing_conversion_complete() { + public function test_get_conversions_for_file_existing_conversion_complete(): void { $this->resetAfterTest(); $sourcefile = $this->create_stored_file(); @@ -195,7 +195,7 @@ class conversion_test extends \advanced_testcase { * Ensure that get_conversions_for_file returns an existing conversion * record with matching sourcefileid and targetformat. */ - public function test_get_conversions_for_file_existing_conversion_multiple_formats_complete() { + public function test_get_conversions_for_file_existing_conversion_multiple_formats_complete(): void { $this->resetAfterTest(); $sourcefile = $this->create_stored_file(); @@ -236,7 +236,7 @@ class conversion_test extends \advanced_testcase { * Ensure that get_conversions_for_file returns an existing conversion * record does not exist, but the file has previously been converted. */ - public function test_get_conversions_for_file_existing_target() { + public function test_get_conversions_for_file_existing_target(): void { $this->resetAfterTest(); $sourcefile = $this->create_stored_file(); @@ -263,7 +263,7 @@ class conversion_test extends \advanced_testcase { /** * Ensure that set_sourcefile sets the correct fileid. */ - public function test_set_sourcefile() { + public function test_set_sourcefile(): void { $this->resetAfterTest(); $sourcefile = $this->create_stored_file(); @@ -278,7 +278,7 @@ class conversion_test extends \advanced_testcase { /** * Ensure that store_destfile_from_path stores the file as expected. */ - public function test_store_destfile_from_path() { + public function test_store_destfile_from_path(): void { $this->resetAfterTest(); $sourcefile = $this->create_stored_file(); @@ -297,7 +297,7 @@ class conversion_test extends \advanced_testcase { /** * Ensure that store_destfile_from_path stores the file as expected. */ - public function test_store_destfile_from_path_delete_existing() { + public function test_store_destfile_from_path_delete_existing(): void { $this->resetAfterTest(); $sourcefile = $this->create_stored_file(); @@ -325,7 +325,7 @@ class conversion_test extends \advanced_testcase { /** * Ensure that store_destfile_from_path stores the file as expected. */ - public function test_store_destfile_from_string() { + public function test_store_destfile_from_string(): void { $this->resetAfterTest(); $sourcefile = $this->create_stored_file(); @@ -345,7 +345,7 @@ class conversion_test extends \advanced_testcase { * Ensure that store_destfile_from_string stores the file as expected when * an existing destfile is found. */ - public function test_store_destfile_from_string_delete_existing() { + public function test_store_destfile_from_string_delete_existing(): void { $this->resetAfterTest(); $sourcefile = $this->create_stored_file(); @@ -373,7 +373,7 @@ class conversion_test extends \advanced_testcase { /** * Ensure that the get_status functions cast the status to integer correctly. */ - public function test_get_status() { + public function test_get_status(): void { $conversion = new conversion(0, (object) [ 'status' => (string) 1, ]); @@ -384,7 +384,7 @@ class conversion_test extends \advanced_testcase { /** * Ensure that get_converter_instance returns false when no converter is set. */ - public function test_get_converter_instance_none_set() { + public function test_get_converter_instance_none_set(): void { $conversion = new conversion(0, (object) []); $this->assertFalse($conversion->get_converter_instance()); } @@ -392,7 +392,7 @@ class conversion_test extends \advanced_testcase { /** * Ensure that get_converter_instance returns false when no valid converter is set. */ - public function test_get_converter_instance_invalid_set() { + public function test_get_converter_instance_invalid_set(): void { $conversion = new conversion(0, (object) [ 'converter' => '\\fileconverter_not_a_valid_converter\\converter', ]); @@ -402,7 +402,7 @@ class conversion_test extends \advanced_testcase { /** * Ensure that get_converter_instance returns an instance when a valid converter is set. */ - public function test_get_converter_instance_valid_set() { + public function test_get_converter_instance_valid_set(): void { $conversion = new conversion(0, (object) [ 'converter' => \fileconverter_unoconv\converter::class, ]); @@ -412,7 +412,7 @@ class conversion_test extends \advanced_testcase { /** * Test that all old conversion records are removed periodically. */ - public function test_remove_old_conversion_records_old() { + public function test_remove_old_conversion_records_old(): void { $this->resetAfterTest(); global $DB; @@ -432,7 +432,7 @@ class conversion_test extends \advanced_testcase { /** * Test that all old conversion records are removed periodically. */ - public function test_remove_old_conversion_records_young() { + public function test_remove_old_conversion_records_young(): void { $this->resetAfterTest(); global $DB; @@ -452,7 +452,7 @@ class conversion_test extends \advanced_testcase { /** * Test orphan records are removed. */ - public function test_remove_orphan_records() { + public function test_remove_orphan_records(): void { global $DB; $this->resetAfterTest(); diff --git a/files/tests/converter_test.php b/files/tests/converter_test.php index ae766c8856c..94f6209f882 100644 --- a/files/tests/converter_test.php +++ b/files/tests/converter_test.php @@ -155,7 +155,7 @@ class converter_test extends advanced_testcase { /** * Test the start_conversion function. */ - public function test_start_conversion_existing_single() { + public function test_start_conversion_existing_single(): void { $this->resetAfterTest(); $sourcefile = $this->create_stored_file(); @@ -176,7 +176,7 @@ class converter_test extends advanced_testcase { /** * Test the start_conversion function. */ - public function test_start_conversion_existing_multiple() { + public function test_start_conversion_existing_multiple(): void { $this->resetAfterTest(); $sourcefile = $this->create_stored_file(); @@ -204,7 +204,7 @@ class converter_test extends advanced_testcase { /** * Test the start_conversion function. */ - public function test_start_conversion_no_existing() { + public function test_start_conversion_no_existing(): void { $this->resetAfterTest(); $sourcefile = $this->create_stored_file(); @@ -218,7 +218,7 @@ class converter_test extends advanced_testcase { /** * Test the get_document_converter_classes function with no enabled plugins. */ - public function test_get_document_converter_classes_no_plugins() { + public function test_get_document_converter_classes_no_plugins(): void { $converter = $this->get_testable_mock(['get_enabled_plugins']); $converter->method('get_enabled_plugins')->willReturn([]); @@ -230,7 +230,7 @@ class converter_test extends advanced_testcase { /** * Test the get_document_converter_classes function when no class was found. */ - public function test_get_document_converter_classes_plugin_class_not_found() { + public function test_get_document_converter_classes_plugin_class_not_found(): void { $converter = $this->get_testable_mock(['get_enabled_plugins']); $converter->method('get_enabled_plugins')->willReturn([ 'noplugin' => '\not\a\real\plugin', @@ -244,7 +244,7 @@ class converter_test extends advanced_testcase { /** * Test the get_document_converter_classes function when the returned classes do not meet requirements. */ - public function test_get_document_converter_classes_plugin_class_requirements_not_met() { + public function test_get_document_converter_classes_plugin_class_requirements_not_met(): void { $plugin = $this->getMockBuilder(\core_file_converter_requirements_not_met::class) ->onlyMethods([]) ->getMock(); @@ -262,7 +262,7 @@ class converter_test extends advanced_testcase { /** * Test the get_document_converter_classes function when the returned classes do not meet requirements. */ - public function test_get_document_converter_classes_plugin_class_met_not_supported() { + public function test_get_document_converter_classes_plugin_class_met_not_supported(): void { $plugin = $this->getMockBuilder(\core_file_converter_type_not_supported::class) ->onlyMethods([]) ->getMock(); @@ -280,7 +280,7 @@ class converter_test extends advanced_testcase { /** * Test the get_document_converter_classes function when the returned classes do not meet requirements. */ - public function test_get_document_converter_classes_plugin_class_met_and_supported() { + public function test_get_document_converter_classes_plugin_class_met_and_supported(): void { $plugin = $this->getMockBuilder(\core_file_converter_type_supported::class) ->onlyMethods([]) ->getMock(); @@ -300,7 +300,7 @@ class converter_test extends advanced_testcase { /** * Test the can_convert_storedfile_to function with a directory. */ - public function test_can_convert_storedfile_to_directory() { + public function test_can_convert_storedfile_to_directory(): void { $converter = $this->get_testable_mock(); // A file with filename '.' is a directory. @@ -312,7 +312,7 @@ class converter_test extends advanced_testcase { /** * Test the can_convert_storedfile_to function with an empty file. */ - public function test_can_convert_storedfile_to_emptyfile() { + public function test_can_convert_storedfile_to_emptyfile(): void { $converter = $this->get_testable_mock(); // A file with filename '.' is a directory. @@ -324,7 +324,7 @@ class converter_test extends advanced_testcase { /** * Test the can_convert_storedfile_to function with a file with indistinguished mimetype. */ - public function test_can_convert_storedfile_to_no_mimetype() { + public function test_can_convert_storedfile_to_no_mimetype(): void { $converter = $this->get_testable_mock(); // A file with filename '.' is a directory. @@ -338,7 +338,7 @@ class converter_test extends advanced_testcase { /** * Test the can_convert_storedfile_to function with a file with a known mimetype and extension. */ - public function test_can_convert_storedfile_to_docx() { + public function test_can_convert_storedfile_to_docx(): void { $returnvalue = (object) []; $converter = $this->get_testable_mock([ @@ -363,7 +363,7 @@ class converter_test extends advanced_testcase { /** * Test the can_convert_format_to function. */ - public function test_can_convert_format_to_found() { + public function test_can_convert_format_to_found(): void { $converter = $this->get_testable_mock(['get_document_converter_classes']); $mock = $this->get_mocked_converter(); @@ -378,7 +378,7 @@ class converter_test extends advanced_testcase { /** * Test the can_convert_format_to function. */ - public function test_can_convert_format_to_not_found() { + public function test_can_convert_format_to_not_found(): void { $converter = $this->get_testable_mock(['get_document_converter_classes']); $converter->method('get_document_converter_classes') @@ -391,7 +391,7 @@ class converter_test extends advanced_testcase { /** * Test the can_convert_storedfile_to function with an empty file. */ - public function test_poll_conversion_in_progress() { + public function test_poll_conversion_in_progress(): void { $this->resetAfterTest(); $converter = $this->get_testable_mock([ @@ -429,7 +429,7 @@ class converter_test extends advanced_testcase { * Test poll_conversion with an in-progress conversion where we are * unable to instantiate the converter instance. */ - public function test_poll_conversion_in_progress_fail() { + public function test_poll_conversion_in_progress_fail(): void { $this->resetAfterTest(); $converter = $this->get_testable_mock([ @@ -461,7 +461,7 @@ class converter_test extends advanced_testcase { /** * Test the can_convert_storedfile_to function with an empty file. */ - public function test_poll_conversion_none_supported() { + public function test_poll_conversion_none_supported(): void { $this->resetAfterTest(); $converter = $this->get_testable_mock([ @@ -489,7 +489,7 @@ class converter_test extends advanced_testcase { /** * Test the can_convert_storedfile_to function with an empty file. */ - public function test_poll_conversion_pick_first() { + public function test_poll_conversion_pick_first(): void { $this->resetAfterTest(); $converterinstance = $this->get_mocked_converter([ @@ -530,7 +530,7 @@ class converter_test extends advanced_testcase { /** * Test the can_convert_storedfile_to function with an empty file. */ - public function test_poll_conversion_pick_subsequent() { + public function test_poll_conversion_pick_subsequent(): void { $this->resetAfterTest(); $converterinstance = $this->get_mocked_converter([ @@ -603,7 +603,7 @@ class converter_test extends advanced_testcase { /** * Test the start_conversion with a single converter which succeeds. */ - public function test_start_conversion_one_supported_success() { + public function test_start_conversion_one_supported_success(): void { $this->resetAfterTest(); $converter = $this->get_testable_mock([ @@ -625,7 +625,7 @@ class converter_test extends advanced_testcase { /** * Test the start_conversion with a single converter which failes. */ - public function test_start_conversion_one_supported_failure() { + public function test_start_conversion_one_supported_failure(): void { $this->resetAfterTest(); $converter = $this->get_testable_mock([ @@ -648,7 +648,7 @@ class converter_test extends advanced_testcase { /** * Test the start_conversion with two converters - fail, then succeed. */ - public function test_start_conversion_two_supported() { + public function test_start_conversion_two_supported(): void { $this->resetAfterTest(); $converter = $this->get_testable_mock([ @@ -674,7 +674,7 @@ class converter_test extends advanced_testcase { /** * Ensure that get_next_converter returns false when no converters are available. */ - public function test_get_next_converter_no_converters() { + public function test_get_next_converter_no_converters(): void { $rcm = new \ReflectionMethod(converter::class, 'get_next_converter'); $converter = new \core_files\converter(); @@ -686,7 +686,7 @@ class converter_test extends advanced_testcase { * Ensure that get_next_converter returns false when already on the * only converter. */ - public function test_get_next_converter_only_converters() { + public function test_get_next_converter_only_converters(): void { $rcm = new \ReflectionMethod(converter::class, 'get_next_converter'); $converter = new converter(); @@ -698,7 +698,7 @@ class converter_test extends advanced_testcase { * Ensure that get_next_converter returns false when already on the * last converter. */ - public function test_get_next_converter_last_converters() { + public function test_get_next_converter_last_converters(): void { $rcm = new \ReflectionMethod(converter::class, 'get_next_converter'); $converter = new converter(); @@ -710,7 +710,7 @@ class converter_test extends advanced_testcase { * Ensure that get_next_converter returns the next vlaue when in a * current converter. */ - public function test_get_next_converter_middle_converters() { + public function test_get_next_converter_middle_converters(): void { $rcm = new \ReflectionMethod(converter::class, 'get_next_converter'); $converter = new converter(); @@ -722,7 +722,7 @@ class converter_test extends advanced_testcase { * Ensure that get_next_converter returns the next vlaue when in a * current converter. */ - public function test_get_next_converter_first() { + public function test_get_next_converter_first(): void { $rcm = new \ReflectionMethod(converter::class, 'get_next_converter'); $converter = new converter(); diff --git a/files/tests/externallib_test.php b/files/tests/externallib_test.php index d513ecff899..48c7f0b1be4 100644 --- a/files/tests/externallib_test.php +++ b/files/tests/externallib_test.php @@ -43,7 +43,7 @@ class externallib_test extends \advanced_testcase { * Test core_files_external::upload(). */ - public function test_upload() { + public function test_upload(): void { global $USER; $this->resetAfterTest(); @@ -109,7 +109,7 @@ class externallib_test extends \advanced_testcase { /* * Make sure only user component is allowed in core_files_external::upload(). */ - public function test_upload_param_component() { + public function test_upload_param_component(): void { global $USER; $this->resetAfterTest(); @@ -134,7 +134,7 @@ class externallib_test extends \advanced_testcase { /* * Make sure only draft areas are allowed in core_files_external::upload(). */ - public function test_upload_param_area() { + public function test_upload_param_area(): void { global $USER; $this->resetAfterTest(); @@ -162,7 +162,7 @@ class externallib_test extends \advanced_testcase { /** * Test getting a list of files with and without a context ID. */ - public function test_get_files() { + public function test_get_files(): void { global $USER, $DB; $this->resetAfterTest(); @@ -303,7 +303,7 @@ class externallib_test extends \advanced_testcase { /** * Test delete draft files */ - public function test_delete_draft_files() { + public function test_delete_draft_files(): void { global $USER; $this->resetAfterTest(); @@ -356,7 +356,7 @@ class externallib_test extends \advanced_testcase { /** * Test get_unused_draft_itemid. */ - public function test_get_unused_draft_itemid() { + public function test_get_unused_draft_itemid(): void { global $USER; $this->resetAfterTest(); diff --git a/files/tests/privacy/provider_test.php b/files/tests/privacy/provider_test.php index 9b413fea53a..622778b03af 100644 --- a/files/tests/privacy/provider_test.php +++ b/files/tests/privacy/provider_test.php @@ -43,7 +43,7 @@ class provider_test extends provider_testcase { /** * Test getting the context for the user ID related to this plugin. */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { $this->resetAfterTest(); // Create a user. @@ -60,7 +60,7 @@ class provider_test extends provider_testcase { /** * Test that data is exported correctly for this plugin. */ - public function test_export_user_data() { + public function test_export_user_data(): void { global $DB; $this->resetAfterTest(); @@ -88,7 +88,7 @@ class provider_test extends provider_testcase { /** * Test for provider::delete_data_for_all_users_in_context(). */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; $this->resetAfterTest(); @@ -114,7 +114,7 @@ class provider_test extends provider_testcase { /** * Test for provider::delete_data_for_user(). */ - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; $this->resetAfterTest(); @@ -141,7 +141,7 @@ class provider_test extends provider_testcase { /** * Test that only users within a course context are fetched. */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { $this->resetAfterTest(); $component = 'core_files'; @@ -173,7 +173,7 @@ class provider_test extends provider_testcase { /** * Test that data for users in approved userlist is deleted. */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { $this->resetAfterTest(); $component = 'core_files'; diff --git a/filter/activitynames/tests/filter_test.php b/filter/activitynames/tests/filter_test.php index 55875a2737a..08cf97134c8 100644 --- a/filter/activitynames/tests/filter_test.php +++ b/filter/activitynames/tests/filter_test.php @@ -33,7 +33,7 @@ namespace filter_activitynames; */ class filter_test extends \advanced_testcase { - public function test_links() { + public function test_links(): void { $this->resetAfterTest(true); // Create a test course. @@ -71,7 +71,7 @@ class filter_test extends \advanced_testcase { $this->assertEquals($page2->name, $matches[3][1]); } - public function test_links_activity_named_hyphen() { + public function test_links_activity_named_hyphen(): void { $this->resetAfterTest(true); // Create a test course. @@ -100,7 +100,7 @@ class filter_test extends \advanced_testcase { $this->assertEquals($page->name, $matches[3][0]); } - public function test_cache() { + public function test_cache(): void { $this->resetAfterTest(true); // Create a test courses. diff --git a/filter/algebra/tests/filter_test.php b/filter/algebra/tests/filter_test.php index 8834f13fefb..3bc118050b2 100644 --- a/filter/algebra/tests/filter_test.php +++ b/filter/algebra/tests/filter_test.php @@ -53,23 +53,23 @@ class filter_test extends \basic_testcase { $this->filter = new filter_algebra(\context_system::instance(), array()); } - function test_algebra_filter_no_algebra() { + function test_algebra_filter_no_algebra(): void { $this->assertEquals('

Look no algebra!

', $this->filter->filter('

Look no algebra!

')); } - function test_algebra_filter_pluginfile() { + function test_algebra_filter_pluginfile(): void { $this->assertEquals('', $this->filter->filter('')); } - function test_algebra_filter_draftfile() { + function test_algebra_filter_draftfile(): void { $this->assertEquals('', $this->filter->filter('')); } - function test_algebra_filter_unified_diff() { + function test_algebra_filter_unified_diff(): void { $diff = ' diff -u -r1.1 Worksheet.php --- Worksheet.php 26 Sep 2003 04:18:02 -0000 1.1 diff --git a/filter/data/tests/filter_test.php b/filter/data/tests/filter_test.php index c9e54656805..888b2761690 100644 --- a/filter/data/tests/filter_test.php +++ b/filter/data/tests/filter_test.php @@ -39,7 +39,7 @@ class filter_test extends \advanced_testcase { * * @return void */ - public function test_filter() { + public function test_filter(): void { $this->resetAfterTest(true); $this->setAdminUser(); diff --git a/filter/displayh5p/tests/filter_test.php b/filter/displayh5p/tests/filter_test.php index 9609c68c3e0..bb75386b2f8 100644 --- a/filter/displayh5p/tests/filter_test.php +++ b/filter/displayh5p/tests/filter_test.php @@ -59,7 +59,7 @@ class filter_test extends \advanced_testcase { * * @dataProvider texts_provider */ - public function test_filter_urls($text, $filteredtextpattern) { + public function test_filter_urls($text, $filteredtextpattern): void { $filterplugin = new filter_displayh5p(null, array()); diff --git a/filter/displayh5p/tests/upgradelib_test.php b/filter/displayh5p/tests/upgradelib_test.php index 91b43a7def0..0d80e6e1594 100644 --- a/filter/displayh5p/tests/upgradelib_test.php +++ b/filter/displayh5p/tests/upgradelib_test.php @@ -35,7 +35,7 @@ class upgradelib_test extends \advanced_testcase { /** * test_filter_displayh5p_reorder */ - public function test_filter_displayh5p_reorder() { + public function test_filter_displayh5p_reorder(): void { $this->resetAfterTest(true); $this->setAdminUser(); diff --git a/filter/emoticon/tests/filter_test.php b/filter/emoticon/tests/filter_test.php index 7046390c478..121adb3ba84 100644 --- a/filter/emoticon/tests/filter_test.php +++ b/filter/emoticon/tests/filter_test.php @@ -83,7 +83,7 @@ class filter_test extends \advanced_testcase { * * @dataProvider filter_emoticon_provider */ - public function test_filter_emoticon($input, $format, $expected) { + public function test_filter_emoticon($input, $format, $expected): void { $this->resetAfterTest(); $filter = new testable_filter_emoticon(); @@ -166,7 +166,7 @@ class filter_test extends \advanced_testcase { * Tests the filter doesn't break anything if activated but invalid format passed. * */ - public function test_filter_invalidformat() { + public function test_filter_invalidformat(): void { global $PAGE; $this->resetAfterTest(); @@ -183,7 +183,7 @@ class filter_test extends \advanced_testcase { * Tests the filter doesn't break anything if activated but no emoticons available. * */ - public function test_filter_emptyemoticons() { + public function test_filter_emptyemoticons(): void { global $CFG; $this->resetAfterTest(); // Empty the emoticons array. diff --git a/filter/glossary/tests/filter_test.php b/filter/glossary/tests/filter_test.php index 0f46ac7eb53..ab02d5bcc05 100644 --- a/filter/glossary/tests/filter_test.php +++ b/filter/glossary/tests/filter_test.php @@ -30,7 +30,7 @@ namespace filter_glossary; */ class filter_test extends \advanced_testcase { - public function test_link_to_entry_with_alias() { + public function test_link_to_entry_with_alias(): void { global $CFG; $this->resetAfterTest(true); @@ -71,7 +71,7 @@ class filter_test extends \advanced_testcase { $this->assertEquals($glossary->name . ': second alias', $matches[2][2]); } - public function test_longest_link_used() { + public function test_longest_link_used(): void { global $CFG; $this->resetAfterTest(true); @@ -108,7 +108,7 @@ class filter_test extends \advanced_testcase { $this->assertEquals($glossary->name . ': Time', $matches[2][0]); } - public function test_link_to_category() { + public function test_link_to_category(): void { global $CFG; $this->resetAfterTest(true); @@ -146,7 +146,7 @@ class filter_test extends \advanced_testcase { /** * Test ampersands. */ - public function test_ampersands() { + public function test_ampersands(): void { global $CFG; $this->resetAfterTest(true); @@ -192,7 +192,7 @@ class filter_test extends \advanced_testcase { /** * Test brackets. */ - public function test_brackets() { + public function test_brackets(): void { global $CFG; $this->resetAfterTest(true); @@ -235,7 +235,7 @@ class filter_test extends \advanced_testcase { $this->assertEquals($glossary->name . ': Test (2)', $matches[2][2]); } - public function test_exclude_excludes_link_to_entry_with_alias() { + public function test_exclude_excludes_link_to_entry_with_alias(): void { global $CFG, $GLOSSARY_EXCLUDEENTRY; $this->resetAfterTest(true); @@ -275,7 +275,7 @@ class filter_test extends \advanced_testcase { $this->assertEquals($glossary->name . ': other entry', $matches[2][0]); } - public function test_exclude_does_not_exclude_categories() { + public function test_exclude_does_not_exclude_categories(): void { global $CFG, $GLOSSARY_EXCLUDEENTRY; $this->resetAfterTest(true); diff --git a/filter/mathjaxloader/tests/filter_test.php b/filter/mathjaxloader/tests/filter_test.php index e445e06c20f..21107d6435c 100644 --- a/filter/mathjaxloader/tests/filter_test.php +++ b/filter/mathjaxloader/tests/filter_test.php @@ -41,7 +41,7 @@ class filter_test extends \advanced_testcase { * * @dataProvider map_language_code_expected_mappings */ - public function test_map_language_code($moodlelangcode, $mathjaxlangcode) { + public function test_map_language_code($moodlelangcode, $mathjaxlangcode): void { $filter = new filter_mathjaxloader(\context_system::instance(), []); $this->assertEquals($mathjaxlangcode, $filter->map_language_code($moodlelangcode)); diff --git a/filter/mathjaxloader/tests/filtermath_test.php b/filter/mathjaxloader/tests/filtermath_test.php index be65eb45aa6..5e33d25a37f 100644 --- a/filter/mathjaxloader/tests/filtermath_test.php +++ b/filter/mathjaxloader/tests/filtermath_test.php @@ -40,7 +40,7 @@ class filtermath_test extends \advanced_testcase { * * @dataProvider math_filtering_inputs */ - public function test_math_filtering($inputtext, $expected) { + public function test_math_filtering($inputtext, $expected): void { $filter = new filter_mathjaxloader(\context_system::instance(), []); $this->assertEquals($expected, $filter->filter($inputtext)); } diff --git a/filter/mediaplugin/tests/filter_test.php b/filter/mediaplugin/tests/filter_test.php index 8b198da733b..1987495fe1b 100644 --- a/filter/mediaplugin/tests/filter_test.php +++ b/filter/mediaplugin/tests/filter_test.php @@ -35,7 +35,7 @@ require_once($CFG->dirroot . '/filter/mediaplugin/filter.php'); // Include the c class filter_test extends \advanced_testcase { - function test_filter_mediaplugin_link() { + function test_filter_mediaplugin_link(): void { $this->resetAfterTest(true); // We need to enable the media plugins. diff --git a/filter/multilang/tests/filter_test.php b/filter/multilang/tests/filter_test.php index e00ea99af52..b946091d8b8 100644 --- a/filter/multilang/tests/filter_test.php +++ b/filter/multilang/tests/filter_test.php @@ -135,7 +135,7 @@ class filter_test extends \advanced_testcase { * @param string $targetlang the laguage to set as the current languge . * @param array $parentlangs Array child lang => parent lang. E.g. ['es_co' => 'es', 'es_mx' => 'es']. */ - public function test_filtering($expectedoutput, $input, $targetlang, $parentlangs = []) { + public function test_filtering($expectedoutput, $input, $targetlang, $parentlangs = []): void { global $SESSION; $SESSION->forcelang = $targetlang; diff --git a/filter/tests/external/external_test.php b/filter/tests/external/external_test.php index 8d68c54acc5..f2be4520444 100644 --- a/filter/tests/external/external_test.php +++ b/filter/tests/external/external_test.php @@ -50,7 +50,7 @@ class external_test extends externallib_advanced_testcase { /** * Test get_available_in_context_system */ - public function test_get_available_in_context_system() { + public function test_get_available_in_context_system(): void { global $DB; $this->resetAfterTest(true); @@ -63,7 +63,7 @@ class external_test extends externallib_advanced_testcase { /** * Test get_available_in_context_category */ - public function test_get_available_in_context_category() { + public function test_get_available_in_context_category(): void { global $DB; $this->resetAfterTest(true); @@ -107,7 +107,7 @@ class external_test extends externallib_advanced_testcase { /** * Test get_available_in_context_course */ - public function test_get_available_in_context_course() { + public function test_get_available_in_context_course(): void { global $DB; $this->resetAfterTest(true); @@ -151,7 +151,7 @@ class external_test extends externallib_advanced_testcase { /** * Test get_available_in_context_module */ - public function test_get_available_in_context_module() { + public function test_get_available_in_context_module(): void { global $DB; $this->resetAfterTest(true); @@ -207,7 +207,7 @@ class external_test extends externallib_advanced_testcase { * Test get_all_states * @covers \core_filters\external\get_all_states::execute */ - public function test_get_all_states() { + public function test_get_all_states(): void { $this->resetAfterTest(true); $this->setAdminUser(); diff --git a/filter/tex/tests/filter_test.php b/filter/tex/tests/filter_test.php index a9e1e751e49..1244326660d 100644 --- a/filter/tex/tests/filter_test.php +++ b/filter/tex/tests/filter_test.php @@ -66,7 +66,7 @@ class filter_test extends \advanced_testcase { } } - function test_delimiters() { + function test_delimiters(): void { // First test the list of supported delimiters. $this->run_with_delimiters('$$', '$$', true); $this->run_with_delimiters('\\(', '\\)', true); diff --git a/filter/tex/tests/lib_test.php b/filter/tex/tests/lib_test.php index 3159386ed53..441790fcab6 100644 --- a/filter/tex/tests/lib_test.php +++ b/filter/tex/tests/lib_test.php @@ -59,7 +59,7 @@ class lib_test extends advanced_testcase { * @param $formula The formula to test * @param $expected The sanitized version of the formula we expect to get */ - public function test_filter_tex_sanitize_formula(string $formula, string $expected) { + public function test_filter_tex_sanitize_formula(string $formula, string $expected): void { $this->assertEquals($expected, filter_tex_sanitize_formula($formula)); } } diff --git a/filter/urltolink/tests/filter_test.php b/filter/urltolink/tests/filter_test.php index 6154372755a..66f6e7c5945 100644 --- a/filter/urltolink/tests/filter_test.php +++ b/filter/urltolink/tests/filter_test.php @@ -202,7 +202,7 @@ class filter_test extends \basic_testcase { /** * @dataProvider get_convert_urls_into_links_test_cases */ - function test_convert_urls_into_links($text, $correctresult) { + function test_convert_urls_into_links($text, $correctresult): void { $testablefilter = new testable_filter_urltolink(); $testablefilter->convert_urls_into_links($text); $this->assertEquals($correctresult, $text); diff --git a/grade/export/ods/tests/event/events_test.php b/grade/export/ods/tests/event/events_test.php index 87e2dbd66bb..79bba738649 100644 --- a/grade/export/ods/tests/event/events_test.php +++ b/grade/export/ods/tests/event/events_test.php @@ -35,7 +35,7 @@ class events_test extends \advanced_testcase { /** * Test course_module_instance_list_viewed event. */ - public function test_logging() { + public function test_logging(): void { // There is no proper API to call to trigger this event, so what we are // doing here is simply making sure that the events returns the right information. $course = $this->getDataGenerator()->create_course(); diff --git a/grade/export/txt/tests/event/events_test.php b/grade/export/txt/tests/event/events_test.php index c3c222d90fc..d01fb7a3299 100644 --- a/grade/export/txt/tests/event/events_test.php +++ b/grade/export/txt/tests/event/events_test.php @@ -35,7 +35,7 @@ class events_test extends \advanced_testcase { /** * Test course_module_instance_list_viewed event. */ - public function test_logging() { + public function test_logging(): void { // There is no proper API to call to trigger this event, so what we are // doing here is simply making sure that the events returns the right information. $course = $this->getDataGenerator()->create_course(); diff --git a/grade/export/xls/tests/event/events_test.php b/grade/export/xls/tests/event/events_test.php index 75921b7195a..f2f9a18b673 100644 --- a/grade/export/xls/tests/event/events_test.php +++ b/grade/export/xls/tests/event/events_test.php @@ -35,7 +35,7 @@ class events_test extends \advanced_testcase { /** * Test course_module_instance_list_viewed event. */ - public function test_logging() { + public function test_logging(): void { // There is no proper API to call to trigger this event, so what we are // doing here is simply making sure that the events returns the right information. $course = $this->getDataGenerator()->create_course(); diff --git a/grade/export/xml/tests/event/events_test.php b/grade/export/xml/tests/event/events_test.php index d2b94bd04b9..9c8f909088d 100644 --- a/grade/export/xml/tests/event/events_test.php +++ b/grade/export/xml/tests/event/events_test.php @@ -35,7 +35,7 @@ class events_test extends \advanced_testcase { /** * Test course_module_instance_list_viewed event. */ - public function test_logging() { + public function test_logging(): void { // There is no proper API to call to trigger this event, so what we are // doing here is simply making sure that the events returns the right information. $course = $this->getDataGenerator()->create_course(); diff --git a/grade/grading/form/guide/tests/guide_test.php b/grade/grading/form/guide/tests/guide_test.php index ff25d88c629..6a1bc12ae6a 100644 --- a/grade/grading/form/guide/tests/guide_test.php +++ b/grade/grading/form/guide/tests/guide_test.php @@ -36,7 +36,7 @@ class guide_test extends \advanced_testcase { /** * Unit test to get draft instance and create new instance. */ - public function test_get_or_create_instance() { + public function test_get_or_create_instance(): void { global $DB; $this->resetAfterTest(true); diff --git a/grade/grading/form/guide/tests/privacy/provider_test.php b/grade/grading/form/guide/tests/privacy/provider_test.php index 3b69b4ceb7d..b011afc7111 100644 --- a/grade/grading/form/guide/tests/privacy/provider_test.php +++ b/grade/grading/form/guide/tests/privacy/provider_test.php @@ -44,7 +44,7 @@ class provider_test extends provider_testcase { /** * Ensure that export_user_preferences returns no data if the user has no data. */ - public function test_export_user_preferences_not_defined() { + public function test_export_user_preferences_not_defined(): void { $user = \core_user::get_user_by_username('admin'); provider::export_user_preferences($user->id); @@ -55,7 +55,7 @@ class provider_test extends provider_testcase { /** * Ensure that export_user_preferences returns single preferences. */ - public function test_export_user_preferences() { + public function test_export_user_preferences(): void { $this->resetAfterTest(); // Define a user preference. @@ -83,7 +83,7 @@ class provider_test extends provider_testcase { /** * Test the export of guide data. */ - public function test_get_gradingform_export_data() { + public function test_get_gradingform_export_data(): void { global $DB; $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -121,7 +121,7 @@ class provider_test extends provider_testcase { /** * Test the deletion of guide user information via the instance ID. */ - public function test_delete_gradingform_for_instances() { + public function test_delete_gradingform_for_instances(): void { global $DB; $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); diff --git a/grade/grading/form/rubric/tests/privacy/provider_test.php b/grade/grading/form/rubric/tests/privacy/provider_test.php index be18d4391b8..258888c0a8c 100644 --- a/grade/grading/form/rubric/tests/privacy/provider_test.php +++ b/grade/grading/form/rubric/tests/privacy/provider_test.php @@ -41,7 +41,7 @@ class provider_test extends provider_testcase { /** * Test the export of rubric data. */ - public function test_get_gradingform_export_data() { + public function test_get_gradingform_export_data(): void { global $DB; $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -81,7 +81,7 @@ class provider_test extends provider_testcase { /** * Test the deletion of rubric user information via the instance ID. */ - public function test_delete_gradingform_for_instances() { + public function test_delete_gradingform_for_instances(): void { global $DB; $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); diff --git a/grade/grading/tests/grading_manager_test.php b/grade/grading/tests/grading_manager_test.php index e43c8b6af7a..54b629ddb0d 100644 --- a/grade/grading/tests/grading_manager_test.php +++ b/grade/grading/tests/grading_manager_test.php @@ -32,7 +32,7 @@ require_once($CFG->dirroot . '/grade/grading/lib.php'); // Include the code to t * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class grading_manager_test extends \advanced_testcase { - public function test_basic_instantiation() { + public function test_basic_instantiation(): void { $manager1 = get_grading_manager(); $fakecontext = (object)array( @@ -50,7 +50,7 @@ class grading_manager_test extends \advanced_testcase { /** * Unit test to set and get grading areas */ - public function test_set_and_get_grading_area() { + public function test_set_and_get_grading_area(): void { global $DB; $this->resetAfterTest(true); @@ -92,7 +92,7 @@ class grading_manager_test extends \advanced_testcase { /** * Unit test to check the tokenize method */ - public function test_tokenize() { + public function test_tokenize(): void { $UTFfailuremessage = 'A test using UTF-8 characters has failed. Consider updating PHP and PHP\'s PCRE or INTL extensions (MDL-30494)'; diff --git a/grade/grading/tests/privacy/legacy_polyfill_test.php b/grade/grading/tests/privacy/legacy_polyfill_test.php index 13190762037..8189743c894 100644 --- a/grade/grading/tests/privacy/legacy_polyfill_test.php +++ b/grade/grading/tests/privacy/legacy_polyfill_test.php @@ -30,7 +30,7 @@ class legacy_polyfill_test extends \advanced_testcase { /** * Test that the core_grading\privacy\legacy_polyfill works and that the static _export_gradingform_instance_data can be called. */ - public function test_export_gradingform_instance_data() { + public function test_export_gradingform_instance_data(): void { $context = \context_system::instance(); $mock = $this->createMock(test_gradingform_legacy_polyfill_mock_wrapper::class); @@ -45,7 +45,7 @@ class legacy_polyfill_test extends \advanced_testcase { /** * Test for _get_metadata shim. */ - public function test_get_metadata() { + public function test_get_metadata(): void { $collection = new \core_privacy\local\metadata\collection('core_gradingform'); $this->assertSame($collection, test_legacy_polyfill_gradingform_provider::get_metadata($collection)); } @@ -53,7 +53,7 @@ class legacy_polyfill_test extends \advanced_testcase { /** * Test the _delete_gradingform_for_instances shim. */ - public function test_delete_gradingform_for_instances() { + public function test_delete_gradingform_for_instances(): void { $context = \context_system::instance(); $mock = $this->createMock(test_gradingform_legacy_polyfill_mock_wrapper::class); diff --git a/grade/grading/tests/privacy/provider_test.php b/grade/grading/tests/privacy/provider_test.php index c24065fce62..7319f40a85f 100644 --- a/grade/grading/tests/privacy/provider_test.php +++ b/grade/grading/tests/privacy/provider_test.php @@ -63,7 +63,7 @@ class provider_test extends provider_testcase { /** * Test getting the context for the user ID related to this plugin. */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { global $DB; $this->resetAfterTest(); @@ -90,7 +90,7 @@ class provider_test extends provider_testcase { /** * Test retrieval of user ids in a given context. */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { $this->resetAfterTest(); $this->grading_setup_test_scenario_data(); // Instance two has one user who created the definitions and another who modified it. @@ -103,7 +103,7 @@ class provider_test extends provider_testcase { /** * Export for a user with no grading definitions created or modified will not have any data exported. */ - public function test_export_user_data_no_content() { + public function test_export_user_data_no_content(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); @@ -120,7 +120,7 @@ class provider_test extends provider_testcase { /** * Test that data is exported correctly for this plugin. */ - public function test_export_user_data() { + public function test_export_user_data(): void { global $DB; $this->resetAfterTest(); @@ -199,7 +199,7 @@ class provider_test extends provider_testcase { /** * Test for provider::delete_data_for_all_users_in_context(). */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; $this->resetAfterTest(); @@ -220,7 +220,7 @@ class provider_test extends provider_testcase { /** * Test for provider::delete_data_for_user(). */ - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; $this->resetAfterTest(); @@ -263,7 +263,7 @@ class provider_test extends provider_testcase { /** * Test exporting user data relating to an item ID. */ - public function test_export_item_data() { + public function test_export_item_data(): void { global $DB; $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -301,7 +301,7 @@ class provider_test extends provider_testcase { /** * Test deleting user data related to a context and item ID. */ - public function test_delete_instance_data() { + public function test_delete_instance_data(): void { global $DB; $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -354,7 +354,7 @@ class provider_test extends provider_testcase { /** * Test the deletion of multiple instances at once. */ - public function test_delete_data_for_instances() { + public function test_delete_data_for_instances(): void { global $DB; $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); diff --git a/grade/import/csv/tests/load_data_test.php b/grade/import/csv/tests/load_data_test.php index 20188b8f421..e7ffc403454 100644 --- a/grade/import/csv/tests/load_data_test.php +++ b/grade/import/csv/tests/load_data_test.php @@ -86,7 +86,7 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@example.com,75.00,,75.00,{exportdat /** * Test loading data and returning preview content. */ - public function test_load_csv_content() { + public function test_load_csv_content(): void { $encoding = 'utf8'; $separator = 'comma'; $previewrows = 5; @@ -146,7 +146,7 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@example.com,75.00,,75.00,{exportdat /** * Test fetching grade items for the course. */ - public function test_fetch_grade_items() { + public function test_fetch_grade_items(): void { $gradeitemsarray = \grade_item::fetch_all(array('courseid' => $this->courseid)); $gradeitems = \phpunit_gradeimport_csv_load_data::fetch_grade_items($this->courseid); @@ -174,7 +174,7 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@example.com,75.00,,75.00,{exportdat /** * Test the inserting of grade record data. */ - public function test_insert_grade_record() { + public function test_insert_grade_record(): void { global $DB, $USER; $user = $this->getDataGenerator()->create_user(); @@ -213,7 +213,7 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@example.com,75.00,,75.00,{exportdat /** * Test preparing a new grade item for import into the gradebook. */ - public function test_import_new_grade_item() { + public function test_import_new_grade_item(): void { global $DB; $this->setAdminUser(); @@ -288,7 +288,7 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@example.com,75.00,,75.00,{exportdat * @param boolean $successexpected Whether we expect for a user to be found or not. * @param int $allowaccountssameemail Value for $CFG->allowaccountssameemail */ - public function test_check_user_exists($field, $value, $successexpected, $allowaccountssameemail = 0) { + public function test_check_user_exists($field, $value, $successexpected, $allowaccountssameemail = 0): void { $this->resetAfterTest(); $generator = $this->getDataGenerator(); @@ -358,7 +358,7 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@example.com,75.00,,75.00,{exportdat /** * Test preparing feedback for inserting / updating into the gradebook. */ - public function test_create_feedback() { + public function test_create_feedback(): void { $testarray = $this->csv_load($this->oktext); $testobject = new \phpunit_gradeimport_csv_load_data(); @@ -374,7 +374,7 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@example.com,75.00,,75.00,{exportdat /** * Test preparing grade_items for upgrading into the gradebook. */ - public function test_update_grade_item() { + public function test_update_grade_item(): void { $testarray = $this->csv_load($this->oktext); $testobject = new \phpunit_gradeimport_csv_load_data(); @@ -407,7 +407,7 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@example.com,75.00,,75.00,{exportdat /** * Test importing data and mapping it with items in the course. */ - public function test_map_user_data_with_value() { + public function test_map_user_data_with_value(): void { // Need to add one of the users into the system. $user = new \stdClass(); $user->firstname = 'Anne'; @@ -460,7 +460,7 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@example.com,75.00,,75.00,{exportdat /** * Test importing data into the gradebook. */ - public function test_prepare_import_grade_data() { + public function test_prepare_import_grade_data(): void { global $DB; // Need to add one of the users into the system. @@ -513,7 +513,7 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@example.com,75.00,,75.00,{exportdat /* * Test importing csv data into the gradebook using "Last downloaded from this course" column and force import option. */ - public function test_force_import_option() { + public function test_force_import_option(): void { // Need to add users into the system. $user = new \stdClass(); diff --git a/grade/report/grader/tests/privacy/provider_test.php b/grade/report/grader/tests/privacy/provider_test.php index 1557d1c8e79..d6351087a56 100644 --- a/grade/report/grader/tests/privacy/provider_test.php +++ b/grade/report/grader/tests/privacy/provider_test.php @@ -51,7 +51,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Ensure that export_user_preferences returns no data if the user has no data. */ - public function test_export_user_preferences_not_defined() { + public function test_export_user_preferences_not_defined(): void { $user = \core_user::get_user_by_username('admin'); provider::export_user_preferences($user->id); @@ -63,7 +63,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { * Ensure that export_user_preferences returns single preferences. * These preferences can be set on each course, but the value is shared in the whole site. */ - public function test_export_user_preferences_single() { + public function test_export_user_preferences_single(): void { // Create test user, add some preferences. $user = $this->getDataGenerator()->create_user(); $this->setUser($user); @@ -89,7 +89,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Ensure that export_user_preferences returns preferences. */ - public function test_export_user_preferences_multiple() { + public function test_export_user_preferences_multiple(): void { // Create a course and add a user preference. $user = $this->getDataGenerator()->create_user(); $this->setUser($user); diff --git a/grade/report/history/tests/report_test.php b/grade/report/history/tests/report_test.php index d10e101484a..013adb895df 100644 --- a/grade/report/history/tests/report_test.php +++ b/grade/report/history/tests/report_test.php @@ -30,7 +30,7 @@ class report_test extends \advanced_testcase { /** * Create some grades. */ - public function test_query_db() { + public function test_query_db(): void { $this->resetAfterTest(); // Making the setup. @@ -194,7 +194,7 @@ class report_test extends \advanced_testcase { /** * Test the get users helper method. */ - public function test_get_users() { + public function test_get_users(): void { $this->resetAfterTest(); // Making the setup. @@ -436,7 +436,7 @@ class report_test extends \advanced_testcase { * @param $teachergroups * @param $expectedusers */ - public function test_get_users_with_groups($groupmode, $teacherrole, $teachergroups, $expectedusers) { + public function test_get_users_with_groups($groupmode, $teacherrole, $teachergroups, $expectedusers): void { global $DB; $this->resetAfterTest(); @@ -513,7 +513,7 @@ class report_test extends \advanced_testcase { /** * Test the get graders helper method. */ - public function test_graders() { + public function test_graders(): void { $this->resetAfterTest(); // Making the setup. diff --git a/grade/report/overview/tests/externallib_test.php b/grade/report/overview/tests/externallib_test.php index 47e9d43e181..25329ad34f4 100644 --- a/grade/report/overview/tests/externallib_test.php +++ b/grade/report/overview/tests/externallib_test.php @@ -107,7 +107,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_course_grades function case student */ - public function test_get_course_grades_student() { + public function test_get_course_grades_student(): void { // A user can see his own grades in both courses. $this->setUser($this->student1); @@ -151,7 +151,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_course_grades function case admin */ - public function test_get_course_grades_admin() { + public function test_get_course_grades_admin(): void { // A admin must see all student grades. $this->setAdminUser(); @@ -185,7 +185,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_course_grades function case teacher */ - public function test_get_course_grades_teacher() { + public function test_get_course_grades_teacher(): void { // Teachers don't see grades. $this->setUser($this->teacher); @@ -198,7 +198,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_course_grades function case incorrect permissions */ - public function test_get_course_grades_permissions() { + public function test_get_course_grades_permissions(): void { // Student can't see other student grades. $this->setUser($this->student2); @@ -209,7 +209,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test view_grade_report function */ - public function test_view_grade_report() { + public function test_view_grade_report(): void { global $USER; // Redirect events to the sink, so we can recover them later. @@ -243,7 +243,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test view_grade_report_permissions function */ - public function test_view_grade_report_permissions() { + public function test_view_grade_report_permissions(): void { $this->setUser($this->student2); $this->expectException('moodle_exception'); diff --git a/grade/report/singleview/tests/screen_test.php b/grade/report/singleview/tests/screen_test.php index 9a98cac97c2..c337efa584a 100644 --- a/grade/report/singleview/tests/screen_test.php +++ b/grade/report/singleview/tests/screen_test.php @@ -37,7 +37,7 @@ class screen_test extends \advanced_testcase { /** * Test load_users method. */ - public function test_load_users() { + public function test_load_users(): void { global $DB; $this->setAdminUser(); diff --git a/grade/report/user/tests/externallib_test.php b/grade/report/user/tests/externallib_test.php index 0c82e6bc10d..d6c57df2ece 100644 --- a/grade/report/user/tests/externallib_test.php +++ b/grade/report/user/tests/externallib_test.php @@ -95,7 +95,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_grades_table function case teacher */ - public function test_get_grades_table_teacher() { + public function test_get_grades_table_teacher(): void { $this->resetAfterTest(true); @@ -129,7 +129,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_grades_table function case student */ - public function test_get_grades_table_student() { + public function test_get_grades_table_student(): void { global $CFG, $DB; $this->resetAfterTest(true); @@ -173,7 +173,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_grades_table function case incorrect permissions */ - public function test_get_grades_table_permissions() { + public function test_get_grades_table_permissions(): void { global $CFG, $DB; $this->resetAfterTest(true); @@ -197,7 +197,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test view_grade_report function */ - public function test_view_grade_report() { + public function test_view_grade_report(): void { global $USER; $this->resetAfterTest(true); @@ -246,7 +246,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_grades_items function case teacher */ - public function test_get_grade_items_teacher() { + public function test_get_grade_items_teacher(): void { $this->resetAfterTest(true); @@ -350,7 +350,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_grades_items function case student */ - public function test_get_grade_items_student() { + public function test_get_grade_items_student(): void { $this->resetAfterTest(true); diff --git a/grade/report/user/tests/lib_test.php b/grade/report/user/tests/lib_test.php index 59bb6dc5fe6..c24090a0ba0 100644 --- a/grade/report/user/tests/lib_test.php +++ b/grade/report/user/tests/lib_test.php @@ -62,7 +62,7 @@ class lib_test extends \advanced_testcase { /** * Tests the gradereport_user_myprofile_navigation() function. */ - public function test_gradereport_user_myprofile_navigation() { + public function test_gradereport_user_myprofile_navigation(): void { $this->setAdminUser(); $iscurrentuser = false; @@ -76,7 +76,7 @@ class lib_test extends \advanced_testcase { * Tests the gradereport_user_myprofile_navigation() function for a user * without permission to view the grade node. */ - public function test_gradereport_user_myprofile_navigation_without_permission() { + public function test_gradereport_user_myprofile_navigation_without_permission(): void { $this->setUser($this->user); $iscurrentuser = true; diff --git a/grade/report/user/tests/privacy/provider_test.php b/grade/report/user/tests/privacy/provider_test.php index 58ac0271b85..a159121a7a4 100644 --- a/grade/report/user/tests/privacy/provider_test.php +++ b/grade/report/user/tests/privacy/provider_test.php @@ -46,7 +46,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Ensure that export_user_preferences returns no data if the user has no data. */ - public function test_export_user_preferences_not_defined() { + public function test_export_user_preferences_not_defined(): void { $user = \core_user::get_user_by_username('admin'); provider::export_user_preferences($user->id); @@ -58,7 +58,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { * Ensure that export_user_preferences returns single preferences. * These preferences can be set on each course, but the value is shared in the whole site. */ - public function test_export_user_preferences_single() { + public function test_export_user_preferences_single(): void { // Define a user preference. $user = $this->getDataGenerator()->create_user(); $this->setUser($user); diff --git a/grade/tests/component_gradeitem_test.php b/grade/tests/component_gradeitem_test.php index f8bc016288e..9eb34f84279 100644 --- a/grade/tests/component_gradeitem_test.php +++ b/grade/tests/component_gradeitem_test.php @@ -45,7 +45,7 @@ class component_gradeitem_test extends advanced_testcase { * * @covers ::get_formatted_grade_for_user */ - public function test_get_formatted_grade_for_user_with_points() { + public function test_get_formatted_grade_for_user_with_points(): void { $grade = $this->initialise_test_and_get_grade_item(5, 4); $this->assertEquals(4, $grade->grade); @@ -58,7 +58,7 @@ class component_gradeitem_test extends advanced_testcase { * * @covers ::get_formatted_grade_for_user */ - public function test_get_formatted_grade_for_user_with_letters() { + public function test_get_formatted_grade_for_user_with_letters(): void { $grade = $this->initialise_test_and_get_grade_item(5, 4, GRADE_DISPLAY_TYPE_LETTER); $this->assertEquals(4, $grade->grade); @@ -71,7 +71,7 @@ class component_gradeitem_test extends advanced_testcase { * * @covers ::get_formatted_grade_for_user */ - public function test_get_formatted_grade_for_user_with_percentage() { + public function test_get_formatted_grade_for_user_with_percentage(): void { $grade = $this->initialise_test_and_get_grade_item(5, 4, GRADE_DISPLAY_TYPE_PERCENTAGE); $this->assertEquals(4, $grade->grade); @@ -84,7 +84,7 @@ class component_gradeitem_test extends advanced_testcase { * * @covers ::get_formatted_grade_for_user */ - public function test_get_formatted_grade_for_user_with_points_letter() { + public function test_get_formatted_grade_for_user_with_points_letter(): void { $grade = $this->initialise_test_and_get_grade_item(5, 4, GRADE_DISPLAY_TYPE_REAL_LETTER); $this->assertEquals(4, $grade->grade); @@ -97,7 +97,7 @@ class component_gradeitem_test extends advanced_testcase { * * @covers ::get_formatted_grade_for_user */ - public function test_get_formatted_grade_for_user_with_scales() { + public function test_get_formatted_grade_for_user_with_scales(): void { $grade = $this->initialise_test_and_get_grade_item(-2, 2); $this->assertEquals(2, $grade->grade); @@ -110,7 +110,7 @@ class component_gradeitem_test extends advanced_testcase { * * @covers ::get_formatted_grade_for_user */ - public function test_get_formatted_grade_for_user_with_rubric() { + public function test_get_formatted_grade_for_user_with_rubric(): void { $this->resetAfterTest(); $generator = \testing_util::get_data_generator(); @@ -163,7 +163,7 @@ class component_gradeitem_test extends advanced_testcase { * * @covers ::get_formatted_grade_for_user */ - public function test_get_formatted_grade_for_user_with_marking_guide() { + public function test_get_formatted_grade_for_user_with_marking_guide(): void { $this->resetAfterTest(); $generator = \testing_util::get_data_generator(); diff --git a/grade/tests/edittreelib_test.php b/grade/tests/edittreelib_test.php index 8b011755dd0..54ae8231ea4 100644 --- a/grade/tests/edittreelib_test.php +++ b/grade/tests/edittreelib_test.php @@ -33,7 +33,7 @@ require_once($CFG->dirroot.'/grade/edit/tree/lib.php'); * @license http://www.gnu.org/copyleft/gpl.html GNU Public License */ class edittreelib_test extends \advanced_testcase { - public function test_format_number() { + public function test_format_number(): void { $numinput = array(0, 1, 1.01, '1.010', 1.2345); $numoutput = array(0.0, 1.0, 1.01, 1.01, 1.2345); @@ -43,7 +43,7 @@ class edittreelib_test extends \advanced_testcase { } } - public function test_grade_edit_tree_column_range_get_item_cell() { + public function test_grade_edit_tree_column_range_get_item_cell(): void { global $DB, $CFG; $this->resetAfterTest(true); diff --git a/grade/tests/event/events_test.php b/grade/tests/event/events_test.php index b1136f70d2d..921c55ca569 100644 --- a/grade/tests/event/events_test.php +++ b/grade/tests/event/events_test.php @@ -61,7 +61,7 @@ class events_test extends \advanced_testcase { * There is no external API for triggering this event, so the unit test will simply * create and trigger the event and ensure the data is returned as expected. */ - public function test_grade_letter_created() { + public function test_grade_letter_created(): void { // Create a grade letter created event. $event = \core\event\grade_letter_created::create(array( 'objectid' => 10, @@ -85,7 +85,7 @@ class events_test extends \advanced_testcase { * There is no external API for triggering this event, so the unit test will simply * create and trigger the event and ensure the data is returned as expected. */ - public function test_grade_letter_deleted() { + public function test_grade_letter_deleted(): void { // Create a grade letter deleted event. $event = \core\event\grade_letter_deleted::create(array( 'objectid' => 10, @@ -109,7 +109,7 @@ class events_test extends \advanced_testcase { * There is no external API for triggering this event, so the unit test will simply * create and trigger the event and ensure the data is returned as expected. */ - public function test_grade_letter_updated() { + public function test_grade_letter_updated(): void { // Create a grade letter updated event. $event = \core\event\grade_letter_updated::create(array( 'objectid' => 10, @@ -130,7 +130,7 @@ class events_test extends \advanced_testcase { /** * Test the scale created event. */ - public function test_scale_created() { + public function test_scale_created(): void { $gradescale = new \grade_scale(); $gradescale->name = 'unittestscale3'; $gradescale->courseid = $this->course->id; @@ -156,7 +156,7 @@ class events_test extends \advanced_testcase { /** * Test the scale deleted event. */ - public function test_scale_deleted() { + public function test_scale_deleted(): void { $gradescale = new \grade_scale(); $gradescale->name = 'unittestscale3'; $gradescale->courseid = $this->course->id; @@ -179,7 +179,7 @@ class events_test extends \advanced_testcase { /** * Test the scale updated event. */ - public function test_scale_updated() { + public function test_scale_updated(): void { $gradescale = new \grade_scale(); $gradescale->name = 'unittestscale3'; $gradescale->courseid = $this->course->id; diff --git a/grade/tests/export_test.php b/grade/tests/export_test.php index cac5153d783..870319e810e 100644 --- a/grade/tests/export_test.php +++ b/grade/tests/export_test.php @@ -40,7 +40,7 @@ class export_test extends \advanced_testcase { * @param int $inputformat The format of the input string * @param string $expected The expected result of the format. */ - public function test_format_feedback($input, $inputformat, $expected) { + public function test_format_feedback($input, $inputformat, $expected): void { $feedback = $this->getMockForAbstractClass( \grade_export::class, [], @@ -60,7 +60,7 @@ class export_test extends \advanced_testcase { /** * Ensure that feedback is correctly formatted. Test augmented functionality to handle file links */ - public function test_format_feedback_with_grade() { + public function test_format_feedback_with_grade(): void { $this->resetAfterTest(); $dg = $this->getDataGenerator(); $c1 = $dg->create_course(); diff --git a/grade/tests/external/create_gradecategories_test.php b/grade/tests/external/create_gradecategories_test.php index 87c0b3d0342..65192ec9ee2 100644 --- a/grade/tests/external/create_gradecategories_test.php +++ b/grade/tests/external/create_gradecategories_test.php @@ -41,7 +41,7 @@ class create_gradecategories_test extends \externallib_advanced_testcase { * * @return void */ - public function test_create_gradecategories() { + public function test_create_gradecategories(): void { global $DB; $this->resetAfterTest(true); $course = $this->getDataGenerator()->create_course(); diff --git a/grade/tests/external/get_feedback_test.php b/grade/tests/external/get_feedback_test.php index b0180301eb4..9c90734ab68 100644 --- a/grade/tests/external/get_feedback_test.php +++ b/grade/tests/external/get_feedback_test.php @@ -42,7 +42,7 @@ class get_feedback_test extends \externallib_advanced_testcase { * @param array $expected The expected feedback data. * @return void */ - public function test_get_feedback(?string $feedback, array $expected) { + public function test_get_feedback(?string $feedback, array $expected): void { $this->resetAfterTest(true); $course = $this->getDataGenerator()->create_course(); @@ -111,7 +111,7 @@ class get_feedback_test extends \externallib_advanced_testcase { * @return void */ public function test_get_feedback_invalid_request(string $loggeduserrole, bool $feedbacknotincourse, - array $expectedexception = []) { + array $expectedexception = []): void { $this->resetAfterTest(true); // Create a course with a user and a grade item. diff --git a/grade/tests/importlib_test.php b/grade/tests/importlib_test.php index 83d6bd8915f..f79f19be35b 100644 --- a/grade/tests/importlib_test.php +++ b/grade/tests/importlib_test.php @@ -80,7 +80,7 @@ class importlib_test extends \advanced_testcase { * * @covers ::grade_import_commit */ - public function test_grade_import_commit() { + public function test_grade_import_commit(): void { global $USER, $DB, $CFG; $this->resetAfterTest(); diff --git a/grade/tests/lib_test.php b/grade/tests/lib_test.php index f24e9af25fe..a616657626e 100644 --- a/grade/tests/lib_test.php +++ b/grade/tests/lib_test.php @@ -48,7 +48,7 @@ class lib_test extends \advanced_testcase { /** * Test can_output_item. */ - public function test_can_output_item() { + public function test_can_output_item(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator(); @@ -182,7 +182,7 @@ class lib_test extends \advanced_testcase { * * @covers \grade_report::ungraded_counts */ - public function test_ungraded_counts_count_sumgrades() { + public function test_ungraded_counts_count_sumgrades(): void { global $DB; $this->resetAfterTest(true); @@ -377,7 +377,7 @@ class lib_test extends \advanced_testcase { * * @covers \grade_report::ungraded_counts */ - public function test_ungraded_counts_hidden_grades(bool $hidden, array $expectedcount, array $expectedsumarray) { + public function test_ungraded_counts_hidden_grades(bool $hidden, array $expectedcount, array $expectedsumarray): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -477,7 +477,7 @@ class lib_test extends \advanced_testcase { * * @covers \grade_report::ungraded_counts */ - public function test_ungraded_count_sumgrades_groups() { + public function test_ungraded_count_sumgrades_groups(): void { global $DB; $this->resetAfterTest(); @@ -640,7 +640,7 @@ class lib_test extends \advanced_testcase { * @covers \grade_report::ungraded_counts */ public function test_ungraded_counts_only_active_enrol(bool $onlyactive, - int $hascapability, ?bool $showonlyactiveenrolpref, array $expectedcount, array $expectedsumarray) { + int $hascapability, ?bool $showonlyactiveenrolpref, array $expectedcount, array $expectedsumarray): void { global $CFG, $DB; $this->resetAfterTest(); @@ -793,7 +793,7 @@ class lib_test extends \advanced_testcase { * * @covers \grade_report::calculate_average */ - public function test_calculate_average(int $meanselection, array $expectedmeancount, array $expectedaverage) { + public function test_calculate_average(int $meanselection, array $expectedmeancount, array $expectedaverage): void { global $DB; $this->resetAfterTest(true); @@ -902,7 +902,7 @@ class lib_test extends \advanced_testcase { * * @covers \grade_report::item_types */ - public function test_item_types() { + public function test_item_types(): void { $this->resetAfterTest(true); $course1 = $this->getDataGenerator()->create_course(); @@ -976,7 +976,7 @@ class lib_test extends \advanced_testcase { * * @covers ::get_gradable_users */ - public function test_get_gradable_users() { + public function test_get_gradable_users(): void { global $DB; $this->setAdminUser(); diff --git a/grade/tests/privacy/provider_test.php b/grade/tests/privacy/provider_test.php index 27c3ea8a280..31ebd297dd0 100644 --- a/grade/tests/privacy/provider_test.php +++ b/grade/tests/privacy/provider_test.php @@ -54,7 +54,7 @@ class provider_test extends provider_testcase { $PAGE->get_renderer('core'); } - public function test_get_contexts_for_userid_gradebook_edits() { + public function test_get_contexts_for_userid_gradebook_edits(): void { $dg = $this->getDataGenerator(); $c1 = $dg->create_course(); @@ -179,7 +179,7 @@ class provider_test extends provider_testcase { $this->assertArrayHasKey($c1ctx->id, $contexts); } - public function test_get_contexts_for_userid_grades_and_history() { + public function test_get_contexts_for_userid_grades_and_history(): void { $dg = $this->getDataGenerator(); $c1 = $dg->create_course(); @@ -253,7 +253,7 @@ class provider_test extends provider_testcase { /** * Test that the appropriate user IDs are returned for a given context. */ - public function test_get_users_in_context_gradebook_edits() { + public function test_get_users_in_context_gradebook_edits(): void { $dg = $this->getDataGenerator(); $c1 = $dg->create_course(); @@ -348,7 +348,7 @@ class provider_test extends provider_testcase { /** * Test that the appropriate user IDs are returned for a given context. */ - public function test_get_users_in_context_grades_and_history() { + public function test_get_users_in_context_grades_and_history(): void { $dg = $this->getDataGenerator(); $c1 = $dg->create_course(); @@ -404,7 +404,7 @@ class provider_test extends provider_testcase { $this->assertEquals([$u2->id], $userlist->get_userids()); } - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; $fs = new \file_storage(); @@ -644,7 +644,7 @@ class provider_test extends provider_testcase { $this->assertEquals(0, count($files)); } - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; $fs = new \file_storage(); @@ -895,7 +895,7 @@ class provider_test extends provider_testcase { /** * Test deleting multiple users for a context works. */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { global $DB; $dg = $this->getDataGenerator(); @@ -966,7 +966,7 @@ class provider_test extends provider_testcase { $this->assertFalse($DB->record_exists('grade_grades', ['userid' => $u4->id, 'itemid' => $gi2a->id])); } - public function test_export_data_for_user_about_grades_and_history() { + public function test_export_data_for_user_about_grades_and_history(): void { $dg = $this->getDataGenerator(); $c1 = $dg->create_course(); @@ -1283,7 +1283,7 @@ class provider_test extends provider_testcase { $this->assertEquals(get_string('privacy:request:historyactiondelete', 'core_grades'), $grade['action']); } - public function test_export_data_for_user_with_scale() { + public function test_export_data_for_user_with_scale(): void { global $DB; $dg = $this->getDataGenerator(); $c1 = $dg->create_course(); @@ -1316,7 +1316,7 @@ class provider_test extends provider_testcase { $this->assertEquals('Reasonable', $data->grades[2]['grade_formatted']); } - public function test_export_data_for_user_about_gradebook_edits() { + public function test_export_data_for_user_about_gradebook_edits(): void { global $DB; $dg = $this->getDataGenerator(); $c1 = $dg->create_course(); diff --git a/grade/tests/querylib_test.php b/grade/tests/querylib_test.php index 28b36a32ce7..19b106ab917 100644 --- a/grade/tests/querylib_test.php +++ b/grade/tests/querylib_test.php @@ -32,7 +32,7 @@ require_once($CFG->dirroot.'/grade/querylib.php'); */ class querylib_test extends \advanced_testcase { - public function test_grade_get_gradable_activities() { + public function test_grade_get_gradable_activities(): void { $this->resetAfterTest(true); $course = $this->getDataGenerator()->create_course(); @@ -51,7 +51,7 @@ class querylib_test extends \advanced_testcase { $this->assertTrue(isset($cms[$forum1->cmid])); } - public function test_grade_get_grade_items_for_activity() { + public function test_grade_get_grade_items_for_activity(): void { $this->resetAfterTest(true); $course = $this->getDataGenerator()->create_course(); diff --git a/grade/tests/report_graderlib_test.php b/grade/tests/report_graderlib_test.php index ef6e7f20f18..f4f31b452a4 100644 --- a/grade/tests/report_graderlib_test.php +++ b/grade/tests/report_graderlib_test.php @@ -42,7 +42,7 @@ class report_graderlib_test extends \advanced_testcase { * * process_data() processes submitted grade and feedback data */ - public function test_process_data() { + public function test_process_data(): void { global $DB, $CFG; $this->resetAfterTest(true); @@ -112,7 +112,7 @@ class report_graderlib_test extends \advanced_testcase { $this->assertEquals($studentgrade->finalgrade, $toobig); } - public function test_collapsed_preferences() { + public function test_collapsed_preferences(): void { $this->resetAfterTest(true); $emptypreferences = array('aggregatesonly' => array(), 'gradesonly' => array()); @@ -239,7 +239,7 @@ class report_graderlib_test extends \advanced_testcase { * @covers \grade_report_grader::get_collapsed_preferences * @covers \grade_report_grader::filter_collapsed_categories */ - public function test_old_collapsed_preferences() { + public function test_old_collapsed_preferences(): void { $this->resetAfterTest(true); $user1 = $this->getDataGenerator()->create_user(); @@ -459,7 +459,7 @@ class report_graderlib_test extends \advanced_testcase { * Previously, with an ungraded quiz (which results in a grade item with type GRADETYPE_NONE) * there was a bug in get_right_rows in some situations. */ - public function test_get_right_rows() { + public function test_get_right_rows(): void { global $USER, $DB; $this->resetAfterTest(true); diff --git a/grade/tests/reportlib_test.php b/grade/tests/reportlib_test.php index c94216b980c..f9c85841e2d 100644 --- a/grade/tests/reportlib_test.php +++ b/grade/tests/reportlib_test.php @@ -66,7 +66,7 @@ class reportlib_test extends advanced_testcase { /** * Tests grade_report::blank_hidden_total_and_adjust_bounds() */ - public function test_blank_hidden_total_and_adjust_bounds() { + public function test_blank_hidden_total_and_adjust_bounds(): void { global $DB; $this->resetAfterTest(true); diff --git a/grade/tests/reportuserlib_test.php b/grade/tests/reportuserlib_test.php index 19f270065a8..119cff1a535 100644 --- a/grade/tests/reportuserlib_test.php +++ b/grade/tests/reportuserlib_test.php @@ -41,7 +41,7 @@ class reportuserlib_test extends \advanced_testcase { * inject_rowspans() returns the count of the number of elements, sets maxdepth on the * report object and sets the rowspan property on any element that has children. */ - public function test_inject_rowspans() { + public function test_inject_rowspans(): void { global $CFG, $USER, $DB; parent::setUp(); diff --git a/group/tests/customfield/group_handler_test.php b/group/tests/customfield/group_handler_test.php index 11b3f9b9780..a9073168ddc 100644 --- a/group/tests/customfield/group_handler_test.php +++ b/group/tests/customfield/group_handler_test.php @@ -66,14 +66,14 @@ class group_handler_test extends advanced_testcase { /** * Test configuration context. */ - public function test_get_configuration_context() { + public function test_get_configuration_context(): void { $this->assertInstanceOf(context_system::class, $this->handler->get_configuration_context()); } /** * Test getting config URL. */ - public function test_get_configuration_url() { + public function test_get_configuration_url(): void { $this->assertInstanceOf(moodle_url::class, $this->handler->get_configuration_url()); $this->assertEquals('/group/customfield.php', $this->handler->get_configuration_url()->out_as_local_url()); } @@ -81,7 +81,7 @@ class group_handler_test extends advanced_testcase { /** * Test getting instance context. */ - public function test_get_instance_context() { + public function test_get_instance_context(): void { global $COURSE; $this->resetAfterTest(); @@ -98,7 +98,7 @@ class group_handler_test extends advanced_testcase { /** * Test can configure check. */ - public function test_can_configure() { + public function test_can_configure(): void { $this->resetAfterTest(); $user = self::getDataGenerator()->create_user(); @@ -116,7 +116,7 @@ class group_handler_test extends advanced_testcase { /** * Test can edit functionality. */ - public function test_can_edit() { + public function test_can_edit(): void { $this->resetAfterTest(); $course = self::getDataGenerator()->create_course(); @@ -139,7 +139,7 @@ class group_handler_test extends advanced_testcase { /** * Test can view functionality. */ - public function test_can_view() { + public function test_can_view(): void { $this->resetAfterTest(); $course = self::getDataGenerator()->create_course(); diff --git a/group/tests/customfield/grouping_handler_test.php b/group/tests/customfield/grouping_handler_test.php index 152d2ccfa7d..ca2b87a9bea 100644 --- a/group/tests/customfield/grouping_handler_test.php +++ b/group/tests/customfield/grouping_handler_test.php @@ -66,14 +66,14 @@ class grouping_handler_test extends advanced_testcase { /** * Test configuration context. */ - public function test_get_configuration_context() { + public function test_get_configuration_context(): void { $this->assertInstanceOf(context_system::class, $this->handler->get_configuration_context()); } /** * Test getting config URL. */ - public function test_get_configuration_url() { + public function test_get_configuration_url(): void { $this->assertInstanceOf(moodle_url::class, $this->handler->get_configuration_url()); $this->assertEquals('/group/grouping_customfield.php', $this->handler->get_configuration_url()->out_as_local_url()); } @@ -81,7 +81,7 @@ class grouping_handler_test extends advanced_testcase { /** * Test getting instance context. */ - public function test_get_instance_context() { + public function test_get_instance_context(): void { global $COURSE; $this->resetAfterTest(); @@ -98,7 +98,7 @@ class grouping_handler_test extends advanced_testcase { /** * Test can configure check. */ - public function test_can_configure() { + public function test_can_configure(): void { $this->resetAfterTest(); $user = self::getDataGenerator()->create_user(); @@ -116,7 +116,7 @@ class grouping_handler_test extends advanced_testcase { /** * Test can edit functionality. */ - public function test_can_edit() { + public function test_can_edit(): void { $this->resetAfterTest(); $course = self::getDataGenerator()->create_course(); @@ -139,7 +139,7 @@ class grouping_handler_test extends advanced_testcase { /** * Test can view functionality. */ - public function test_can_view() { + public function test_can_view(): void { $this->resetAfterTest(); $course = self::getDataGenerator()->create_course(); diff --git a/group/tests/externallib_test.php b/group/tests/externallib_test.php index e185e4cc635..550e4d1dc30 100644 --- a/group/tests/externallib_test.php +++ b/group/tests/externallib_test.php @@ -81,7 +81,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test create_groups */ - public function test_create_groups() { + public function test_create_groups(): void { global $DB; $this->resetAfterTest(true); @@ -171,7 +171,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test create_groups with custom fields. */ - public function test_create_groups_with_customfields() { + public function test_create_groups_with_customfields(): void { global $DB; $this->resetAfterTest(); @@ -233,7 +233,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test update_groups */ - public function test_update_groups() { + public function test_update_groups(): void { global $DB; $this->resetAfterTest(true); @@ -317,7 +317,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test update_groups with custom fields. */ - public function test_update_groups_with_customfields() { + public function test_update_groups_with_customfields(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -443,7 +443,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_groups */ - public function test_get_groups() { + public function test_get_groups(): void { global $DB; $this->resetAfterTest(true); @@ -517,7 +517,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_groups with customfields. */ - public function test_get_groups_with_customfields() { + public function test_get_groups_with_customfields(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -544,7 +544,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test delete_groups */ - public function test_delete_groups() { + public function test_delete_groups(): void { global $DB; $this->resetAfterTest(true); @@ -594,7 +594,7 @@ class externallib_test extends externallib_advanced_testcase { * Test create and update groupings. * @return void */ - public function test_create_update_groupings() { + public function test_create_update_groupings(): void { global $DB; $this->resetAfterTest(true); @@ -652,7 +652,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test create_groupings with custom fields. */ - public function test_create_groupings_with_customfields() { + public function test_create_groupings_with_customfields(): void { global $DB; $this->resetAfterTest(); @@ -689,7 +689,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test update_groups with custom fields. */ - public function test_update_groupings_with_customfields() { + public function test_update_groupings_with_customfields(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -719,7 +719,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_groupings */ - public function test_get_groupings() { + public function test_get_groupings(): void { global $DB; $this->resetAfterTest(true); @@ -796,7 +796,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_groupings with customfields. */ - public function test_get_groupings_with_customfields() { + public function test_get_groupings_with_customfields(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -846,7 +846,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test delete_groupings. */ - public function test_delete_groupings() { + public function test_delete_groupings(): void { global $DB; $this->resetAfterTest(true); @@ -899,7 +899,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_groups */ - public function test_get_course_user_groups() { + public function test_get_course_user_groups(): void { global $DB; $this->resetAfterTest(true); @@ -1039,7 +1039,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_activity_allowed_groups */ - public function test_get_activity_allowed_groups() { + public function test_get_activity_allowed_groups(): void { global $DB; $this->resetAfterTest(true); @@ -1139,7 +1139,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_activity_groupmode */ - public function test_get_activity_groupmode() { + public function test_get_activity_groupmode(): void { global $DB; $this->resetAfterTest(true); @@ -1185,7 +1185,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test add_group_members. */ - public function test_add_group_members() { + public function test_add_group_members(): void { global $DB; $this->resetAfterTest(true); @@ -1244,7 +1244,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test delete_group_members. */ - public function test_delete_group_members() { + public function test_delete_group_members(): void { global $DB; $this->resetAfterTest(true); diff --git a/group/tests/lib_test.php b/group/tests/lib_test.php index 0b6645ddd61..0fc33bae688 100644 --- a/group/tests/lib_test.php +++ b/group/tests/lib_test.php @@ -38,7 +38,7 @@ require_once($CFG->dirroot . '/lib/grouplib.php'); */ class lib_test extends \advanced_testcase { - public function test_member_added_event() { + public function test_member_added_event(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -61,7 +61,7 @@ class lib_test extends \advanced_testcase { $this->assertEquals($url, $event->get_url()); } - public function test_member_removed_event() { + public function test_member_removed_event(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -85,7 +85,7 @@ class lib_test extends \advanced_testcase { $this->assertEquals($url, $event->get_url()); } - public function test_group_created_event() { + public function test_group_created_event(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -104,7 +104,7 @@ class lib_test extends \advanced_testcase { $this->assertEquals($url, $event->get_url()); } - public function test_grouping_created_event() { + public function test_grouping_created_event(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -124,7 +124,7 @@ class lib_test extends \advanced_testcase { $this->assertEquals($url, $event->get_url()); } - public function test_group_updated_event() { + public function test_group_updated_event(): void { global $DB; $this->resetAfterTest(); @@ -153,7 +153,7 @@ class lib_test extends \advanced_testcase { $this->assertEquals($url, $event->get_url()); } - public function test_group_updated_event_does_not_require_names() { + public function test_group_updated_event_does_not_require_names(): void { global $DB; $this->resetAfterTest(); @@ -180,7 +180,7 @@ class lib_test extends \advanced_testcase { $this->assertEquals($url, $event->get_url()); } - public function test_grouping_updated_event() { + public function test_grouping_updated_event(): void { global $DB; $this->resetAfterTest(); @@ -211,7 +211,7 @@ class lib_test extends \advanced_testcase { $this->assertEquals($url, $event->get_url()); } - public function test_grouping_updated_event_does_not_require_names() { + public function test_grouping_updated_event_does_not_require_names(): void { global $DB; $this->resetAfterTest(); @@ -248,7 +248,7 @@ class lib_test extends \advanced_testcase { $this->assertEquals($url, $event->get_url()); } - public function test_group_deleted_event() { + public function test_group_deleted_event(): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -266,7 +266,7 @@ class lib_test extends \advanced_testcase { $this->assertEquals($url, $event->get_url()); } - public function test_grouping_deleted_event() { + public function test_grouping_deleted_event(): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -285,7 +285,7 @@ class lib_test extends \advanced_testcase { $this->assertEquals($url, $event->get_url()); } - public function test_groups_delete_group_members() { + public function test_groups_delete_group_members(): void { global $DB; $this->resetAfterTest(); @@ -324,7 +324,7 @@ class lib_test extends \advanced_testcase { $this->assertFalse($DB->record_exists('groups_members', array('groupid' => $group1->id, 'userid' => $user2->id))); } - public function test_groups_remove_member() { + public function test_groups_remove_member(): void { global $DB; $this->resetAfterTest(); @@ -354,7 +354,7 @@ class lib_test extends \advanced_testcase { $this->assertFalse($DB->record_exists('groups_members', array('groupid' => $group2->id, 'userid' => $user1->id))); } - public function test_groups_delete_groupings_groups() { + public function test_groups_delete_groupings_groups(): void { global $DB; $this->resetAfterTest(); @@ -384,7 +384,7 @@ class lib_test extends \advanced_testcase { array('groupid' => $group1c2->id, 'groupingid' => $grouping1c2->id))); } - public function test_groups_delete_groups() { + public function test_groups_delete_groups(): void { global $DB; $this->resetAfterTest(); @@ -415,7 +415,7 @@ class lib_test extends \advanced_testcase { $this->assertFalse($DB->record_exists('groupings_groups', array('groupid' => $group1->id, 'groupingid' => $grouping1->id))); } - public function test_groups_delete_groupings() { + public function test_groups_delete_groupings(): void { global $DB; $this->resetAfterTest(); @@ -445,7 +445,7 @@ class lib_test extends \advanced_testcase { * @covers ::groups_create_group * @covers ::groups_get_group */ - public function test_groups_with_customfield() { + public function test_groups_with_customfield(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -529,7 +529,7 @@ class lib_test extends \advanced_testcase { $this->assertSame('Updated input for grouping1', $customfield['value']); } - public function test_groups_create_autogroups() { + public function test_groups_create_autogroups(): void { global $DB; $this->resetAfterTest(); @@ -585,7 +585,7 @@ class lib_test extends \advanced_testcase { /** * Test groups_create_group enabling a group conversation. */ - public function test_groups_create_group_with_conversation() { + public function test_groups_create_group_with_conversation(): void { global $DB; $this->resetAfterTest(); @@ -623,7 +623,7 @@ class lib_test extends \advanced_testcase { /** * Test groups_update_group enabling and disabling a group conversation. */ - public function test_groups_update_group_conversation() { + public function test_groups_update_group_conversation(): void { global $DB; $this->resetAfterTest(); @@ -681,7 +681,7 @@ class lib_test extends \advanced_testcase { /** * Test groups_add_member to conversation. */ - public function test_groups_add_member_conversation() { + public function test_groups_add_member_conversation(): void { global $DB; $this->resetAfterTest(); @@ -723,7 +723,7 @@ class lib_test extends \advanced_testcase { /** * Test groups_remove_member to conversation. */ - public function test_groups_remove_member_conversation() { + public function test_groups_remove_member_conversation(): void { global $DB; $this->resetAfterTest(); @@ -770,7 +770,7 @@ class lib_test extends \advanced_testcase { /** * Test if you enable group messaging in a group with members these are added to the conversation. */ - public function test_add_members_group_updated_conversation_enabled() { + public function test_add_members_group_updated_conversation_enabled(): void { global $DB; $this->resetAfterTest(); @@ -885,7 +885,7 @@ class lib_test extends \advanced_testcase { * * @covers \core_group::set_groups_messaging */ - public function test_set_groups_messaging() { + public function test_set_groups_messaging(): void { $this->resetAfterTest(); $this->setAdminUser(); $dg = $this->getDataGenerator(); @@ -925,7 +925,7 @@ class lib_test extends \advanced_testcase { * * @covers \core_group::set_groups_messaging */ - public function test_set_groups_messaging_doesnt_exist() { + public function test_set_groups_messaging_doesnt_exist(): void { $this->resetAfterTest(); $this->setAdminUser(); diff --git a/group/tests/privacy/provider_test.php b/group/tests/privacy/provider_test.php index 3345b1a8f41..eed514dbbd8 100644 --- a/group/tests/privacy/provider_test.php +++ b/group/tests/privacy/provider_test.php @@ -42,7 +42,7 @@ class provider_test extends provider_testcase { /** * Test for provider::get_metadata(). */ - public function test_get_metadata() { + public function test_get_metadata(): void { $collection = new collection('core_group'); $newcollection = provider::get_metadata($collection); $itemcollection = $newcollection->get_collection(); @@ -65,7 +65,7 @@ class provider_test extends provider_testcase { /** * Test for provider::export_groups() to export manual group memberships. */ - public function test_export_groups() { + public function test_export_groups(): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -106,7 +106,7 @@ class provider_test extends provider_testcase { /** * Test for provider::export_groups() to export group memberships of a component. */ - public function test_export_groups_for_component() { + public function test_export_groups_for_component(): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -151,7 +151,7 @@ class provider_test extends provider_testcase { /** * Test for provider::delete_groups_for_all_users() to delete manual group memberships. */ - public function test_delete_groups_for_all_users() { + public function test_delete_groups_for_all_users(): void { global $DB; $this->resetAfterTest(); @@ -214,7 +214,7 @@ class provider_test extends provider_testcase { /** * Test for provider::delete_groups_for_all_users() to delete group memberships of a component. */ - public function test_delete_groups_for_all_users_for_component() { + public function test_delete_groups_for_all_users_for_component(): void { global $DB; $this->resetAfterTest(); @@ -279,7 +279,7 @@ class provider_test extends provider_testcase { /** * Test for provider::delete_groups_for_all_users() to check deleting from cache. */ - public function test_delete_groups_for_all_users_deletes_cache() { + public function test_delete_groups_for_all_users_deletes_cache(): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -310,7 +310,7 @@ class provider_test extends provider_testcase { /** * Test for provider::delete_groups_for_user() to delete manual group memberships. */ - public function test_delete_groups_for_user() { + public function test_delete_groups_for_user(): void { global $DB; $this->resetAfterTest(); @@ -412,7 +412,7 @@ class provider_test extends provider_testcase { /** * Test for provider::delete_groups_for_user() to delete group memberships of a component. */ - public function test_delete_groups_for_user_for_component() { + public function test_delete_groups_for_user_for_component(): void { global $DB; $this->resetAfterTest(); @@ -516,7 +516,7 @@ class provider_test extends provider_testcase { /** * Test for provider::delete_groups_for_users() to delete group memberships of a component. */ - public function test_delete_groups_for_users_for_component() { + public function test_delete_groups_for_users_for_component(): void { global $DB; $this->resetAfterTest(); @@ -655,7 +655,7 @@ class provider_test extends provider_testcase { /** * Test for provider::delete_groups_for_user() to check deleting from cache. */ - public function test_delete_groups_for_user_deletes_cache() { + public function test_delete_groups_for_user_deletes_cache(): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -683,7 +683,7 @@ class provider_test extends provider_testcase { /** * Test for provider::get_contexts_for_userid(). */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { $this->resetAfterTest(); $course1 = $this->getDataGenerator()->create_course(); @@ -729,7 +729,7 @@ class provider_test extends provider_testcase { /** * Test for provider::get_contexts_for_userid() when there are group memberships from other components. */ - public function test_get_contexts_for_userid_component() { + public function test_get_contexts_for_userid_component(): void { $this->resetAfterTest(); $course1 = $this->getDataGenerator()->create_course(); @@ -766,7 +766,7 @@ class provider_test extends provider_testcase { /** * Test for provider::export_user_data(). */ - public function test_export_user_data() { + public function test_export_user_data(): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -810,7 +810,7 @@ class provider_test extends provider_testcase { /** * Test for provider::delete_data_for_all_users_in_context(). */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; $this->resetAfterTest(); @@ -873,7 +873,7 @@ class provider_test extends provider_testcase { /** * Test for provider::delete_data_for_user(). */ - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; $this->resetAfterTest(); @@ -975,7 +975,7 @@ class provider_test extends provider_testcase { /** * Test for provider::delete_data_for_users(). */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { global $DB; $this->resetAfterTest(); @@ -1047,7 +1047,7 @@ class provider_test extends provider_testcase { /** * Test for provider::get_users_in_context(). */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { $this->resetAfterTest(); $course1 = $this->getDataGenerator()->create_course(); diff --git a/h5p/tests/editor_test.php b/h5p/tests/editor_test.php index d2f1fc76381..b04e5c6c070 100644 --- a/h5p/tests/editor_test.php +++ b/h5p/tests/editor_test.php @@ -76,7 +76,7 @@ class editor_test extends advanced_testcase { /** * Test that existing content is properly set. */ - public function test_set_content() { + public function test_set_content(): void { $this->resetAfterTest(); autoloader::register(); @@ -136,7 +136,7 @@ class editor_test extends advanced_testcase { /** * Tests that library and file area are properly set. */ - public function test_set_library() { + public function test_set_library(): void { global $USER; $library = 'H5P.Accordion 1.5'; @@ -175,7 +175,7 @@ class editor_test extends advanced_testcase { /** * Test that required assets (js and css) and form will be loaded in page. */ - public function test_add_editor_to_form() { + public function test_add_editor_to_form(): void { global $PAGE, $CFG; $this->resetAfterTest(); @@ -233,7 +233,7 @@ class editor_test extends advanced_testcase { /** * Test new content creation. */ - public function test_save_content() { + public function test_save_content(): void { global $DB; $this->resetAfterTest(); diff --git a/h5p/tests/event/deleted_test.php b/h5p/tests/event/deleted_test.php index ebd171b041d..5117a340334 100644 --- a/h5p/tests/event/deleted_test.php +++ b/h5p/tests/event/deleted_test.php @@ -41,7 +41,7 @@ class deleted_test extends \advanced_testcase { * test_event_h5p_deleted description * @runInSeparateProcess */ - public function test_event_h5p_deleted() { + public function test_event_h5p_deleted(): void { $this->resetAfterTest(true); $user = $this->getDataGenerator()->create_user(); diff --git a/h5p/tests/event/moved_test.php b/h5p/tests/event/moved_test.php index 8a3b8f166b0..47aeec1d832 100644 --- a/h5p/tests/event/moved_test.php +++ b/h5p/tests/event/moved_test.php @@ -41,7 +41,7 @@ class moved_test extends \advanced_testcase { * test_event_h5p_viewed description * @runInSeparateProcess */ - public function test_event_h5p_viewed() { + public function test_event_h5p_viewed(): void { $this->resetAfterTest(true); $user = $this->getDataGenerator()->create_user(); diff --git a/h5p/tests/external/external_test.php b/h5p/tests/external/external_test.php index 03736f476ae..878edafd4d0 100644 --- a/h5p/tests/external/external_test.php +++ b/h5p/tests/external/external_test.php @@ -56,7 +56,7 @@ class external_test extends externallib_advanced_testcase { /** * test_get_trusted_h5p_file description */ - public function test_get_trusted_h5p_file() { + public function test_get_trusted_h5p_file(): void { $this->resetAfterTest(true); $this->setAdminUser(); @@ -101,7 +101,7 @@ class external_test extends externallib_advanced_testcase { /** * test_h5p_invalid_url description */ - public function test_h5p_invalid_url() { + public function test_h5p_invalid_url(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -131,7 +131,7 @@ class external_test extends externallib_advanced_testcase { /** * test_h5p_file_not_found description */ - public function test_h5p_file_not_found() { + public function test_h5p_file_not_found(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -160,7 +160,7 @@ class external_test extends externallib_advanced_testcase { * Test the request to get_trusted_h5p_file * using webservice/pluginfile.php as url param. */ - public function test_allow_webservice_pluginfile_in_url_param() { + public function test_allow_webservice_pluginfile_in_url_param(): void { $this->resetAfterTest(true); $this->setAdminUser(); @@ -202,7 +202,7 @@ class external_test extends externallib_advanced_testcase { * Test the request to get_trusted_h5p_file * using tokenpluginfile.php as url param. */ - public function test_allow_tokenluginfile_in_url_param() { + public function test_allow_tokenluginfile_in_url_param(): void { $this->resetAfterTest(true); $this->setAdminUser(); diff --git a/h5p/tests/file_storage_test.php b/h5p/tests/file_storage_test.php index a1f9b5c290a..065f0e516c2 100644 --- a/h5p/tests/file_storage_test.php +++ b/h5p/tests/file_storage_test.php @@ -318,7 +318,7 @@ class file_storage_test extends \advanced_testcase { /** * Test that cached files can be retrieved via a key. */ - public function test_getCachedAssets() { + public function test_getCachedAssets(): void { $basedirectory = $this->h5p_tempath . '/' . 'test-1.0'; @@ -414,7 +414,7 @@ class file_storage_test extends \advanced_testcase { /** * Retrieve content from a file given a specific path. */ - public function test_getContent() { + public function test_getContent(): void { $basedirectory = $this->h5p_tempath . '/' . 'test-1.0'; $machinename = 'TestLib'; @@ -438,7 +438,7 @@ class file_storage_test extends \advanced_testcase { /** * Test that an upgrade script can be found on the file system. */ - public function test_getUpgradeScript() { + public function test_getUpgradeScript(): void { // Upload an upgrade file. $machinename = 'TestLib'; $majorversion = 3; @@ -472,7 +472,7 @@ class file_storage_test extends \advanced_testcase { * | |- testscript.min.js * |- h5p.json */ - public function test_saveFileFromZip() { + public function test_saveFileFromZip(): void { $ziparchive = new zip_archive(); $path = __DIR__ . '/fixtures/h5ptest.zip'; @@ -500,7 +500,7 @@ class file_storage_test extends \advanced_testcase { /** * Test that a library is fully deleted from the file system */ - public function test_delete_library() { + public function test_delete_library(): void { $basedirectory = $this->h5p_tempath . '/' . 'test-1.0'; diff --git a/h5p/tests/framework_test.php b/h5p/tests/framework_test.php index 185a3624bca..c7d2fc32df6 100644 --- a/h5p/tests/framework_test.php +++ b/h5p/tests/framework_test.php @@ -49,7 +49,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of getPlatformInfo(). */ - public function test_getPlatformInfo() { + public function test_getPlatformInfo(): void { global $CFG; $platforminfo = $this->framework->getPlatformInfo(); @@ -70,7 +70,7 @@ class framework_test extends \advanced_testcase { * therefore it might take longer time to execute. * In order to execute this test PHPUNIT_LONGTEST should be set to true in phpunit.xml or directly in config.php. */ - public function test_fetchExternalData_no_path_defined() { + public function test_fetchExternalData_no_path_defined(): void { if (!PHPUNIT_LONGTEST) { $this->markTestSkipped('PHPUNIT_LONGTEST is not defined'); @@ -101,7 +101,7 @@ class framework_test extends \advanced_testcase { * therefore it might take longer time to execute. * In order to execute this test PHPUNIT_LONGTEST should be set to true in phpunit.xml or directly in config.php. */ - public function test_fetchExternalData_path_defined() { + public function test_fetchExternalData_path_defined(): void { global $CFG; if (!PHPUNIT_LONGTEST) { @@ -134,7 +134,7 @@ class framework_test extends \advanced_testcase { * therefore it might take longer time to execute. * In order to execute this test PHPUNIT_LONGTEST should be set to true in phpunit.xml or directly in config.php. */ - public function test_fetchExternalData_url_not_h5p() { + public function test_fetchExternalData_url_not_h5p(): void { if (!PHPUNIT_LONGTEST) { // This test is intensive and requires downloading the content of an external file. @@ -161,7 +161,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of fetchExternalData() when the URL is invalid. */ - public function test_fetchExternalData_url_invalid() { + public function test_fetchExternalData_url_invalid(): void { // Provide an invalid URL to an external file. $url = "someprotocol://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"; @@ -174,7 +174,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of setLibraryTutorialUrl(). */ - public function test_setLibraryTutorialUrl() { + public function test_setLibraryTutorialUrl(): void { global $DB; $this->resetAfterTest(); @@ -223,7 +223,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of setErrorMessage(). */ - public function test_setErrorMessage() { + public function test_setErrorMessage(): void { // Set an error message and an error code. $message = "Error message"; $code = '404'; @@ -244,7 +244,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of setInfoMessage(). */ - public function test_setInfoMessage() { + public function test_setInfoMessage(): void { $message = "Info message"; // Set an info message. @@ -261,7 +261,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of getMessages() when requesting the info messages. */ - public function test_getMessages_info() { + public function test_getMessages_info(): void { // Set an info message. $this->framework->setInfoMessage("Info message"); // Set an error message. @@ -285,7 +285,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of getMessages() when requesting the error messages. */ - public function test_getMessages_error() { + public function test_getMessages_error(): void { // Set an info message. $this->framework->setInfoMessage("Info message"); // Set an error message. @@ -321,7 +321,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of t() when translating existing string that does not require any arguments. */ - public function test_t_existing_string_no_args() { + public function test_t_existing_string_no_args(): void { // Existing language string without passed arguments. $translation = $this->framework->t('No copyright information available for this content.'); @@ -332,7 +332,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of t() when translating existing string that does require parameters. */ - public function test_t_existing_string_args() { + public function test_t_existing_string_args(): void { // Existing language string with passed arguments. $translation = $this->framework->t('Illegal option %option in %library', ['%option' => 'example', '%library' => 'Test library']); @@ -344,7 +344,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of t() when translating non-existent string. */ - public function test_t_non_existent_string() { + public function test_t_non_existent_string(): void { // Non-existing language string. $message = 'Random message %option'; @@ -361,7 +361,7 @@ class framework_test extends \advanced_testcase { * Test the behaviour of getLibraryFileUrl() when requesting a file URL from an existing library and * the folder name is parsable. **/ - public function test_getLibraryFileUrl() { + public function test_getLibraryFileUrl(): void { global $CFG; $this->resetAfterTest(); @@ -383,7 +383,7 @@ class framework_test extends \advanced_testcase { * Test the behaviour of getLibraryFileUrl() when requesting a file URL from a non-existent library and * the folder name is parsable. **/ - public function test_getLibraryFileUrl_non_existent_library() { + public function test_getLibraryFileUrl_non_existent_library(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator()->get_plugin_generator('core_h5p'); @@ -404,7 +404,7 @@ class framework_test extends \advanced_testcase { * Test the behaviour of getLibraryFileUrl() when requesting a file URL from an existing library and * the folder name is not parsable. **/ - public function test_getLibraryFileUrl_not_parsable_folder_name() { + public function test_getLibraryFileUrl_not_parsable_folder_name(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator()->get_plugin_generator('core_h5p'); @@ -426,7 +426,7 @@ class framework_test extends \advanced_testcase { * Test the behaviour of getLibraryFileUrl() when requesting a file URL from a library that has multiple * versions and the folder name is parsable. **/ - public function test_getLibraryFileUrl_library_has_multiple_versions() { + public function test_getLibraryFileUrl_library_has_multiple_versions(): void { global $CFG; $this->resetAfterTest(); @@ -449,7 +449,7 @@ class framework_test extends \advanced_testcase { * Test the behaviour of getLibraryFileUrl() when requesting a file URL from a library that has multiple * patch versions and the folder name is parsable. **/ - public function test_getLibraryFileUrl_library_has_multiple_patch_versions() { + public function test_getLibraryFileUrl_library_has_multiple_patch_versions(): void { global $CFG; $this->resetAfterTest(); @@ -473,7 +473,7 @@ class framework_test extends \advanced_testcase { * Test the behaviour of getLibraryFileUrl() when requesting a file URL from a sub-folder * of an existing library and the folder name is parsable. **/ - public function test_getLibraryFileUrl_library_subfolder() { + public function test_getLibraryFileUrl_library_subfolder(): void { global $CFG; $this->resetAfterTest(); @@ -494,7 +494,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of loadAddons(). */ - public function test_loadAddons() { + public function test_loadAddons(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator()->get_plugin_generator('core_h5p'); @@ -536,7 +536,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of loadLibraries(). */ - public function test_loadLibraries() { + public function test_loadLibraries(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator()->get_plugin_generator('core_h5p'); @@ -559,7 +559,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of test_getLibraryId() when requesting an existing machine name. */ - public function test_getLibraryId_existing_machine_name() { + public function test_getLibraryId_existing_machine_name(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator()->get_plugin_generator('core_h5p'); @@ -578,7 +578,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of test_getLibraryId() when requesting a non-existent machine name. */ - public function test_getLibraryId_non_existent_machine_name() { + public function test_getLibraryId_non_existent_machine_name(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator()->get_plugin_generator('core_h5p'); @@ -596,7 +596,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of test_getLibraryId() when requesting a non-existent major version. */ - public function test_getLibraryId_non_existent_major_version() { + public function test_getLibraryId_non_existent_major_version(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator()->get_plugin_generator('core_h5p'); @@ -614,7 +614,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of test_getLibraryId() when requesting a non-existent minor version. */ - public function test_getLibraryId_non_existent_minor_version() { + public function test_getLibraryId_non_existent_minor_version(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator()->get_plugin_generator('core_h5p'); @@ -772,7 +772,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of isInDevMode(). */ - public function test_isInDevMode() { + public function test_isInDevMode(): void { $isdevmode = $this->framework->isInDevMode(); $this->assertFalse($isdevmode); @@ -887,7 +887,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of saveLibraryData() when saving data for a new library. */ - public function test_saveLibraryData_new_library() { + public function test_saveLibraryData_new_library(): void { global $DB; $this->resetAfterTest(); @@ -938,7 +938,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of saveLibraryData() when saving (updating) data for an existing library. */ - public function test_saveLibraryData_existing_library() { + public function test_saveLibraryData_existing_library(): void { global $DB; $this->resetAfterTest(); @@ -995,7 +995,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of insertContent(). */ - public function test_insertContent() { + public function test_insertContent(): void { global $DB; $this->resetAfterTest(); @@ -1024,7 +1024,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of insertContent(). */ - public function test_insertContent_latestlibrary() { + public function test_insertContent_latestlibrary(): void { global $DB; $this->resetAfterTest(); @@ -1059,7 +1059,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of updateContent(). */ - public function test_updateContent() { + public function test_updateContent(): void { global $DB; $this->resetAfterTest(); @@ -1150,7 +1150,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of saveLibraryDependencies(). */ - public function test_saveLibraryDependencies() { + public function test_saveLibraryDependencies(): void { global $DB; $this->resetAfterTest(); @@ -1191,7 +1191,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of deleteContentData(). */ - public function test_deleteContentData() { + public function test_deleteContentData(): void { global $DB; $this->resetAfterTest(); @@ -1245,7 +1245,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of resetContentUserData(). */ - public function test_resetContentUserData() { + public function test_resetContentUserData(): void { global $DB; $this->resetAfterTest(); @@ -1297,7 +1297,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of deleteLibraryUsage(). */ - public function test_deleteLibraryUsage() { + public function test_deleteLibraryUsage(): void { global $DB; $this->resetAfterTest(); @@ -1328,7 +1328,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of test_saveLibraryUsage(). */ - public function test_saveLibraryUsage() { + public function test_saveLibraryUsage(): void { global $DB; $this->resetAfterTest(); @@ -1380,7 +1380,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of getLibraryUsage() without skipping a particular h5p content. */ - public function test_getLibraryUsage_no_skip_content() { + public function test_getLibraryUsage_no_skip_content(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator()->get_plugin_generator('core_h5p'); @@ -1431,7 +1431,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of getLibraryUsage() when skipping a particular content. */ - public function test_getLibraryUsage_skip_content() { + public function test_getLibraryUsage_skip_content(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator()->get_plugin_generator('core_h5p'); @@ -1455,7 +1455,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of loadLibrary() when requesting an existing library. */ - public function test_loadLibrary_existing_library() { + public function test_loadLibrary_existing_library(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator()->get_plugin_generator('core_h5p'); @@ -1516,7 +1516,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of loadLibrary() when requesting a non-existent library. */ - public function test_loadLibrary_non_existent_library() { + public function test_loadLibrary_non_existent_library(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator()->get_plugin_generator('core_h5p'); @@ -1597,7 +1597,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of alterLibrarySemantics(). */ - public function test_alterLibrarySemantics() { + public function test_alterLibrarySemantics(): void { global $DB; $this->resetAfterTest(); @@ -1637,7 +1637,7 @@ class framework_test extends \advanced_testcase { * Test the behaviour of deleteLibraryDependencies() when requesting to delete the * dependencies of an existing library. */ - public function test_deleteLibraryDependencies_existing_library() { + public function test_deleteLibraryDependencies_existing_library(): void { global $DB; $this->resetAfterTest(); @@ -1666,7 +1666,7 @@ class framework_test extends \advanced_testcase { * Test the behaviour of deleteLibraryDependencies() when requesting to delete the * dependencies of a non-existent library. */ - public function test_deleteLibraryDependencies_non_existent_library() { + public function test_deleteLibraryDependencies_non_existent_library(): void { global $DB; $this->resetAfterTest(); @@ -1694,7 +1694,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of deleteLibrary(). */ - public function test_deleteLibrary() { + public function test_deleteLibrary(): void { global $DB; $this->resetAfterTest(); @@ -1748,7 +1748,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of loadContent(). */ - public function test_loadContent() { + public function test_loadContent(): void { global $DB; $this->resetAfterTest(); @@ -1800,7 +1800,7 @@ class framework_test extends \advanced_testcase { * Test the behaviour of loadContentDependencies() when requesting content dependencies * without specifying the dependency type. */ - public function test_loadContentDependencies_no_type_defined() { + public function test_loadContentDependencies_no_type_defined(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator()->get_plugin_generator('core_h5p'); @@ -1859,7 +1859,7 @@ class framework_test extends \advanced_testcase { * Test the behaviour of loadContentDependencies() when requesting content dependencies * with specifying the dependency type. */ - public function test_loadContentDependencies_type_defined() { + public function test_loadContentDependencies_type_defined(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator()->get_plugin_generator('core_h5p'); @@ -1973,7 +1973,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of updateContentFields(). */ - public function test_updateContentFields() { + public function test_updateContentFields(): void { global $DB; $this->resetAfterTest(); @@ -2009,7 +2009,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of clearFilteredParameters(). */ - public function test_clearFilteredParameters() { + public function test_clearFilteredParameters(): void { global $DB; $this->resetAfterTest(); @@ -2061,7 +2061,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of getNumNotFiltered(). */ - public function test_getNumNotFiltered() { + public function test_getNumNotFiltered(): void { global $DB; $this->resetAfterTest(); @@ -2106,7 +2106,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of getNumContent(). */ - public function test_getNumContent() { + public function test_getNumContent(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator()->get_plugin_generator('core_h5p'); @@ -2138,7 +2138,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of getNumContent() when certain contents are being skipped. */ - public function test_getNumContent_skip_content() { + public function test_getNumContent_skip_content(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator()->get_plugin_generator('core_h5p'); @@ -2163,7 +2163,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of isContentSlugAvailable(). */ - public function test_isContentSlugAvailable() { + public function test_isContentSlugAvailable(): void { $this->resetAfterTest(); $slug = 'h5p-test-slug-1'; @@ -2178,7 +2178,7 @@ class framework_test extends \advanced_testcase { /** * Test that a record is stored for cached assets. */ - public function test_saveCachedAssets() { + public function test_saveCachedAssets(): void { global $DB; $this->resetAfterTest(); @@ -2210,7 +2210,7 @@ class framework_test extends \advanced_testcase { /** * Test that the correct libraries are removed from the cached assets table */ - public function test_deleteCachedAssets() { + public function test_deleteCachedAssets(): void { global $DB; $this->resetAfterTest(); @@ -2291,7 +2291,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of getLibraryContentCount(). */ - public function test_getLibraryContentCount() { + public function test_getLibraryContentCount(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator()->get_plugin_generator('core_h5p'); @@ -2412,7 +2412,7 @@ class framework_test extends \advanced_testcase { /** * Test the behaviour of get_latest_library_version(). */ - public function test_get_latest_library_version() { + public function test_get_latest_library_version(): void { global $DB; $this->resetAfterTest(); diff --git a/h5p/tests/generator_test.php b/h5p/tests/generator_test.php index 623bf3cd220..e61bdcf4361 100644 --- a/h5p/tests/generator_test.php +++ b/h5p/tests/generator_test.php @@ -43,7 +43,7 @@ class generator_test extends \advanced_testcase { * Test the returned data of generate_h5p_data() when the method is called without requesting * creation of library files. */ - public function test_generate_h5p_data_no_files_created_return_data() { + public function test_generate_h5p_data_no_files_created_return_data(): void { global $DB; $this->resetAfterTest(); @@ -99,7 +99,7 @@ class generator_test extends \advanced_testcase { * Test the returned data of generate_h5p_data() when the method requests * creation of library files. */ - public function test_generate_h5p_data_files_created_return_data() { + public function test_generate_h5p_data_files_created_return_data(): void { global $DB; $this->resetAfterTest(); @@ -159,7 +159,7 @@ class generator_test extends \advanced_testcase { * @param bool $createlibraryfiles Whether to create library files on the filesystem * @param bool $expected The expectation whether the files have been created or not **/ - public function test_generate_h5p_data_files_creation(bool $createlibraryfiles, bool $expected) { + public function test_generate_h5p_data_files_creation(bool $createlibraryfiles, bool $expected): void { global $DB; $this->resetAfterTest(); @@ -215,7 +215,7 @@ class generator_test extends \advanced_testcase { * @dataProvider generate_h5p_data_xapistates_provider * @param array|null $filerecord */ - public function test_generate_h5p_data_xapistates(?array $filerecord) { + public function test_generate_h5p_data_xapistates(?array $filerecord): void { global $DB; $this->resetAfterTest(); @@ -326,7 +326,7 @@ class generator_test extends \advanced_testcase { * Test the behaviour of create_library_record(). Test whether the library data is properly * saved in the database. */ - public function test_create_library_record() { + public function test_create_library_record(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator()->get_plugin_generator('core_h5p'); @@ -369,7 +369,7 @@ class generator_test extends \advanced_testcase { * @param array $h5pdata The h5p content data * @param \stdClass $expected The expected saved data **/ - public function test_create_h5p_record(array $h5pdata, \stdClass $expected) { + public function test_create_h5p_record(array $h5pdata, \stdClass $expected): void { global $DB; $this->resetAfterTest(); @@ -492,7 +492,7 @@ class generator_test extends \advanced_testcase { * @param array $contentslibrariestdata The h5p contents libraries data. * @param \stdClass $expected The expected saved data. **/ - public function test_create_contents_libraries_record(array $contentslibrariestdata, \stdClass $expected) { + public function test_create_contents_libraries_record(array $contentslibrariestdata, \stdClass $expected): void { global $DB; $this->resetAfterTest(); @@ -552,7 +552,7 @@ class generator_test extends \advanced_testcase { * @param array $librarydependencydata The library dependency data. * @param \stdClass $expected The expected saved data. **/ - public function test_create_library_dependency_record(array $librarydependencydata, \stdClass $expected) { + public function test_create_library_dependency_record(array $librarydependencydata, \stdClass $expected): void { global $DB; $this->resetAfterTest(); diff --git a/h5p/tests/h5p_core_test.php b/h5p/tests/h5p_core_test.php index 32064c28d94..d596b2fdeee 100644 --- a/h5p/tests/h5p_core_test.php +++ b/h5p/tests/h5p_core_test.php @@ -193,7 +193,7 @@ class h5p_core_test extends \advanced_testcase { /** * Test if no handler has been defined. */ - public function test_get_default_handler() { + public function test_get_default_handler(): void { global $CFG; $this->resetAfterTest(true); diff --git a/iplookup/tests/geoip_test.php b/iplookup/tests/geoip_test.php index b547c186ff1..1cc920402dd 100644 --- a/iplookup/tests/geoip_test.php +++ b/iplookup/tests/geoip_test.php @@ -51,7 +51,7 @@ class geoip_test extends \advanced_testcase { * @dataProvider ip_provider * @param string $ip The IP to test */ - public function test_ip($ip) { + public function test_ip($ip): void { $this->setup_geoip2file(); // Note: The results we get from the iplookup tests are beyond our control. diff --git a/lib/antivirus/clamav/tests/scanner_test.php b/lib/antivirus/clamav/tests/scanner_test.php index a2dcb20e298..696e15bfc48 100644 --- a/lib/antivirus/clamav/tests/scanner_test.php +++ b/lib/antivirus/clamav/tests/scanner_test.php @@ -41,7 +41,7 @@ class scanner_test extends \advanced_testcase { @unlink($this->tempfile); } - public function test_scan_file_not_exists() { + public function test_scan_file_not_exists(): void { $antivirus = $this->getMockBuilder('\antivirus_clamav\scanner') ->onlyMethods(array('scan_file_execute_commandline', 'message_admins')) ->getMock(); @@ -54,7 +54,7 @@ class scanner_test extends \advanced_testcase { $this->assertDebuggingCalled(); } - public function test_scan_file_no_virus() { + public function test_scan_file_no_virus(): void { $methods = array( 'scan_file_execute_commandline', 'scan_file_execute_socket', @@ -95,7 +95,7 @@ class scanner_test extends \advanced_testcase { $this->assertEquals(0, $antivirus->scan_file($this->tempfile, '')); } - public function test_scan_file_virus() { + public function test_scan_file_virus(): void { $methods = array( 'scan_file_execute_commandline', 'scan_file_execute_socket', @@ -136,7 +136,7 @@ class scanner_test extends \advanced_testcase { $this->assertEquals(1, $antivirus->scan_file($this->tempfile, '')); } - public function test_scan_file_error_donothing() { + public function test_scan_file_error_donothing(): void { $methods = array( 'scan_file_execute_commandline', 'scan_file_execute_socket', @@ -183,7 +183,7 @@ class scanner_test extends \advanced_testcase { $this->assertEquals(2, $antivirus->scan_file($this->tempfile, '')); } - public function test_scan_file_error_actlikevirus() { + public function test_scan_file_error_actlikevirus(): void { $methods = array( 'scan_file_execute_commandline', 'scan_file_execute_socket', @@ -233,7 +233,7 @@ class scanner_test extends \advanced_testcase { $this->assertEquals(1, $antivirus->scan_file($this->tempfile, '')); } - public function test_scan_file_error_tryagain() { + public function test_scan_file_error_tryagain(): void { $methods = array( 'scan_file_execute_commandline', 'scan_file_execute_unixsocket', @@ -265,7 +265,7 @@ class scanner_test extends \advanced_testcase { $this->assertFileDoesNotExist($this->tempfile); } - public function test_scan_data_no_virus() { + public function test_scan_data_no_virus(): void { $methods = array( 'scan_data_execute_socket', 'message_admins', @@ -299,7 +299,7 @@ class scanner_test extends \advanced_testcase { $this->assertEquals(0, $antivirus->scan_data('')); } - public function test_scan_data_virus() { + public function test_scan_data_virus(): void { $methods = array( 'scan_data_execute_socket', 'message_admins', @@ -333,7 +333,7 @@ class scanner_test extends \advanced_testcase { $this->assertEquals(1, $antivirus->scan_data('')); } - public function test_scan_data_error_donothing() { + public function test_scan_data_error_donothing(): void { $methods = array( 'scan_data_execute_socket', 'message_admins', @@ -371,7 +371,7 @@ class scanner_test extends \advanced_testcase { $this->assertEquals(2, $antivirus->scan_data('')); } - public function test_scan_data_error_actlikevirus() { + public function test_scan_data_error_actlikevirus(): void { $methods = array( 'scan_data_execute_socket', 'message_admins', diff --git a/lib/ddl/tests/ddl_test.php b/lib/ddl/tests/ddl_test.php index 85456aec28e..8f5c1d088c9 100644 --- a/lib/ddl/tests/ddl_test.php +++ b/lib/ddl/tests/ddl_test.php @@ -164,7 +164,7 @@ class ddl_test extends \database_driver_testcase { /** * Test behaviour of table_exists() */ - public function test_table_exists() { + public function test_table_exists(): void { $DB = $this->tdb; // Do not use global $DB! $dbman = $this->tdb->get_manager(); @@ -209,7 +209,7 @@ class ddl_test extends \database_driver_testcase { /** * Test behaviour of create_table() */ - public function test_create_table() { + public function test_create_table(): void { $DB = $this->tdb; // Do not use global $DB! $dbman = $this->tdb->get_manager(); @@ -559,7 +559,7 @@ class ddl_test extends \database_driver_testcase { * InnoDB is known to failed during data insertion instead * of table creation when text fields contain actual data. */ - public function test_row_size_limits() { + public function test_row_size_limits(): void { $DB = $this->tdb; // Do not use global $DB! $dbman = $this->tdb->get_manager(); @@ -644,7 +644,7 @@ class ddl_test extends \database_driver_testcase { /** * Test behaviour of drop_table() */ - public function test_drop_table() { + public function test_drop_table(): void { $DB = $this->tdb; // Do not use global $DB! $dbman = $this->tdb->get_manager(); @@ -677,7 +677,7 @@ class ddl_test extends \database_driver_testcase { /** * Test behaviour of rename_table() */ - public function test_rename_table() { + public function test_rename_table(): void { $DB = $this->tdb; // Do not use global $DB! $dbman = $this->tdb->get_manager(); @@ -712,7 +712,7 @@ class ddl_test extends \database_driver_testcase { /** * Test behaviour of field_exists() */ - public function test_field_exists() { + public function test_field_exists(): void { $dbman = $this->tdb->get_manager(); $table = $this->create_deftable('test_table0'); @@ -776,7 +776,7 @@ class ddl_test extends \database_driver_testcase { /** * Test behaviour of add_field() */ - public function test_add_field() { + public function test_add_field(): void { $DB = $this->tdb; // Do not use global $DB! $dbman = $this->tdb->get_manager(); @@ -941,7 +941,7 @@ class ddl_test extends \database_driver_testcase { /** * Test behaviour of drop_field() */ - public function test_drop_field() { + public function test_drop_field(): void { $DB = $this->tdb; // Do not use global $DB! $dbman = $this->tdb->get_manager(); @@ -998,7 +998,7 @@ class ddl_test extends \database_driver_testcase { /** * Test behaviour of change_field_type() */ - public function test_change_field_type() { + public function test_change_field_type(): void { $DB = $this->tdb; // Do not use global $DB! $dbman = $this->tdb->get_manager(); @@ -1158,7 +1158,7 @@ class ddl_test extends \database_driver_testcase { /** * Test behaviour of test_change_field_precision() */ - public function test_change_field_precision() { + public function test_change_field_precision(): void { $DB = $this->tdb; // Do not use global $DB! $dbman = $this->tdb->get_manager(); @@ -1674,7 +1674,7 @@ class ddl_test extends \database_driver_testcase { $this->assertTrue($dbman->table_exists('test_table1')); } - public function test_temp_tables() { + public function test_temp_tables(): void { $DB = $this->tdb; // Do not use global $DB! $dbman = $this->tdb->get_manager(); @@ -1791,7 +1791,7 @@ class ddl_test extends \database_driver_testcase { $this->assertFalse($dbman->table_exists('test_temp')); } - public function test_concurrent_temp_tables() { + public function test_concurrent_temp_tables(): void { $DB = $this->tdb; // Do not use global $DB! $dbman = $this->tdb->get_manager(); @@ -1839,7 +1839,7 @@ class ddl_test extends \database_driver_testcase { /** * get_columns should return an empty array for ex-temptables. */ - public function test_leftover_temp_tables_columns() { + public function test_leftover_temp_tables_columns(): void { $DB = $this->tdb; // Do not use global $DB! $dbman = $this->tdb->get_manager(); @@ -1857,7 +1857,7 @@ class ddl_test extends \database_driver_testcase { /** * Deleting a temp table should not purge the whole cache */ - public function test_leftover_temp_tables_cache() { + public function test_leftover_temp_tables_cache(): void { $DB = $this->tdb; // Do not use global $DB! $dbman = $this->tdb->get_manager(); @@ -1904,7 +1904,7 @@ class ddl_test extends \database_driver_testcase { $dbman->drop_table($table1); } - public function test_reset_sequence() { + public function test_reset_sequence(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -1943,12 +1943,12 @@ class ddl_test extends \database_driver_testcase { $dbman->drop_table($table); } - public function test_reserved_words() { + public function test_reserved_words(): void { $reserved = sql_generator::getAllReservedWords(); $this->assertTrue(count($reserved) > 1); } - public function test_index_hints() { + public function test_index_hints(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -1992,7 +1992,7 @@ class ddl_test extends \database_driver_testcase { $this->assertTrue($dbman->index_exists($table, $index)); } - public function test_index_max_bytes() { + public function test_index_max_bytes(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -2040,7 +2040,7 @@ class ddl_test extends \database_driver_testcase { } } - public function test_index_composed_max_bytes() { + public function test_index_composed_max_bytes(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -2099,7 +2099,7 @@ class ddl_test extends \database_driver_testcase { } } - public function test_char_size_limit() { + public function test_char_size_limit(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -2174,7 +2174,7 @@ class ddl_test extends \database_driver_testcase { } } - public function test_object_name() { + public function test_object_name(): void { $gen = $this->tdb->get_manager()->generator; // This will form short object name and max length should not be exceeded. @@ -2282,7 +2282,7 @@ class ddl_test extends \database_driver_testcase { * @param bool $reserved Whether the column name is reserved or not. * @param string $columnname The column name to be quoted, according to the value of $reserved. **/ - public function test_get_enc_quoted($reserved, $columnname) { + public function test_get_enc_quoted($reserved, $columnname): void { $DB = $this->tdb; $gen = $DB->get_manager()->generator; @@ -2331,7 +2331,7 @@ class ddl_test extends \database_driver_testcase { * @param string $oldcolumnname The column name to be renamed. * @param string $newcolumnname The new column name. **/ - public function test_sql_generator_get_rename_field_sql($reserved, $oldcolumnname, $newcolumnname) { + public function test_sql_generator_get_rename_field_sql($reserved, $oldcolumnname, $newcolumnname): void { $DB = $this->tdb; $gen = $DB->get_manager()->generator; $prefix = $DB->get_prefix(); @@ -2400,7 +2400,7 @@ class ddl_test extends \database_driver_testcase { } } - public function test_get_nullable_fields_in_index() { + public function test_get_nullable_fields_in_index(): void { $DB = $this->tdb; $gen = $DB->get_manager()->generator; @@ -2450,7 +2450,7 @@ class ddl_test extends \database_driver_testcase { /** * Tests check_database_schema(). */ - public function test_check_database_schema() { + public function test_check_database_schema(): void { global $CFG, $DB; $dbmanager = $DB->get_manager(); diff --git a/lib/dml/tests/dml_table_test.php b/lib/dml/tests/dml_table_test.php index 16b444aff79..f0ef6ecc8bd 100644 --- a/lib/dml/tests/dml_table_test.php +++ b/lib/dml/tests/dml_table_test.php @@ -81,7 +81,7 @@ class dml_table_test extends \database_driver_testcase { string $fieldprefix, string $tablealias, string $expected - ) { + ): void { $dbman = $this->tdb->get_manager(); $xmldbtable = new xmldb_table($tablename); @@ -165,7 +165,7 @@ class dml_table_test extends \database_driver_testcase { string $fieldprefix, \stdClass $result, \stdClass $expected - ) { + ): void { $dbman = $this->tdb->get_manager(); $tablename = 'test_table_extraction'; @@ -201,7 +201,7 @@ class dml_table_test extends \database_driver_testcase { string $fieldprefix, string $tablealias, string $expected - ) { + ): void { $dbman = $this->tdb->get_manager(); $tablename = 'test_table_extraction'; diff --git a/lib/dml/tests/dml_test.php b/lib/dml/tests/dml_test.php index ae0fb3bf960..d3c77b6d9d4 100644 --- a/lib/dml/tests/dml_test.php +++ b/lib/dml/tests/dml_test.php @@ -83,13 +83,13 @@ class dml_test extends \database_driver_testcase { return $source; // No changes, so far. } - public function test_diagnose() { + public function test_diagnose(): void { $DB = $this->tdb; $result = $DB->diagnose(); $this->assertNull($result, 'Database self diagnostics failed %s'); } - public function test_get_server_info() { + public function test_get_server_info(): void { $DB = $this->tdb; $result = $DB->get_server_info(); $this->assertIsArray($result); @@ -97,7 +97,7 @@ class dml_test extends \database_driver_testcase { $this->assertArrayHasKey('version', $result); } - public function test_get_in_or_equal() { + public function test_get_in_or_equal(): void { $DB = $this->tdb; // SQL_PARAMS_QM - IN or =. @@ -305,7 +305,7 @@ class dml_test extends \database_driver_testcase { $this->assertSame($value, 'onevalue'); } - public function test_fix_table_names() { + public function test_fix_table_names(): void { $DB = new moodle_database_for_testing(); $prefix = $DB->get_prefix(); @@ -327,7 +327,7 @@ class dml_test extends \database_driver_testcase { $this->assertSame($expected, $DB->public_fix_table_names($sql)); } - public function test_fix_sql_params() { + public function test_fix_sql_params(): void { $DB = $this->tdb; $prefix = $DB->get_prefix(); @@ -482,7 +482,7 @@ class dml_test extends \database_driver_testcase { /** * Test the database debugging as SQL comment. */ - public function test_add_sql_debugging() { + public function test_add_sql_debugging(): void { global $CFG; $DB = $this->tdb; @@ -553,7 +553,7 @@ EOD; $this->assertEquals(get_site(), $site); } - public function test_strtok() { + public function test_strtok(): void { // Strtok was previously used by bound emulation, make sure it is not used any more. $DB = $this->tdb; $dbman = $this->tdb->get_manager(); @@ -575,7 +575,7 @@ EOD; $this->assertSame(strtok('?'), 'b'); } - public function test_tweak_param_names() { + public function test_tweak_param_names(): void { // Note the tweak_param_names() method is only available in the oracle driver, // hence we look for expected results indirectly, by testing various DML methods. @@ -719,7 +719,7 @@ EOD; $this->assertEquals(0, $DB->count_records($tablename)); } - public function test_get_tables() { + public function test_get_tables(): void { $DB = $this->tdb; $dbman = $this->tdb->get_manager(); @@ -739,7 +739,7 @@ EOD; $this->assertTrue(count($DB->get_tables()) == $original_count); } - public function test_get_indexes() { + public function test_get_indexes(): void { $DB = $this->tdb; $dbman = $this->tdb->get_manager(); @@ -785,7 +785,7 @@ EOD; * conceptually and also in practice, because they cause DBs to use full scans in a * number of situations. But if we support them, we need to ensure get_indexes() work on them. */ - public function test_get_indexes_unique_mixed_nullability() { + public function test_get_indexes_unique_mixed_nullability(): void { $DB = $this->tdb; $dbman = $this->tdb->get_manager(); $table = $this->get_test_table(); @@ -810,7 +810,7 @@ EOD; $this->assertSame($indexcolumns, $index['columns']); } - public function test_get_columns() { + public function test_get_columns(): void { $DB = $this->tdb; $dbman = $this->tdb->get_manager(); @@ -989,19 +989,19 @@ EOD; $this->assertFalse($columns['id']->auto_increment); } - public function test_get_manager() { + public function test_get_manager(): void { $DB = $this->tdb; $dbman = $this->tdb->get_manager(); $this->assertInstanceOf('database_manager', $dbman); } - public function test_setup_is_unicodedb() { + public function test_setup_is_unicodedb(): void { $DB = $this->tdb; $this->assertTrue($DB->setup_is_unicodedb()); } - public function test_set_debug() { // Tests get_debug() too. + public function test_set_debug(): void { // Tests get_debug() too. $DB = $this->tdb; $dbman = $this->tdb->get_manager(); @@ -1036,7 +1036,7 @@ EOD; $DB->set_debug($prevdebug); } - public function test_execute() { + public function test_execute(): void { $DB = $this->tdb; $dbman = $this->tdb->get_manager(); @@ -1126,7 +1126,7 @@ EOD; $this->assertSame($newonetext, $record->onetext); } - public function test_get_recordset() { + public function test_get_recordset(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -1228,7 +1228,7 @@ EOD; // * where_clause() is used internally and is tested in test_get_records() } - public function test_get_recordset_static() { + public function test_get_recordset_static(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -1280,7 +1280,7 @@ EOD; $this->assertEquals(3, $i); } - public function test_get_recordset_iterator_keys() { + public function test_get_recordset_iterator_keys(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -1345,7 +1345,7 @@ EOD; $this->assertEquals(3, $count); } - public function test_get_recordset_list() { + public function test_get_recordset_list(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -1436,7 +1436,7 @@ EOD; // * where_clause() is used internally and is tested in test_get_records() } - public function test_get_recordset_select() { + public function test_get_recordset_select(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -1473,7 +1473,7 @@ EOD; // * limits are tested in test_get_recordset_sql() } - public function test_get_recordset_sql() { + public function test_get_recordset_sql(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -1516,7 +1516,7 @@ EOD; // Note: fetching nulls, empties, LOBs already tested by test_insert_record() no needed here. } - public function test_export_table_recordset() { + public function test_export_table_recordset(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -1546,7 +1546,7 @@ EOD; $this->assertEqualsCanonicalizing($ids, $rids); } - public function test_get_records() { + public function test_get_records(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -1654,7 +1654,7 @@ EOD; // Note: delegate limits testing to test_get_records_sql(). } - public function test_get_records_list() { + public function test_get_records_list(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -1684,7 +1684,7 @@ EOD; // Note: delegate limits testing to test_get_records_sql(). } - public function test_get_records_sql() { + public function test_get_records_sql(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -1803,7 +1803,7 @@ EOD; // Note: fetching nulls, empties, LOBs already tested by test_update_record() no needed here. } - public function test_get_records_menu() { + public function test_get_records_menu(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -1831,7 +1831,7 @@ EOD; // Note: delegate limits testing to test_get_records_sql(). } - public function test_get_records_select_menu() { + public function test_get_records_select_menu(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -1863,7 +1863,7 @@ EOD; // Note: delegate limits testing to test_get_records_sql(). } - public function test_get_records_sql_menu() { + public function test_get_records_sql_menu(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -1895,7 +1895,7 @@ EOD; // Note: delegate limits testing to test_get_records_sql(). } - public function test_get_record() { + public function test_get_record(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -1918,7 +1918,7 @@ EOD; } - public function test_get_record_select() { + public function test_get_record_select(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -1941,7 +1941,7 @@ EOD; // Note: delegates limit testing to test_get_records_sql(). } - public function test_get_record_sql() { + public function test_get_record_sql(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -1997,7 +1997,7 @@ EOD; } } - public function test_get_field() { + public function test_get_field(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -2045,7 +2045,7 @@ EOD; } } - public function test_get_field_select() { + public function test_get_field_select(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -2062,7 +2062,7 @@ EOD; $this->assertEquals(3, $DB->get_field_select($tablename, 'course', "id = ?", array(1))); } - public function test_get_field_sql() { + public function test_get_field_sql(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -2079,7 +2079,7 @@ EOD; $this->assertEquals(3, $DB->get_field_sql("SELECT course FROM {{$tablename}} WHERE id = ?", array(1))); } - public function test_get_fieldset() { + public function test_get_fieldset(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -2105,7 +2105,7 @@ EOD; $this->assertEquals(4, $fieldset[2]); } - public function test_get_fieldset_select() { + public function test_get_fieldset_select(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -2131,7 +2131,7 @@ EOD; $this->assertEquals(6, $fieldset[2]); } - public function test_get_fieldset_sql() { + public function test_get_fieldset_sql(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -2168,7 +2168,7 @@ EOD; $this->assertEquals($binarydata, $fieldset[2]); } - public function test_insert_record_raw() { + public function test_insert_record_raw(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -2238,7 +2238,7 @@ EOD; $this->assertEquals(5, $record->id); } - public function test_insert_record() { + public function test_insert_record(): void { // All the information in this test is fetched from DB by get_recordset() so we // have such method properly tested against nulls, empties and friends... @@ -2520,7 +2520,7 @@ EOD; } } - public function test_insert_records() { + public function test_insert_records(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -2628,7 +2628,7 @@ EOD; } } - public function test_insert_record_with_nullable_unique_index() { + public function test_insert_record_with_nullable_unique_index(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -2690,7 +2690,7 @@ EOD; } - public function test_import_record() { + public function test_import_record(): void { // All the information in this test is fetched from DB by get_recordset() so we // have such method properly tested against nulls, empties and friends... @@ -2856,7 +2856,7 @@ EOD; $this->assertEquals(false, $rs->key()); // Ensure recordset key() method to be working ok after closing. } - public function test_update_record_raw() { + public function test_update_record_raw(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -2897,7 +2897,7 @@ EOD; } } - public function test_update_record() { + public function test_update_record(): void { // All the information in this test is fetched from DB by get_record() so we // have such method properly tested against nulls, empties and friends... @@ -3091,7 +3091,7 @@ EOD; $this->assertEquals(1e300, $DB->get_field($tablename, 'onetext', array('id' => $id))); } - public function test_set_field() { + public function test_set_field(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -3191,7 +3191,7 @@ EOD; // go to set_field_select() because set_field() is just one wrapper over it. } - public function test_set_field_select() { + public function test_set_field_select(): void { // All the information in this test is fetched from DB by get_field() so we // have such method properly tested against nulls, empties and friends... @@ -3337,7 +3337,7 @@ EOD; } } - public function test_count_records() { + public function test_count_records(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -3373,7 +3373,7 @@ EOD; } } - public function test_count_records_select() { + public function test_count_records_select(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -3395,7 +3395,7 @@ EOD; $this->assertSame(2, $DB->count_records_select($tablename, 'course > ?', array(3))); } - public function test_count_records_sql() { + public function test_count_records_sql(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -3432,7 +3432,7 @@ EOD; } } - public function test_record_exists() { + public function test_record_exists(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -3466,7 +3466,7 @@ EOD; } } - public function test_record_exists_select() { + public function test_record_exists_select(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -3486,7 +3486,7 @@ EOD; $this->assertTrue($DB->record_exists_select($tablename, "course = ?", array(3))); } - public function test_record_exists_sql() { + public function test_record_exists_sql(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -3506,7 +3506,7 @@ EOD; $this->assertTrue($DB->record_exists_sql("SELECT * FROM {{$tablename}} WHERE course = ?", array(3))); } - public function test_recordset_locks_delete() { + public function test_recordset_locks_delete(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -3538,7 +3538,7 @@ EOD; $this->assertEquals(4, $DB->count_records($tablename, array())); } - public function test_recordset_locks_update() { + public function test_recordset_locks_update(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -3570,7 +3570,7 @@ EOD; $this->assertEquals(2, $DB->count_records($tablename, array('course' => 10))); } - public function test_delete_records() { + public function test_delete_records(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -3630,7 +3630,7 @@ EOD; } } - public function test_delete_records_select() { + public function test_delete_records_select(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -3650,7 +3650,7 @@ EOD; $this->assertEquals(1, $DB->count_records($tablename)); } - public function test_delete_records_subquery() { + public function test_delete_records_subquery(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -3673,7 +3673,7 @@ EOD; $this->assertEquals(1, $DB->count_records($tablename)); } - public function test_delete_records_list() { + public function test_delete_records_list(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -3696,7 +3696,7 @@ EOD; $this->assertEquals(1, $DB->count_records($tablename)); } - public function test_object_params() { + public function test_object_params(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -3807,13 +3807,13 @@ EOD; } } - public function test_sql_null_from_clause() { + public function test_sql_null_from_clause(): void { $DB = $this->tdb; $sql = "SELECT 1 AS id ".$DB->sql_null_from_clause(); $this->assertEquals(1, $DB->get_field_sql($sql)); } - public function test_sql_bitand() { + public function test_sql_bitand(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -3842,7 +3842,7 @@ EOD; $this->assertEquals(2, reset($result)->res); } - public function test_sql_bitnot() { + public function test_sql_bitnot(): void { $DB = $this->tdb; $not = $DB->sql_bitnot(2); @@ -3852,7 +3852,7 @@ EOD; $this->assertEquals(5, $DB->get_field_sql($sql)); } - public function test_sql_bitor() { + public function test_sql_bitor(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -3881,7 +3881,7 @@ EOD; $this->assertEquals(11, reset($result)->res); } - public function test_sql_bitxor() { + public function test_sql_bitxor(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -3910,13 +3910,13 @@ EOD; $this->assertEquals(9, reset($result)->res); } - public function test_sql_modulo() { + public function test_sql_modulo(): void { $DB = $this->tdb; $sql = "SELECT ".$DB->sql_modulo(10, 7)." AS res ".$DB->sql_null_from_clause(); $this->assertEquals(3, $DB->get_field_sql($sql)); } - public function test_sql_ceil() { + public function test_sql_ceil(): void { $DB = $this->tdb; $sql = "SELECT ".$DB->sql_ceil(665.666)." AS res ".$DB->sql_null_from_clause(); $this->assertEquals(666, $DB->get_field_sql($sql)); @@ -3960,7 +3960,7 @@ EOD; $this->assertEquals(['uno'], $fieldset); } - public function test_cast_char2int() { + public function test_cast_char2int(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -4013,7 +4013,7 @@ EOD; $this->assertSame('0200', next($records)->nametext); } - public function test_cast_char2real() { + public function test_cast_char2real(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -4070,7 +4070,7 @@ EOD; $this->assertEquals('011.13333333', $DB->get_field_sql($sql)); } - public function test_sql_compare_text() { + public function test_sql_compare_text(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -4133,7 +4133,7 @@ EOD; $this->assertSame($clob, $record->description); } - public function test_unique_index_collation_trouble() { + public function test_unique_index_collation_trouble(): void { // Note: this is a work in progress, we should probably move this to ddl test. $DB = $this->tdb; @@ -4173,7 +4173,7 @@ EOD; } } - public function test_sql_equal() { + public function test_sql_equal(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -4229,7 +4229,7 @@ EOD; $this->assertGreaterThanOrEqual(4, count($records)); // At very least, there are 4 records with CI/AI names matching. } - public function test_sql_like() { + public function test_sql_like(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -4345,7 +4345,7 @@ EOD; ], $DB->get_fieldset_select($tablename, 'name', $select, $params)); } - public function test_coalesce() { + public function test_coalesce(): void { $DB = $this->tdb; // Testing not-null occurrences, return 1st. @@ -4385,7 +4385,7 @@ EOD; $this->assertSame('', $DB->get_field_sql($sql, array('paramvalue' => ''))); } - public function test_sql_concat() { + public function test_sql_concat(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -4531,7 +4531,7 @@ EOD; * @param array $params Any parameters to provide to the query * @param @string $expected The expected result */ - public function test_concat_join($concat, $fields, $params, $expected) { + public function test_concat_join($concat, $fields, $params, $expected): void { $DB = $this->tdb; $sql = "SELECT " . $DB->sql_concat_join($concat, $fields) . " AS result" . $DB->sql_null_from_clause(); $result = $DB->get_field_sql($sql, $params); @@ -4711,14 +4711,14 @@ EOD; $this->assertFalse($DB->record_exists($tablename, ['id' => $id])); } - public function test_sql_fullname() { + public function test_sql_fullname(): void { $DB = $this->tdb; $sql = "SELECT ".$DB->sql_fullname(':first', ':last')." AS fullname ".$DB->sql_null_from_clause(); $params = array('first'=>'Firstname', 'last'=>'Surname'); $this->assertEquals("Firstname Surname", $DB->get_field_sql($sql, $params)); } - public function test_sql_order_by_text() { + public function test_sql_order_by_text(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -4779,7 +4779,7 @@ EOD; $this->assertEquals(null, array_shift($records)->name); } - public function test_sql_substring() { + public function test_sql_substring(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -4840,7 +4840,7 @@ EOD; $this->assertEquals(substr($string, $start - 1), $record->name); // PHP's substr is 0-based. } - public function test_sql_length() { + public function test_sql_length(): void { $DB = $this->tdb; $this->assertEquals($DB->get_field_sql( "SELECT ".$DB->sql_length("'aeiou'").$DB->sql_null_from_clause()), 5); @@ -4848,7 +4848,7 @@ EOD; "SELECT ".$DB->sql_length("'áéíóú'").$DB->sql_null_from_clause()), 5); } - public function test_sql_position() { + public function test_sql_position(): void { $DB = $this->tdb; $this->assertEquals($DB->get_field_sql( "SELECT ".$DB->sql_position("'ood'", "'Moodle'").$DB->sql_null_from_clause()), 2); @@ -4856,7 +4856,7 @@ EOD; "SELECT ".$DB->sql_position("'Oracle'", "'Moodle'").$DB->sql_null_from_clause()), 0); } - public function test_sql_empty() { + public function test_sql_empty(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -4894,7 +4894,7 @@ EOD; $this->assertSame('', $record->namenotnullnodeflt); } - public function test_sql_isempty() { + public function test_sql_isempty(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -4935,7 +4935,7 @@ EOD; $this->assertSame('', $record->descriptionnull); } - public function test_sql_isnotempty() { + public function test_sql_isnotempty(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -4976,7 +4976,7 @@ EOD; $this->assertSame('lalala', $record->descriptionnull); // So 'lalala' is the first non-empty 'descriptionnull' record. } - public function test_sql_regex() { + public function test_sql_regex(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); if (!$DB->sql_regex_supported()) { @@ -5024,7 +5024,7 @@ EOD; /** * Test some complicated variations of set_field_select. */ - public function test_set_field_select_complicated() { + public function test_set_field_select_complicated(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -5054,7 +5054,7 @@ EOD; * Test some more complex SQL syntax which moodle uses and depends on to work * useful to determine if new database libraries can be supported. */ - public function test_get_records_sql_complicated() { + public function test_get_records_sql_complicated(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -5200,7 +5200,7 @@ EOD; $this->assertCount($currentcount, $results); } - public function test_replace_all_text() { + public function test_replace_all_text(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -5294,7 +5294,7 @@ EOD; $this->assertEquals($expected, $result); } - public function test_onelevel_commit() { + public function test_onelevel_commit(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -5315,7 +5315,7 @@ EOD; $this->assertEquals(1, $DB->count_records($tablename)); } - public function test_transaction_ignore_error_trouble() { + public function test_transaction_ignore_error_trouble(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -5398,7 +5398,7 @@ EOD; // NOTE: SQL_QUERY_STRUCTURE is intentionally not tested here because it should never fail. } - public function test_onelevel_rollback() { + public function test_onelevel_rollback(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -5426,7 +5426,7 @@ EOD; $this->assertEquals(0, $DB->count_records($tablename)); } - public function test_nested_transactions() { + public function test_nested_transactions(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -5569,7 +5569,7 @@ EOD; $this->assertEquals(3, $i); } - public function test_transactions_forbidden() { + public function test_transactions_forbidden(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -5596,7 +5596,7 @@ EOD; $this->assertEquals(1, $DB->count_records($tablename)); } - public function test_wrong_transactions() { + public function test_wrong_transactions(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -5683,7 +5683,7 @@ EOD; $DB->delete_records($tablename); } - public function test_concurent_transactions() { + public function test_concurent_transactions(): void { // Notes about this test: // 1- MySQL needs to use one engine with transactions support (InnoDB). // 2- MSSQL needs to have enabled versioning for read committed @@ -5758,7 +5758,7 @@ EOD; $DB2->dispose(); } - public function test_session_locks() { + public function test_session_locks(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -5802,7 +5802,7 @@ EOD; $DB2->dispose(); } - public function test_bound_param_types() { + public function test_bound_param_types(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -5864,7 +5864,7 @@ EOD; $this->assertCount(1, $records); } - public function test_bound_param_reserved() { + public function test_bound_param_reserved(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -5892,7 +5892,7 @@ EOD; $this->assertTrue(true); } - public function test_limits_and_offsets() { + public function test_limits_and_offsets(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -6005,7 +6005,7 @@ EOD; /** * Test debugging messages about invalid limit number values. */ - public function test_invalid_limits_debugging() { + public function test_invalid_limits_debugging(): void { $DB = $this->tdb; $dbman = $DB->get_manager(); @@ -6070,7 +6070,7 @@ EOD; $this->assertDebuggingCalled("Negative limitnum parameter detected: -2, did you pass the correct arguments?"); } - public function test_queries_counter() { + public function test_queries_counter(): void { $DB = $this->tdb; $dbman = $this->tdb->get_manager(); @@ -6149,7 +6149,7 @@ EOD; $this->assertEquals($totaldbqueries, $DB->perf_get_queries()); } - public function test_sql_intersect() { + public function test_sql_intersect(): void { $DB = $this->tdb; $dbman = $this->tdb->get_manager(); @@ -6234,7 +6234,7 @@ EOD; /** * Test that the database has full utf8 support (4 bytes). */ - public function test_four_byte_character_insertion() { + public function test_four_byte_character_insertion(): void { $DB = $this->tdb; if ($DB->get_dbfamily() === 'mysql' && strpos($DB->get_dbcollation(), 'utf8_') === 0) { @@ -6281,7 +6281,7 @@ EOD; * @dataProvider get_server_info_mysql_provider */ public function test_get_server_info_mysql( - string $mysqliserverinfo, string $versionfromdb, bool $cfgversionfromdb, string $expecteddbversion) { + string $mysqliserverinfo, string $versionfromdb, bool $cfgversionfromdb, string $expecteddbversion): void { // Avoid to run MySQL-ish related tests when running tests on other DB families. $DB = $this->tdb; if ($DB->get_dbfamily() != 'mysql') { @@ -6395,7 +6395,7 @@ EOD; * @see \mysqli_native_moodle_database::get_server_info * @covers \mysqli_native_moodle_database::get_server_info */ - public function test_get_server_info_dbfamily_mysql() { + public function test_get_server_info_dbfamily_mysql(): void { $DB = $this->tdb; if ($DB->get_dbfamily() != 'mysql') { $this->markTestSkipped("Not MySQL family"); diff --git a/lib/dml/tests/pgsql_native_recordset_test.php b/lib/dml/tests/pgsql_native_recordset_test.php index bee1b5160af..80fbea5f94c 100644 --- a/lib/dml/tests/pgsql_native_recordset_test.php +++ b/lib/dml/tests/pgsql_native_recordset_test.php @@ -101,7 +101,7 @@ class pgsql_native_recordset_test extends basic_testcase { * Tests that get_recordset_sql works when using cursors, which it does when no limit is * specified. */ - public function test_recordset_cursors() { + public function test_recordset_cursors(): void { $this->init_db(3); // Query the table and check the actual queries using debug mode, also check the count. @@ -163,7 +163,7 @@ class pgsql_native_recordset_test extends basic_testcase { * Tests that get_recordset_sql works when using cursors and when there are two overlapping * recordsets being used. */ - public function test_recordset_cursors_overlapping() { + public function test_recordset_cursors_overlapping(): void { $this->init_db(3); $rs1 = $this->specialdb->get_recordset('silly_test_table', null, 'id'); @@ -221,7 +221,7 @@ class pgsql_native_recordset_test extends basic_testcase { /** * Tests that get_recordset_sql works when using cursors and transactions inside. */ - public function test_recordset_cursors_transaction_inside() { + public function test_recordset_cursors_transaction_inside(): void { $this->init_db(3); // Transaction inside the recordset processing. @@ -239,7 +239,7 @@ class pgsql_native_recordset_test extends basic_testcase { /** * Tests that get_recordset_sql works when using cursors and a transaction outside. */ - public function test_recordset_cursors_transaction_outside() { + public function test_recordset_cursors_transaction_outside(): void { $this->init_db(3); // Transaction outside the recordset processing. @@ -257,7 +257,7 @@ class pgsql_native_recordset_test extends basic_testcase { /** * Tests that get_recordset_sql works when using cursors and a transaction overlapping. */ - public function test_recordset_cursors_transaction_overlapping_before() { + public function test_recordset_cursors_transaction_overlapping_before(): void { $this->init_db(3); // Transaction outside the recordset processing. @@ -275,7 +275,7 @@ class pgsql_native_recordset_test extends basic_testcase { /** * Tests that get_recordset_sql works when using cursors and a transaction overlapping. */ - public function test_recordset_cursors_transaction_overlapping_after() { + public function test_recordset_cursors_transaction_overlapping_after(): void { $this->init_db(3); // Transaction outside the recordset processing. @@ -294,7 +294,7 @@ class pgsql_native_recordset_test extends basic_testcase { * Tests that get_recordset_sql works when using cursors and a transaction that 'fails' and gets * rolled back. */ - public function test_recordset_cursors_transaction_rollback() { + public function test_recordset_cursors_transaction_rollback(): void { $this->init_db(3); try { @@ -332,7 +332,7 @@ class pgsql_native_recordset_test extends basic_testcase { /** * Tests that get_recordset_sql works when not using cursors, because a limit is specified. */ - public function test_recordset_no_cursors_limit() { + public function test_recordset_no_cursors_limit(): void { $this->init_db(3); $this->specialdb->set_debug(true); @@ -362,7 +362,7 @@ class pgsql_native_recordset_test extends basic_testcase { * Tests that get_recordset_sql works when not using cursors, because the config setting turns * them off. */ - public function test_recordset_no_cursors_config() { + public function test_recordset_no_cursors_config(): void { $this->init_db(0); $this->specialdb->set_debug(true); diff --git a/lib/dml/tests/recordset_walk_test.php b/lib/dml/tests/recordset_walk_test.php index a44a00e1b0a..4c904acb760 100644 --- a/lib/dml/tests/recordset_walk_test.php +++ b/lib/dml/tests/recordset_walk_test.php @@ -31,7 +31,7 @@ class recordset_walk_test extends \advanced_testcase { $this->resetAfterTest(); } - public function test_no_data() { + public function test_no_data(): void { global $DB; $recordset = $DB->get_recordset('assign'); @@ -47,7 +47,7 @@ class recordset_walk_test extends \advanced_testcase { $walker->close(); } - public function test_simple_callback() { + public function test_simple_callback(): void { global $DB; /** @var \mod_assign_generator $generator */ @@ -72,7 +72,7 @@ class recordset_walk_test extends \advanced_testcase { $walker->close(); } - public function test_extra_params_callback() { + public function test_extra_params_callback(): void { global $DB; /** @var \mod_assign_generator $generator */ diff --git a/lib/dml/tests/sqlsrv_native_moodle_database_test.php b/lib/dml/tests/sqlsrv_native_moodle_database_test.php index 0d4800a6e47..6d32de1d229 100644 --- a/lib/dml/tests/sqlsrv_native_moodle_database_test.php +++ b/lib/dml/tests/sqlsrv_native_moodle_database_test.php @@ -119,7 +119,7 @@ class sqlsrv_native_moodle_database_test extends \advanced_testcase { * @param string $expected The expected resultant query * @dataProvider add_no_lock_to_temp_tables_provider */ - public function test_add_no_lock_to_temp_tables($input, $expected) { + public function test_add_no_lock_to_temp_tables($input, $expected): void { $sqlsrv = new sqlsrv_native_moodle_database(); $reflector = new \ReflectionObject($sqlsrv); @@ -244,7 +244,7 @@ EOT * @param string $expectedmainquery the expected main query * @param bool $expectedresult the expected result */ - public function test_has_query_order_by(string $sql, string $expectedmainquery, bool $expectedresult) { + public function test_has_query_order_by(string $sql, string $expectedmainquery, bool $expectedresult): void { $mainquery = preg_replace('/\(((?>[^()]+)|(?R))*\)/', '()', $sql); $this->assertSame($expectedmainquery, $mainquery); diff --git a/lib/editor/atto/tests/privacy/provider_test.php b/lib/editor/atto/tests/privacy/provider_test.php index 1920417e1a1..e22b4ba65fd 100644 --- a/lib/editor/atto/tests/privacy/provider_test.php +++ b/lib/editor/atto/tests/privacy/provider_test.php @@ -41,7 +41,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * One test to check fetch and export of all drafts. */ - public function test_fetch_and_exports_drafts() { + public function test_fetch_and_exports_drafts(): void { global $USER; $this->resetAfterTest(); @@ -144,7 +144,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test delete_for_all_users_in_context. */ - public function test_delete_for_all_users_in_context() { + public function test_delete_for_all_users_in_context(): void { global $USER, $DB; $this->resetAfterTest(); @@ -230,7 +230,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test delete_for_all_users_in_context. */ - public function test_delete_for_user_in_contexts() { + public function test_delete_for_user_in_contexts(): void { global $USER, $DB; $this->resetAfterTest(); @@ -332,7 +332,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test that user data with different contexts is fetched. */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { $this->resetAfterTest(); $component = 'editor_atto'; @@ -393,7 +393,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test that data for users in approved userlist is deleted. */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { $this->resetAfterTest(); $component = 'editor_atto'; @@ -513,7 +513,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { * Test fetch and delete when another user has editted a draft in your * user context. Edge case. */ - public function test_another_user_edits_you() { + public function test_another_user_edits_you(): void { global $USER, $DB; $this->resetAfterTest(); @@ -566,7 +566,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test fetch and delete when you have edited another user's context. */ - public function test_another_you_edit_different_user() { + public function test_another_you_edit_different_user(): void { global $USER, $DB; $this->resetAfterTest(); diff --git a/lib/editor/tests/privacy/provider_test.php b/lib/editor/tests/privacy/provider_test.php index 6bacfa61ab3..c6d4de68183 100644 --- a/lib/editor/tests/privacy/provider_test.php +++ b/lib/editor/tests/privacy/provider_test.php @@ -41,7 +41,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * When no preference exists, there should be no export. */ - public function test_no_preference() { + public function test_no_preference(): void { global $USER; $this->resetAfterTest(); $this->setAdminUser(); @@ -55,7 +55,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * When preference exists but is empty, there should be no export. */ - public function test_empty_preference() { + public function test_empty_preference(): void { $this->resetAfterTest(); // Create test user, add some preferences. @@ -77,7 +77,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * When an editor is set, the name of that editor will be reported. */ - public function test_editor_atto() { + public function test_editor_atto(): void { $this->resetAfterTest(); // Create test user, add some preferences. diff --git a/lib/external/tests/external_externallib_test.php b/lib/external/tests/external_externallib_test.php index 3139a21c26c..027db14b531 100644 --- a/lib/external/tests/external_externallib_test.php +++ b/lib/external/tests/external_externallib_test.php @@ -38,7 +38,7 @@ class external_externallib_test extends externallib_advanced_testcase { /** * Test get_string */ - public function test_get_string() { + public function test_get_string(): void { $this->resetAfterTest(true); $service = new \stdClass(); @@ -86,7 +86,7 @@ class external_externallib_test extends externallib_advanced_testcase { /** * Test get_string with HTML. */ - public function test_get_string_containing_html() { + public function test_get_string_containing_html(): void { $result = \core_external::get_string('registrationinfo'); $actual = external_api::clean_returnvalue(\core_external::get_string_returns(), $result); $expected = get_string('registrationinfo', 'moodle'); @@ -96,7 +96,7 @@ class external_externallib_test extends externallib_advanced_testcase { /** * Test get_string with arguments containing HTML. */ - public function test_get_string_with_args_containing_html() { + public function test_get_string_with_args_containing_html(): void { $result = \core_external::get_string('added', 'moodle', null, [['value' => 'Test']]); $actual = external_api::clean_returnvalue(\core_external::get_string_returns(), $result); $expected = get_string('added', 'moodle', 'Test'); @@ -106,7 +106,7 @@ class external_externallib_test extends externallib_advanced_testcase { /** * Test get_strings */ - public function test_get_strings() { + public function test_get_strings(): void { $this->resetAfterTest(true); $stringmanager = get_string_manager(); @@ -142,7 +142,7 @@ class external_externallib_test extends externallib_advanced_testcase { /** * Test get_strings with HTML. */ - public function test_get_strings_containing_html() { + public function test_get_strings_containing_html(): void { $result = \core_external::get_strings([['stringid' => 'registrationinfo'], ['stringid' => 'loginaspasswordexplain']]); $actual = external_api::clean_returnvalue(\core_external::get_strings_returns(), $result); $this->assertSame(get_string('registrationinfo', 'moodle'), $actual[0]['string']); @@ -152,7 +152,7 @@ class external_externallib_test extends externallib_advanced_testcase { /** * Test get_strings with arguments containing HTML. */ - public function test_get_strings_with_args_containing_html() { + public function test_get_strings_with_args_containing_html(): void { $result = \core_external::get_strings([ ['stringid' => 'added', 'stringparams' => [['value' => 'Test']]], ['stringid' => 'loggedinas', 'stringparams' => [['value' => 'Test']]]] @@ -165,7 +165,7 @@ class external_externallib_test extends externallib_advanced_testcase { /** * Test get_component_strings */ - public function test_get_component_strings() { + public function test_get_component_strings(): void { global $USER; $this->resetAfterTest(true); @@ -187,7 +187,7 @@ class external_externallib_test extends externallib_advanced_testcase { /** * Test update_inplace_editable() */ - public function test_update_inplace_editable() { + public function test_update_inplace_editable(): void { $this->resetAfterTest(true); // Call service for component that does not have inplace_editable callback. @@ -211,7 +211,7 @@ class external_externallib_test extends externallib_advanced_testcase { /** * Test update_inplace_editable with mathjax. */ - public function test_update_inplace_editable_with_mathjax() { + public function test_update_inplace_editable_with_mathjax(): void { $this->resetAfterTest(true); $this->setAdminUser(); @@ -239,7 +239,7 @@ class external_externallib_test extends externallib_advanced_testcase { $this->assertEquals($editlabel, $res['editlabel']); } - public function test_get_user_dates() { + public function test_get_user_dates(): void { $this->resetAfterTest(); $this->setAdminUser(); diff --git a/lib/external/tests/external_value_test.php b/lib/external/tests/external_value_test.php index 9fe4fef6b45..a52c7b6b95e 100644 --- a/lib/external/tests/external_value_test.php +++ b/lib/external/tests/external_value_test.php @@ -54,7 +54,7 @@ class external_value_test extends advanced_testcase { * @param mixed $requiredstr The string value of the $required param in the debugging message. * @return void */ - public function test_required_param_validation($required, $debuggingexpected, $requiredstr = '') { + public function test_required_param_validation($required, $debuggingexpected, $requiredstr = ''): void { $externalvalue = new external_value(PARAM_INT, 'Cool description', $required); if ($debuggingexpected) { $this->assertDebuggingCalled("Invalid \$required parameter value: '{$requiredstr}' . diff --git a/lib/external/tests/privacy/provider_test.php b/lib/external/tests/privacy/provider_test.php index 282b8dcb051..009e16f8616 100644 --- a/lib/external/tests/privacy/provider_test.php +++ b/lib/external/tests/privacy/provider_test.php @@ -135,7 +135,7 @@ class provider_test extends provider_testcase { * * @covers \core_external\privacy\provider::delete_data_for_all_users_in_context */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; $dg = $this->getDataGenerator(); @@ -174,7 +174,7 @@ class provider_test extends provider_testcase { * Test the export_user_data function. * @covers \core_external\privacy\provider::export_user_data */ - public function test_export_data_for_user() { + public function test_export_data_for_user(): void { global $DB; $dg = $this->getDataGenerator(); @@ -257,7 +257,7 @@ class provider_test extends provider_testcase { * * @covers \core_external\privacy\provider::get_users_in_context */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { $component = 'core_external'; // Create user u1. @@ -343,7 +343,7 @@ class provider_test extends provider_testcase { * * @covers \core_external\privacy\provider::delete_data_for_users */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { $component = 'core_external'; // Create user u1. diff --git a/lib/filebrowser/tests/file_browser_test.php b/lib/filebrowser/tests/file_browser_test.php index 9480fd6eb83..6d0123bbd07 100644 --- a/lib/filebrowser/tests/file_browser_test.php +++ b/lib/filebrowser/tests/file_browser_test.php @@ -170,7 +170,7 @@ class file_browser_test extends \advanced_testcase { /** * Test "Server files" from the course category context, only look for .jpg */ - public function test_file_info_context_coursecat_jpg() { + public function test_file_info_context_coursecat_jpg(): void { // There is one non-empty category child and two category children. @@ -236,7 +236,7 @@ class file_browser_test extends \advanced_testcase { /** * Test "Server files" from the course context (module1) */ - public function test_file_info_context_module_1() { + public function test_file_info_context_module_1(): void { $module1context = \context_module::instance($this->module1->cmid); $browser = get_file_browser(); @@ -252,7 +252,7 @@ class file_browser_test extends \advanced_testcase { /** * Test "Server files" from the course context (module1) */ - public function test_file_info_context_module_2() { + public function test_file_info_context_module_2(): void { $module2context = \context_module::instance($this->module2->cmid); $browser = get_file_browser(); diff --git a/lib/filestorage/tests/file_storage_test.php b/lib/filestorage/tests/file_storage_test.php index 7a0fd34d15c..d5acb1c931b 100644 --- a/lib/filestorage/tests/file_storage_test.php +++ b/lib/filestorage/tests/file_storage_test.php @@ -54,7 +54,7 @@ class file_storage_test extends \advanced_testcase { * * @covers ::create_file_from_string */ - public function test_create_file_from_string() { + public function test_create_file_from_string(): void { global $DB; $this->resetAfterTest(true); @@ -127,7 +127,7 @@ class file_storage_test extends \advanced_testcase { * * @covers ::create_file_from_pathname */ - public function test_create_file_from_pathname() { + public function test_create_file_from_pathname(): void { global $CFG, $DB; $this->resetAfterTest(true); @@ -249,7 +249,7 @@ class file_storage_test extends \advanced_testcase { * @depends test_get_file * @covers ::get_file_preview */ - public function test_get_file_preview(stored_file $file) { + public function test_get_file_preview(stored_file $file): void { global $CFG; $this->resetAfterTest(); @@ -272,7 +272,7 @@ class file_storage_test extends \advanced_testcase { * * @covers ::get_file_preview */ - public function test_get_file_preview_nonimage() { + public function test_get_file_preview_nonimage(): void { $this->resetAfterTest(true); $syscontext = \context_system::instance(); $filerecord = array( @@ -299,7 +299,7 @@ class file_storage_test extends \advanced_testcase { * @copyright 2012 Dongsheng Cai {@link http://dongsheng.org} * @covers \stored_file::rename */ - public function test_file_renaming() { + public function test_file_renaming(): void { global $CFG; $this->resetAfterTest(); @@ -345,7 +345,7 @@ class file_storage_test extends \advanced_testcase { * @copyright 2012 Dongsheng Cai {@link http://dongsheng.org} * @covers ::create_file_from_reference */ - public function test_create_file_from_reference() { + public function test_create_file_from_reference(): void { global $CFG, $DB; $this->resetAfterTest(); @@ -431,7 +431,7 @@ class file_storage_test extends \advanced_testcase { * @copyright 2012 Dongsheng Cai {@link http://dongsheng.org} * @covers ::create_file_from_reference */ - public function test_create_file_from_reference_with_content_hash() { + public function test_create_file_from_reference_with_content_hash(): void { global $CFG, $DB; $this->resetAfterTest(); @@ -600,7 +600,7 @@ class file_storage_test extends \advanced_testcase { * * @covers ::get_area_tree */ - public function test_get_area_tree() { + public function test_get_area_tree(): void { $user = $this->setup_three_private_files(); $fs = get_file_storage(); @@ -659,7 +659,7 @@ class file_storage_test extends \advanced_testcase { * * @covers ::get_file_by_id */ - public function test_get_file_by_id() { + public function test_get_file_by_id(): void { $user = $this->setup_three_private_files(); $fs = get_file_storage(); @@ -680,7 +680,7 @@ class file_storage_test extends \advanced_testcase { * * @covers ::get_file_by_hash */ - public function test_get_file_by_hash() { + public function test_get_file_by_hash(): void { $user = $this->setup_three_private_files(); $fs = get_file_storage(); @@ -700,7 +700,7 @@ class file_storage_test extends \advanced_testcase { * * @covers ::get_external_files */ - public function test_get_external_files() { + public function test_get_external_files(): void { $user = $this->setup_three_private_files(); $fs = get_file_storage(); @@ -767,7 +767,7 @@ class file_storage_test extends \advanced_testcase { * * @covers ::create_directory */ - public function test_create_directory_contextid_negative() { + public function test_create_directory_contextid_negative(): void { $fs = get_file_storage(); $this->expectException('file_exception'); @@ -779,7 +779,7 @@ class file_storage_test extends \advanced_testcase { * * @covers ::create_directory */ - public function test_create_directory_contextid_invalid() { + public function test_create_directory_contextid_invalid(): void { $fs = get_file_storage(); $this->expectException('file_exception'); @@ -791,7 +791,7 @@ class file_storage_test extends \advanced_testcase { * * @covers ::create_directory */ - public function test_create_directory_component_invalid() { + public function test_create_directory_component_invalid(): void { $fs = get_file_storage(); $syscontext = \context_system::instance(); @@ -804,7 +804,7 @@ class file_storage_test extends \advanced_testcase { * * @covers ::create_directory */ - public function test_create_directory_filearea_invalid() { + public function test_create_directory_filearea_invalid(): void { $fs = get_file_storage(); $syscontext = \context_system::instance(); @@ -817,7 +817,7 @@ class file_storage_test extends \advanced_testcase { * * @covers ::create_directory */ - public function test_create_directory_itemid_negative() { + public function test_create_directory_itemid_negative(): void { $fs = get_file_storage(); $syscontext = \context_system::instance(); @@ -830,7 +830,7 @@ class file_storage_test extends \advanced_testcase { * * @covers ::create_directory */ - public function test_create_directory_itemid_invalid() { + public function test_create_directory_itemid_invalid(): void { $fs = get_file_storage(); $syscontext = \context_system::instance(); @@ -843,7 +843,7 @@ class file_storage_test extends \advanced_testcase { * * @covers ::create_directory */ - public function test_create_directory_filepath_invalid() { + public function test_create_directory_filepath_invalid(): void { $fs = get_file_storage(); $syscontext = \context_system::instance(); @@ -856,7 +856,7 @@ class file_storage_test extends \advanced_testcase { * * @covers ::get_directory_files */ - public function test_get_directory_files() { + public function test_get_directory_files(): void { $user = $this->setup_three_private_files(); $fs = get_file_storage(); @@ -918,7 +918,7 @@ class file_storage_test extends \advanced_testcase { * * @covers ::search_references */ - public function test_search_references() { + public function test_search_references(): void { $user = $this->setup_three_private_files(); $fs = get_file_storage(); $repos = repository::get_instances(array('type'=>'user')); @@ -995,7 +995,7 @@ class file_storage_test extends \advanced_testcase { * * @covers ::delete_area_files */ - public function test_delete_area_files() { + public function test_delete_area_files(): void { $user = $this->setup_three_private_files(); $fs = get_file_storage(); @@ -1015,7 +1015,7 @@ class file_storage_test extends \advanced_testcase { * * @covers ::delete_area_files */ - public function test_delete_area_files_itemid() { + public function test_delete_area_files_itemid(): void { $user = $this->setup_three_private_files(); $fs = get_file_storage(); @@ -1034,7 +1034,7 @@ class file_storage_test extends \advanced_testcase { * * @covers ::delete_area_files_select */ - public function test_delete_area_files_select() { + public function test_delete_area_files_select(): void { $user = $this->setup_three_private_files(); $fs = get_file_storage(); @@ -1054,7 +1054,7 @@ class file_storage_test extends \advanced_testcase { * * @covers ::delete_component_files */ - public function test_delete_component_files() { + public function test_delete_component_files(): void { $user = $this->setup_three_private_files(); $fs = get_file_storage(); @@ -1070,7 +1070,7 @@ class file_storage_test extends \advanced_testcase { * * @covers ::create_file_from_url */ - public function test_create_file_from_url() { + public function test_create_file_from_url(): void { $this->resetAfterTest(true); $syscontext = \context_system::instance(); @@ -1105,7 +1105,7 @@ class file_storage_test extends \advanced_testcase { * * @covers ::cron */ - public function test_cron() { + public function test_cron(): void { $this->resetAfterTest(true); // Note: this is only testing DB compatibility atm, rather than @@ -1121,7 +1121,7 @@ class file_storage_test extends \advanced_testcase { * * @covers ::is_area_empty */ - public function test_is_area_empty() { + public function test_is_area_empty(): void { $user = $this->setup_three_private_files(); $fs = get_file_storage(); @@ -1138,7 +1138,7 @@ class file_storage_test extends \advanced_testcase { * * @covers ::move_area_files_to_new_context */ - public function test_move_area_files_to_new_context() { + public function test_move_area_files_to_new_context(): void { $this->resetAfterTest(true); // Create a course with a page resource. @@ -1192,7 +1192,7 @@ class file_storage_test extends \advanced_testcase { * * @covers ::convert_image */ - public function test_convert_image() { + public function test_convert_image(): void { global $CFG; $this->resetAfterTest(false); @@ -1225,7 +1225,7 @@ class file_storage_test extends \advanced_testcase { * * @covers ::convert_image */ - public function test_convert_image_png() { + public function test_convert_image_png(): void { global $CFG; $this->resetAfterTest(false); @@ -1304,7 +1304,7 @@ class file_storage_test extends \advanced_testcase { /** * @covers ::create_file_from_storedfile */ - public function test_create_file_from_storedfile_file_invalid() { + public function test_create_file_from_storedfile_file_invalid(): void { $this->resetAfterTest(true); $filerecord = $this->generate_file_record(); @@ -1319,7 +1319,7 @@ class file_storage_test extends \advanced_testcase { /** * @covers ::create_file_from_storedfile */ - public function test_create_file_from_storedfile_contextid_invalid() { + public function test_create_file_from_storedfile_contextid_invalid(): void { $this->resetAfterTest(true); $filerecord = $this->generate_file_record(); @@ -1339,7 +1339,7 @@ class file_storage_test extends \advanced_testcase { /** * @covers ::create_file_from_storedfile */ - public function test_create_file_from_storedfile_component_invalid() { + public function test_create_file_from_storedfile_component_invalid(): void { $this->resetAfterTest(true); $filerecord = $this->generate_file_record(); @@ -1359,7 +1359,7 @@ class file_storage_test extends \advanced_testcase { /** * @covers ::create_file_from_storedfile */ - public function test_create_file_from_storedfile_filearea_invalid() { + public function test_create_file_from_storedfile_filearea_invalid(): void { $this->resetAfterTest(true); $filerecord = $this->generate_file_record(); @@ -1379,7 +1379,7 @@ class file_storage_test extends \advanced_testcase { /** * @covers ::create_file_from_storedfile */ - public function test_create_file_from_storedfile_itemid_invalid() { + public function test_create_file_from_storedfile_itemid_invalid(): void { $this->resetAfterTest(true); $filerecord = $this->generate_file_record(); @@ -1399,7 +1399,7 @@ class file_storage_test extends \advanced_testcase { /** * @covers ::create_file_from_storedfile */ - public function test_create_file_from_storedfile_filepath_invalid() { + public function test_create_file_from_storedfile_filepath_invalid(): void { $this->resetAfterTest(true); $filerecord = $this->generate_file_record(); @@ -1419,7 +1419,7 @@ class file_storage_test extends \advanced_testcase { /** * @covers ::create_file_from_storedfile */ - public function test_create_file_from_storedfile_filename_invalid() { + public function test_create_file_from_storedfile_filename_invalid(): void { $this->resetAfterTest(true); $filerecord = $this->generate_file_record(); @@ -1438,7 +1438,7 @@ class file_storage_test extends \advanced_testcase { /** * @covers ::create_file_from_storedfile */ - public function test_create_file_from_storedfile_timecreated_invalid() { + public function test_create_file_from_storedfile_timecreated_invalid(): void { $this->resetAfterTest(true); $filerecord = $this->generate_file_record(); @@ -1458,7 +1458,7 @@ class file_storage_test extends \advanced_testcase { /** * @covers ::create_file_from_storedfile */ - public function test_create_file_from_storedfile_timemodified_invalid() { + public function test_create_file_from_storedfile_timemodified_invalid(): void { $this->resetAfterTest(true); $filerecord = $this->generate_file_record(); @@ -1478,7 +1478,7 @@ class file_storage_test extends \advanced_testcase { /** * @covers ::create_file_from_storedfile */ - public function test_create_file_from_storedfile_duplicate() { + public function test_create_file_from_storedfile_duplicate(): void { $this->resetAfterTest(true); $filerecord = $this->generate_file_record(); @@ -1498,7 +1498,7 @@ class file_storage_test extends \advanced_testcase { * * @covers ::create_file_from_storedfile */ - public function test_create_file_from_storedfile() { + public function test_create_file_from_storedfile(): void { $this->resetAfterTest(true); $syscontext = \context_system::instance(); @@ -1535,7 +1535,7 @@ class file_storage_test extends \advanced_testcase { /** * @covers ::create_file_from_string */ - public function test_create_file_from_string_contextid_invalid() { + public function test_create_file_from_string_contextid_invalid(): void { $this->resetAfterTest(true); $filerecord = $this->generate_file_record(); @@ -1551,7 +1551,7 @@ class file_storage_test extends \advanced_testcase { /** * @covers ::create_file_from_string */ - public function test_create_file_from_string_component_invalid() { + public function test_create_file_from_string_component_invalid(): void { $this->resetAfterTest(true); $filerecord = $this->generate_file_record(); @@ -1567,7 +1567,7 @@ class file_storage_test extends \advanced_testcase { /** * @covers ::create_file_from_string */ - public function test_create_file_from_string_filearea_invalid() { + public function test_create_file_from_string_filearea_invalid(): void { $this->resetAfterTest(true); $filerecord = $this->generate_file_record(); @@ -1583,7 +1583,7 @@ class file_storage_test extends \advanced_testcase { /** * @covers ::create_file_from_string */ - public function test_create_file_from_string_itemid_invalid() { + public function test_create_file_from_string_itemid_invalid(): void { $this->resetAfterTest(true); $filerecord = $this->generate_file_record(); @@ -1599,7 +1599,7 @@ class file_storage_test extends \advanced_testcase { /** * @covers ::create_file_from_string */ - public function test_create_file_from_string_filepath_invalid() { + public function test_create_file_from_string_filepath_invalid(): void { $this->resetAfterTest(true); $filerecord = $this->generate_file_record(); @@ -1615,7 +1615,7 @@ class file_storage_test extends \advanced_testcase { /** * @covers ::create_file_from_string */ - public function test_create_file_from_string_filename_invalid() { + public function test_create_file_from_string_filename_invalid(): void { $this->resetAfterTest(true); $filerecord = $this->generate_file_record(); @@ -1631,7 +1631,7 @@ class file_storage_test extends \advanced_testcase { /** * @covers ::create_file_from_string */ - public function test_create_file_from_string_timecreated_invalid() { + public function test_create_file_from_string_timecreated_invalid(): void { $this->resetAfterTest(true); $filerecord = $this->generate_file_record(); @@ -1647,7 +1647,7 @@ class file_storage_test extends \advanced_testcase { /** * @covers ::create_file_from_string */ - public function test_create_file_from_string_timemodified_invalid() { + public function test_create_file_from_string_timemodified_invalid(): void { $this->resetAfterTest(true); $filerecord = $this->generate_file_record(); @@ -1664,7 +1664,7 @@ class file_storage_test extends \advanced_testcase { * Tests for create_file_from_string with a duplicate string. * @covers ::create_file_from_string */ - public function test_create_file_from_string_duplicate() { + public function test_create_file_from_string_duplicate(): void { $this->resetAfterTest(true); $filerecord = $this->generate_file_record(); @@ -1680,7 +1680,7 @@ class file_storage_test extends \advanced_testcase { /** * @covers ::create_file_from_pathname */ - public function test_create_file_from_pathname_contextid_invalid() { + public function test_create_file_from_pathname_contextid_invalid(): void { global $CFG; $path = $CFG->dirroot.'/lib/filestorage/tests/fixtures/testimage.jpg'; @@ -1699,7 +1699,7 @@ class file_storage_test extends \advanced_testcase { /** * @covers ::create_file_from_pathname */ - public function test_create_file_from_pathname_component_invalid() { + public function test_create_file_from_pathname_component_invalid(): void { global $CFG; $path = $CFG->dirroot.'/lib/filestorage/tests/fixtures/testimage.jpg'; @@ -1718,7 +1718,7 @@ class file_storage_test extends \advanced_testcase { /** * @covers ::create_file_from_pathname */ - public function test_create_file_from_pathname_filearea_invalid() { + public function test_create_file_from_pathname_filearea_invalid(): void { global $CFG; $path = $CFG->dirroot.'/lib/filestorage/tests/fixtures/testimage.jpg'; @@ -1737,7 +1737,7 @@ class file_storage_test extends \advanced_testcase { /** * @covers ::create_file_from_pathname */ - public function test_create_file_from_pathname_itemid_invalid() { + public function test_create_file_from_pathname_itemid_invalid(): void { global $CFG; $path = $CFG->dirroot.'/lib/filestorage/tests/fixtures/testimage.jpg'; @@ -1756,7 +1756,7 @@ class file_storage_test extends \advanced_testcase { /** * @covers ::create_file_from_pathname */ - public function test_create_file_from_pathname_filepath_invalid() { + public function test_create_file_from_pathname_filepath_invalid(): void { global $CFG; $path = $CFG->dirroot.'/lib/filestorage/tests/fixtures/testimage.jpg'; @@ -1775,7 +1775,7 @@ class file_storage_test extends \advanced_testcase { /** * @covers ::create_file_from_pathname */ - public function test_create_file_from_pathname_filename_invalid() { + public function test_create_file_from_pathname_filename_invalid(): void { global $CFG; $path = $CFG->dirroot.'/lib/filestorage/tests/fixtures/testimage.jpg'; @@ -1794,7 +1794,7 @@ class file_storage_test extends \advanced_testcase { /** * @covers ::create_file_from_pathname */ - public function test_create_file_from_pathname_timecreated_invalid() { + public function test_create_file_from_pathname_timecreated_invalid(): void { global $CFG; $path = $CFG->dirroot.'/lib/filestorage/tests/fixtures/testimage.jpg'; @@ -1813,7 +1813,7 @@ class file_storage_test extends \advanced_testcase { /** * @covers ::create_file_from_pathname */ - public function test_create_file_from_pathname_timemodified_invalid() { + public function test_create_file_from_pathname_timemodified_invalid(): void { global $CFG; $path = $CFG->dirroot.'/lib/filestorage/tests/fixtures/testimage.jpg'; @@ -1832,7 +1832,7 @@ class file_storage_test extends \advanced_testcase { /** * @covers ::create_file_from_pathname */ - public function test_create_file_from_pathname_duplicate_file() { + public function test_create_file_from_pathname_duplicate_file(): void { global $CFG; $this->resetAfterTest(true); @@ -1855,7 +1855,7 @@ class file_storage_test extends \advanced_testcase { * * @covers \stored_file::delete_reference */ - public function test_delete_reference_on_nonreference() { + public function test_delete_reference_on_nonreference(): void { $this->resetAfterTest(true); $user = $this->setup_three_private_files(); @@ -1884,7 +1884,7 @@ class file_storage_test extends \advanced_testcase { * * @covers \stored_file::delete_reference */ - public function test_delete_reference_one_symlink_does_not_rule_them_all() { + public function test_delete_reference_one_symlink_does_not_rule_them_all(): void { $this->resetAfterTest(true); $user = $this->setup_three_private_files(); @@ -1947,7 +1947,7 @@ class file_storage_test extends \advanced_testcase { * updated immediately. When it is deleted, the references are converted * to true copies. */ - public function test_update_reference_internal() { + public function test_update_reference_internal(): void { purge_all_caches(); $this->resetAfterTest(true); $user = $this->setup_three_private_files(); @@ -2054,7 +2054,7 @@ class file_storage_test extends \advanced_testcase { * * @covers ::get_unused_filename */ - public function test_get_unused_filename() { + public function test_get_unused_filename(): void { global $USER; $this->resetAfterTest(true); @@ -2122,7 +2122,7 @@ class file_storage_test extends \advanced_testcase { * * @covers ::mimetype */ - public function test_mimetype_not_found() { + public function test_mimetype_not_found(): void { $mimetype = \file_storage::mimetype('/path/to/nonexistent/file'); $this->assertEquals('document/unknown', $mimetype); } @@ -2165,7 +2165,7 @@ class file_storage_test extends \advanced_testcase { * * @covers ::mimetype_from_file */ - public function test_mimetype_from_file_not_found() { + public function test_mimetype_from_file_not_found(): void { $mimetype = \file_storage::mimetype_from_file('/path/to/nonexistent/file'); $this->assertEquals('document/unknown', $mimetype); } diff --git a/lib/filestorage/tests/file_system_filedir_test.php b/lib/filestorage/tests/file_system_filedir_test.php index 69d5bca3462..7465cb91727 100644 --- a/lib/filestorage/tests/file_system_filedir_test.php +++ b/lib/filestorage/tests/file_system_filedir_test.php @@ -136,7 +136,7 @@ class file_system_filedir_test extends \advanced_testcase { * * @covers ::__construct */ - public function test_readonly_filesystem_filedir() { + public function test_readonly_filesystem_filedir(): void { $this->resetAfterTest(); // Setup the filedir but remove permissions. @@ -160,7 +160,7 @@ class file_system_filedir_test extends \advanced_testcase { * * @covers ::__construct */ - public function test_readonly_filesystem_trashdir() { + public function test_readonly_filesystem_trashdir(): void { $this->resetAfterTest(); // Setup the trashdir but remove permissions. @@ -183,7 +183,7 @@ class file_system_filedir_test extends \advanced_testcase { * * @covers ::__construct */ - public function test_warnings_put_in_place() { + public function test_warnings_put_in_place(): void { $this->resetAfterTest(); $vfileroot = $this->setup_vfile_root(null); @@ -203,7 +203,7 @@ class file_system_filedir_test extends \advanced_testcase { * * @covers ::get_remote_path_from_hash */ - public function test_get_remote_path_from_hash() { + public function test_get_remote_path_from_hash(): void { $filecontent = 'example content'; $contenthash = \file_storage::hash_from_string($filecontent); $expectedresult = (object) []; @@ -229,7 +229,7 @@ class file_system_filedir_test extends \advanced_testcase { * * @covers ::get_local_path_from_storedfile */ - public function test_get_local_path_from_storedfile_with_recovery() { + public function test_get_local_path_from_storedfile_with_recovery(): void { $filecontent = 'example content'; $file = $this->get_stored_file($filecontent); $fs = $this->get_testable_mock([ @@ -257,7 +257,7 @@ class file_system_filedir_test extends \advanced_testcase { * * @covers ::get_local_path_from_storedfile */ - public function test_get_local_path_from_storedfile_without_recovery() { + public function test_get_local_path_from_storedfile_without_recovery(): void { $filecontent = 'example content'; $file = $this->get_stored_file($filecontent); $fs = $this->get_testable_mock([ @@ -288,7 +288,7 @@ class file_system_filedir_test extends \advanced_testcase { * * @covers ::get_fulldir_from_hash */ - public function test_get_fulldir_from_hash($hash, $hashdir) { + public function test_get_fulldir_from_hash($hash, $hashdir): void { global $CFG; $fs = new file_system_filedir(); @@ -309,7 +309,7 @@ class file_system_filedir_test extends \advanced_testcase { * * @covers ::get_fulldir_from_storedfile */ - public function test_get_fulldir_from_storedfile($hash, $hashdir) { + public function test_get_fulldir_from_storedfile($hash, $hashdir): void { global $CFG; $file = $this->getMockBuilder('stored_file') @@ -340,7 +340,7 @@ class file_system_filedir_test extends \advanced_testcase { * * @covers ::get_contentdir_from_hash */ - public function test_get_contentdir_from_hash($hash, $hashdir) { + public function test_get_contentdir_from_hash($hash, $hashdir): void { $method = new \ReflectionMethod(file_system_filedir::class, 'get_contentdir_from_hash'); $fs = new file_system_filedir(); @@ -359,7 +359,7 @@ class file_system_filedir_test extends \advanced_testcase { * * @covers ::get_contentpath_from_hash */ - public function test_get_contentpath_from_hash($hash, $hashdir) { + public function test_get_contentpath_from_hash($hash, $hashdir): void { $method = new \ReflectionMethod(file_system_filedir::class, 'get_contentpath_from_hash'); $fs = new file_system_filedir(); @@ -379,7 +379,7 @@ class file_system_filedir_test extends \advanced_testcase { * * @covers ::get_trash_fullpath_from_hash */ - public function test_get_trash_fullpath_from_hash($hash, $hashdir) { + public function test_get_trash_fullpath_from_hash($hash, $hashdir): void { global $CFG; $fs = new file_system_filedir(); @@ -400,7 +400,7 @@ class file_system_filedir_test extends \advanced_testcase { * * @covers ::get_trash_fulldir_from_hash */ - public function test_get_trash_fulldir_from_hash($hash, $hashdir) { + public function test_get_trash_fulldir_from_hash($hash, $hashdir): void { global $CFG; $fs = new file_system_filedir(); @@ -416,7 +416,7 @@ class file_system_filedir_test extends \advanced_testcase { * * @covers ::copy_content_from_storedfile */ - public function test_copy_content_from_storedfile() { + public function test_copy_content_from_storedfile(): void { $this->resetAfterTest(); global $CFG; @@ -454,7 +454,7 @@ class file_system_filedir_test extends \advanced_testcase { * * @covers ::recover_file */ - public function test_recover_file() { + public function test_recover_file(): void { $this->resetAfterTest(); // Setup the filedir. @@ -493,7 +493,7 @@ class file_system_filedir_test extends \advanced_testcase { * * @covers ::recover_file */ - public function test_recover_file_already_present() { + public function test_recover_file_already_present(): void { $this->resetAfterTest(); // Setup the filedir. @@ -531,7 +531,7 @@ class file_system_filedir_test extends \advanced_testcase { * * @covers ::recover_file */ - public function test_recover_file_size_mismatch() { + public function test_recover_file_size_mismatch(): void { $this->resetAfterTest(); // Setup the filedir. @@ -567,7 +567,7 @@ class file_system_filedir_test extends \advanced_testcase { * * @covers ::recover_file */ - public function test_recover_file_has_mismatch() { + public function test_recover_file_has_mismatch(): void { $this->resetAfterTest(); // Setup the filedir. @@ -604,7 +604,7 @@ class file_system_filedir_test extends \advanced_testcase { * * @covers ::recover_file */ - public function test_recover_file_alttrash() { + public function test_recover_file_alttrash(): void { $this->resetAfterTest(); // Setup the filedir. @@ -638,7 +638,7 @@ class file_system_filedir_test extends \advanced_testcase { * * @covers ::recover_file */ - public function test_recover_file_contentdir_readonly() { + public function test_recover_file_contentdir_readonly(): void { $this->resetAfterTest(); $filecontent = 'example content'; @@ -674,7 +674,7 @@ class file_system_filedir_test extends \advanced_testcase { * * @covers ::add_file_from_path */ - public function test_add_file_from_path() { + public function test_add_file_from_path(): void { $this->resetAfterTest(); global $CFG; @@ -710,7 +710,7 @@ class file_system_filedir_test extends \advanced_testcase { * * @covers ::add_file_from_path */ - public function test_add_file_from_path_file_unavailable() { + public function test_add_file_from_path_file_unavailable(): void { $this->resetAfterTest(); // Setup the filedir. @@ -730,7 +730,7 @@ class file_system_filedir_test extends \advanced_testcase { * * @covers ::add_file_from_path */ - public function test_add_file_from_path_mismatched_hash() { + public function test_add_file_from_path_mismatched_hash(): void { $this->resetAfterTest(); $filecontent = 'example content'; @@ -752,7 +752,7 @@ class file_system_filedir_test extends \advanced_testcase { * * @covers ::add_file_from_path */ - public function test_add_file_from_path_existing_content_invalid() { + public function test_add_file_from_path_existing_content_invalid(): void { $this->resetAfterTest(); $filecontent = 'example content'; @@ -797,7 +797,7 @@ class file_system_filedir_test extends \advanced_testcase { * * @covers ::add_file_from_path */ - public function test_add_file_from_path_existing_cannot_write_hashpath() { + public function test_add_file_from_path_existing_cannot_write_hashpath(): void { $this->resetAfterTest(); $filecontent = 'example content'; @@ -830,7 +830,7 @@ class file_system_filedir_test extends \advanced_testcase { * * @covers ::add_file_from_string */ - public function test_add_file_from_string() { + public function test_add_file_from_string(): void { $this->resetAfterTest(); global $CFG; @@ -857,7 +857,7 @@ class file_system_filedir_test extends \advanced_testcase { * * @covers ::add_file_from_string */ - public function test_add_file_from_string_existing_cannot_write_hashpath() { + public function test_add_file_from_string_existing_cannot_write_hashpath(): void { $this->resetAfterTest(); $filecontent = 'example content'; @@ -888,7 +888,7 @@ class file_system_filedir_test extends \advanced_testcase { * * @covers ::add_file_from_string */ - public function test_add_file_from_string_existing_matches() { + public function test_add_file_from_string_existing_matches(): void { $this->resetAfterTest(); global $CFG; @@ -922,7 +922,7 @@ class file_system_filedir_test extends \advanced_testcase { * * @covers ::remove_file */ - public function test_remove_file_missing() { + public function test_remove_file_missing(): void { $this->resetAfterTest(); $filecontent = 'example content'; @@ -945,7 +945,7 @@ class file_system_filedir_test extends \advanced_testcase { * * @covers ::remove_file */ - public function test_remove_file_existing_trash() { + public function test_remove_file_existing_trash(): void { $this->resetAfterTest(); $filecontent = 'example content'; @@ -974,7 +974,7 @@ class file_system_filedir_test extends \advanced_testcase { * * @covers ::remove_file */ - public function test_remove_file_empty() { + public function test_remove_file_empty(): void { $this->resetAfterTest(); global $DB; @@ -997,7 +997,7 @@ class file_system_filedir_test extends \advanced_testcase { * * @covers ::remove_file */ - public function test_remove_file_in_use() { + public function test_remove_file_in_use(): void { $this->resetAfterTest(); global $DB; @@ -1030,7 +1030,7 @@ class file_system_filedir_test extends \advanced_testcase { * * @covers ::remove_file */ - public function test_remove_file_expired() { + public function test_remove_file_expired(): void { $this->resetAfterTest(); global $DB; @@ -1062,7 +1062,7 @@ class file_system_filedir_test extends \advanced_testcase { * * @covers ::empty_trash */ - public function test_empty_trash() { + public function test_empty_trash(): void { $this->resetAfterTest(); $filecontent = 'example content'; diff --git a/lib/filestorage/tests/file_system_test.php b/lib/filestorage/tests/file_system_test.php index edd1d8d1075..cdc5e09dda0 100644 --- a/lib/filestorage/tests/file_system_test.php +++ b/lib/filestorage/tests/file_system_test.php @@ -108,7 +108,7 @@ class file_system_test extends \advanced_testcase { * Ensure that the file system is not clonable. * */ - public function test_not_cloneable() { + public function test_not_cloneable(): void { $reflection = new \ReflectionClass('file_system'); $this->assertFalse($reflection->isCloneable()); } @@ -117,7 +117,7 @@ class file_system_test extends \advanced_testcase { * Ensure that the filedir file_system extension is used by default. * */ - public function test_default_class() { + public function test_default_class(): void { $this->resetAfterTest(); // Ensure that the alternative_file_system_class is null. @@ -134,7 +134,7 @@ class file_system_test extends \advanced_testcase { * Ensure that the specified file_system extension class is used. * */ - public function test_supplied_class() { + public function test_supplied_class(): void { global $CFG; $this->resetAfterTest(); @@ -156,7 +156,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::readfile */ - public function test_readfile_remote() { + public function test_readfile_remote(): void { global $CFG; // Mock the filesystem. @@ -189,7 +189,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::readfile */ - public function test_readfile_local() { + public function test_readfile_local(): void { global $CFG; // Mock the filesystem. @@ -227,7 +227,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::get_local_path_from_storedfile */ - public function test_get_local_path_from_storedfile($args, $fetch) { + public function test_get_local_path_from_storedfile($args, $fetch): void { $filepath = '/path/to/file'; $filecontent = 'example content'; @@ -254,7 +254,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::get_remote_path_from_storedfile */ - public function test_get_remote_path_from_storedfile() { + public function test_get_remote_path_from_storedfile(): void { $filepath = '/path/to/file'; $filecontent = 'example content'; @@ -284,7 +284,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::is_file_readable_locally_by_hash */ - public function test_is_file_readable_locally_by_hash() { + public function test_is_file_readable_locally_by_hash(): void { $filecontent = 'example content'; $contenthash = \file_storage::hash_from_string($filecontent); $filepath = __FILE__; @@ -305,7 +305,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::is_file_readable_locally_by_hash */ - public function test_is_file_readable_locally_by_hash_empty() { + public function test_is_file_readable_locally_by_hash_empty(): void { $filecontent = ''; $contenthash = \file_storage::hash_from_string($filecontent); @@ -324,7 +324,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::is_file_readable_remotely_by_hash */ - public function test_is_file_readable_remotely_by_hash() { + public function test_is_file_readable_remotely_by_hash(): void { $filecontent = 'example content'; $contenthash = \file_storage::hash_from_string($filecontent); @@ -344,7 +344,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::is_file_readable_remotely_by_hash */ - public function test_is_file_readable_remotely_by_hash_empty() { + public function test_is_file_readable_remotely_by_hash_empty(): void { $filecontent = ''; $contenthash = \file_storage::hash_from_string($filecontent); @@ -363,7 +363,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::is_file_readable_remotely_by_hash */ - public function test_is_file_readable_remotely_by_hash_not_found() { + public function test_is_file_readable_remotely_by_hash_not_found(): void { $filecontent = 'example content'; $contenthash = \file_storage::hash_from_string($filecontent); @@ -383,7 +383,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::is_file_readable_remotely_by_storedfile */ - public function test_is_file_readable_remotely_by_storedfile() { + public function test_is_file_readable_remotely_by_storedfile(): void { $file = $this->get_stored_file('example content'); $fs = $this->get_testable_mock([ @@ -401,7 +401,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::is_file_readable_remotely_by_storedfile */ - public function test_is_file_readable_remotely_by_storedfile_empty() { + public function test_is_file_readable_remotely_by_storedfile_empty(): void { $fs = $this->get_testable_mock([ 'get_remote_path_from_storedfile', ]); @@ -418,7 +418,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::is_file_readable_locally_by_storedfile */ - public function test_is_file_readable_locally_by_storedfile_empty() { + public function test_is_file_readable_locally_by_storedfile_empty(): void { $fs = $this->get_testable_mock([ 'get_local_path_from_storedfile', ]); @@ -435,7 +435,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::is_file_readable_locally_by_storedfile */ - public function test_is_file_readable_remotely_by_storedfile_not_found() { + public function test_is_file_readable_remotely_by_storedfile_not_found(): void { $file = $this->get_stored_file('example content'); $fs = $this->get_testable_mock([ @@ -453,7 +453,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::is_file_readable_locally_by_storedfile */ - public function test_is_file_readable_locally_by_storedfile_unreadable() { + public function test_is_file_readable_locally_by_storedfile_unreadable(): void { $fs = $this->get_testable_mock([ 'get_local_path_from_storedfile', ]); @@ -471,7 +471,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::is_file_readable_locally_by_storedfile */ - public function test_is_file_readable_locally_by_storedfile_passes_fetch() { + public function test_is_file_readable_locally_by_storedfile_passes_fetch(): void { $fs = $this->get_testable_mock([ 'get_local_path_from_storedfile', ]); @@ -489,7 +489,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::is_file_removable */ - public function test_is_file_removable_empty() { + public function test_is_file_removable_empty(): void { $filecontent = ''; $contenthash = \file_storage::hash_from_string($filecontent); @@ -503,7 +503,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::is_file_removable */ - public function test_is_file_removable_in_use() { + public function test_is_file_removable_in_use(): void { $this->resetAfterTest(); global $DB; @@ -526,7 +526,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::is_file_removable */ - public function test_is_file_removable_not_in_use() { + public function test_is_file_removable_not_in_use(): void { $this->resetAfterTest(); global $DB; @@ -549,7 +549,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::get_content */ - public function test_get_content() { + public function test_get_content(): void { global $CFG; // Mock the filesystem. @@ -574,7 +574,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::get_content */ - public function test_get_content_empty() { + public function test_get_content_empty(): void { global $CFG; $filecontent = ''; @@ -597,7 +597,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::list_files */ - public function test_list_files() { + public function test_list_files(): void { $filecontent = 'example content'; $file = $this->get_stored_file($filecontent); $filepath = __FILE__; @@ -629,7 +629,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::extract_to_pathname */ - public function test_extract_to_pathname() { + public function test_extract_to_pathname(): void { $filecontent = 'example content'; $file = $this->get_stored_file($filecontent); $filepath = __FILE__; @@ -662,7 +662,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::extract_to_storage */ - public function test_extract_to_storage() { + public function test_extract_to_storage(): void { $filecontent = 'example content'; $file = $this->get_stored_file($filecontent); $filepath = __FILE__; @@ -703,7 +703,7 @@ class file_system_test extends \advanced_testcase { * file, and passes the path to the archive. * */ - public function test_add_storedfile_to_archive_directory() { + public function test_add_storedfile_to_archive_directory(): void { $file = $this->get_stored_file('', '.'); $archivepath = 'example'; $expectedresult = (object) []; @@ -739,7 +739,7 @@ class file_system_test extends \advanced_testcase { * file, and passes the path to the archive. * */ - public function test_add_storedfile_to_archive_file() { + public function test_add_storedfile_to_archive_file(): void { $file = $this->get_stored_file('example content'); $filepath = __LINE__; $archivepath = 'example'; @@ -780,7 +780,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::add_to_curl_request */ - public function test_add_to_curl_request() { + public function test_add_to_curl_request(): void { $file = $this->get_stored_file('example content'); $filepath = __FILE__; $archivepath = 'example'; @@ -804,7 +804,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::get_imageinfo */ - public function test_get_imageinfo_not_image() { + public function test_get_imageinfo_not_image(): void { $filecontent = 'example content'; $file = $this->get_stored_file($filecontent); @@ -825,7 +825,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::get_imageinfo */ - public function test_get_imageinfo() { + public function test_get_imageinfo(): void { $filepath = '/path/to/file'; $filecontent = 'example content'; $expectedresult = (object) []; @@ -861,7 +861,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::is_image_from_storedfile */ - public function test_is_image_empty_filesize() { + public function test_is_image_empty_filesize(): void { $filecontent = 'example content'; $file = $this->get_stored_file($filecontent, null, ['get_filesize']); @@ -882,7 +882,7 @@ class file_system_test extends \advanced_testcase { * @param bool $isimage Whether this mimetype should be detected as an image * @covers ::is_image_from_storedfile */ - public function test_is_image_from_storedfile_mimetype($mimetype, $isimage) { + public function test_is_image_from_storedfile_mimetype($mimetype, $isimage): void { $filecontent = 'example content'; $file = $this->get_stored_file($filecontent, null, ['get_mimetype']); @@ -900,7 +900,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::get_imageinfo_from_path */ - public function test_get_imageinfo_from_path() { + public function test_get_imageinfo_from_path(): void { $filepath = __DIR__ . "/fixtures/testimage.jpg"; // Get the filesystem mock. @@ -921,7 +921,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::get_imageinfo_from_path */ - public function test_get_imageinfo_from_path_no_image() { + public function test_get_imageinfo_from_path_no_image(): void { $filepath = __FILE__; // Get the filesystem mock. @@ -937,7 +937,7 @@ class file_system_test extends \advanced_testcase { * Test that get_imageinfo_from_path returns an appropriate response * for an svg image with viewbox attribute. */ - public function test_get_imageinfo_from_path_svg_viewbox() { + public function test_get_imageinfo_from_path_svg_viewbox(): void { $filepath = __DIR__ . '/fixtures/testimage_viewbox.svg'; // Get the filesystem mock. @@ -958,7 +958,7 @@ class file_system_test extends \advanced_testcase { * Test that get_imageinfo_from_path returns an appropriate response * for an svg image with width and height attributes. */ - public function test_get_imageinfo_from_path_svg_with_width_height() { + public function test_get_imageinfo_from_path_svg_with_width_height(): void { $filepath = __DIR__ . '/fixtures/testimage_width_height.svg'; // Get the filesystem mock. @@ -979,7 +979,7 @@ class file_system_test extends \advanced_testcase { * Test that get_imageinfo_from_path returns an appropriate response * for an svg image without attributes. */ - public function test_get_imageinfo_from_path_svg_without_attribute() { + public function test_get_imageinfo_from_path_svg_without_attribute(): void { $filepath = __DIR__ . '/fixtures/testimage.svg'; // Get the filesystem mock. @@ -1000,7 +1000,7 @@ class file_system_test extends \advanced_testcase { * Test that get_imageinfo_from_path returns an appropriate response * for a file which is not an correct svg. */ - public function test_get_imageinfo_from_path_svg_invalid() { + public function test_get_imageinfo_from_path_svg_invalid(): void { $filepath = __DIR__ . '/fixtures/testimage_error.svg'; // Get the filesystem mock. @@ -1017,7 +1017,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::get_content_file_handle */ - public function test_get_content_file_handle_default() { + public function test_get_content_file_handle_default(): void { $filecontent = 'example content'; $file = $this->get_stored_file($filecontent); @@ -1037,7 +1037,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::get_content_file_handle */ - public function test_get_content_file_handle_gz() { + public function test_get_content_file_handle_gz(): void { $filecontent = 'example content'; $file = $this->get_stored_file($filecontent); @@ -1056,7 +1056,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::get_content_file_handle */ - public function test_get_content_file_handle_invalid() { + public function test_get_content_file_handle_invalid(): void { $filecontent = 'example content'; $file = $this->get_stored_file($filecontent); @@ -1093,7 +1093,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::mimetype_from_hash */ - public function test_mimetype_from_hash_using_filename() { + public function test_mimetype_from_hash_using_filename(): void { $filepath = '/path/to/file/not/currently/on/disk'; $filecontent = 'example content'; $filename = 'test.jpg'; @@ -1112,7 +1112,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::mimetype_from_hash */ - public function test_mimetype_from_hash_using_file_content() { + public function test_mimetype_from_hash_using_file_content(): void { $filecontent = 'example content'; $contenthash = \file_storage::hash_from_string($filecontent); $filename = 'example'; @@ -1131,7 +1131,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::mimetype_from_hash */ - public function test_mimetype_from_hash_using_file_content_remote() { + public function test_mimetype_from_hash_using_file_content_remote(): void { $filepath = '/path/to/file/not/currently/on/disk'; $filecontent = 'example content'; $contenthash = \file_storage::hash_from_string($filecontent); @@ -1159,7 +1159,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::mimetype_from_storedfile */ - public function test_mimetype_from_storedfile_empty() { + public function test_mimetype_from_storedfile_empty(): void { $file = $this->get_stored_file(''); $fs = $this->get_testable_mock(); @@ -1173,7 +1173,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::mimetype_from_storedfile */ - public function test_mimetype_from_storedfile_using_filename() { + public function test_mimetype_from_storedfile_using_filename(): void { $filepath = '/path/to/file/not/currently/on/disk'; $fs = $this->get_testable_mock(['get_remote_path_from_storedfile']); $fs->method('get_remote_path_from_storedfile')->willReturn($filepath); @@ -1190,7 +1190,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::mimetype_from_storedfile */ - public function test_mimetype_from_storedfile_using_file_content() { + public function test_mimetype_from_storedfile_using_file_content(): void { $filepath = __DIR__ . "/fixtures/testimage.jpg"; $fs = $this->get_testable_mock(['get_local_path_from_hash']); $fs->method('get_local_path_from_hash')->willReturn($filepath); @@ -1207,7 +1207,7 @@ class file_system_test extends \advanced_testcase { * * @covers ::mimetype_from_storedfile */ - public function test_mimetype_from_storedfile_using_file_content_remote() { + public function test_mimetype_from_storedfile_using_file_content_remote(): void { $filepath = __DIR__ . "/fixtures/testimage.jpg"; $fs = $this->get_testable_mock([ diff --git a/lib/filestorage/tests/mbz_packer_test.php b/lib/filestorage/tests/mbz_packer_test.php index affed9f5f48..42e28d890d3 100644 --- a/lib/filestorage/tests/mbz_packer_test.php +++ b/lib/filestorage/tests/mbz_packer_test.php @@ -30,7 +30,7 @@ require_once($CFG->libdir . '/filestorage/file_progress.php'); */ class mbz_packer_test extends \advanced_testcase { - public function test_archive_with_both_options() { + public function test_archive_with_both_options(): void { global $CFG; $this->resetAfterTest(); @@ -99,7 +99,7 @@ class mbz_packer_test extends \advanced_testcase { /** * @dataProvider usezipbackups_provider */ - public function test_extract_to_pathname_returnvalue_successful($usezipbackups) { + public function test_extract_to_pathname_returnvalue_successful($usezipbackups): void { global $CFG; $this->resetAfterTest(); @@ -122,7 +122,7 @@ class mbz_packer_test extends \advanced_testcase { /** * @dataProvider usezipbackups_provider */ - public function test_extract_to_pathname_returnvalue_failure($usezipbackups) { + public function test_extract_to_pathname_returnvalue_failure($usezipbackups): void { global $CFG; $this->resetAfterTest(); diff --git a/lib/filestorage/tests/stored_file_test.php b/lib/filestorage/tests/stored_file_test.php index bc66972ccbc..bd07c47c283 100644 --- a/lib/filestorage/tests/stored_file_test.php +++ b/lib/filestorage/tests/stored_file_test.php @@ -35,7 +35,7 @@ class stored_file_test extends advanced_testcase { * an image that is not supposed to be rotated. * @covers ::rotate_image() */ - public function test_rotate_image_does_not_rotate_image() { + public function test_rotate_image_does_not_rotate_image(): void { global $CFG; $this->resetAfterTest(); @@ -64,7 +64,7 @@ class stored_file_test extends advanced_testcase { * that is supposed to be rotated. * @covers ::rotate_image() */ - public function test_rotate_image_rotates_image() { + public function test_rotate_image_rotates_image(): void { global $CFG; $this->resetAfterTest(); diff --git a/lib/filestorage/tests/tgz_packer_test.php b/lib/filestorage/tests/tgz_packer_test.php index 22ca0f1505b..20dc7e3b811 100644 --- a/lib/filestorage/tests/tgz_packer_test.php +++ b/lib/filestorage/tests/tgz_packer_test.php @@ -107,7 +107,7 @@ class tgz_packer_test extends \advanced_testcase implements file_progress { /** * Tests getting the item. */ - public function test_get_packer() { + public function test_get_packer(): void { $packer = get_file_packer('application/x-gzip'); $this->assertInstanceOf('tgz_packer', $packer); } @@ -115,7 +115,7 @@ class tgz_packer_test extends \advanced_testcase implements file_progress { /** * Tests basic archive and extract to file paths. */ - public function test_to_normal_files() { + public function test_to_normal_files(): void { global $CFG; $packer = get_file_packer('application/x-gzip'); @@ -156,7 +156,7 @@ class tgz_packer_test extends \advanced_testcase implements file_progress { /** * Tests archive and extract to Moodle file system. */ - public function test_to_stored_files() { + public function test_to_stored_files(): void { global $CFG; $packer = get_file_packer('application/x-gzip'); @@ -222,7 +222,7 @@ class tgz_packer_test extends \advanced_testcase implements file_progress { /** * Tests extracting with a list of specified files. */ - public function test_only_specified_files() { + public function test_only_specified_files(): void { global $CFG; $packer = get_file_packer('application/x-gzip'); @@ -254,7 +254,7 @@ class tgz_packer_test extends \advanced_testcase implements file_progress { /** * Tests extracting files returning only a boolean state with success. */ - public function test_extract_to_pathname_returnvalue_successful() { + public function test_extract_to_pathname_returnvalue_successful(): void { $packer = get_file_packer('application/x-gzip'); // Prepare files. @@ -272,7 +272,7 @@ class tgz_packer_test extends \advanced_testcase implements file_progress { /** * Tests extracting files returning only a boolean state with failure. */ - public function test_extract_to_pathname_returnvalue_failure() { + public function test_extract_to_pathname_returnvalue_failure(): void { $packer = get_file_packer('application/x-gzip'); // Create sample files. @@ -290,7 +290,7 @@ class tgz_packer_test extends \advanced_testcase implements file_progress { /** * Tests the progress reporting. */ - public function test_file_progress() { + public function test_file_progress(): void { global $CFG; // Set up. @@ -347,7 +347,7 @@ class tgz_packer_test extends \advanced_testcase implements file_progress { /** * Tests the list_files function with and without an index file. */ - public function test_list_files() { + public function test_list_files(): void { global $CFG; // Set up. @@ -414,7 +414,7 @@ class tgz_packer_test extends \advanced_testcase implements file_progress { return $actualinfo; } - public function test_is_tgz_file() { + public function test_is_tgz_file(): void { global $CFG; // Set up. diff --git a/lib/filestorage/tests/zip_packer_test.php b/lib/filestorage/tests/zip_packer_test.php index 41ea6bfffe7..ca4eabec019 100644 --- a/lib/filestorage/tests/zip_packer_test.php +++ b/lib/filestorage/tests/zip_packer_test.php @@ -65,7 +65,7 @@ class zip_packer_test extends \advanced_testcase implements file_progress { ); } - public function test_get_packer() { + public function test_get_packer(): void { $this->resetAfterTest(false); $packer = get_file_packer(); $this->assertInstanceOf('zip_packer', $packer); @@ -77,7 +77,7 @@ class zip_packer_test extends \advanced_testcase implements file_progress { /** * @depends test_get_packer */ - public function test_list_files() { + public function test_list_files(): void { $this->resetAfterTest(false); $files = array( @@ -140,7 +140,7 @@ class zip_packer_test extends \advanced_testcase implements file_progress { /** * @depends test_list_files */ - public function test_archive_to_pathname() { + public function test_archive_to_pathname(): void { global $CFG; $this->resetAfterTest(false); @@ -198,7 +198,7 @@ class zip_packer_test extends \advanced_testcase implements file_progress { /** * @depends test_archive_to_pathname */ - public function test_archive_to_storage() { + public function test_archive_to_storage(): void { $this->resetAfterTest(false); $packer = get_file_packer('application/zip'); @@ -221,7 +221,7 @@ class zip_packer_test extends \advanced_testcase implements file_progress { /** * @depends test_archive_to_storage */ - public function test_extract_to_pathname() { + public function test_extract_to_pathname(): void { global $CFG; $this->resetAfterTest(false); @@ -264,7 +264,7 @@ class zip_packer_test extends \advanced_testcase implements file_progress { * * @link https://bugs.php.net/bug.php?id=77214 */ - public function test_zip_entry_path_having_folder_ending_with_dot() { + public function test_zip_entry_path_having_folder_ending_with_dot(): void { global $CFG; $this->resetAfterTest(false); @@ -335,7 +335,7 @@ class zip_packer_test extends \advanced_testcase implements file_progress { /** * @depends test_archive_to_storage */ - public function test_extract_to_pathname_onlyfiles() { + public function test_extract_to_pathname_onlyfiles(): void { global $CFG; $this->resetAfterTest(false); @@ -375,7 +375,7 @@ class zip_packer_test extends \advanced_testcase implements file_progress { /** * @depends test_archive_to_storage */ - public function test_extract_to_pathname_returnvalue_successful() { + public function test_extract_to_pathname_returnvalue_successful(): void { global $CFG; $this->resetAfterTest(false); @@ -393,7 +393,7 @@ class zip_packer_test extends \advanced_testcase implements file_progress { /** * @depends test_archive_to_storage */ - public function test_extract_to_pathname_returnvalue_failure() { + public function test_extract_to_pathname_returnvalue_failure(): void { global $CFG; $this->resetAfterTest(false); @@ -410,7 +410,7 @@ class zip_packer_test extends \advanced_testcase implements file_progress { /** * @depends test_archive_to_storage */ - public function test_extract_to_storage() { + public function test_extract_to_storage(): void { global $CFG; $this->resetAfterTest(false); @@ -450,7 +450,7 @@ class zip_packer_test extends \advanced_testcase implements file_progress { /** * @depends test_extract_to_storage */ - public function test_add_files() { + public function test_add_files(): void { global $CFG; $this->resetAfterTest(false); @@ -489,7 +489,7 @@ class zip_packer_test extends \advanced_testcase implements file_progress { unlink($archive); } - public function test_close_archive() { + public function test_close_archive(): void { global $CFG; $this->resetAfterTest(true); @@ -559,7 +559,7 @@ class zip_packer_test extends \advanced_testcase implements file_progress { /** * @depends test_add_files */ - public function test_open_archive() { + public function test_open_archive(): void { global $CFG; $this->resetAfterTest(true); @@ -606,7 +606,7 @@ class zip_packer_test extends \advanced_testcase implements file_progress { /** * Test opening an encrypted archive */ - public function test_open_encrypted_archive() { + public function test_open_encrypted_archive(): void { $this->resetAfterTest(); // The archive contains a single encrypted "hello.txt" file. @@ -624,7 +624,7 @@ class zip_packer_test extends \advanced_testcase implements file_progress { /** * Tests the progress reporting. */ - public function test_file_progress() { + public function test_file_progress(): void { global $CFG; // Set up. diff --git a/lib/form/tests/autocomplete_test.php b/lib/form/tests/autocomplete_test.php index 40f3ea79714..6ce54f0f268 100644 --- a/lib/form/tests/autocomplete_test.php +++ b/lib/form/tests/autocomplete_test.php @@ -36,7 +36,7 @@ class autocomplete_test extends \basic_testcase { /** * Testcase for validation */ - public function test_validation() { + public function test_validation(): void { // A default select with single values validates the data. $options = array('1' => 'One', 2 => 'Two'); $element = new MoodleQuickForm_autocomplete('testel', null, $options); diff --git a/lib/form/tests/course_test.php b/lib/form/tests/course_test.php index dcd104a8669..9bd3c074e8d 100644 --- a/lib/form/tests/course_test.php +++ b/lib/form/tests/course_test.php @@ -36,7 +36,7 @@ class course_test extends \basic_testcase { /** * Test constructor supports all declared attributes. */ - public function test_constructor_attributes() { + public function test_constructor_attributes(): void { $attributes = [ 'exclude' => [1, 2], 'requiredcapabilities' => ['moodle/course:update'], diff --git a/lib/form/tests/dateselector_test.php b/lib/form/tests/dateselector_test.php index b3f1cd1fb44..af34f17cc1e 100644 --- a/lib/form/tests/dateselector_test.php +++ b/lib/form/tests/dateselector_test.php @@ -124,7 +124,7 @@ class dateselector_test extends \advanced_testcase { /** * Testcase to check exportvalue */ - public function test_exportvalue() { + public function test_exportvalue(): void { global $USER; $testvals = $this->testvals; @@ -146,7 +146,7 @@ class dateselector_test extends \advanced_testcase { /** * Testcase to check onQuickformEvent */ - public function test_onquickformevent() { + public function test_onquickformevent(): void { global $USER; $testvals = $this->testvals; // Get dummy form for data. diff --git a/lib/form/tests/datetimeselector_test.php b/lib/form/tests/datetimeselector_test.php index e33983e9ed1..235c43343c9 100644 --- a/lib/form/tests/datetimeselector_test.php +++ b/lib/form/tests/datetimeselector_test.php @@ -136,7 +136,7 @@ class datetimeselector_test extends \advanced_testcase { /** * Testcase to check exportvalue */ - public function test_exportvalue() { + public function test_exportvalue(): void { global $USER; $testvals = $this->testvals; @@ -158,7 +158,7 @@ class datetimeselector_test extends \advanced_testcase { /** * Testcase to check onQuickformEvent */ - public function test_onquickformevent() { + public function test_onquickformevent(): void { global $USER; $testvals = $this->testvals; // Get dummy form for data. diff --git a/lib/form/tests/duration_test.php b/lib/form/tests/duration_test.php index a19ce851e20..5158f8f6391 100644 --- a/lib/form/tests/duration_test.php +++ b/lib/form/tests/duration_test.php @@ -135,7 +135,7 @@ class duration_test extends \basic_testcase { /** * Testcase for testing conversion of seconds to the best possible unit with a non-default default unit. */ - public function test_seconds_to_unit_different_default_unit() { + public function test_seconds_to_unit_different_default_unit(): void { $mform = $this->get_test_form(); $element = $mform->addElement('duration', 'testel', null, ['defaultunit' => DAYSECS, 'optional' => false]); diff --git a/lib/form/tests/external_test.php b/lib/form/tests/external_test.php index 95dfb38332f..34f8ba7121e 100644 --- a/lib/form/tests/external_test.php +++ b/lib/form/tests/external_test.php @@ -43,7 +43,7 @@ class external_test extends advanced_testcase { /** * Test the core_form_get_filetypes_browser_data external function */ - public function test_get_filetypes_browser_data() { + public function test_get_filetypes_browser_data(): void { $data = external::get_filetypes_browser_data('', true, ''); $data = external_api::clean_returnvalue(external::get_filetypes_browser_data_returns(), $data); diff --git a/lib/form/tests/filetypes_util_test.php b/lib/form/tests/filetypes_util_test.php index f1702741d37..d932964423f 100644 --- a/lib/form/tests/filetypes_util_test.php +++ b/lib/form/tests/filetypes_util_test.php @@ -42,7 +42,7 @@ class filetypes_util_test extends advanced_testcase { /** * Test normalizing list of extensions. */ - public function test_normalize_file_types() { + public function test_normalize_file_types(): void { $this->resetAfterTest(true); $util = new filetypes_util(); @@ -74,7 +74,7 @@ class filetypes_util_test extends advanced_testcase { /** * Test MIME type formal recognition. */ - public function test_looks_like_mimetype() { + public function test_looks_like_mimetype(): void { $this->resetAfterTest(true); $util = new filetypes_util(); @@ -93,7 +93,7 @@ class filetypes_util_test extends advanced_testcase { /** * Test getting/checking group. */ - public function test_is_filetype_group() { + public function test_is_filetype_group(): void { $this->resetAfterTest(true); $util = new filetypes_util(); @@ -111,7 +111,7 @@ class filetypes_util_test extends advanced_testcase { /** * Test describing list of extensions. */ - public function test_describe_file_types() { + public function test_describe_file_types(): void { $this->resetAfterTest(true); $util = new filetypes_util(); @@ -169,7 +169,7 @@ class filetypes_util_test extends advanced_testcase { /** * Test expanding mime types into extensions. */ - public function test_expand() { + public function test_expand(): void { $this->resetAfterTest(true); $util = new filetypes_util(); @@ -207,7 +207,7 @@ class filetypes_util_test extends advanced_testcase { /** * Test checking that a type is among others. */ - public function test_is_listed() { + public function test_is_listed(): void { $this->resetAfterTest(true); $util = new filetypes_util(); @@ -250,7 +250,7 @@ class filetypes_util_test extends advanced_testcase { /** * Test getting types not present in a list. */ - public function test_get_not_listed() { + public function test_get_not_listed(): void { $this->resetAfterTest(true); $util = new filetypes_util(); @@ -411,7 +411,7 @@ class filetypes_util_test extends advanced_testcase { * @param string $list The space , or ; separated list of types supported * @param boolean $expected The expected result. True if the file is allowed, false if not. */ - public function test_is_allowed_file_type($filename, $list, $expected) { + public function test_is_allowed_file_type($filename, $list, $expected): void { $util = new filetypes_util(); $this->assertSame($expected, $util->is_allowed_file_type($filename, $list)); } @@ -480,7 +480,7 @@ class filetypes_util_test extends advanced_testcase { * @param string $filetypes The filetypes to check * @param array $expected The expected result. The list of non existant file types. */ - public function test_get_unknown_file_types($filetypes, $expected) { + public function test_get_unknown_file_types($filetypes, $expected): void { $util = new filetypes_util(); $this->assertSame($expected, $util->get_unknown_file_types($filetypes)); } diff --git a/lib/form/tests/float_test.php b/lib/form/tests/float_test.php index 6f769dd032c..71e3cbde5b9 100644 --- a/lib/form/tests/float_test.php +++ b/lib/form/tests/float_test.php @@ -56,7 +56,7 @@ class float_test extends \advanced_testcase { /** * Testcase to check generated timestamp */ - public function test_exportValue() { + public function test_exportValue(): void { $element = new MoodleQuickForm_float('testel'); $value = ['testel' => 3.14]; diff --git a/lib/form/tests/privacy/provider_test.php b/lib/form/tests/privacy/provider_test.php index dc42e39b204..f8c728f4781 100644 --- a/lib/form/tests/privacy/provider_test.php +++ b/lib/form/tests/privacy/provider_test.php @@ -40,7 +40,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * When no preference exists, there should be no export. */ - public function test_no_preference() { + public function test_no_preference(): void { global $USER; $this->resetAfterTest(); $this->setAdminUser(); @@ -56,7 +56,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { * @param string $val Value of the preference filemanager_recentviewmode * @param string $desc Text describing the preference */ - public function test_filemanager_recentviewmode(string $val, string $desc) { + public function test_filemanager_recentviewmode(string $val, string $desc): void { $this->resetAfterTest(); // Create test user, add some preferences. diff --git a/lib/grade/tests/grade_category_test.php b/lib/grade/tests/grade_category_test.php index 46f8c53ad8f..0e3a934f618 100644 --- a/lib/grade/tests/grade_category_test.php +++ b/lib/grade/tests/grade_category_test.php @@ -31,7 +31,7 @@ require_once(__DIR__.'/fixtures/lib.php'); */ class grade_category_test extends \grade_base_testcase { - public function test_grade_category() { + public function test_grade_category(): void { $this->sub_test_grade_category_construct(); $this->sub_test_grade_category_build_path(); $this->sub_test_grade_category_fetch(); diff --git a/lib/grade/tests/grade_grade_test.php b/lib/grade/tests/grade_grade_test.php index ab6b768cfbe..73a32d98a35 100644 --- a/lib/grade/tests/grade_grade_test.php +++ b/lib/grade/tests/grade_grade_test.php @@ -30,7 +30,7 @@ require_once(__DIR__.'/fixtures/lib.php'); */ class grade_grade_test extends \grade_base_testcase { - public function test_grade_grade() { + public function test_grade_grade(): void { $this->sub_test_grade_grade_construct(); $this->sub_test_grade_grade_insert(); $this->sub_test_grade_grade_update(); @@ -206,7 +206,7 @@ class grade_grade_test extends \grade_base_testcase { * * @covers \grade_grade::flatten_dependencies_array() */ - public function test_flatten_dependencies() { + public function test_flatten_dependencies(): void { // First test a simple normal case. $a = array(1 => array(2, 3), 2 => array(), 3 => array(4), 4 => array()); $b = array(); @@ -303,7 +303,7 @@ class grade_grade_test extends \grade_base_testcase { $this->assertSame($expectedb, $b); } - public function test_grade_grade_min_max() { + public function test_grade_grade_min_max(): void { global $CFG; $initialminmaxtouse = $CFG->grade_minmaxtouse; @@ -372,7 +372,7 @@ class grade_grade_test extends \grade_base_testcase { $CFG->grade_minmaxtouse = $initialminmaxtouse; } - public function test_grade_grade_min_max_with_course_item() { + public function test_grade_grade_min_max_with_course_item(): void { global $CFG, $DB; $initialminmaxtouse = $CFG->grade_minmaxtouse; @@ -432,7 +432,7 @@ class grade_grade_test extends \grade_base_testcase { $CFG->grade_minmaxtouse = $initialminmaxtouse; } - public function test_grade_grade_min_max_with_category_item() { + public function test_grade_grade_min_max_with_category_item(): void { global $CFG, $DB; $initialminmaxtouse = $CFG->grade_minmaxtouse; @@ -644,7 +644,7 @@ class grade_grade_test extends \grade_base_testcase { /** * Tests get_hiding_affected by locked category and overridden grades. */ - public function test_category_get_hiding_affected() { + public function test_category_get_hiding_affected(): void { $generator = $this->getDataGenerator(); // Create the data we need for the tests. diff --git a/lib/grade/tests/grade_item_test.php b/lib/grade/tests/grade_item_test.php index 53925e0a159..c3352022be8 100644 --- a/lib/grade/tests/grade_item_test.php +++ b/lib/grade/tests/grade_item_test.php @@ -29,7 +29,7 @@ require_once(__DIR__.'/fixtures/lib.php'); * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class grade_item_test extends \grade_base_testcase { - public function test_grade_item() { + public function test_grade_item(): void { $this->sub_test_grade_item_construct(); $this->sub_test_grade_item_insert(); $this->sub_test_grade_item_delete(); @@ -818,7 +818,7 @@ class grade_item_test extends \grade_base_testcase { return $DB->get_record('grade_items', array('id' => $item->id)); } - public function test_set_aggregation_fields_for_aggregation() { + public function test_set_aggregation_fields_for_aggregation(): void { $course = $this->getDataGenerator()->create_course(); $gi = new \grade_item(array('courseid' => $course->id, 'itemtype' => 'manual'), false); @@ -1071,7 +1071,7 @@ class grade_item_test extends \grade_base_testcase { /** * Test grade item duplication expecting success. */ - public function test_grade_duplicate_grade_item_success() { + public function test_grade_duplicate_grade_item_success(): void { $cat = new \grade_category(); $cat->courseid = $this->courseid; $cat->fullname = 'Grade category'; @@ -1111,7 +1111,7 @@ class grade_item_test extends \grade_base_testcase { /** * Test grade item duplication exception expected with incomplete grade item. */ - public function test_grade_duplicate_grade_item_incomplete() { + public function test_grade_duplicate_grade_item_incomplete(): void { // Grade item is not valid because it is empty. $gi = new \grade_item(); $gi->courseid = $this->courseid; @@ -1122,7 +1122,7 @@ class grade_item_test extends \grade_base_testcase { /** * Test grade item duplication exception expected because item must be in db. */ - public function test_grade_duplicate_grade_item_not_in_db() { + public function test_grade_duplicate_grade_item_not_in_db(): void { $cat = new \grade_category(); $cat->courseid = $this->courseid; $cat->fullname = 'Grade category'; diff --git a/lib/grade/tests/grade_object_test.php b/lib/grade/tests/grade_object_test.php index 4ad43e1c814..1d1cf58481e 100644 --- a/lib/grade/tests/grade_object_test.php +++ b/lib/grade/tests/grade_object_test.php @@ -30,7 +30,7 @@ require_once(__DIR__ . '/fixtures/lib.php'); */ class grade_object_test extends \grade_base_testcase { - public function test_fetch_all_helper() { + public function test_fetch_all_helper(): void { // Simple ID lookup. $params = array('id' => $this->grade_items[0]->id); $items = \grade_object::fetch_all_helper('grade_items', 'grade_item', $params); diff --git a/lib/grade/tests/grade_outcome_test.php b/lib/grade/tests/grade_outcome_test.php index 5e164346ad7..63a4121a70b 100644 --- a/lib/grade/tests/grade_outcome_test.php +++ b/lib/grade/tests/grade_outcome_test.php @@ -30,7 +30,7 @@ require_once(__DIR__.'/fixtures/lib.php'); */ class grade_outcome_test extends \grade_base_testcase { - public function test_grade_outcome() { + public function test_grade_outcome(): void { $this->sub_test_grade_outcome_construct(); $this->sub_test_grade_outcome_insert(); $this->sub_test_grade_outcome_update(); diff --git a/lib/grade/tests/grade_scale_test.php b/lib/grade/tests/grade_scale_test.php index 7af18c7a7e0..2b2ea9513d5 100644 --- a/lib/grade/tests/grade_scale_test.php +++ b/lib/grade/tests/grade_scale_test.php @@ -30,7 +30,7 @@ require_once(__DIR__.'/fixtures/lib.php'); */ class grade_scale_test extends \grade_base_testcase { - public function test_grade_scale() { + public function test_grade_scale(): void { $this->sub_test_scale_construct(); $this->sub_test_grade_scale_insert(); $this->sub_test_grade_scale_update(); diff --git a/lib/mlbackend/python/tests/processor_test.php b/lib/mlbackend/python/tests/processor_test.php index d14dd088ccc..f15b97d469f 100644 --- a/lib/mlbackend/python/tests/processor_test.php +++ b/lib/mlbackend/python/tests/processor_test.php @@ -34,14 +34,14 @@ class processor_test extends \advanced_testcase { * @param string $required A sample of the required package version * @param int $result Expected value returned by the tested method */ - public function test_check_pip_package_version($actual, $required, $result) { + public function test_check_pip_package_version($actual, $required, $result): void { $this->assertSame($result, \mlbackend_python\processor::check_pip_package_version($actual, $required)); } /** * Check that the {@link \mlbackend_python\processor::check_pip_package_version()} can be called with single argument. */ - public function test_check_pip_package_version_default() { + public function test_check_pip_package_version_default(): void { $this->assertSame(-1, \mlbackend_python\processor::check_pip_package_version('0.0.1')); $this->assertSame(0, \mlbackend_python\processor::check_pip_package_version( diff --git a/lib/phpunit/tests/advanced_test.php b/lib/phpunit/tests/advanced_test.php index 818bbe51bda..b876bacadf4 100644 --- a/lib/phpunit/tests/advanced_test.php +++ b/lib/phpunit/tests/advanced_test.php @@ -31,7 +31,7 @@ class advanced_test extends \advanced_testcase { require_once(__DIR__ . '/fixtures/adhoc_test_task.php'); } - public function test_debugging() { + public function test_debugging(): void { global $CFG; $this->resetAfterTest(); @@ -76,7 +76,7 @@ class advanced_test extends \advanced_testcase { $this->assertDebuggingCalled('pokus', DEBUG_MINIMAL); } - public function test_set_user() { + public function test_set_user(): void { global $USER, $DB, $SESSION; $this->resetAfterTest(); @@ -123,7 +123,7 @@ class advanced_test extends \advanced_testcase { $this->assertObjectNotHasProperty('sometestvalue', $SESSION); } - public function test_set_admin_user() { + public function test_set_admin_user(): void { global $USER; $this->resetAfterTest(); @@ -133,7 +133,7 @@ class advanced_test extends \advanced_testcase { $this->assertTrue(is_siteadmin()); } - public function test_set_guest_user() { + public function test_set_guest_user(): void { global $USER; $this->resetAfterTest(); @@ -143,7 +143,7 @@ class advanced_test extends \advanced_testcase { $this->assertTrue(isguestuser()); } - public function test_database_reset() { + public function test_database_reset(): void { global $DB; $this->resetAfterTest(); @@ -206,7 +206,7 @@ class advanced_test extends \advanced_testcase { $this->assertEquals(2, $DB->count_records('user')); } - public function test_change_detection() { + public function test_change_detection(): void { global $DB, $CFG, $COURSE, $SITE, $USER; $this->preventResetByRollback(); @@ -287,12 +287,12 @@ class advanced_test extends \advanced_testcase { } } - public function test_getDataGenerator() { + public function test_getDataGenerator(): void { $generator = $this->getDataGenerator(); $this->assertInstanceOf('testing_data_generator', $generator); } - public function test_database_mock1() { + public function test_database_mock1(): void { global $DB; try { @@ -306,14 +306,14 @@ class advanced_test extends \advanced_testcase { // Rest continues after reset. } - public function test_database_mock2() { + public function test_database_mock2(): void { global $DB; // Now the database should be back to normal. $this->assertFalse($DB->get_record('user', array('id'=>9999))); } - public function test_assert_time_current() { + public function test_assert_time_current(): void { $this->assertTimeCurrent(time()); $this->setCurrentTimeStart(); @@ -395,7 +395,7 @@ class advanced_test extends \advanced_testcase { ]; } - public function test_message_processors_reset() { + public function test_message_processors_reset(): void { global $DB; $this->resetAfterTest(true); @@ -544,7 +544,7 @@ class advanced_test extends \advanced_testcase { /** * @depends test_message_redirection */ - public function test_message_redirection_noreset($sink) { + public function test_message_redirection_noreset($sink): void { if ($this->isInIsolation()) { $this->markTestSkipped('State cannot be carried over between tests in isolated tests'); } @@ -575,11 +575,11 @@ class advanced_test extends \advanced_testcase { /** * @depends test_message_redirection_noreset */ - public function test_message_redirection_reset() { + public function test_message_redirection_reset(): void { $this->assertFalse(\phpunit_util::is_redirecting_messages(), 'Test reset must stop message redirection.'); } - public function test_set_timezone() { + public function test_set_timezone(): void { global $CFG; $this->resetAfterTest(); @@ -622,7 +622,7 @@ class advanced_test extends \advanced_testcase { } - public function test_locale_reset() { + public function test_locale_reset(): void { global $CFG; $this->resetAfterTest(); @@ -671,7 +671,7 @@ class advanced_test extends \advanced_testcase { /** * This test sets a user agent and makes sure that it is cleared when the test is reset. */ - public function test_it_resets_useragent_after_test() { + public function test_it_resets_useragent_after_test(): void { $this->resetAfterTest(); $fakeagent = 'New user agent set.'; diff --git a/lib/phpunit/tests/basic_test.php b/lib/phpunit/tests/basic_test.php index 361963f0900..500ff3eb63b 100644 --- a/lib/phpunit/tests/basic_test.php +++ b/lib/phpunit/tests/basic_test.php @@ -42,7 +42,7 @@ class basic_test extends \basic_testcase { * Tests that bootstrapping has occurred correctly * @return void */ - public function test_bootstrap() { + public function test_bootstrap(): void { global $CFG; // The httpswwwroot has been deprecated, we keep it as an alias for backwards compatibility with plugins only. @@ -55,7 +55,7 @@ class basic_test extends \basic_testcase { * This is just a verification if I understand the PHPUnit assert docs right --skodak * @return void */ - public function test_assert_behaviour() { + public function test_assert_behaviour(): void { // Arrays. $a = array('a', 'b', 'c'); $b = array('a', 'c', 'b'); @@ -120,7 +120,7 @@ class basic_test extends \basic_testcase { * Make sure there are no sloppy Windows line endings * that would break our tests. */ - public function test_lineendings() { + public function test_lineendings(): void { $string = <<assertTrue($this->testassertexecuted); $this->testassertexecuted = false; } @@ -140,7 +140,7 @@ STRING; /** * Test assert Tag */ - public function test_assert_tag() { + public function test_assert_tag(): void { // This should succeed. self::assertTag(['id' => 'testid'], "
"); $this->expectException(\PHPUnit\Framework\ExpectationFailedException::class); diff --git a/lib/phpunit/tests/phpunit_dataset_test.php b/lib/phpunit/tests/phpunit_dataset_test.php index 262ef52befb..c0c1cd64d6f 100644 --- a/lib/phpunit/tests/phpunit_dataset_test.php +++ b/lib/phpunit/tests/phpunit_dataset_test.php @@ -42,7 +42,7 @@ class phpunit_dataset_test extends advanced_testcase { /** * @covers ::from_files */ - public function test_from_files() { + public function test_from_files(): void { $ds = new phpunit_dataset(); @@ -148,7 +148,7 @@ class phpunit_dataset_test extends advanced_testcase { * @covers ::from_file */ public function test_from_file(string $fullpath, string $tablename, ?string $exception, - array $tables, array $columns, array $rows) { + array $tables, array $columns, array $rows): void { $ds = new phpunit_dataset(); @@ -238,7 +238,7 @@ class phpunit_dataset_test extends advanced_testcase { * @covers ::from_string */ public function test_from_string(string $content, string $type, string $tablename, ?string $exception, - array $tables, array $columns, array $rows) { + array $tables, array $columns, array $rows): void { $ds = new phpunit_dataset(); @@ -381,7 +381,7 @@ class phpunit_dataset_test extends advanced_testcase { * @covers ::from_array */ public function test_from_array(array $structure, ?string $exception, - array $tables, array $columns, array $rows, ?bool $repeated = false) { + array $tables, array $columns, array $rows, ?bool $repeated = false): void { $ds = new phpunit_dataset(); @@ -472,7 +472,7 @@ class phpunit_dataset_test extends advanced_testcase { * @covers ::load_csv */ public function test_load_csv(array $files, ?string $exception, - array $tables, array $columns, array $rows) { + array $tables, array $columns, array $rows): void { $ds = new phpunit_dataset(); @@ -640,7 +640,7 @@ class phpunit_dataset_test extends advanced_testcase { * @covers ::load_xml */ public function test_load_xml(array $files, ?string $exception, - array $tables, array $columns, array $rows) { + array $tables, array $columns, array $rows): void { $ds = new phpunit_dataset(); @@ -908,7 +908,7 @@ class phpunit_dataset_test extends advanced_testcase { * @dataProvider get_rows_provider * @covers ::get_rows */ - public function test_get_rows(array $files, array $filter, ?string $exception, array $rows) { + public function test_get_rows(array $files, array $filter, ?string $exception, array $rows): void { $ds = new phpunit_dataset(); diff --git a/lib/phpunit/tests/util_test.php b/lib/phpunit/tests/util_test.php index 4676e4177a3..5109333b9f8 100644 --- a/lib/phpunit/tests/util_test.php +++ b/lib/phpunit/tests/util_test.php @@ -28,7 +28,7 @@ class util_test extends \advanced_testcase { /** * @dataProvider set_table_modified_by_sql_provider */ - public function test_set_table_modified_by_sql($sql, $expectations) { + public function test_set_table_modified_by_sql($sql, $expectations): void { \phpunit_util::reset_updated_table_list(); \phpunit_util::set_table_modified_by_sql($sql); foreach ($expectations as $table => $present) { diff --git a/lib/testing/tests/testing_generator_test.php b/lib/testing/tests/testing_generator_test.php index 7b6c6d519d1..472cc273c95 100644 --- a/lib/testing/tests/testing_generator_test.php +++ b/lib/testing/tests/testing_generator_test.php @@ -26,19 +26,19 @@ namespace core; * @covers \core\testing_data_generator */ class testing_generator_test extends \advanced_testcase { - public function test_get_plugin_generator_good_case() { + public function test_get_plugin_generator_good_case(): void { $generator = $this->getDataGenerator()->get_plugin_generator('core_question'); $this->assertInstanceOf('core_question_generator', $generator); } - public function test_get_plugin_generator_sloppy_name() { + public function test_get_plugin_generator_sloppy_name(): void { $generator = $this->getDataGenerator()->get_plugin_generator('quiz'); $this->assertDebuggingCalled('Please specify the component you want a generator for as ' . 'mod_quiz, not quiz.', DEBUG_DEVELOPER); $this->assertInstanceOf('mod_quiz_generator', $generator); } - public function test_get_default_generator() { + public function test_get_default_generator(): void { $generator = $this->getDataGenerator()->get_plugin_generator('block_somethingthatdoesnotexist'); $this->assertInstanceOf('default_block_generator', $generator); } @@ -46,13 +46,13 @@ class testing_generator_test extends \advanced_testcase { /** * Test plugin generator, with no component directory. */ - public function test_get_plugin_generator_no_component_dir() { + public function test_get_plugin_generator_no_component_dir(): void { $this->expectException(\coding_exception::class); $this->expectExceptionMessage('Component core_cohort does not support generators yet. Missing tests/generator/lib.php.'); $generator = $this->getDataGenerator()->get_plugin_generator('core_cohort'); } - public function test_create_user() { + public function test_create_user(): void { global $DB, $CFG; require_once($CFG->dirroot.'/user/lib.php'); @@ -129,7 +129,7 @@ class testing_generator_test extends \advanced_testcase { $this->assertSame('Cats, Dogs', $userdetails['interests']); } - public function test_create() { + public function test_create(): void { global $DB; $this->resetAfterTest(true); @@ -212,7 +212,7 @@ class testing_generator_test extends \advanced_testcase { } } - public function test_create_module() { + public function test_create_module(): void { global $CFG, $SITE, $DB; $this->setAdminUser(); @@ -370,7 +370,7 @@ class testing_generator_test extends \advanced_testcase { $this->assertEquals($optionsavailability['availability'], $cm4->availability); } - public function test_create_block() { + public function test_create_block(): void { global $CFG; if (!file_exists("$CFG->dirroot/blocks/online_users/")) { $this->markTestSkipped('Can not find standard Online users block'); @@ -383,7 +383,7 @@ class testing_generator_test extends \advanced_testcase { $this->assertNotEmpty($page); } - public function test_enrol_user() { + public function test_enrol_user(): void { global $DB; $this->resetAfterTest(); @@ -470,7 +470,7 @@ class testing_generator_test extends \advanced_testcase { $this->assertFalse($result); } - public function test_create_grade_category() { + public function test_create_grade_category(): void { global $DB, $CFG; require_once $CFG->libdir . '/grade/constants.php'; @@ -500,7 +500,7 @@ class testing_generator_test extends \advanced_testcase { $this->assertEquals($gradecategory->id, $gradecategory2->parent); } - public function test_create_custom_profile_field_category() { + public function test_create_custom_profile_field_category(): void { global $DB; $this->resetAfterTest(); @@ -532,7 +532,7 @@ class testing_generator_test extends \advanced_testcase { $this->assertEquals(10, $record->sortorder); } - public function test_create_custom_profile_field() { + public function test_create_custom_profile_field(): void { global $DB; $this->resetAfterTest(); diff --git a/lib/tests/accesslib_has_capability_test.php b/lib/tests/accesslib_has_capability_test.php index 8a274c6c6fd..b63210c375d 100644 --- a/lib/tests/accesslib_has_capability_test.php +++ b/lib/tests/accesslib_has_capability_test.php @@ -42,7 +42,7 @@ class accesslib_has_capability_test extends \advanced_testcase { * @param string[] $lockedcontexts The list of contexts, by name, to mark as locked * @param string[] $blocked The list of contexts which will be 'blocked' by has_capability */ - public function test_locked_contexts($lockedcontexts, $blocked) { + public function test_locked_contexts($lockedcontexts, $blocked): void { global $DB; $this->resetAfterTest(); @@ -207,7 +207,7 @@ class accesslib_has_capability_test extends \advanced_testcase { * @param string[] $lockedcontexts The list of contexts, by name, to mark as locked * @param string[] $blocked The list of contexts which will be 'blocked' by has_capability */ - public function test_locked_contexts_for_admin_with_config($lockedcontexts, $blocked) { + public function test_locked_contexts_for_admin_with_config($lockedcontexts, $blocked): void { global $DB; $this->resetAfterTest(); diff --git a/lib/tests/accesslib_test.php b/lib/tests/accesslib_test.php index dd210c7c264..be464e2f660 100644 --- a/lib/tests/accesslib_test.php +++ b/lib/tests/accesslib_test.php @@ -45,7 +45,7 @@ class accesslib_test extends advanced_testcase { /** * Verify comparison of context instances in phpunit asserts. */ - public function test_context_comparisons() { + public function test_context_comparisons(): void { $frontpagecontext1 = context_course::instance(SITEID); context_helper::reset_caches(); $frontpagecontext2 = context_course::instance(SITEID); @@ -61,7 +61,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::accesslib_clear_all_caches_for_unit_testing */ - public function test_accesslib_clear_all_caches() { + public function test_accesslib_clear_all_caches(): void { global $ACCESSLIB_PRIVATE; $this->resetAfterTest(); @@ -78,7 +78,7 @@ class accesslib_test extends advanced_testcase { /** * Check modifying capability record is not exposed to other code. */ - public function test_capabilities_mutation() { + public function test_capabilities_mutation(): void { $oldcap = get_capability_info('moodle/site:config'); $cap = get_capability_info('moodle/site:config'); unset($cap->name); @@ -94,7 +94,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::get_role_access */ - public function test_get_role_access() { + public function test_get_role_access(): void { global $DB; $roles = $DB->get_records('role'); @@ -118,7 +118,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::get_guest_role */ - public function test_get_guest_role() { + public function test_get_guest_role(): void { global $CFG; $guest = get_guest_role(); @@ -133,7 +133,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::is_siteadmin */ - public function test_is_siteadmin() { + public function test_is_siteadmin(): void { global $DB, $CFG; $this->resetAfterTest(); @@ -177,7 +177,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::is_enrolled */ - public function test_is_enrolled() { + public function test_is_enrolled(): void { global $DB; $this->resetAfterTest(); @@ -229,7 +229,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::isloggedin */ - public function test_isloggedin() { + public function test_isloggedin(): void { global $USER; $this->resetAfterTest(); @@ -245,7 +245,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::isguestuser */ - public function test_isguestuser() { + public function test_isguestuser(): void { global $DB; $this->resetAfterTest(); @@ -274,7 +274,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::is_safe_capability */ - public function test_is_safe_capability() { + public function test_is_safe_capability(): void { global $DB; // Note: there is not much to test, just make sure no notices are throw for the most dangerous cap. $capability = $DB->get_record('capabilities', array('name'=>'moodle/site:config'), '*', MUST_EXIST); @@ -286,7 +286,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::get_context_info_array */ - public function test_get_context_info_array() { + public function test_get_context_info_array(): void { $this->resetAfterTest(); $syscontext = context_system::instance(); @@ -355,7 +355,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::has_coursecontact_role */ - public function test_has_coursecontact_role() { + public function test_has_coursecontact_role(): void { global $DB, $CFG; $this->resetAfterTest(); @@ -381,7 +381,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::create_role */ - public function test_create_role() { + public function test_create_role(): void { global $DB; $this->resetAfterTest(); @@ -415,7 +415,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::assign_capability */ - public function test_assign_capability() { + public function test_assign_capability(): void { global $DB, $USER; $this->resetAfterTest(); @@ -490,7 +490,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::unassign_capability */ - public function test_unassign_capability() { + public function test_unassign_capability(): void { global $DB, $USER; $this->resetAfterTest(); @@ -542,7 +542,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::role_assign */ - public function test_role_assign() { + public function test_role_assign(): void { global $DB, $USER; $this->resetAfterTest(); @@ -599,7 +599,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::role_unassign */ - public function test_role_unassign() { + public function test_role_unassign(): void { global $DB, $USER; $this->resetAfterTest(); @@ -645,7 +645,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::role_unassign_all */ - public function test_role_unassign_all() { + public function test_role_unassign_all(): void { global $DB; $this->resetAfterTest(); @@ -702,7 +702,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::get_roles_with_capability */ - public function test_get_roles_with_capability() { + public function test_get_roles_with_capability(): void { global $DB; $this->resetAfterTest(); @@ -737,7 +737,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::delete_role */ - public function test_delete_role() { + public function test_delete_role(): void { global $DB; $this->resetAfterTest(); @@ -792,7 +792,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::get_all_roles */ - public function test_get_all_roles() { + public function test_get_all_roles(): void { global $DB; $this->resetAfterTest(); @@ -849,7 +849,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::get_role_archetypes */ - public function test_get_role_archetypes() { + public function test_get_role_archetypes(): void { $archetypes = get_role_archetypes(); $this->assertCount(8, $archetypes); // There are 8 archetypes in standard install. foreach ($archetypes as $k => $v) { @@ -862,7 +862,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::get_archetype_roles */ - public function test_get_archetype_roles() { + public function test_get_archetype_roles(): void { $this->resetAfterTest(); // New install should have at least 1 role for each archetype. @@ -884,7 +884,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::role_get_name */ - public function test_role_get_name() { + public function test_role_get_name(): void { global $DB; $this->resetAfterTest(); @@ -937,7 +937,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::role_fix_names */ - public function test_role_fix_names() { + public function test_role_fix_names(): void { global $DB; $this->resetAfterTest(); @@ -995,7 +995,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::get_default_role_archetype_allows */ - public function test_get_default_role_archetype_allows() { + public function test_get_default_role_archetype_allows(): void { $archetypes = get_role_archetypes(); foreach ($archetypes as $archetype) { @@ -1046,7 +1046,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::core_role_set_assign_allowed */ - public function test_core_role_set_assign_allowed() { + public function test_core_role_set_assign_allowed(): void { global $DB, $CFG; $this->resetAfterTest(); @@ -1077,7 +1077,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::core_role_set_override_allowed */ - public function test_core_role_set_override_allowed() { + public function test_core_role_set_override_allowed(): void { global $DB, $CFG; $this->resetAfterTest(); @@ -1108,7 +1108,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::core_role_set_switch_allowed */ - public function test_core_role_set_switch_allowed() { + public function test_core_role_set_switch_allowed(): void { global $DB, $CFG; $this->resetAfterTest(); @@ -1139,7 +1139,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::core_role_set_view_allowed */ - public function test_core_role_set_view_allowed() { + public function test_core_role_set_view_allowed(): void { global $DB, $CFG; $this->resetAfterTest(); @@ -1170,7 +1170,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::get_assignable_roles */ - public function test_get_assignable_roles() { + public function test_get_assignable_roles(): void { global $DB; $this->resetAfterTest(); @@ -1279,7 +1279,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::get_assignable_roles */ - public function test_get_assignable_roles_distinct_usercount() { + public function test_get_assignable_roles_distinct_usercount(): void { global $DB; $this->resetAfterTest(true); @@ -1314,7 +1314,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::get_switchable_roles */ - public function test_get_switchable_roles() { + public function test_get_switchable_roles(): void { global $DB; $this->resetAfterTest(); @@ -1374,7 +1374,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::get_overridable_roles */ - public function test_get_overridable_roles() { + public function test_get_overridable_roles(): void { global $DB; $this->resetAfterTest(); @@ -1469,7 +1469,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::get_viewable_roles */ - public function test_get_viewable_roles_course() { + public function test_get_viewable_roles_course(): void { global $DB; $this->resetAfterTest(); @@ -1506,7 +1506,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::get_viewable_roles */ - public function test_get_viewable_roles_system() { + public function test_get_viewable_roles_system(): void { global $DB; $this->resetAfterTest(); @@ -1541,7 +1541,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::get_default_contextlevels */ - public function test_get_default_contextlevels() { + public function test_get_default_contextlevels(): void { $archetypes = get_role_archetypes(); $alllevels = context_helper::get_all_levels(); foreach ($archetypes as $archetype) { @@ -1558,7 +1558,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::set_role_contextlevels */ - public function test_set_role_contextlevels() { + public function test_set_role_contextlevels(): void { global $DB; $this->resetAfterTest(); @@ -1584,7 +1584,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::get_roles_for_contextlevels */ - public function test_get_roles_for_contextlevels() { + public function test_get_roles_for_contextlevels(): void { global $DB; $allroles = get_all_roles(); @@ -1606,7 +1606,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::get_default_enrol_roles */ - public function test_get_default_enrol_roles() { + public function test_get_default_enrol_roles(): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -1636,7 +1636,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::get_role_users */ - public function test_get_role_users() { + public function test_get_role_users(): void { global $DB; $this->resetAfterTest(); @@ -1741,7 +1741,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::get_roles_used_in_context */ - public function test_get_roles_used_in_context() { + public function test_get_roles_used_in_context(): void { global $DB; $this->resetAfterTest(); @@ -1783,7 +1783,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::get_user_roles_in_course */ - public function test_get_user_roles_in_course() { + public function test_get_user_roles_in_course(): void { global $DB, $CFG; $this->resetAfterTest(); @@ -1851,7 +1851,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::get_user_roles */ - public function test_get_user_roles() { + public function test_get_user_roles(): void { global $DB, $CFG; $this->resetAfterTest(); @@ -1891,7 +1891,7 @@ class accesslib_test extends advanced_testcase { * @covers ::has_any_capability * @covers ::has_all_capabilities */ - public function test_has_capability_and_friends() { + public function test_has_capability_and_friends(): void { global $DB; $this->resetAfterTest(); @@ -1989,7 +1989,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::get_deprecated_capability_info */ - public function test_get_deprecated_capability_info() { + public function test_get_deprecated_capability_info(): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); $coursecontext = context_course::instance($course->id); @@ -2008,7 +2008,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::get_deprecated_capability_info */ - public function test_get_deprecated_capability_info_through_has_capability() { + public function test_get_deprecated_capability_info_through_has_capability(): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); $coursecontext = context_course::instance($course->id); @@ -2027,7 +2027,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::get_deprecated_capability_info */ - public function test_get_deprecated_capability_info_through_get_user_capability_contexts() { + public function test_get_deprecated_capability_info_through_get_user_capability_contexts(): void { $this->resetAfterTest(); $category = $this->getDataGenerator()->create_category(); $course = $this->getDataGenerator()->create_course(['categoryid' => $category->id]); @@ -2051,7 +2051,7 @@ class accesslib_test extends advanced_testcase { * @dataProvider deprecated_capabilities_use_cases */ public function test_get_deprecated_capability_specific_cases(string $capability, array $debugmessages, - bool $expectedexisting) { + bool $expectedexisting): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); $coursecontext = context_course::instance($course->id); @@ -2122,7 +2122,7 @@ class accesslib_test extends advanced_testcase { * @covers ::get_with_capability_sql * @covers ::has_capability */ - public function test_fake_capability() { + public function test_fake_capability(): void { global $DB; $this->resetAfterTest(); @@ -2173,7 +2173,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::assign_capability */ - public function test_fake_capability_assign() { + public function test_fake_capability_assign(): void { global $DB; $this->resetAfterTest(); @@ -2198,7 +2198,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::unassign_capability */ - public function test_fake_capability_unassign() { + public function test_fake_capability_unassign(): void { global $DB; $this->resetAfterTest(); @@ -2225,7 +2225,7 @@ class accesslib_test extends advanced_testcase { * @covers ::get_role_definitions * @covers ::role_change_permission */ - public function test_role_definition_caching() { + public function test_role_definition_caching(): void { global $DB; $this->resetAfterTest(); @@ -2294,7 +2294,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::get_user_capability_course */ - public function test_get_user_capability_course() { + public function test_get_user_capability_course(): void { global $CFG, $USER; $this->resetAfterTest(); @@ -2481,7 +2481,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::get_user_capability_contexts */ - public function test_get_user_capability_contexts() { + public function test_get_user_capability_contexts(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator(); @@ -2579,7 +2579,7 @@ class accesslib_test extends advanced_testcase { * @covers ::guess_if_creator_will_have_course_capability * @covers ::has_capability */ - public function test_guess_if_creator_will_have_course_capability() { + public function test_guess_if_creator_will_have_course_capability(): void { global $DB, $CFG, $USER; $this->resetAfterTest(); @@ -2706,7 +2706,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::require_capability */ - public function test_require_capability() { + public function test_require_capability(): void { $this->resetAfterTest(); $syscontext = context_system::instance(); @@ -2749,7 +2749,7 @@ class accesslib_test extends advanced_testcase { * @covers ::groups_get_members_join * @covers ::get_suspended_userids */ - public function test_get_enrolled_sql_different_course() { + public function test_get_enrolled_sql_different_course(): void { global $DB; $this->resetAfterTest(); @@ -2788,7 +2788,7 @@ class accesslib_test extends advanced_testcase { * @covers ::groups_get_members_join * @covers ::get_suspended_userids */ - public function test_get_enrolled_sql_role_only() { + public function test_get_enrolled_sql_role_only(): void { global $DB; $this->resetAfterTest(); @@ -2824,7 +2824,7 @@ class accesslib_test extends advanced_testcase { * @covers ::groups_get_members_join * @covers ::get_suspended_userids */ - public function test_get_enrolled_sql_multiple_enrolments() { + public function test_get_enrolled_sql_multiple_enrolments(): void { global $DB; $this->resetAfterTest(); @@ -2881,7 +2881,7 @@ class accesslib_test extends advanced_testcase { * @covers ::groups_get_members_join * @covers ::get_suspended_userids */ - public function test_get_enrolled_sql_userswithgroups() { + public function test_get_enrolled_sql_userswithgroups(): void { $this->resetAfterTest(); $systemcontext = context_system::instance(); @@ -2930,7 +2930,7 @@ class accesslib_test extends advanced_testcase { * @covers ::groups_get_members_join * @covers ::get_suspended_userids */ - public function test_get_enrolled_sql_userswithoutgroup() { + public function test_get_enrolled_sql_userswithoutgroup(): void { global $DB; $this->resetAfterTest(); @@ -2972,7 +2972,7 @@ class accesslib_test extends advanced_testcase { * @covers ::groups_get_members_join * @covers ::get_suspended_userids */ - public function test_get_enrolled_sql_userswithhiddengroups() { + public function test_get_enrolled_sql_userswithhiddengroups(): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -3160,7 +3160,7 @@ class accesslib_test extends advanced_testcase { * @covers ::get_enrolled_users * @covers ::get_suspended_userids */ - public function test_get_enrolled_sql_course($users, $counts) { + public function test_get_enrolled_sql_course($users, $counts): void { global $DB; $this->resetAfterTest(); @@ -3224,7 +3224,7 @@ class accesslib_test extends advanced_testcase { /** * A small functional test of permission evaluations. */ - public function test_permission_evaluation() { + public function test_permission_evaluation(): void { global $USER, $SITE, $CFG, $DB, $ACCESSLIB_PRIVATE; $this->resetAfterTest(); @@ -4090,7 +4090,7 @@ class accesslib_test extends advanced_testcase { * * @covers \context_system::get_capabilities */ - public function test_context_module_caps_returned_by_get_capabilities_in_sys_context() { + public function test_context_module_caps_returned_by_get_capabilities_in_sys_context(): void { $actual = context_system::instance()->get_capabilities(); // Just test a few representative capabilities. @@ -4105,7 +4105,7 @@ class accesslib_test extends advanced_testcase { * * @covers \context_coursecat::get_capabilities */ - public function test_context_module_caps_returned_by_get_capabilities_in_course_cat_context() { + public function test_context_module_caps_returned_by_get_capabilities_in_course_cat_context(): void { $this->resetAfterTest(true); $generator = $this->getDataGenerator(); $cat = $generator->create_category(); @@ -4124,7 +4124,7 @@ class accesslib_test extends advanced_testcase { * * @covers \context_course::get_capabilities */ - public function test_context_module_caps_returned_by_get_capabilities_in_course_context() { + public function test_context_module_caps_returned_by_get_capabilities_in_course_context(): void { $this->resetAfterTest(true); $generator = $this->getDataGenerator(); $cat = $generator->create_category(); @@ -4144,7 +4144,7 @@ class accesslib_test extends advanced_testcase { * * @covers \context_module::get_capabilities */ - public function test_context_module_caps_returned_by_get_capabilities_mod_context() { + public function test_context_module_caps_returned_by_get_capabilities_mod_context(): void { $this->resetAfterTest(true); $generator = $this->getDataGenerator(); $cat = $generator->create_category(); @@ -4222,7 +4222,7 @@ class accesslib_test extends advanced_testcase { * @covers ::update_capabilities * @covers ::update_capabilities */ - public function test_update_capabilities() { + public function test_update_capabilities(): void { global $DB, $SITE; $this->resetAfterTest(true); @@ -4417,7 +4417,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::reset_role_capabilities */ - public function test_reset_role_capabilities() { + public function test_reset_role_capabilities(): void { global $DB; $this->resetAfterTest(true); $generator = $this->getDataGenerator(); @@ -4454,7 +4454,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::count_role_users */ - public function test_count_role_users() { + public function test_count_role_users(): void { global $DB; $this->resetAfterTest(true); $generator = self::getDataGenerator(); @@ -4494,7 +4494,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::get_users_by_capability */ - public function test_get_users_by_capability() { + public function test_get_users_by_capability(): void { global $DB; $this->resetAfterTest(); @@ -4546,7 +4546,7 @@ class accesslib_test extends advanced_testcase { /** * @covers ::get_with_capability_sql */ - public function test_get_with_capability_sql() { + public function test_get_with_capability_sql(): void { global $DB; $this->resetAfterTest(); @@ -4625,7 +4625,7 @@ class accesslib_test extends advanced_testcase { * @param array $capabilitiestoprevent capabilities to override to prevent in the course context. */ public function test_get_with_capability_join_when_overrides_present( - bool $studentshouldbereturned, array $capabilitiestoprevent) { + bool $studentshouldbereturned, array $capabilitiestoprevent): void { global $DB; $this->resetAfterTest(); $generator = $this->getDataGenerator(); @@ -4670,7 +4670,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::get_profile_roles */ - public function test_get_profile_roles() { + public function test_get_profile_roles(): void { global $DB; $this->resetAfterTest(); @@ -5017,7 +5017,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::get_parent_contexts */ - public function test_get_parent_contexts_preload() { + public function test_get_parent_contexts_preload(): void { global $DB; $this->resetAfterTest(); @@ -5061,7 +5061,7 @@ class accesslib_test extends advanced_testcase { * @covers ::get_with_capability_join * @covers ::get_with_capability_sql */ - public function test_get_with_capability_sql_locked() { + public function test_get_with_capability_sql_locked(): void { global $DB; $this->resetAfterTest(); @@ -5150,7 +5150,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::get_users_by_capability */ - public function test_get_users_by_capability_locked() { + public function test_get_users_by_capability_locked(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator(); @@ -5229,7 +5229,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::require_all_capabilities */ - public function test_require_all_capabilities() { + public function test_require_all_capabilities(): void { global $DB; $this->resetAfterTest(); @@ -5262,7 +5262,7 @@ class accesslib_test extends advanced_testcase { * * @covers ::get_navigation_filter_context */ - public function test_get_navigation_filter_context() { + public function test_get_navigation_filter_context(): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); set_config('filternavigationwithsystemcontext', 0); diff --git a/lib/tests/adminlib_test.php b/lib/tests/adminlib_test.php index 8be6e3e11fb..9562011e0a6 100644 --- a/lib/tests/adminlib_test.php +++ b/lib/tests/adminlib_test.php @@ -75,7 +75,7 @@ class adminlib_test extends \advanced_testcase { * @param string $column name * @param bool $expected whether it should be replaced */ - public function test_db_should_replace(string $table, string $column, bool $expected) { + public function test_db_should_replace(string $table, string $column, bool $expected): void { $actual = db_should_replace($table, $column); $this->assertSame($actual, $expected); } @@ -120,7 +120,7 @@ class adminlib_test extends \advanced_testcase { * @param string $column name * @param bool $expected whether it should be replaced */ - public function test_db_should_replace_additional_skip_tables(string $table, string $column, bool $expected) { + public function test_db_should_replace_additional_skip_tables(string $table, string $column, bool $expected): void { $this->resetAfterTest(); $additionalskiptables = 'context, quiz_attempts, role_assignments '; $actual = db_should_replace($table, $column, $additionalskiptables); @@ -132,7 +132,7 @@ class adminlib_test extends \advanced_testcase { * * @covers ::admin_output_new_settings_by_page */ - public function test_admin_output_new_settings_by_page() { + public function test_admin_output_new_settings_by_page(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -163,7 +163,7 @@ class adminlib_test extends \advanced_testcase { * * @covers ::admin_apply_default_settings */ - public function test_admin_apply_default_settings() { + public function test_admin_apply_default_settings(): void { global $DB; $this->resetAfterTest(); diff --git a/lib/tests/admintree_test.php b/lib/tests/admintree_test.php index 30110ace62e..0f668268343 100644 --- a/lib/tests/admintree_test.php +++ b/lib/tests/admintree_test.php @@ -46,7 +46,7 @@ class admintree_test extends \advanced_testcase { /** * Adding nodes into the admin tree. */ - public function test_add_nodes() { + public function test_add_nodes(): void { $tree = new admin_root(true); $tree->add('root', $one = new admin_category('one', 'One')); @@ -104,13 +104,13 @@ class admintree_test extends \advanced_testcase { $this->assertEquals(array('zero', 'one', 'two', 'three', 'four', 'five', 'six'), $map); } - public function test_add_nodes_before_invalid1() { + public function test_add_nodes_before_invalid1(): void { $tree = new admin_root(true); $this->expectException(\coding_exception::class); $tree->add('root', new admin_externalpage('foo', 'Foo', 'http://foo.bar'), array('moodle:site/config')); } - public function test_add_nodes_before_invalid2() { + public function test_add_nodes_before_invalid2(): void { $tree = new admin_root(true); $this->expectException(\coding_exception::class); $tree->add('root', new admin_category('bar', 'Bar'), ''); @@ -119,7 +119,7 @@ class admintree_test extends \advanced_testcase { /** * Test that changes to config trigger events. */ - public function test_config_log_created_event() { + public function test_config_log_created_event(): void { global $DB; $this->resetAfterTest(); $this->setAdminUser(); @@ -156,7 +156,7 @@ class admintree_test extends \advanced_testcase { /** * Testing whether a configexecutable setting is executable. */ - public function test_admin_setting_configexecutable() { + public function test_admin_setting_configexecutable(): void { global $CFG; $this->resetAfterTest(); @@ -193,7 +193,7 @@ class admintree_test extends \advanced_testcase { /** * Saving of values. */ - public function test_config_logging() { + public function test_config_logging(): void { global $DB; $this->resetAfterTest(); $this->setAdminUser(); @@ -291,7 +291,7 @@ class admintree_test extends \advanced_testcase { return $count; } - public function test_preventexecpath() { + public function test_preventexecpath(): void { $this->resetAfterTest(); set_config('preventexecpath', 0); @@ -369,7 +369,7 @@ class admintree_test extends \advanced_testcase { /** * Test setting an empty duration displays the correct validation message. */ - public function test_emptydurationvalue() { + public function test_emptydurationvalue(): void { $this->resetAfterTest(); $adminsetting = new admin_setting_configduration('abc_cde/duration', 'some desc', '', ''); @@ -383,7 +383,7 @@ class admintree_test extends \advanced_testcase { * For testing the admin settings element only. Test for blocked hosts functionality can be found * in lib/tests/curl_security_helper_test.php */ - public function test_mixedhostiplist() { + public function test_mixedhostiplist(): void { $this->resetAfterTest(); $adminsetting = new admin_setting_configmixedhostiplist('abc_cde/hostiplist', 'some desc', '', ''); @@ -434,7 +434,7 @@ class admintree_test extends \advanced_testcase { /** * Verifies the $ADMIN global (adminroot cache) is properly reset when changing users, which might occur naturally during cron. */ - public function test_adminroot_cache_reset() { + public function test_adminroot_cache_reset(): void { $this->resetAfterTest(); global $DB; // Current user is a manager at site context, which won't have access to the 'debugging' section of the admin tree. diff --git a/lib/tests/ajaxlib_test.php b/lib/tests/ajaxlib_test.php index cea813f01e9..bf04d5ddea8 100644 --- a/lib/tests/ajaxlib_test.php +++ b/lib/tests/ajaxlib_test.php @@ -79,49 +79,49 @@ class ajaxlib_test extends \advanced_testcase { } } - public function test_output_capture_normal_debug_none() { + public function test_output_capture_normal_debug_none(): void { // In normal conditions, and with DEBUG_NONE set, we should not receive any output or throw any exceptions. set_debugging(DEBUG_NONE); $this->helper_test_clean_output(); } - public function test_output_capture_normal_debug_normal() { + public function test_output_capture_normal_debug_normal(): void { // In normal conditions, and with DEBUG_NORMAL set, we should not receive any output or throw any exceptions. set_debugging(DEBUG_NORMAL); $this->helper_test_clean_output(); } - public function test_output_capture_normal_debug_all() { + public function test_output_capture_normal_debug_all(): void { // In normal conditions, and with DEBUG_ALL set, we should not receive any output or throw any exceptions. set_debugging(DEBUG_ALL); $this->helper_test_clean_output(); } - public function test_output_capture_normal_debugdeveloper() { + public function test_output_capture_normal_debugdeveloper(): void { // In normal conditions, and with DEBUG_DEVELOPER set, we should not receive any output or throw any exceptions. set_debugging(DEBUG_DEVELOPER); $this->helper_test_clean_output(); } - public function test_output_capture_error_debug_none() { + public function test_output_capture_error_debug_none(): void { // With DEBUG_NONE set, we should not throw any exception, but the output will be returned. set_debugging(DEBUG_NONE); $this->helper_test_dirty_output(); } - public function test_output_capture_error_debug_normal() { + public function test_output_capture_error_debug_normal(): void { // With DEBUG_NORMAL set, we should not throw any exception, but the output will be returned. set_debugging(DEBUG_NORMAL); $this->helper_test_dirty_output(); } - public function test_output_capture_error_debug_all() { + public function test_output_capture_error_debug_all(): void { // In error conditions, and with DEBUG_ALL set, we should not receive any output or throw any exceptions. set_debugging(DEBUG_ALL); $this->helper_test_dirty_output(); } - public function test_output_capture_error_debugdeveloper() { + public function test_output_capture_error_debugdeveloper(): void { // With DEBUG_DEVELOPER set, we should throw an exception. set_debugging(DEBUG_DEVELOPER); $this->helper_test_dirty_output(true); diff --git a/lib/tests/analysers_test.php b/lib/tests/analysers_test.php index 875646c6b16..ad0d4db3346 100644 --- a/lib/tests/analysers_test.php +++ b/lib/tests/analysers_test.php @@ -40,7 +40,7 @@ class analysers_test extends \advanced_testcase { * * @return void */ - public function test_courses_analyser() { + public function test_courses_analyser(): void { $this->resetAfterTest(true); $course1 = $this->getDataGenerator()->create_course(); @@ -86,7 +86,7 @@ class analysers_test extends \advanced_testcase { * * @return void */ - public function test_site_courses_analyser() { + public function test_site_courses_analyser(): void { $this->resetAfterTest(true); $course1 = $this->getDataGenerator()->create_course(); @@ -128,7 +128,7 @@ class analysers_test extends \advanced_testcase { * * @return void */ - public function test_student_enrolments_analyser() { + public function test_student_enrolments_analyser(): void { global $DB; $this->resetAfterTest(true); @@ -194,7 +194,7 @@ class analysers_test extends \advanced_testcase { * * @return null */ - public function test_get_analysables_iterator() { + public function test_get_analysables_iterator(): void { global $DB; $this->resetAfterTest(true); diff --git a/lib/tests/analytics/indicators_test.php b/lib/tests/analytics/indicators_test.php index c0f479d496a..6f17eb1d668 100644 --- a/lib/tests/analytics/indicators_test.php +++ b/lib/tests/analytics/indicators_test.php @@ -40,7 +40,7 @@ class indicators_test extends \advanced_testcase { * * @return void */ - public function test_core_indicators() { + public function test_core_indicators(): void { global $DB; $this->preventResetByRollback(); diff --git a/lib/tests/antivirus_test.php b/lib/tests/antivirus_test.php index 9367fd1f2d4..401d9f61b4f 100644 --- a/lib/tests/antivirus_test.php +++ b/lib/tests/antivirus_test.php @@ -71,7 +71,7 @@ class antivirus_test extends advanced_testcase { @unlink($this->tempfile); } - public function test_manager_get_antivirus() { + public function test_manager_get_antivirus(): void { // We are using clamav plugin in the test, // as the only plugin we know exists for sure. $antivirusviaget = \core\antivirus\manager::get_antivirus('clamav'); @@ -79,7 +79,7 @@ class antivirus_test extends advanced_testcase { $this->assertEquals($antivirusdirect, $antivirusviaget); } - public function test_manager_scan_file_no_virus() { + public function test_manager_scan_file_no_virus(): void { // Run mock scanning. $this->assertFileExists($this->tempfile); $this->assertEmpty(\core\antivirus\manager::scan_file($this->tempfile, 'OK', true)); @@ -87,7 +87,7 @@ class antivirus_test extends advanced_testcase { $this->assertFileExists($this->tempfile); } - public function test_manager_scan_file_error() { + public function test_manager_scan_file_error(): void { // Run mock scanning. $this->assertFileExists($this->tempfile); $this->assertEmpty(\core\antivirus\manager::scan_file($this->tempfile, 'ERROR', true)); @@ -96,7 +96,7 @@ class antivirus_test extends advanced_testcase { } // Check API for NA status i.e. when no scanners are enabled. - public function test_antivirus_check_na() { + public function test_antivirus_check_na(): void { global $CFG; $CFG->antiviruses = ''; // Enable logs. @@ -111,7 +111,7 @@ class antivirus_test extends advanced_testcase { } // Check API for UNKNOWN status i.e. when the system's logstore reader is not '\core\log\sql_internal_table_reader'. - public function test_antivirus_check_unknown() { + public function test_antivirus_check_unknown(): void { // Run mock scanning. $this->assertFileExists($this->tempfile); $this->assertEmpty(\core\antivirus\manager::scan_file($this->tempfile, 'OK', true)); @@ -121,7 +121,7 @@ class antivirus_test extends advanced_testcase { } // Check API for OK status i.e. antivirus enabled, logstore is ok, no scanner issues occurred recently. - public function test_antivirus_check_ok() { + public function test_antivirus_check_ok(): void { // Enable logs. $this->enable_logging(); // Run mock scanning. @@ -133,7 +133,7 @@ class antivirus_test extends advanced_testcase { } // Check API for ERROR status i.e. scanner issue within a certain timeframe/threshold. - public function test_antivirus_check_error() { + public function test_antivirus_check_error(): void { global $USER, $DB; // Enable logs. $this->enable_logging(); @@ -146,7 +146,7 @@ class antivirus_test extends advanced_testcase { $this->assertFileExists($this->tempfile); } - public function test_manager_scan_file_virus() { + public function test_manager_scan_file_virus(): void { // Run mock scanning without deleting infected file. $this->assertFileExists($this->tempfile); $this->expectException(\core\antivirus\scanner_exception::class); @@ -161,7 +161,7 @@ class antivirus_test extends advanced_testcase { $this->assertFileDoesNotExist($this->tempfile); } - public function test_manager_send_message_to_user_email_scan_file_virus() { + public function test_manager_send_message_to_user_email_scan_file_virus(): void { $sink = $this->redirectEmails(); $exception = null; try { @@ -177,7 +177,7 @@ class antivirus_test extends advanced_testcase { $sink->close(); } - public function test_manager_send_message_to_admin_email_scan_file_virus() { + public function test_manager_send_message_to_admin_email_scan_file_virus(): void { $sink = $this->redirectMessages(); $exception = null; try { @@ -194,7 +194,7 @@ class antivirus_test extends advanced_testcase { $sink->close(); } - public function test_manager_quarantine_file_virus() { + public function test_manager_quarantine_file_virus(): void { try { set_config('enablequarantine', true, 'antivirus'); \core\antivirus\manager::scan_file($this->tempfile, 'FOUND', true); @@ -211,7 +211,7 @@ class antivirus_test extends advanced_testcase { $this->assertEquals(0, count($quarantinedfiles)); } - public function test_manager_none_quarantine_file_virus() { + public function test_manager_none_quarantine_file_virus(): void { try { \core\antivirus\manager::scan_file($this->tempfile, 'FOUND', true); } catch (\core\antivirus\scanner_exception $ex) { @@ -222,23 +222,23 @@ class antivirus_test extends advanced_testcase { $this->assertEquals(0, count($quarantinedfiles)); } - public function test_manager_scan_data_no_virus() { + public function test_manager_scan_data_no_virus(): void { // Run mock scanning. $this->assertEmpty(\core\antivirus\manager::scan_data('OK')); } - public function test_manager_scan_data_error() { + public function test_manager_scan_data_error(): void { // Run mock scanning. $this->assertEmpty(\core\antivirus\manager::scan_data('ERROR')); } - public function test_manager_scan_data_virus() { + public function test_manager_scan_data_virus(): void { // Run mock scanning. $this->expectException(\core\antivirus\scanner_exception::class); $this->assertEmpty(\core\antivirus\manager::scan_data('FOUND')); } - public function test_manager_send_message_to_user_email_scan_data_virus() { + public function test_manager_send_message_to_user_email_scan_data_virus(): void { $sink = $this->redirectEmails(); set_config('notifyemail', 'fake@example.com', 'antivirus'); $exception = null; @@ -254,7 +254,7 @@ class antivirus_test extends advanced_testcase { $sink->close(); } - public function test_manager_send_message_to_admin_email_scan_data_virus() { + public function test_manager_send_message_to_admin_email_scan_data_virus(): void { $sink = $this->redirectMessages(); $exception = null; try { @@ -271,7 +271,7 @@ class antivirus_test extends advanced_testcase { $sink->close(); } - public function test_manager_quarantine_data_virus() { + public function test_manager_quarantine_data_virus(): void { set_config('enablequarantine', true, 'antivirus'); $exception = null; try { @@ -290,7 +290,7 @@ class antivirus_test extends advanced_testcase { } - public function test_manager_none_quarantine_data_virus() { + public function test_manager_none_quarantine_data_virus(): void { $exception = null; try { \core\antivirus\manager::scan_data('FOUND'); diff --git a/lib/tests/authlib_test.php b/lib/tests/authlib_test.php index 8d70a0a79b5..1e02010f7ed 100644 --- a/lib/tests/authlib_test.php +++ b/lib/tests/authlib_test.php @@ -26,7 +26,7 @@ namespace core; * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class authlib_test extends \advanced_testcase { - public function test_lockout() { + public function test_lockout(): void { global $CFG; require_once("$CFG->libdir/authlib.php"); @@ -110,7 +110,7 @@ class authlib_test extends \advanced_testcase { ini_set('error_log', $oldlog); } - public function test_authenticate_user_login() { + public function test_authenticate_user_login(): void { global $CFG; $this->resetAfterTest(); @@ -436,7 +436,7 @@ class authlib_test extends \advanced_testcase { unset($CFG->enableloginrecaptcha); } - public function test_user_loggedin_event_exceptions() { + public function test_user_loggedin_event_exceptions(): void { try { $event = \core\event\user_loggedin::create(array('objectid' => 1)); $this->fail('\core\event\user_loggedin requires other[\'username\']'); diff --git a/lib/tests/behat_lib_test.php b/lib/tests/behat_lib_test.php index fefaf4c3629..303eb1f3504 100644 --- a/lib/tests/behat_lib_test.php +++ b/lib/tests/behat_lib_test.php @@ -58,7 +58,7 @@ class behat_lib_test extends advanced_testcase { * @param bool $expectedvalue Expected value returned by behat_is_requested_url() function. * @param array $environment Values to override $_SERVER global variable. */ - public function test_behat_is_requested_url($url, $expectedvalue, $environment) { + public function test_behat_is_requested_url($url, $expectedvalue, $environment): void { // Save $_SERVER variable. $server = $_SERVER; diff --git a/lib/tests/blocklib_test.php b/lib/tests/blocklib_test.php index b46e471ad27..548527189fb 100644 --- a/lib/tests/blocklib_test.php +++ b/lib/tests/blocklib_test.php @@ -79,19 +79,19 @@ class blocklib_test extends \advanced_testcase { return $return; } - public function test_no_regions_initially() { + public function test_no_regions_initially(): void { // Exercise SUT & Validate. $this->assertEquals(array(), $this->blockmanager->get_regions()); } - public function test_add_region() { + public function test_add_region(): void { // Exercise SUT. $this->blockmanager->add_region('a-region-name', false); // Validate. $this->assertEquals(array('a-region-name'), $this->blockmanager->get_regions()); } - public function test_add_regions() { + public function test_add_regions(): void { // Set up fixture. $regions = array('a-region', 'another-region'); // Exercise SUT. @@ -100,7 +100,7 @@ class blocklib_test extends \advanced_testcase { $this->assertEqualsCanonicalizing($regions, $this->blockmanager->get_regions()); } - public function test_add_region_twice() { + public function test_add_region_twice(): void { // Exercise SUT. $this->blockmanager->add_region('a-region-name', false); $this->blockmanager->add_region('another-region', false); @@ -108,7 +108,7 @@ class blocklib_test extends \advanced_testcase { $this->assertEqualsCanonicalizing(array('a-region-name', 'another-region'), $this->blockmanager->get_regions()); } - public function test_cannot_add_region_after_loaded() { + public function test_cannot_add_region_after_loaded(): void { // Set up fixture. $this->blockmanager->mark_loaded(); // Exercise SUT. @@ -119,7 +119,7 @@ class blocklib_test extends \advanced_testcase { /** * Testing adding a custom region. */ - public function test_add_custom_region() { + public function test_add_custom_region(): void { global $SESSION; // Exercise SUT. $this->blockmanager->add_region('a-custom-region-name'); @@ -134,7 +134,7 @@ class blocklib_test extends \advanced_testcase { /** * Test adding two custom regions using add_regions method. */ - public function test_add_custom_regions() { + public function test_add_custom_regions(): void { global $SESSION; // Set up fixture. $regions = array('a-region', 'another-custom-region'); @@ -150,7 +150,7 @@ class blocklib_test extends \advanced_testcase { /** * Test adding two custom block regions. */ - public function test_add_custom_region_twice() { + public function test_add_custom_region_twice(): void { // Exercise SUT. $this->blockmanager->add_region('a-custom-region-name'); $this->blockmanager->add_region('another-custom-region'); @@ -163,7 +163,7 @@ class blocklib_test extends \advanced_testcase { /** * Test to ensure that we cannot add a region after the blocks have been loaded. */ - public function test_cannot_add_custom_region_after_loaded() { + public function test_cannot_add_custom_region_after_loaded(): void { // Set up fixture. $this->blockmanager->mark_loaded(); // Exercise SUT. @@ -171,7 +171,7 @@ class blocklib_test extends \advanced_testcase { $this->blockmanager->add_region('too-late'); } - public function test_set_default_region() { + public function test_set_default_region(): void { // Set up fixture. $this->blockmanager->add_region('a-region-name', false); // Exercise SUT. @@ -180,13 +180,13 @@ class blocklib_test extends \advanced_testcase { $this->assertEquals('a-region-name', $this->blockmanager->get_default_region()); } - public function test_cannot_set_unknown_region_as_default() { + public function test_cannot_set_unknown_region_as_default(): void { // Exercise SUT. $this->expectException(\coding_exception::class); $this->blockmanager->set_default_region('a-region-name'); } - public function test_cannot_change_default_region_after_loaded() { + public function test_cannot_change_default_region_after_loaded(): void { // Set up fixture. $this->blockmanager->mark_loaded(); // Exercise SUT. @@ -194,7 +194,7 @@ class blocklib_test extends \advanced_testcase { $this->blockmanager->set_default_region('too-late'); } - public function test_matching_page_type_patterns() { + public function test_matching_page_type_patterns(): void { $this->assertEqualsCanonicalizing(array('site-index', 'site-index-*', 'site-*', '*'), matching_page_type_patterns('site-index')); @@ -243,7 +243,7 @@ class blocklib_test extends \advanced_testcase { } } - public function test_empty_initially() { + public function test_empty_initially(): void { $this->purge_blocks(); // Set up fixture. @@ -256,7 +256,7 @@ class blocklib_test extends \advanced_testcase { $this->assertEquals(array('a-region' => array()), $blocks); } - public function test_adding_and_retrieving_one_block() { + public function test_adding_and_retrieving_one_block(): void { $this->purge_blocks(); // Set up fixture. @@ -275,7 +275,7 @@ class blocklib_test extends \advanced_testcase { $this->assertContainsBlocksOfType(array($blockname), $blocks); } - public function test_adding_and_retrieving_two_blocks() { + public function test_adding_and_retrieving_two_blocks(): void { $this->purge_blocks(); // Set up fixture. @@ -295,7 +295,7 @@ class blocklib_test extends \advanced_testcase { $this->assertContainsBlocksOfType(array($blockname, $blockname), $blocks); } - public function test_adding_blocks() { + public function test_adding_blocks(): void { $this->purge_blocks(); // Set up fixture. @@ -320,7 +320,7 @@ class blocklib_test extends \advanced_testcase { * * @return null */ - public function test_block_instances() { + public function test_block_instances(): void { $this->purge_blocks(); // Set up fixture. @@ -340,7 +340,7 @@ class blocklib_test extends \advanced_testcase { $this->assertInstanceOf('\block_base', block_instance_by_id($blocks[0]->instance->id)); } - public function test_block_not_included_in_different_context() { + public function test_block_not_included_in_different_context(): void { $this->purge_blocks(); // Set up fixture. @@ -362,7 +362,7 @@ class blocklib_test extends \advanced_testcase { $this->assertContainsBlocksOfType(array(), $blocks); } - public function test_block_included_in_sub_context() { + public function test_block_included_in_sub_context(): void { $this->purge_blocks(); // Set up fixture. @@ -383,7 +383,7 @@ class blocklib_test extends \advanced_testcase { $this->assertContainsBlocksOfType(array($blockname), $blocks); } - public function test_block_not_included_on_different_page_type() { + public function test_block_not_included_on_different_page_type(): void { $this->purge_blocks(); // Set up fixture. @@ -403,7 +403,7 @@ class blocklib_test extends \advanced_testcase { $this->assertContainsBlocksOfType(array(), $blocks); } - public function test_block_not_included_on_different_sub_page() { + public function test_block_not_included_on_different_sub_page(): void { $this->purge_blocks(); // Set up fixture. @@ -423,7 +423,7 @@ class blocklib_test extends \advanced_testcase { $this->assertContainsBlocksOfType(array(), $blocks); } - public function test_block_included_with_explicit_sub_page() { + public function test_block_included_with_explicit_sub_page(): void { $this->purge_blocks(); // Set up fixture. @@ -443,7 +443,7 @@ class blocklib_test extends \advanced_testcase { $this->assertContainsBlocksOfType(array($blockname), $blocks); } - public function test_block_included_with_page_type_pattern() { + public function test_block_included_with_page_type_pattern(): void { $this->purge_blocks(); // Set up fixture. @@ -463,7 +463,7 @@ class blocklib_test extends \advanced_testcase { $this->assertContainsBlocksOfType(array($blockname), $blocks); } - public function test_matching_page_type_patterns_from_pattern() { + public function test_matching_page_type_patterns_from_pattern(): void { $pattern = '*'; $expected = array('*'); $this->assertEquals($expected, array_values(matching_page_type_patterns_from_pattern($pattern))); @@ -513,7 +513,7 @@ class blocklib_test extends \advanced_testcase { $this->assertEquals($expected, array_values(matching_page_type_patterns_from_pattern($pattern))); } - public function test_delete_instances() { + public function test_delete_instances(): void { global $DB; $this->purge_blocks(); $this->setAdminUser(); @@ -576,7 +576,7 @@ class blocklib_test extends \advanced_testcase { \context_block::instance($tokeep); // Would throw an exception if it was deleted. } - public function test_create_all_block_instances() { + public function test_create_all_block_instances(): void { global $CFG, $PAGE, $DB; $this->setAdminUser(); @@ -659,7 +659,7 @@ class blocklib_test extends \advanced_testcase { /** * Test the block instance time fields (timecreated, timemodified). */ - public function test_block_instance_times() { + public function test_block_instance_times(): void { global $DB; $this->purge_blocks(); @@ -726,7 +726,7 @@ class blocklib_test extends \advanced_testcase { /** * Tests that dashboard pages get their blocks loaded correctly. */ - public function test_default_dashboard() { + public function test_default_dashboard(): void { global $CFG, $PAGE, $DB; $storedpage = $PAGE; require_once($CFG->dirroot . '/my/lib.php'); diff --git a/lib/tests/client_test.php b/lib/tests/client_test.php index 66cdb3b7a7b..d3d1b3020b8 100644 --- a/lib/tests/client_test.php +++ b/lib/tests/client_test.php @@ -83,7 +83,7 @@ class client_test extends advanced_testcase { * @param array $expected * @throws ReflectionException */ - public function test_map_userinfo_to_fields(array $mapping, array $expected) { + public function test_map_userinfo_to_fields(array $mapping, array $expected): void { $dataset = [ "name" => (object) [ "firstname" => "John", diff --git a/lib/tests/collator_test.php b/lib/tests/collator_test.php index 4fa5c5be1dd..14d0ddd9cc4 100644 --- a/lib/tests/collator_test.php +++ b/lib/tests/collator_test.php @@ -83,7 +83,7 @@ class collator_test extends \advanced_testcase { /** * Tests the static asort method. */ - public function test_asort() { + public function test_asort(): void { $arr = array('b' => 'ab', 1 => 'aa', 0 => 'cc'); $result = core_collator::asort($arr); $this->assertSame(array('aa', 'ab', 'cc'), array_values($arr)); @@ -155,7 +155,7 @@ class collator_test extends \advanced_testcase { /** * Tests the static asort_objects_by_method method. */ - public function test_asort_objects_by_method() { + public function test_asort_objects_by_method(): void { $objects = array( 'b' => new string_test_class('ab'), 1 => new string_test_class('aa'), @@ -180,7 +180,7 @@ class collator_test extends \advanced_testcase { /** * Tests the static asort_objects_by_method method. */ - public function test_asort_objects_by_property() { + public function test_asort_objects_by_property(): void { $objects = array( 'b' => new string_test_class('ab'), 1 => new string_test_class('aa'), @@ -205,7 +205,7 @@ class collator_test extends \advanced_testcase { /** * Tests the sorting of an array of arrays by key. */ - public function test_asort_array_of_arrays_by_key() { + public function test_asort_array_of_arrays_by_key(): void { $array = array( 'a' => array('name' => 'bravo'), 'b' => array('name' => 'charlie'), @@ -265,7 +265,7 @@ class collator_test extends \advanced_testcase { /** * Tests the static ksort method. */ - public function test_ksort() { + public function test_ksort(): void { $arr = array('b' => 'ab', 1 => 'aa', 0 => 'cc'); $result = core_collator::ksort($arr); $this->assertSame(array(0, 1, 'b'), array_keys($arr)); diff --git a/lib/tests/completionlib_test.php b/lib/tests/completionlib_test.php index cf99198f9cf..fe93eed5e79 100644 --- a/lib/tests/completionlib_test.php +++ b/lib/tests/completionlib_test.php @@ -98,7 +98,7 @@ class completionlib_test extends advanced_testcase { * @covers ::is_enabled_for_site * @covers ::is_enabled */ - public function test_is_enabled() { + public function test_is_enabled(): void { global $CFG; $this->mock_setup(); @@ -136,7 +136,7 @@ class completionlib_test extends advanced_testcase { /** * @covers ::update_state */ - public function test_update_state() { + public function test_update_state(): void { $this->mock_setup(); $mockbuilder = $this->getMockBuilder('completion_info'); @@ -361,7 +361,7 @@ class completionlib_test extends advanced_testcase { * @param int $expectedstate * @covers ::internal_get_state */ - public function test_internal_get_state(int $completionview, int $completionusegrade, string $unsetfield, int $expectedstate) { + public function test_internal_get_state(int $completionview, int $completionusegrade, string $unsetfield, int $expectedstate): void { $this->setup_data(); /** @var \mod_assign_generator $assigngenerator */ @@ -446,7 +446,7 @@ class completionlib_test extends advanced_testcase { * @param int $expectedstate Expected completion state * @covers ::internal_get_state */ - public function test_internal_get_state_with_grade_criteria(array $completioncriteria, ?int $studentgrade, int $expectedstate) { + public function test_internal_get_state_with_grade_criteria(array $completioncriteria, ?int $studentgrade, int $expectedstate): void { $this->setup_data(); /** @var \mod_assign_generator $assigngenerator */ @@ -488,7 +488,7 @@ class completionlib_test extends advanced_testcase { * * @covers ::internal_get_state */ - public function test_internal_get_state_with_different_user() { + public function test_internal_get_state_with_different_user(): void { $this->setup_data(); /** @var \mod_assign_generator $assigngenerator */ @@ -532,7 +532,7 @@ class completionlib_test extends advanced_testcase { * * @covers ::internal_get_state */ - public function test_internal_get_state_with_custom_completion() { + public function test_internal_get_state_with_custom_completion(): void { $this->setup_data(); $choicerecord = [ @@ -560,7 +560,7 @@ class completionlib_test extends advanced_testcase { /** * @covers ::set_module_viewed */ - public function test_set_module_viewed() { + public function test_set_module_viewed(): void { $this->mock_setup(); $mockbuilder = $this->getMockBuilder('completion_info'); @@ -618,7 +618,7 @@ class completionlib_test extends advanced_testcase { /** * @covers ::count_user_data */ - public function test_count_user_data() { + public function test_count_user_data(): void { global $DB; $this->mock_setup(); @@ -637,7 +637,7 @@ class completionlib_test extends advanced_testcase { /** * @covers ::delete_all_state */ - public function test_delete_all_state() { + public function test_delete_all_state(): void { global $DB; $this->mock_setup(); @@ -657,7 +657,7 @@ class completionlib_test extends advanced_testcase { /** * @covers ::reset_all_state */ - public function test_reset_all_state() { + public function test_reset_all_state(): void { global $DB; $this->mock_setup(); @@ -734,7 +734,7 @@ class completionlib_test extends advanced_testcase { * @param int $completion The completion state expected. * @covers ::get_data */ - public function test_get_data(bool $wholecourse, bool $sameuser, bool $hasrecord, int $completion) { + public function test_get_data(bool $wholecourse, bool $sameuser, bool $hasrecord, int $completion): void { global $DB; $this->setup_data(); @@ -875,7 +875,7 @@ class completionlib_test extends advanced_testcase { * * @covers ::get_completion_data */ - public function test_get_completion_data() { + public function test_get_completion_data(): void { $this->setup_data(); $choicegenerator = $this->getDataGenerator()->get_plugin_generator('mod_choice'); $choice = $choicegenerator->create_instance([ @@ -928,7 +928,7 @@ class completionlib_test extends advanced_testcase { * * @covers ::get_other_cm_completion_data */ - public function test_get_other_cm_completion_data() { + public function test_get_other_cm_completion_data(): void { global $DB; $this->setup_data(); @@ -1002,7 +1002,7 @@ class completionlib_test extends advanced_testcase { /** * @covers ::internal_set_data */ - public function test_internal_set_data() { + public function test_internal_set_data(): void { global $DB; $this->setup_data(); @@ -1112,7 +1112,7 @@ class completionlib_test extends advanced_testcase { /** * @covers ::get_progress_all */ - public function test_get_progress_all_few() { + public function test_get_progress_all_few(): void { global $DB; $this->mock_setup(); @@ -1149,7 +1149,7 @@ class completionlib_test extends advanced_testcase { /** * @covers ::get_progress_all */ - public function test_get_progress_all_lots() { + public function test_get_progress_all_lots(): void { global $DB; $this->mock_setup(); @@ -1207,7 +1207,7 @@ class completionlib_test extends advanced_testcase { /** * @covers ::inform_grade_changed */ - public function test_inform_grade_changed() { + public function test_inform_grade_changed(): void { $this->mock_setup(); $mockbuilder = $this->getMockBuilder('completion_info'); @@ -1278,7 +1278,7 @@ class completionlib_test extends advanced_testcase { /** * @covers ::internal_get_grade_state */ - public function test_internal_get_grade_state() { + public function test_internal_get_grade_state(): void { $this->mock_setup(); $item = new stdClass; @@ -1347,7 +1347,7 @@ class completionlib_test extends advanced_testcase { /** * @test ::get_activities */ - public function test_get_activities() { + public function test_get_activities(): void { global $CFG; $this->resetAfterTest(); @@ -1391,7 +1391,7 @@ class completionlib_test extends advanced_testcase { /** * @test ::has_activities */ - public function test_has_activities() { + public function test_has_activities(): void { global $CFG; $this->resetAfterTest(); @@ -1419,7 +1419,7 @@ class completionlib_test extends advanced_testcase { * @covers ::delete_course_completion_data * @covers ::delete_all_completion_data */ - public function test_course_delete_prerequisite() { + public function test_course_delete_prerequisite(): void { global $DB; $this->setup_data(); @@ -1457,7 +1457,7 @@ class completionlib_test extends advanced_testcase { * * @covers \core\event\course_module_completion_updated */ - public function test_course_module_completion_updated_event() { + public function test_course_module_completion_updated_event(): void { global $USER, $CFG; $this->setup_data(); @@ -1495,7 +1495,7 @@ class completionlib_test extends advanced_testcase { * * @covers \core\event\course_completed */ - public function test_course_completed_event() { + public function test_course_completed_event(): void { global $USER; $this->setup_data(); @@ -1524,7 +1524,7 @@ class completionlib_test extends advanced_testcase { * * @covers \core\event\course_completed */ - public function test_course_completed_message() { + public function test_course_completed_message(): void { $this->setup_data(); $this->setAdminUser(); @@ -1552,7 +1552,7 @@ class completionlib_test extends advanced_testcase { * * @covers \core\event\course_completion_updated */ - public function test_course_completion_updated_event() { + public function test_course_completion_updated_event(): void { $this->setup_data(); $coursecontext = context_course::instance($this->course->id); $coursecompletionevent = \core\event\course_completion_updated::create( @@ -1578,7 +1578,7 @@ class completionlib_test extends advanced_testcase { /** * @covers \completion_can_view_data */ - public function test_completion_can_view_data() { + public function test_completion_can_view_data(): void { $this->setup_data(); $student = $this->getDataGenerator()->create_user(); @@ -1616,7 +1616,7 @@ class completionlib_test extends advanced_testcase { * @covers ::get_grade_completion */ public function test_get_grade_completion(bool $completionusegrade, bool $hasgrade, ?int $passinggrade, - ?string $expectedexception, ?int $expectedresult) { + ?string $expectedexception, ?int $expectedresult): void { $this->setup_data(); /** @var \mod_assign_generator $assigngenerator */ @@ -1649,7 +1649,7 @@ class completionlib_test extends advanced_testcase { * * @covers ::get_grade_completion */ - public function test_get_grade_completion_without_grade_item() { + public function test_get_grade_completion_without_grade_item(): void { global $DB; $this->setup_data(); @@ -1689,7 +1689,7 @@ class completionlib_test extends advanced_testcase { * * @covers \aggregate_completions */ - public function test_aggregate_completions() { + public function test_aggregate_completions(): void { global $DB, $CFG; require_once($CFG->dirroot.'/completion/criteria/completion_criteria_activity.php'); $this->resetAfterTest(true); @@ -1786,7 +1786,7 @@ class completionlib_test extends advanced_testcase { * * @covers \completion_completion::_save */ - public function test_save() { + public function test_save(): void { global $DB; $this->resetAfterTest(true); @@ -1830,7 +1830,7 @@ class completionlib_test extends advanced_testcase { * * @covers \completion_completion::mark_enrolled */ - public function test_mark_enrolled() { + public function test_mark_enrolled(): void { global $DB; $this->resetAfterTest(true); @@ -1873,7 +1873,7 @@ class completionlib_test extends advanced_testcase { * * @covers \completion_completion::mark_inprogress */ - public function test_mark_inprogress() { + public function test_mark_inprogress(): void { global $DB; $this->resetAfterTest(true); @@ -1916,7 +1916,7 @@ class completionlib_test extends advanced_testcase { * * @covers \completion_completion::mark_complete */ - public function test_mark_complete() { + public function test_mark_complete(): void { global $DB; $this->resetAfterTest(true); @@ -1958,7 +1958,7 @@ class completionlib_test extends advanced_testcase { * * @covers \completion_criteria_completion::mark_complete */ - public function test_criteria_mark_complete() { + public function test_criteria_mark_complete(): void { global $DB; $this->resetAfterTest(true); @@ -1996,7 +1996,7 @@ class completionlib_test extends advanced_testcase { * * @covers ::delete_all_completion_data */ - public function test_course_reset_completion() { + public function test_course_reset_completion(): void { global $DB; $this->setup_data(); diff --git a/lib/tests/componentlib_test.php b/lib/tests/componentlib_test.php index 7e6ac394b86..be76d9468c4 100644 --- a/lib/tests/componentlib_test.php +++ b/lib/tests/componentlib_test.php @@ -44,7 +44,7 @@ require_once($CFG->libdir.'/componentlib.class.php'); */ class componentlib_test extends \advanced_testcase { - public function test_component_installer() { + public function test_component_installer(): void { global $CFG; $url = $this->getExternalTestFileUrl(''); @@ -78,7 +78,7 @@ class componentlib_test extends \advanced_testcase { /** * Test the public API of the {@link lang_installer} class. */ - public function test_lang_installer() { + public function test_lang_installer(): void { // Test the manipulation with the download queue. $installer = new testable_lang_installer(); diff --git a/lib/tests/configonlylib_test.php b/lib/tests/configonlylib_test.php index 3532e7a3a2a..f2a466f4ab7 100644 --- a/lib/tests/configonlylib_test.php +++ b/lib/tests/configonlylib_test.php @@ -34,7 +34,7 @@ class configonlylib_test extends \advanced_testcase { /** * Test cleaning of invalid utf-8 entities. */ - public function test_min_fix_utf8() { + public function test_min_fix_utf8(): void { $this->assertSame('abc', min_fix_utf8('abc')); $this->assertSame("žlutý koníček přeskočil potůček \n\t\r", min_fix_utf8("žlutý koníček přeskočil potůček \n\t\r\0")); $this->assertSame('aš', min_fix_utf8('a'.chr(130).'š'), 'This fails with buggy iconv() when mbstring extenstion is not available as fallback.'); @@ -43,7 +43,7 @@ class configonlylib_test extends \advanced_testcase { /** * Test minimalistic parameter cleaning. */ - public function test_min_clean_param() { + public function test_min_clean_param(): void { $this->assertSame('foo', min_clean_param('foo', 'RAW')); $this->assertSame('aš', min_clean_param('a'.chr(130).'š', 'RAW')); @@ -60,7 +60,7 @@ class configonlylib_test extends \advanced_testcase { /** * Test minimalistic getting of page parameters. */ - public function test_min_optional_param() { + public function test_min_optional_param(): void { $this->resetAfterTest(); $_GET['foo'] = 'bar'; @@ -81,7 +81,7 @@ class configonlylib_test extends \advanced_testcase { /** * Test fail-safe minimalistic slashargument processing. */ - public function test_min_get_slash_argument() { + public function test_min_get_slash_argument(): void { global $CFG; $this->resetAfterTest(); diff --git a/lib/tests/content_test.php b/lib/tests/content_test.php index 52c8f56ddd8..e440e315298 100644 --- a/lib/tests/content_test.php +++ b/lib/tests/content_test.php @@ -38,7 +38,7 @@ class content_test extends \advanced_testcase { /** * A test to confirm only valid cases allow exporting of course content. */ - public function test_can_export_context_course() { + public function test_can_export_context_course(): void { global $DB; $this->resetAfterTest(); @@ -101,7 +101,7 @@ class content_test extends \advanced_testcase { /** * A test to confirm unsupported contexts will return false when checking whether content can be exported. */ - public function test_can_export_context_unsupported_context() { + public function test_can_export_context_unsupported_context(): void { $this->resetAfterTest(); $course1 = $this->getDataGenerator()->create_course(); diff --git a/lib/tests/context/block_test.php b/lib/tests/context/block_test.php index 1cc42bbe534..16a9f0f7875 100644 --- a/lib/tests/context/block_test.php +++ b/lib/tests/context/block_test.php @@ -33,7 +33,7 @@ class block_test extends \advanced_testcase { * Tests legacy class name. * @covers \context_block */ - public function test_legacy_classname() { + public function test_legacy_classname(): void { $this->resetAfterTest(); $block = $this->getDataGenerator()->create_block('online_users'); @@ -48,7 +48,7 @@ class block_test extends \advanced_testcase { * @covers ::instance * @covers \core\context::instance_by_id */ - public function test_factory_methods() { + public function test_factory_methods(): void { $this->resetAfterTest(); $block = $this->getDataGenerator()->create_block('online_users'); @@ -66,7 +66,7 @@ class block_test extends \advanced_testcase { * Tests covered method. * @covers ::get_short_name */ - public function test_get_short_name() { + public function test_get_short_name(): void { $this->assertSame('block', block::get_short_name()); } @@ -74,7 +74,7 @@ class block_test extends \advanced_testcase { * Tests levels. * @coversNothing */ - public function test_level() { + public function test_level(): void { $this->assertSame(80, block::LEVEL); $this->assertSame(CONTEXT_BLOCK, block::LEVEL); } @@ -83,7 +83,7 @@ class block_test extends \advanced_testcase { * Tests covered method. * @covers ::get_level_name */ - public function test_get_level_name() { + public function test_get_level_name(): void { $this->assertSame('Block', block::get_level_name()); } @@ -91,7 +91,7 @@ class block_test extends \advanced_testcase { * Tests covered method. * @covers ::get_context_name */ - public function test_get_context_name() { + public function test_get_context_name(): void { $this->resetAfterTest(); $block = $this->getDataGenerator()->create_block('online_users'); @@ -108,7 +108,7 @@ class block_test extends \advanced_testcase { * Tests covered method. * @covers ::get_url */ - public function test_get_url() { + public function test_get_url(): void { $this->resetAfterTest(); $block = $this->getDataGenerator()->create_block('online_users'); @@ -124,7 +124,7 @@ class block_test extends \advanced_testcase { * Tests covered method. * @covers ::get_compatible_role_archetypes */ - public function test_get_compatible_role_archetypes() { + public function test_get_compatible_role_archetypes(): void { global $DB; $allarchetypes = $DB->get_fieldset_select('role', 'DISTINCT archetype', 'archetype IS NOT NULL'); @@ -138,7 +138,7 @@ class block_test extends \advanced_testcase { * Tests covered method. * @covers ::get_possible_parent_levels */ - public function test_get_possible_parent_levels() { + public function test_get_possible_parent_levels(): void { $result = block::get_possible_parent_levels(); // All except itself. $this->assertContains(system::LEVEL, $result); @@ -157,7 +157,7 @@ class block_test extends \advanced_testcase { * Tests covered method. * @covers ::get_capabilities */ - public function test_get_capabilities() { + public function test_get_capabilities(): void { $this->resetAfterTest(); $block = $this->getDataGenerator()->create_block('online_users'); @@ -178,7 +178,7 @@ class block_test extends \advanced_testcase { * Tests covered method. * @covers ::create_level_instances */ - public function test_create_level_instances() { + public function test_create_level_instances(): void { global $DB; $this->resetAfterTest(); @@ -194,7 +194,7 @@ class block_test extends \advanced_testcase { * Tests covered method. * @covers ::get_child_contexts */ - public function test_get_child_contexts() { + public function test_get_child_contexts(): void { $this->resetAfterTest(); $block = $this->getDataGenerator()->create_block('online_users'); @@ -208,7 +208,7 @@ class block_test extends \advanced_testcase { * Tests covered method. * @covers ::get_cleanup_sql */ - public function test_get_cleanup_sql() { + public function test_get_cleanup_sql(): void { global $DB; $this->resetAfterTest(); @@ -225,7 +225,7 @@ class block_test extends \advanced_testcase { * Tests covered method. * @covers ::build_paths */ - public function test_build_paths() { + public function test_build_paths(): void { global $DB; $this->resetAfterTest(); @@ -247,7 +247,7 @@ class block_test extends \advanced_testcase { * Tests covered method. * @covers ::set_locked */ - public function test_set_locked() { + public function test_set_locked(): void { global $DB; $this->resetAfterTest(); diff --git a/lib/tests/context/course_test.php b/lib/tests/context/course_test.php index 982098d7f92..6c4afd306fe 100644 --- a/lib/tests/context/course_test.php +++ b/lib/tests/context/course_test.php @@ -33,7 +33,7 @@ class course_test extends \advanced_testcase { * Tests legacy class. * @coversNothing */ - public function test_legacy_classname() { + public function test_legacy_classname(): void { global $SITE; $course = $SITE; $context = \context_course::instance($course->id); @@ -46,7 +46,7 @@ class course_test extends \advanced_testcase { * @covers ::instance * @covers \core\context::instance_by_id */ - public function test_factory_methods() { + public function test_factory_methods(): void { global $SITE; $course = $SITE; $context = course::instance($course->id); @@ -62,7 +62,7 @@ class course_test extends \advanced_testcase { * Tests covered method. * @covers ::get_short_name */ - public function test_get_short_name() { + public function test_get_short_name(): void { $this->assertSame('course', course::get_short_name()); } @@ -70,7 +70,7 @@ class course_test extends \advanced_testcase { * Tests levels. * @coversNothing */ - public function test_level() { + public function test_level(): void { $this->assertSame(50, course::LEVEL); $this->assertSame(CONTEXT_COURSE, course::LEVEL); } @@ -79,7 +79,7 @@ class course_test extends \advanced_testcase { * Tests covered method. * @covers ::get_level_name */ - public function test_get_level_name() { + public function test_get_level_name(): void { $this->assertSame('Course', course::get_level_name()); } @@ -87,7 +87,7 @@ class course_test extends \advanced_testcase { * Tests covered method. * @covers ::get_context_name */ - public function test_get_context_name() { + public function test_get_context_name(): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(['fullname' => 'Test course', 'shortname' => 'TST']); @@ -104,7 +104,7 @@ class course_test extends \advanced_testcase { * Tests covered method. * @covers ::get_url */ - public function test_get_url() { + public function test_get_url(): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -122,7 +122,7 @@ class course_test extends \advanced_testcase { * @covers ::get_behat_reference_columns() * @covers \core\context_helper::resolve_behat_reference */ - public function test_resolve_behat_reference() { + public function test_resolve_behat_reference(): void { $this->resetAfterTest(); $instance = $this->getDataGenerator()->create_course(['shortname' => 'xyz']); @@ -148,7 +148,7 @@ class course_test extends \advanced_testcase { * Tests covered method. * @covers ::get_compatible_role_archetypes */ - public function test_get_compatible_role_archetypes() { + public function test_get_compatible_role_archetypes(): void { global $DB; $allarchetypes = $DB->get_fieldset_select('role', 'DISTINCT archetype', 'archetype IS NOT NULL'); @@ -167,7 +167,7 @@ class course_test extends \advanced_testcase { * Tests covered method. * @covers ::get_possible_parent_levels */ - public function test_get_possible_parent_levels() { + public function test_get_possible_parent_levels(): void { $this->assertSame([coursecat::LEVEL], course::get_possible_parent_levels()); } @@ -175,7 +175,7 @@ class course_test extends \advanced_testcase { * Tests covered method. * @covers ::get_capabilities */ - public function test_get_capabilities() { + public function test_get_capabilities(): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -195,7 +195,7 @@ class course_test extends \advanced_testcase { * Tests covered method. * @covers ::create_level_instances */ - public function test_create_level_instances() { + public function test_create_level_instances(): void { global $DB; $this->resetAfterTest(); @@ -211,7 +211,7 @@ class course_test extends \advanced_testcase { * Tests covered method. * @covers ::get_child_contexts */ - public function test_get_child_contexts() { + public function test_get_child_contexts(): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -229,7 +229,7 @@ class course_test extends \advanced_testcase { * Tests covered method. * @covers ::get_cleanup_sql */ - public function test_get_cleanup_sql() { + public function test_get_cleanup_sql(): void { global $DB; $this->resetAfterTest(); @@ -246,7 +246,7 @@ class course_test extends \advanced_testcase { * Tests covered method. * @covers ::build_paths */ - public function test_build_paths() { + public function test_build_paths(): void { global $DB; $this->resetAfterTest(); @@ -269,7 +269,7 @@ class course_test extends \advanced_testcase { * Tests covered method. * @covers ::set_locked */ - public function test_set_locked() { + public function test_set_locked(): void { global $DB; $this->resetAfterTest(); diff --git a/lib/tests/context/coursecat_test.php b/lib/tests/context/coursecat_test.php index 7fb5425c97a..f5188741477 100644 --- a/lib/tests/context/coursecat_test.php +++ b/lib/tests/context/coursecat_test.php @@ -33,7 +33,7 @@ class coursecat_test extends \advanced_testcase { * Tests legacy class name. * @coversNothing */ - public function test_legacy_classname() { + public function test_legacy_classname(): void { $category = \core_course_category::get_default(); $context = \context_coursecat::instance($category->id); $this->assertInstanceOf(coursecat::class, $context); @@ -45,7 +45,7 @@ class coursecat_test extends \advanced_testcase { * @covers ::instance * @covers \core\context::instance_by_id */ - public function test_factory_methods() { + public function test_factory_methods(): void { $category = \core_course_category::get_default(); $context = coursecat::instance($category->id); $this->assertInstanceOf(coursecat::class, $context); @@ -60,7 +60,7 @@ class coursecat_test extends \advanced_testcase { * Tests covered method. * @covers ::get_short_name */ - public function test_get_short_name() { + public function test_get_short_name(): void { $this->assertSame('coursecat', coursecat::get_short_name()); } @@ -68,7 +68,7 @@ class coursecat_test extends \advanced_testcase { * Tests levels. * @coversNothing */ - public function test_level() { + public function test_level(): void { $this->assertSame(40, coursecat::LEVEL); $this->assertSame(CONTEXT_COURSECAT, coursecat::LEVEL); } @@ -77,7 +77,7 @@ class coursecat_test extends \advanced_testcase { * Tests covered method. * @covers ::get_level_name */ - public function test_get_level_name() { + public function test_get_level_name(): void { $this->assertSame('Category', coursecat::get_level_name()); } @@ -85,7 +85,7 @@ class coursecat_test extends \advanced_testcase { * Tests covered method. * @covers ::get_context_name */ - public function test_get_context_name() { + public function test_get_context_name(): void { $category = \core_course_category::get_default(); $context = coursecat::instance($category->id); $this->assertSame('Category: Category 1', $context->get_context_name()); @@ -99,7 +99,7 @@ class coursecat_test extends \advanced_testcase { * Tests covered method. * @covers ::get_url */ - public function test_get_url() { + public function test_get_url(): void { $category = \core_course_category::get_default(); $context = coursecat::instance($category->id); $expected = new \moodle_url('/course/index.php', ['categoryid' => $category->id]); @@ -114,7 +114,7 @@ class coursecat_test extends \advanced_testcase { * @covers ::get_behat_reference_columns() * @covers \core\context_helper::resolve_behat_reference */ - public function test_resolve_behat_reference() { + public function test_resolve_behat_reference(): void { $this->resetAfterTest(); $instance = $this->getDataGenerator()->create_category(['idnumber' => 'xyz']); @@ -140,7 +140,7 @@ class coursecat_test extends \advanced_testcase { * Tests covered method. * @covers ::get_compatible_role_archetypes */ - public function test_get_compatible_role_archetypes() { + public function test_get_compatible_role_archetypes(): void { global $DB; $allarchetypes = $DB->get_fieldset_select('role', 'DISTINCT archetype', 'archetype IS NOT NULL'); @@ -158,7 +158,7 @@ class coursecat_test extends \advanced_testcase { * Tests covered method. * @covers ::get_possible_parent_levels */ - public function test_get_possible_parent_levels() { + public function test_get_possible_parent_levels(): void { $this->assertSame([system::LEVEL, coursecat::LEVEL], coursecat::get_possible_parent_levels()); } @@ -166,7 +166,7 @@ class coursecat_test extends \advanced_testcase { * Tests covered method. * @covers ::get_capabilities */ - public function test_get_capabilities() { + public function test_get_capabilities(): void { $category = \core_course_category::get_default(); $context = coursecat::instance($category->id); @@ -182,7 +182,7 @@ class coursecat_test extends \advanced_testcase { * Tests covered method. * @covers ::create_level_instances */ - public function test_create_level_instances() { + public function test_create_level_instances(): void { global $DB; $this->resetAfterTest(); @@ -198,7 +198,7 @@ class coursecat_test extends \advanced_testcase { * Tests covered method. * @covers ::get_child_contexts */ - public function test_get_child_contexts() { + public function test_get_child_contexts(): void { $this->resetAfterTest(); $category = \core_course_category::get_default(); @@ -218,7 +218,7 @@ class coursecat_test extends \advanced_testcase { * Tests covered method. * @covers ::get_cleanup_sql */ - public function test_get_cleanup_sql() { + public function test_get_cleanup_sql(): void { global $DB; $this->resetAfterTest(); @@ -235,7 +235,7 @@ class coursecat_test extends \advanced_testcase { * Tests covered method. * @covers ::build_paths */ - public function test_build_paths() { + public function test_build_paths(): void { global $DB; $this->resetAfterTest(); @@ -257,7 +257,7 @@ class coursecat_test extends \advanced_testcase { * Tests covered method. * @covers ::set_locked */ - public function test_set_locked() { + public function test_set_locked(): void { global $DB; $this->resetAfterTest(); diff --git a/lib/tests/context/module_test.php b/lib/tests/context/module_test.php index a8fba3f200b..033d3ea895b 100644 --- a/lib/tests/context/module_test.php +++ b/lib/tests/context/module_test.php @@ -33,7 +33,7 @@ class module_test extends \advanced_testcase { * Tests legacy class. * @coversNothing */ - public function test_legacy_classname() { + public function test_legacy_classname(): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -49,7 +49,7 @@ class module_test extends \advanced_testcase { * @covers ::instance * @covers \core\context::instance_by_id */ - public function test_factory_methods() { + public function test_factory_methods(): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -68,7 +68,7 @@ class module_test extends \advanced_testcase { * Tests covered method. * @covers ::get_short_name */ - public function test_get_short_name() { + public function test_get_short_name(): void { $this->assertSame('module', module::get_short_name()); } @@ -76,7 +76,7 @@ class module_test extends \advanced_testcase { * Tests context level. * @coversNothing */ - public function test_level() { + public function test_level(): void { $this->assertSame(70, module::LEVEL); $this->assertSame(CONTEXT_MODULE, module::LEVEL); } @@ -85,7 +85,7 @@ class module_test extends \advanced_testcase { * Tests covered method. * @covers ::get_level_name */ - public function test_get_level_name() { + public function test_get_level_name(): void { $this->assertSame('Activity module', module::get_level_name()); } @@ -93,7 +93,7 @@ class module_test extends \advanced_testcase { * Tests covered method. * @covers ::get_context_name */ - public function test_get_context_name() { + public function test_get_context_name(): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -111,7 +111,7 @@ class module_test extends \advanced_testcase { * Tests covered method. * @covers ::get_url */ - public function test_get_url() { + public function test_get_url(): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -130,7 +130,7 @@ class module_test extends \advanced_testcase { * @covers ::get_behat_reference_columns() * @covers \core\context_helper::resolve_behat_reference */ - public function test_resolve_behat_reference() { + public function test_resolve_behat_reference(): void { global $DB; $this->resetAfterTest(); @@ -159,7 +159,7 @@ class module_test extends \advanced_testcase { * Tests covered method. * @covers ::get_compatible_role_archetypes */ - public function test_get_compatible_role_archetypes() { + public function test_get_compatible_role_archetypes(): void { global $DB; $allarchetypes = $DB->get_fieldset_select('role', 'DISTINCT archetype', 'archetype IS NOT NULL'); @@ -177,7 +177,7 @@ class module_test extends \advanced_testcase { * Tests covered method. * @covers ::get_possible_parent_levels */ - public function test_get_possible_parent_levels() { + public function test_get_possible_parent_levels(): void { $this->assertSame([course::LEVEL], module::get_possible_parent_levels()); } @@ -185,7 +185,7 @@ class module_test extends \advanced_testcase { * Tests covered method. * @covers ::get_capabilities */ - public function test_get_capabilities() { + public function test_get_capabilities(): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -206,7 +206,7 @@ class module_test extends \advanced_testcase { * Tests covered method. * @covers ::create_level_instances */ - public function test_create_level_instances() { + public function test_create_level_instances(): void { global $DB; $this->resetAfterTest(); @@ -223,7 +223,7 @@ class module_test extends \advanced_testcase { * Tests covered method. * @covers ::get_child_contexts */ - public function test_get_child_contexts() { + public function test_get_child_contexts(): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -238,7 +238,7 @@ class module_test extends \advanced_testcase { * Tests covered method. * @covers ::get_cleanup_sql */ - public function test_get_cleanup_sql() { + public function test_get_cleanup_sql(): void { global $DB; $this->resetAfterTest(); @@ -257,7 +257,7 @@ class module_test extends \advanced_testcase { * Tests covered method. * @covers ::build_paths */ - public function test_build_paths() { + public function test_build_paths(): void { global $DB; $this->resetAfterTest(); @@ -283,7 +283,7 @@ class module_test extends \advanced_testcase { * Tests covered method. * @covers ::set_locked */ - public function test_set_locked() { + public function test_set_locked(): void { global $DB; $this->resetAfterTest(); diff --git a/lib/tests/context/system_test.php b/lib/tests/context/system_test.php index ccf873186aa..790794d18f0 100644 --- a/lib/tests/context/system_test.php +++ b/lib/tests/context/system_test.php @@ -33,7 +33,7 @@ class system_test extends \advanced_testcase { * Tests legacy class. * @coversNothing */ - public function test_legacy_classname() { + public function test_legacy_classname(): void { $context = \context_system::instance(); $this->assertInstanceOf(system::class, $context); $this->assertInstanceOf(\context_system::class, $context); @@ -44,7 +44,7 @@ class system_test extends \advanced_testcase { * @covers ::instance * @covers \core\context::instance_by_id */ - public function test_factory_methods() { + public function test_factory_methods(): void { $context = system::instance(); $this->assertInstanceOf(system::class, $context); $this->assertEquals(SYSCONTEXTID, $context->id); @@ -58,7 +58,7 @@ class system_test extends \advanced_testcase { * Tests covered method. * @covers ::get_short_name */ - public function test_get_short_name() { + public function test_get_short_name(): void { $this->assertSame('system', system::get_short_name()); } @@ -66,7 +66,7 @@ class system_test extends \advanced_testcase { * Tests context level. * @coversNothing */ - public function test_level() { + public function test_level(): void { $this->assertSame(10, system::LEVEL); $this->assertSame(CONTEXT_SYSTEM, system::LEVEL); } @@ -75,7 +75,7 @@ class system_test extends \advanced_testcase { * Tests covered method. * @covers ::get_level_name */ - public function test_get_level_name() { + public function test_get_level_name(): void { $this->assertSame('System', system::get_level_name()); } @@ -83,7 +83,7 @@ class system_test extends \advanced_testcase { * Tests covered method. * @covers ::get_context_name */ - public function test_get_context_name() { + public function test_get_context_name(): void { $context = system::instance(); $this->assertSame('System', $context->get_context_name()); $this->assertSame('System', $context->get_context_name(true)); @@ -96,7 +96,7 @@ class system_test extends \advanced_testcase { * Tests covered method. * @covers ::get_url */ - public function test_get_url() { + public function test_get_url(): void { $context = system::instance(); $expected = new \moodle_url('/'); $url = $context->get_url(); @@ -108,7 +108,7 @@ class system_test extends \advanced_testcase { * Tests covered method. * @covers \core\context_helper::resolve_behat_reference */ - public function test_resolve_behat_reference() { + public function test_resolve_behat_reference(): void { $syscontext = context\system::instance(); $result = context_helper::resolve_behat_reference('System', ''); @@ -128,7 +128,7 @@ class system_test extends \advanced_testcase { * Tests covered method. * @covers ::get_compatible_role_archetypes */ - public function test_get_compatible_role_archetypes() { + public function test_get_compatible_role_archetypes(): void { global $DB; $allarchetypes = $DB->get_fieldset_select('role', 'DISTINCT archetype', 'archetype IS NOT NULL'); @@ -146,7 +146,7 @@ class system_test extends \advanced_testcase { * Tests covered method. * @covers ::get_possible_parent_levels */ - public function test_get_possible_parent_levels() { + public function test_get_possible_parent_levels(): void { $this->assertSame([], system::get_possible_parent_levels()); } @@ -154,7 +154,7 @@ class system_test extends \advanced_testcase { * Tests covered method. * @covers ::get_capabilities */ - public function test_get_capabilities() { + public function test_get_capabilities(): void { global $DB; $context = system::instance(); @@ -167,7 +167,7 @@ class system_test extends \advanced_testcase { * Tests covered method. * @covers ::create_level_instances */ - public function test_create_level_instances() { + public function test_create_level_instances(): void { context_helper::create_instances(system::LEVEL); } @@ -175,7 +175,7 @@ class system_test extends \advanced_testcase { * Tests covered method. * @covers ::get_child_contexts */ - public function test_get_child_contexts() { + public function test_get_child_contexts(): void { global $DB; $context = system::instance(); @@ -190,7 +190,7 @@ class system_test extends \advanced_testcase { * Tests covered method. * @covers ::get_cleanup_sql */ - public function test_get_cleanup_sql() { + public function test_get_cleanup_sql(): void { // Nothing to clean up actually. context_helper::cleanup_instances(); } @@ -199,7 +199,7 @@ class system_test extends \advanced_testcase { * Tests covered method. * @covers ::build_paths */ - public function test_build_paths() { + public function test_build_paths(): void { global $DB; $this->resetAfterTest(); @@ -217,7 +217,7 @@ class system_test extends \advanced_testcase { * Tests covered method. * @covers ::set_locked */ - public function test_set_locked() { + public function test_set_locked(): void { $context = system::instance(); $context->set_locked(false); diff --git a/lib/tests/context/user_test.php b/lib/tests/context/user_test.php index d961337c182..2421c082bf5 100644 --- a/lib/tests/context/user_test.php +++ b/lib/tests/context/user_test.php @@ -33,7 +33,7 @@ class user_test extends \advanced_testcase { * Tests legacy class. * @coversNothing */ - public function test_legacy_classname() { + public function test_legacy_classname(): void { $admin = get_admin(); $context = \context_user::instance($admin->id); $this->assertInstanceOf(user::class, $context); @@ -45,7 +45,7 @@ class user_test extends \advanced_testcase { * @covers ::instance * @covers \core\context::instance_by_id */ - public function test_factory_methods() { + public function test_factory_methods(): void { $admin = get_admin(); $context = user::instance($admin->id); $this->assertInstanceOf(user::class, $context); @@ -60,7 +60,7 @@ class user_test extends \advanced_testcase { * Tests covered method. * @covers ::get_short_name */ - public function test_get_short_name() { + public function test_get_short_name(): void { $this->assertSame('user', user::get_short_name()); } @@ -68,7 +68,7 @@ class user_test extends \advanced_testcase { * Tests context level. * @coversNothing */ - public function test_level() { + public function test_level(): void { $this->assertSame(30, user::LEVEL); $this->assertSame(CONTEXT_USER, user::LEVEL); } @@ -77,7 +77,7 @@ class user_test extends \advanced_testcase { * Tests covered method. * @covers ::get_level_name */ - public function test_get_level_name() { + public function test_get_level_name(): void { $this->assertSame('User', user::get_level_name()); } @@ -85,7 +85,7 @@ class user_test extends \advanced_testcase { * Tests covered method. * @covers ::get_context_name */ - public function test_get_context_name() { + public function test_get_context_name(): void { $admin = get_admin(); $context = user::instance($admin->id); $this->assertSame('User: Admin User', $context->get_context_name()); @@ -99,7 +99,7 @@ class user_test extends \advanced_testcase { * Tests covered method. * @covers ::get_url */ - public function test_get_url() { + public function test_get_url(): void { $admin = get_admin(); $context = user::instance($admin->id); $expected = new \moodle_url('/user/profile.php', ['id' => $admin->id]); @@ -114,7 +114,7 @@ class user_test extends \advanced_testcase { * @covers ::get_behat_reference_columns() * @covers \core\context_helper::resolve_behat_reference */ - public function test_resolve_behat_reference() { + public function test_resolve_behat_reference(): void { $this->resetAfterTest(); $instance = $this->getDataGenerator()->create_user(); @@ -140,7 +140,7 @@ class user_test extends \advanced_testcase { * Tests covered method. * @covers ::get_compatible_role_archetypes */ - public function test_get_compatible_role_archetypes() { + public function test_get_compatible_role_archetypes(): void { global $DB; $allarchetypes = $DB->get_fieldset_select('role', 'DISTINCT archetype', 'archetype IS NOT NULL'); @@ -154,7 +154,7 @@ class user_test extends \advanced_testcase { * Tests covered method. * @covers ::get_possible_parent_levels */ - public function test_get_possible_parent_levels() { + public function test_get_possible_parent_levels(): void { $this->assertSame([system::LEVEL], user::get_possible_parent_levels()); } @@ -162,7 +162,7 @@ class user_test extends \advanced_testcase { * Tests covered method. * @covers ::get_capabilities */ - public function test_get_capabilities() { + public function test_get_capabilities(): void { $admin = get_admin(); $context = user::instance($admin->id); @@ -180,7 +180,7 @@ class user_test extends \advanced_testcase { * Tests covered method. * @covers ::create_level_instances */ - public function test_create_level_instances() { + public function test_create_level_instances(): void { global $DB; $this->resetAfterTest(); @@ -196,7 +196,7 @@ class user_test extends \advanced_testcase { * Tests covered method. * @covers ::get_child_contexts */ - public function test_get_child_contexts() { + public function test_get_child_contexts(): void { $admin = get_admin(); $context = user::instance($admin->id); @@ -208,7 +208,7 @@ class user_test extends \advanced_testcase { * Tests covered method. * @covers ::get_cleanup_sql */ - public function test_get_cleanup_sql() { + public function test_get_cleanup_sql(): void { global $DB; $this->resetAfterTest(); @@ -225,7 +225,7 @@ class user_test extends \advanced_testcase { * Tests covered method. * @covers ::build_paths */ - public function test_build_paths() { + public function test_build_paths(): void { global $DB; $this->resetAfterTest(); @@ -247,7 +247,7 @@ class user_test extends \advanced_testcase { * Tests covered method. * @covers ::set_locked */ - public function test_set_locked() { + public function test_set_locked(): void { global $DB; $this->resetAfterTest(); diff --git a/lib/tests/context_helper_test.php b/lib/tests/context_helper_test.php index 52140a19a25..7c42ce2d1c2 100644 --- a/lib/tests/context_helper_test.php +++ b/lib/tests/context_helper_test.php @@ -31,7 +31,7 @@ class context_helper_test extends \advanced_testcase { * Tests covered method. * @covers ::parse_external_level */ - public function test_parse_external_level() { + public function test_parse_external_level(): void { $this->assertSame(context\system::class, context_helper::parse_external_level('system')); $this->assertSame(context\system::class, context_helper::parse_external_level(CONTEXT_SYSTEM)); $this->assertSame(context\system::class, context_helper::parse_external_level((string)CONTEXT_SYSTEM)); @@ -66,7 +66,7 @@ class context_helper_test extends \advanced_testcase { * Tests covered method. * @covers ::resolve_behat_reference */ - public function test_resolve_behat_reference() { + public function test_resolve_behat_reference(): void { $this->assertNull(context_helper::resolve_behat_reference('blahbla', 'blahbla')); $this->assertNull(context_helper::resolve_behat_reference('', '')); $this->assertNull(context_helper::resolve_behat_reference('0', '')); @@ -86,7 +86,7 @@ class context_helper_test extends \advanced_testcase { * Tests covered method. * @covers ::get_class_for_level */ - public function test_get_class_for_level() { + public function test_get_class_for_level(): void { $this->assertSame(context\system::class, context_helper::get_class_for_level(CONTEXT_SYSTEM)); $this->assertSame(context\system::class, context_helper::get_class_for_level((string)CONTEXT_SYSTEM)); @@ -119,7 +119,7 @@ class context_helper_test extends \advanced_testcase { * Tests covered method. * @covers ::get_all_levels */ - public function test_get_all_levels() { + public function test_get_all_levels(): void { $levels = context_helper::get_all_levels(); $this->assertArrayHasKey(CONTEXT_SYSTEM, $levels); @@ -160,7 +160,7 @@ class context_helper_test extends \advanced_testcase { * Tests covered method. * @covers ::get_child_levels */ - public function test_get_child_levels() { + public function test_get_child_levels(): void { $alllevels = context_helper::get_all_levels(); $childlevels = context_helper::get_child_levels(CONTEXT_SYSTEM); @@ -206,7 +206,7 @@ class context_helper_test extends \advanced_testcase { * Tests covered method. * @covers ::get_compatible_levels */ - public function test_get_compatible_levels() { + public function test_get_compatible_levels(): void { $levels = context_helper::get_compatible_levels('manager'); $this->assertContains(CONTEXT_SYSTEM, $levels); $this->assertNotContains(CONTEXT_USER, $levels); @@ -261,7 +261,7 @@ class context_helper_test extends \advanced_testcase { * Tests covered method. * @covers ::cleanup_instances */ - public function test_cleanup_instances() { + public function test_cleanup_instances(): void { global $DB; $this->resetAfterTest(); @@ -296,7 +296,7 @@ class context_helper_test extends \advanced_testcase { * Tests covered method. * @covers ::create_instances */ - public function test_create_instances() { + public function test_create_instances(): void { global $DB; $this->resetAfterTest(); @@ -326,7 +326,7 @@ class context_helper_test extends \advanced_testcase { * Tests covered method. * @covers ::build_all_paths */ - public function test_build_all_paths() { + public function test_build_all_paths(): void { $this->resetAfterTest(); $this->preventResetByRollback(); @@ -339,7 +339,7 @@ class context_helper_test extends \advanced_testcase { * Tests covered method. * @covers ::reset_caches */ - public function test_reset_caches() { + public function test_reset_caches(): void { $this->resetAfterTest(); $this->preventResetByRollback(); @@ -351,7 +351,7 @@ class context_helper_test extends \advanced_testcase { * Tests covered method. * @covers ::get_preload_record_columns */ - public function test_get_preload_record_columns() { + public function test_get_preload_record_columns(): void { $expected = array ( 'testalias.id' => 'ctxid', 'testalias.path' => 'ctxpath', @@ -368,7 +368,7 @@ class context_helper_test extends \advanced_testcase { * Tests covered method. * @covers ::get_preload_record_columns_sql */ - public function test_get_preload_record_columns_sql() { + public function test_get_preload_record_columns_sql(): void { global $DB; $result = context_helper::get_preload_record_columns_sql('testalias'); @@ -385,7 +385,7 @@ class context_helper_test extends \advanced_testcase { * Tests covered method. * @covers ::preload_from_record */ - public function test_preload_from_record() { + public function test_preload_from_record(): void { global $DB; $select = context_helper::get_preload_record_columns_sql('testalias'); @@ -406,7 +406,7 @@ class context_helper_test extends \advanced_testcase { * Tests covered method. * @covers ::preload_contexts_by_id */ - public function test_preload_contexts_by_id() { + public function test_preload_contexts_by_id(): void { global $DB; $contextids = $DB->get_fieldset_sql("SELECT id FROM {context}", []); @@ -421,7 +421,7 @@ class context_helper_test extends \advanced_testcase { * Tests covered method. * @covers ::preload_course */ - public function test_preload_course() { + public function test_preload_course(): void { global $SITE; context_helper::preload_course($SITE->id); } @@ -430,7 +430,7 @@ class context_helper_test extends \advanced_testcase { * Tests covered method. * @covers ::delete_instance */ - public function test_delete_instance() { + public function test_delete_instance(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); @@ -450,7 +450,7 @@ class context_helper_test extends \advanced_testcase { * Tests covered method. * @covers ::get_level_name */ - public function test_get_level_name() { + public function test_get_level_name(): void { $allevels = context_helper::get_all_levels(); foreach ($allevels as $level => $classname) { $name = context_helper::get_level_name($level); @@ -469,7 +469,7 @@ class context_helper_test extends \advanced_testcase { * Tests covered method. * @covers ::get_navigation_filter_context */ - public function test_get_navigation_filter_context() { + public function test_get_navigation_filter_context(): void { global $CFG; $this->resetAfterTest(); diff --git a/lib/tests/context_test.php b/lib/tests/context_test.php index 3fffc43cb01..cda064c777a 100644 --- a/lib/tests/context_test.php +++ b/lib/tests/context_test.php @@ -31,7 +31,7 @@ class context_test extends \advanced_testcase { * Tests legacy class name. * @coversNothing */ - public function test_legacy_classname() { + public function test_legacy_classname(): void { $this->assertSame('core\context', context::class); $context = \context_system::instance(); @@ -43,7 +43,7 @@ class context_test extends \advanced_testcase { * Tests covered method. * @covers ::instance_by_id */ - public function test_factory_methods() { + public function test_factory_methods(): void { $context = context::instance_by_id(SYSCONTEXTID); $this->assertSame('core\\context\\system', get_class($context)); } @@ -53,7 +53,7 @@ class context_test extends \advanced_testcase { * @covers ::__set * @covers ::__unset */ - public function test_propery_change_protection() { + public function test_propery_change_protection(): void { $context = context\system::instance(); $context->contextlevel = -10; @@ -79,7 +79,7 @@ class context_test extends \advanced_testcase { * Tests covered method. * @covers ::__get */ - public function test_incorrect_property() { + public function test_incorrect_property(): void { $context = context\system::instance(); $a = $context->whatever; @@ -90,7 +90,7 @@ class context_test extends \advanced_testcase { * Tests covered method. * @covers ::getIterator */ - public function test_iterator() { + public function test_iterator(): void { $context = context\system::instance(); $array = iterator_to_array($context->getIterator()); $expected = [ diff --git a/lib/tests/core_media_player_native_test.php b/lib/tests/core_media_player_native_test.php index 22a8bcf3d75..6d563f47c20 100644 --- a/lib/tests/core_media_player_native_test.php +++ b/lib/tests/core_media_player_native_test.php @@ -43,7 +43,7 @@ class core_media_player_native_test extends \advanced_testcase { /** * Test method get_supported_extensions */ - public function test_get_supported_extensions() { + public function test_get_supported_extensions(): void { global $CFG; require_once($CFG->libdir . '/filelib.php'); $nativeextensions = file_get_typegroup('extension', ['html_video', 'html_audio']); @@ -76,7 +76,7 @@ class core_media_player_native_test extends \advanced_testcase { /** * Test method get_attribute */ - public function test_get_attribute() { + public function test_get_attribute(): void { $urls = [ new \moodle_url('http://example.org/some_filename.mp4'), new \moodle_url('http://example.org/some_filename_hires.mp4'), @@ -94,7 +94,7 @@ class core_media_player_native_test extends \advanced_testcase { /** * Test methods add_attributes and remove_attributes */ - public function test_add_remove_attributes() { + public function test_add_remove_attributes(): void { $urls = [ new \moodle_url('http://example.org/some_filename.mp4'), new \moodle_url('http://example.org/some_filename_hires.mp4'), @@ -133,7 +133,7 @@ class core_media_player_native_test extends \advanced_testcase { /** * Test method replace_sources */ - public function test_replace_sources() { + public function test_replace_sources(): void { $urls = [ new \moodle_url('http://example.org/some_filename.mp4'), new \moodle_url('http://example.org/some_filename_hires.mp4'), diff --git a/lib/tests/core_renderer_template_exploit_test.php b/lib/tests/core_renderer_template_exploit_test.php index 992fa1f95bc..6b6173dfb3f 100644 --- a/lib/tests/core_renderer_template_exploit_test.php +++ b/lib/tests/core_renderer_template_exploit_test.php @@ -404,7 +404,7 @@ class core_renderer_template_exploit_test extends \advanced_testcase { $js, $expected, $include - ) { + ): void { $page = new \moodle_page(); $renderer = $page->get_renderer('core'); diff --git a/lib/tests/csslib_test.php b/lib/tests/csslib_test.php index 4cdb18d63b3..11c4b83dfd8 100644 --- a/lib/tests/csslib_test.php +++ b/lib/tests/csslib_test.php @@ -34,7 +34,7 @@ class csslib_test extends \advanced_testcase { /** * Test that css_is_colour function throws an exception. */ - public function test_css_is_colour() { + public function test_css_is_colour(): void { $this->expectException('coding_exception'); $this->expectExceptionMessage('css_is_colour() can not be used anymore.'); css_is_colour(); @@ -43,7 +43,7 @@ class csslib_test extends \advanced_testcase { /** * Test that css_is_width function throws an exception. */ - public function test_css_is_width() { + public function test_css_is_width(): void { $this->expectException('coding_exception'); $this->expectExceptionMessage('css_is_width() can not be used anymore.'); css_is_width(); diff --git a/lib/tests/csvclass_test.php b/lib/tests/csvclass_test.php index 1bf9e49c3df..fc218d1d6ab 100644 --- a/lib/tests/csvclass_test.php +++ b/lib/tests/csvclass_test.php @@ -82,7 +82,7 @@ class csvclass_test extends \advanced_testcase { '; } - public function test_csv_functions() { + public function test_csv_functions(): void { global $CFG; $csvexport = new csv_export_writer(); $csvexport->set_filename('unittest'); diff --git a/lib/tests/curl_security_helper_test.php b/lib/tests/curl_security_helper_test.php index aa88abd7e99..3d92e9f588b 100644 --- a/lib/tests/curl_security_helper_test.php +++ b/lib/tests/curl_security_helper_test.php @@ -167,7 +167,7 @@ class curl_security_helper_test extends \advanced_testcase { * @param bool $expected the expected result. * @dataProvider curl_security_settings_data_provider */ - public function test_curl_security_helper_is_enabled($blockedhosts, $allowedports, $expected) { + public function test_curl_security_helper_is_enabled($blockedhosts, $allowedports, $expected): void { $this->resetAfterTest(true); $helper = new \core\files\curl_security_helper(); set_config('curlsecurityblockedhosts', $blockedhosts); @@ -199,7 +199,7 @@ class curl_security_helper_test extends \advanced_testcase { * @param bool $expected the expected result. * @dataProvider curl_security_host_data_provider */ - public function test_curl_security_helper_host_is_blocked($host, $blockedhosts, $expected) { + public function test_curl_security_helper_host_is_blocked($host, $blockedhosts, $expected): void { $this->resetAfterTest(true); $helper = new \core\files\curl_security_helper(); set_config('curlsecurityblockedhosts', $blockedhosts); @@ -253,7 +253,7 @@ class curl_security_helper_test extends \advanced_testcase { * @param bool $expected the expected result. * @dataProvider curl_security_port_data_provider */ - public function test_curl_security_helper_port_is_blocked($port, $allowedports, $expected) { + public function test_curl_security_helper_port_is_blocked($port, $allowedports, $expected): void { $this->resetAfterTest(true); $helper = new \core\files\curl_security_helper(); set_config('curlsecurityallowedport', $allowedports); @@ -289,7 +289,7 @@ class curl_security_helper_test extends \advanced_testcase { /** * Test for \core\files\curl_security_helper::get_blocked_url_string(). */ - public function test_curl_security_helper_get_blocked_url_string() { + public function test_curl_security_helper_get_blocked_url_string(): void { $helper = new \core\files\curl_security_helper(); $this->assertEquals(get_string('curlsecurityurlblocked', 'admin'), $helper->get_blocked_url_string()); } diff --git a/lib/tests/customcontext_test.php b/lib/tests/customcontext_test.php index 26f00bf81f3..9bdb8e38a2d 100644 --- a/lib/tests/customcontext_test.php +++ b/lib/tests/customcontext_test.php @@ -54,7 +54,7 @@ class customcontext_test extends \advanced_testcase { /** * Test case for custom context classes */ - public function test_customcontexts() { + public function test_customcontexts(): void { global $CFG; static $customcontexts = array( 11 => 'context_bogus1', diff --git a/lib/tests/datalib_test.php b/lib/tests/datalib_test.php index 29e04102ad2..77b03dc8a4c 100644 --- a/lib/tests/datalib_test.php +++ b/lib/tests/datalib_test.php @@ -36,7 +36,7 @@ class datalib_test extends \advanced_testcase { /** * Do a test of the user search SQL with database users. */ - public function test_users_search_sql() { + public function test_users_search_sql(): void { global $DB; $this->resetAfterTest(); @@ -154,19 +154,19 @@ class datalib_test extends \advanced_testcase { } } - public function test_users_order_by_sql_simple() { + public function test_users_order_by_sql_simple(): void { list($sort, $params) = users_order_by_sql(); $this->assert_same_sql('lastname, firstname, id', $sort); $this->assertEquals(array(), $params); } - public function test_users_order_by_sql_table_prefix() { + public function test_users_order_by_sql_table_prefix(): void { list($sort, $params) = users_order_by_sql('u'); $this->assert_same_sql('u.lastname, u.firstname, u.id', $sort); $this->assertEquals(array(), $params); } - public function test_users_order_by_sql_search_no_extra_fields() { + public function test_users_order_by_sql_search_no_extra_fields(): void { global $CFG, $DB; $this->resetAfterTest(true); @@ -182,7 +182,7 @@ class datalib_test extends \advanced_testcase { 'usersortexact3' => 'search'), $params); } - public function test_users_order_by_sql_search_with_extra_fields_and_prefix() { + public function test_users_order_by_sql_search_with_extra_fields_and_prefix(): void { global $CFG, $DB; $this->resetAfterTest(); @@ -220,7 +220,7 @@ class datalib_test extends \advanced_testcase { 'usersortexact3' => 'search', 'usersortexact4' => 'search'), $params); } - public function test_get_admin() { + public function test_get_admin(): void { global $CFG, $DB; $this->resetAfterTest(); @@ -252,7 +252,7 @@ class datalib_test extends \advanced_testcase { $this->assertEquals($odlread, $DB->perf_get_reads()); } - public function test_get_admins() { + public function test_get_admins(): void { global $CFG, $DB; $this->resetAfterTest(); @@ -283,7 +283,7 @@ class datalib_test extends \advanced_testcase { $this->assertEquals($odlread+1, $DB->perf_get_reads()); } - public function test_get_course() { + public function test_get_course(): void { global $DB, $PAGE, $SITE; $this->resetAfterTest(); @@ -338,7 +338,7 @@ class datalib_test extends \advanced_testcase { ], reset($courses)); } - public function test_increment_revision_number() { + public function test_increment_revision_number(): void { global $DB; $this->resetAfterTest(); @@ -395,7 +395,7 @@ class datalib_test extends \advanced_testcase { $this->assertEquals($record1->cacherev, $record2->cacherev); } - public function test_get_coursemodule_from_id() { + public function test_get_coursemodule_from_id(): void { global $CFG; $this->resetAfterTest(); @@ -461,7 +461,7 @@ class datalib_test extends \advanced_testcase { } } - public function test_get_coursemodule_from_instance() { + public function test_get_coursemodule_from_instance(): void { global $CFG; $this->resetAfterTest(); @@ -525,7 +525,7 @@ class datalib_test extends \advanced_testcase { } } - public function test_get_coursemodules_in_course() { + public function test_get_coursemodules_in_course(): void { global $CFG; $this->resetAfterTest(); @@ -594,7 +594,7 @@ class datalib_test extends \advanced_testcase { } } - public function test_get_all_instances_in_courses() { + public function test_get_all_instances_in_courses(): void { global $CFG; $this->resetAfterTest(); @@ -649,7 +649,7 @@ class datalib_test extends \advanced_testcase { } } - public function test_get_all_instances_in_course() { + public function test_get_all_instances_in_course(): void { global $CFG; $this->resetAfterTest(); @@ -705,7 +705,7 @@ class datalib_test extends \advanced_testcase { /** * Test max courses in category */ - public function test_max_courses_in_category() { + public function test_max_courses_in_category(): void { global $CFG; $this->resetAfterTest(); @@ -770,7 +770,7 @@ class datalib_test extends \advanced_testcase { /** * Test debug message for max courses in category */ - public function test_debug_max_courses_in_category() { + public function test_debug_max_courses_in_category(): void { global $CFG; $this->resetAfterTest(); diff --git a/lib/tests/datalib_update_with_unique_index_test.php b/lib/tests/datalib_update_with_unique_index_test.php index 8cb864f66a9..bdf32f8f144 100644 --- a/lib/tests/datalib_update_with_unique_index_test.php +++ b/lib/tests/datalib_update_with_unique_index_test.php @@ -26,40 +26,40 @@ namespace core; */ class datalib_update_with_unique_index_test extends \advanced_testcase { - public function test_decompose_update_into_safe_changes_identity() { + public function test_decompose_update_into_safe_changes_identity(): void { $this->assertEquals(array(), decompose_update_into_safe_changes( array(1 => 1, 2 => 2), -1)); } - public function test_decompose_update_into_safe_changes_no_overlap() { + public function test_decompose_update_into_safe_changes_no_overlap(): void { $this->assertEquals(array(array(1, 3), array(2, 4)), decompose_update_into_safe_changes( array(1 => 3, 2 => 4), -1)); } - public function test_decompose_update_into_safe_changes_shift() { + public function test_decompose_update_into_safe_changes_shift(): void { $this->assertSame(array(array(3, 4), array(2, 3), array(1, 2)), decompose_update_into_safe_changes( array(1 => 2, 2 => 3, 3 => 4), -1)); } - public function test_decompose_decompose_update_into_safe_changes_simple_swap() { + public function test_decompose_decompose_update_into_safe_changes_simple_swap(): void { $this->assertEquals(array(array(1, -1), array(2, 1), array(-1, 2)), decompose_update_into_safe_changes( array(1 => 2, 2 => 1), -1)); } - public function test_decompose_update_into_safe_changes_cycle() { + public function test_decompose_update_into_safe_changes_cycle(): void { $this->assertEquals(array(array(1, -2), array(3, 1), array(2, 3), array(-2, 2)), decompose_update_into_safe_changes( array(1 => 2, 2 => 3 , 3 => 1), -2)); } - public function test_decompose_update_into_safe_changes_complex() { + public function test_decompose_update_into_safe_changes_complex(): void { $this->assertEquals(array(array(9, 10), array(8, 9), array(1, -1), array(5, 1), array(7, 5), array(-1, 7), array(4, -1), array(6, 4), array(-1, 6)), decompose_update_into_safe_changes( array(1 => 7, 2 => 2, 3 => 3, 4 => 6, 5 => 1, 6 => 4, 7 => 5, 8 => 9, 9 => 10), -1)); } - public function test_decompose_update_into_safe_changes_unused_value_id_used() { + public function test_decompose_update_into_safe_changes_unused_value_id_used(): void { try { decompose_update_into_safe_changes(array(1 => 1), 1); $this->fail('Expected exception was not thrown'); @@ -68,7 +68,7 @@ class datalib_update_with_unique_index_test extends \advanced_testcase { } } - public function test_decompose_update_into_safe_changes_string_values() { + public function test_decompose_update_into_safe_changes_string_values(): void { // Sometimes this happens when data has been loaded from the database. $this->assertEquals(array(array(1, -1), array(2, 1), array(3, 2), array(4, 3), array(-1, 4)), @@ -76,7 +76,7 @@ class datalib_update_with_unique_index_test extends \advanced_testcase { array(1 => '4', 2 => '1', 3 => '2', 4 => '3'), -1)); } - public function test_reorder_rows() { + public function test_reorder_rows(): void { global $DB; $dbman = $DB->get_manager(); $this->resetAfterTest(); diff --git a/lib/tests/date_legacy_test.php b/lib/tests/date_legacy_test.php index f26e164a1f1..b0d9bcc6496 100644 --- a/lib/tests/date_legacy_test.php +++ b/lib/tests/date_legacy_test.php @@ -25,7 +25,7 @@ namespace core; * @author Petr Skoda */ class date_legacy_test extends \advanced_testcase { - public function test_settings() { + public function test_settings(): void { global $CFG; $this->resetAfterTest(); @@ -37,7 +37,7 @@ class date_legacy_test extends \advanced_testcase { $this->assertSame('99', $user->timezone); } - public function test_get_user_timezone() { + public function test_get_user_timezone(): void { global $CFG, $USER; $this->resetAfterTest(); @@ -110,7 +110,7 @@ class date_legacy_test extends \advanced_testcase { $this->assertSame('Europe/Berlin', $tz); } - public function test_dst_offset_on() { + public function test_dst_offset_on(): void { $time = gmmktime(1, 1, 1, 3, 1, 2015); $this->assertSame(3600, dst_offset_on($time, 'Pacific/Auckland')); $this->assertSame(0, dst_offset_on($time, 'Australia/Perth')); @@ -126,7 +126,7 @@ class date_legacy_test extends \advanced_testcase { $this->assertSame(3600, dst_offset_on($time, 'America/New_York')); } - public function test_make_timestamp() { + public function test_make_timestamp(): void { global $CFG; $this->resetAfterTest(); @@ -171,7 +171,7 @@ class date_legacy_test extends \advanced_testcase { } } - public function test_usergetdate() { + public function test_usergetdate(): void { global $CFG; $this->resetAfterTest(); @@ -242,7 +242,7 @@ class date_legacy_test extends \advanced_testcase { } } - public function test_userdate() { + public function test_userdate(): void { global $CFG; $this->resetAfterTest(); @@ -284,7 +284,7 @@ class date_legacy_test extends \advanced_testcase { } } - public function test_usertime() { + public function test_usertime(): void { // This is a useless bad hack, it needs to be completely eliminated. $time = gmmktime(1, 1, 1, 3, 1, 2015); @@ -304,7 +304,7 @@ class date_legacy_test extends \advanced_testcase { $this->assertSame($time - (60 * 60 * -5), usertime($time, 'America/New_York')); } - public function test_usertimezone() { + public function test_usertimezone(): void { global $USER; $this->resetAfterTest(); diff --git a/lib/tests/date_test.php b/lib/tests/date_test.php index ed825e84d4e..98f4396cb90 100644 --- a/lib/tests/date_test.php +++ b/lib/tests/date_test.php @@ -39,7 +39,7 @@ class date_test extends advanced_testcase { /** * @covers ::get_default_php_timezone */ - public function test_get_default_php_timezone() { + public function test_get_default_php_timezone(): void { $this->resetAfterTest(); $origtz = core_date::get_default_php_timezone(); @@ -58,7 +58,7 @@ class date_test extends advanced_testcase { /** * @covers ::normalise_timezone */ - public function test_normalise_timezone() { + public function test_normalise_timezone(): void { $this->resetAfterTest(); $this->setTimezone('Pacific/Auckland'); @@ -125,7 +125,7 @@ class date_test extends advanced_testcase { /** * @covers ::normalise_timezone */ - public function test_windows_conversion() { + public function test_windows_conversion(): void { $file = __DIR__ . '/fixtures/timezonewindows.xml'; $contents = file_get_contents($file); @@ -150,7 +150,7 @@ class date_test extends advanced_testcase { /** * Sanity test for PHP stuff. */ - public function test_php_gmt_offsets() { + public function test_php_gmt_offsets(): void { $this->resetAfterTest(); $this->setTimezone('Pacific/Auckland', 'Pacific/Auckland'); @@ -182,7 +182,7 @@ class date_test extends advanced_testcase { * * @coversNothing */ - public function test_timezone_all_lang_strings() { + public function test_timezone_all_lang_strings(): void { // We only run this test when PHPUNIT_LONGTEST is enabled, test_get_localised_timezone() // is already checking the names of a few, hopefully stable enough to be run always. if (!PHPUNIT_LONGTEST) { @@ -200,7 +200,7 @@ class date_test extends advanced_testcase { /** * @covers ::get_localised_timezone */ - public function test_get_localised_timezone() { + public function test_get_localised_timezone(): void { $this->resetAfterTest(); $this->setTimezone('Pacific/Auckland', 'Pacific/Auckland'); @@ -236,7 +236,7 @@ class date_test extends advanced_testcase { /** * @covers ::get_list_of_timezones */ - public function test_get_list_of_timezones() { + public function test_get_list_of_timezones(): void { $this->resetAfterTest(); $this->setTimezone('Pacific/Auckland', 'Pacific/Auckland'); @@ -287,7 +287,7 @@ class date_test extends advanced_testcase { /** * @covers ::get_server_timezone */ - public function test_get_server_timezone() { + public function test_get_server_timezone(): void { global $CFG; $this->resetAfterTest(); @@ -315,7 +315,7 @@ class date_test extends advanced_testcase { /** * @covers ::get_server_timezone_object */ - public function test_get_server_timezone_object() { + public function test_get_server_timezone_object(): void { $this->resetAfterTest(); $zones = core_date::get_list_of_timezones(); @@ -330,7 +330,7 @@ class date_test extends advanced_testcase { /** * @covers ::set_default_server_timezone */ - public function test_set_default_server_timezone() { + public function test_set_default_server_timezone(): void { global $CFG; $this->resetAfterTest(); @@ -452,7 +452,7 @@ class date_test extends advanced_testcase { * @param string $tz The legacy timezone. * @param string $expected The expected converted timezone. */ - public function test_get_legacy_user_timezone($tz, $expected) { + public function test_get_legacy_user_timezone($tz, $expected): void { $this->setTimezone('Australia/Perth', 'Australia/Perth'); $this->assertEquals($expected, core_date::get_user_timezone($tz)); } @@ -460,7 +460,7 @@ class date_test extends advanced_testcase { /** * @covers ::get_user_timezone */ - public function test_get_user_timezone() { + public function test_get_user_timezone(): void { global $CFG, $USER; $this->resetAfterTest(); @@ -599,7 +599,7 @@ class date_test extends advanced_testcase { /** * @covers ::get_user_timezone_object */ - public function test_get_user_timezone_object() { + public function test_get_user_timezone_object(): void { global $CFG, $USER; $this->resetAfterTest(); diff --git a/lib/tests/editorlib_test.php b/lib/tests/editorlib_test.php index 2bb0a5725fc..0a4584a1fde 100644 --- a/lib/tests/editorlib_test.php +++ b/lib/tests/editorlib_test.php @@ -29,7 +29,7 @@ class editorlib_test extends \advanced_testcase { /** * Tests the installation of event handlers from file */ - public function test_get_preferred_editor() { + public function test_get_preferred_editor(): void { // Fake a user agent. $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_5; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.21 5 Safari/534.10'; diff --git a/lib/tests/environment_test.php b/lib/tests/environment_test.php index ebadd7b8b0a..340ccbe76ab 100644 --- a/lib/tests/environment_test.php +++ b/lib/tests/environment_test.php @@ -31,7 +31,7 @@ class environment_test extends \advanced_testcase { /** * Test the environment check status. */ - public function test_environment_check_status() { + public function test_environment_check_status(): void { global $CFG; require_once($CFG->libdir.'/environmentlib.php'); @@ -65,7 +65,7 @@ class environment_test extends \advanced_testcase { * @dataProvider environment_provider * @param environment_results $result */ - public function test_environment($result) { + public function test_environment($result): void { $sslmessages = ['ssl/tls configuration not supported', 'invalid ssl/tls configuration']; if ($result->part === 'php_setting' @@ -97,7 +97,7 @@ class environment_test extends \advanced_testcase { /** * Test the get_list_of_environment_versions() function. */ - public function test_get_list_of_environment_versions() { + public function test_get_list_of_environment_versions(): void { global $CFG; require_once($CFG->libdir.'/environmentlib.php'); // Build a sample xmlised environment.xml. @@ -143,7 +143,7 @@ END; /** * Test the environment_verify_plugin() function. */ - public function test_verify_plugin() { + public function test_verify_plugin(): void { global $CFG; require_once($CFG->libdir.'/environmentlib.php'); // Build sample xmlised environment file fragments. @@ -173,7 +173,7 @@ END; * Test the restrict_php_version() function returns true if the current * PHP version is greater than the restricted version */ - public function test_restrict_php_version_greater_than_restricted_version() { + public function test_restrict_php_version_greater_than_restricted_version(): void { global $CFG; require_once($CFG->libdir.'/environmentlib.php'); @@ -196,7 +196,7 @@ END; * Test the restrict_php_version() function returns true if the current * PHP version is equal to the restricted version */ - public function test_restrict_php_version_equal_to_restricted_version() { + public function test_restrict_php_version_equal_to_restricted_version(): void { global $CFG; require_once($CFG->libdir.'/environmentlib.php'); @@ -215,7 +215,7 @@ END; * Test the restrict_php_version() function returns false if the current * PHP version is less than the restricted version */ - public function test_restrict_php_version_less_than_restricted_version() { + public function test_restrict_php_version_less_than_restricted_version(): void { global $CFG; require_once($CFG->libdir.'/environmentlib.php'); diff --git a/lib/tests/event/base_test.php b/lib/tests/event/base_test.php index 30dc2c91cbe..6b47fe16fcc 100644 --- a/lib/tests/event/base_test.php +++ b/lib/tests/event/base_test.php @@ -32,7 +32,7 @@ class base_test extends \advanced_testcase { const DEBUGGING_MSG = 'Events API using $handlers array has been deprecated in favour of Events 2 API, please use it instead.'; - public function test_event_properties() { + public function test_event_properties(): void { global $USER; $system = \context_system::instance(); @@ -87,7 +87,7 @@ class base_test extends \advanced_testcase { $this->assertSame(1, $event3->anonymous); } - public function test_event_properties_guessing() { + public function test_event_properties_guessing(): void { global $USER; $this->resetAfterTest(); @@ -120,7 +120,7 @@ class base_test extends \advanced_testcase { $this->assertSame($user->id, $event->relateduserid); } - public function test_observers_parsing() { + public function test_observers_parsing(): void { global $CFG; $observers = array( @@ -287,7 +287,7 @@ class base_test extends \advanced_testcase { $this->assertDebuggingCalled(); } - public function test_normal_dispatching() { + public function test_normal_dispatching(): void { $observers = array( array( 'eventname' => '\core_tests\event\unittest_executed', @@ -323,7 +323,7 @@ class base_test extends \advanced_testcase { \core_tests\event\unittest_observer::$info); } - public function test_event_sink() { + public function test_event_sink(): void { $sink = $this->redirectEvents(); $event1 = \core_tests\event\unittest_executed::create(array('context'=>\context_system::instance(), 'other'=>array('sample'=>1, 'xx'=>10))); $event1->trigger(); @@ -356,7 +356,7 @@ class base_test extends \advanced_testcase { $this->assertSame($event3, $retult[0]); } - public function test_ignore_exceptions() { + public function test_ignore_exceptions(): void { $observers = array( array( @@ -387,7 +387,7 @@ class base_test extends \advanced_testcase { \core_tests\event\unittest_observer::$info); } - public function test_external_buffer() { + public function test_external_buffer(): void { global $DB; $this->preventResetByRollback(); @@ -461,7 +461,7 @@ class base_test extends \advanced_testcase { \core_tests\event\unittest_observer::$info); } - public function test_rollback() { + public function test_rollback(): void { global $DB; $this->resetAfterTest(); @@ -514,7 +514,7 @@ class base_test extends \advanced_testcase { $this->assertCount(1, \core_tests\event\unittest_observer::$event); } - public function test_forced_rollback() { + public function test_forced_rollback(): void { global $DB; $this->resetAfterTest(); @@ -556,7 +556,7 @@ class base_test extends \advanced_testcase { $this->assertCount(1, \core_tests\event\unittest_observer::$event); } - public function test_deprecated() { + public function test_deprecated(): void { global $DB; $this->resetAfterTest(true); @@ -573,7 +573,7 @@ class base_test extends \advanced_testcase { $this->assertSame($event::LEVEL_TEACHING, $event->edulevel); } - public function test_legacy() { + public function test_legacy(): void { global $DB, $CFG; $this->resetAfterTest(true); @@ -623,7 +623,7 @@ class base_test extends \advanced_testcase { $this->assertCount(0, $logs); } - public function test_restore_event() { + public function test_restore_event(): void { $event1 = \core_tests\event\unittest_executed::create(array('context'=>\context_system::instance(), 'other'=>array('sample'=>1, 'xx'=>10))); $data1 = $event1->get_data(); @@ -657,7 +657,7 @@ class base_test extends \advanced_testcase { } - public function test_trigger_problems() { + public function test_trigger_problems(): void { $this->resetAfterTest(true); $event = \core_tests\event\unittest_executed::create(array('context'=>\context_system::instance(), 'other'=>array('sample'=>5, 'xx'=>10))); @@ -690,7 +690,7 @@ class base_test extends \advanced_testcase { } } - public function test_bad_events() { + public function test_bad_events(): void { $this->resetAfterTest(true); try { @@ -749,7 +749,7 @@ class base_test extends \advanced_testcase { $this->assertDebuggingCalled('Event property objectid must be set when objecttable is defined'); } - public function test_problematic_events() { + public function test_problematic_events(): void { $this->resetAfterTest(true); $event1 = \core_tests\event\problematic_event1::create(array('context'=>\context_system::instance())); @@ -800,7 +800,7 @@ class base_test extends \advanced_testcase { $this->assertDebuggingCalled(); } - public function test_record_snapshots() { + public function test_record_snapshots(): void { global $DB; $this->resetAfterTest(true); @@ -837,12 +837,12 @@ class base_test extends \advanced_testcase { } } - public function test_get_name() { + public function test_get_name(): void { $event = \core_tests\event\noname_event::create(array('other' => array('sample' => 1, 'xx' => 10))); $this->assertEquals("core_tests: noname event", $event->get_name()); } - public function test_iteration() { + public function test_iteration(): void { $event = \core_tests\event\unittest_executed::create(array('context'=>\context_system::instance(), 'other'=>array('sample'=>1, 'xx'=>10))); $data = array(); @@ -856,7 +856,7 @@ class base_test extends \advanced_testcase { /** * Test that all observer information is returned correctly. */ - public function test_get_all_observers() { + public function test_get_all_observers(): void { // Retrieve all observers. $observers = \core\event\manager::get_all_observers(); @@ -884,7 +884,7 @@ class base_test extends \advanced_testcase { * Test formatting of the get_explanation method. * This formats the information from an events class docblock. */ - public function test_get_explanation() { + public function test_get_explanation(): void { $explanation = \core_tests\event\full_docblock::get_explanation(); $expected = "This is an explanation of the event. @@ -912,7 +912,7 @@ and nothing else."; * Test that general information about an event is returned * by the get_static_info() method. */ - public function test_get_static_info() { + public function test_get_static_info(): void { $staticinfo = \core_tests\event\static_info_viewing::get_static_info(); $expected = array( @@ -934,7 +934,7 @@ and nothing else."; * the base event class or the final, implemented event class. This enables us to subscribe * to things like all course module view events, all comment created events, etc. */ - public function test_observe_parent_event() { + public function test_observe_parent_event(): void { $this->resetAfterTest(); // Ensure this has been reset prior to using it. diff --git a/lib/tests/event/contentbank_content_created_test.php b/lib/tests/event/contentbank_content_created_test.php index b83e6c5337e..52e145f68ce 100644 --- a/lib/tests/event/contentbank_content_created_test.php +++ b/lib/tests/event/contentbank_content_created_test.php @@ -51,7 +51,7 @@ class contentbank_content_created_test extends \advanced_testcase { * * @covers ::create_from_record */ - public function test_content_created() { + public function test_content_created(): void { $this->resetAfterTest(); $this->setAdminUser(); diff --git a/lib/tests/event/contentbank_content_deleted_test.php b/lib/tests/event/contentbank_content_deleted_test.php index 8e9191b131a..81cc9f36020 100644 --- a/lib/tests/event/contentbank_content_deleted_test.php +++ b/lib/tests/event/contentbank_content_deleted_test.php @@ -51,7 +51,7 @@ class contentbank_content_deleted_test extends \advanced_testcase { * * @covers ::create_from_record */ - public function test_content_deleted() { + public function test_content_deleted(): void { global $DB; $this->resetAfterTest(); diff --git a/lib/tests/event/contentbank_content_updated_test.php b/lib/tests/event/contentbank_content_updated_test.php index 9292785824b..2379a8b81d6 100644 --- a/lib/tests/event/contentbank_content_updated_test.php +++ b/lib/tests/event/contentbank_content_updated_test.php @@ -51,7 +51,7 @@ class contentbank_content_updated_test extends \advanced_testcase { * * @covers ::create_from_record */ - public function test_content_updated() { + public function test_content_updated(): void { $this->resetAfterTest(); $this->setAdminUser(); diff --git a/lib/tests/event/contentbank_content_uploaded_test.php b/lib/tests/event/contentbank_content_uploaded_test.php index 2aa131f1327..131fc4f735e 100644 --- a/lib/tests/event/contentbank_content_uploaded_test.php +++ b/lib/tests/event/contentbank_content_uploaded_test.php @@ -53,7 +53,7 @@ class contentbank_content_uploaded_test extends \advanced_testcase { * * @covers ::create_from_record */ - public function test_content_created() { + public function test_content_created(): void { global $USER, $CFG; $this->resetAfterTest(); diff --git a/lib/tests/event/contentbank_content_viewed_test.php b/lib/tests/event/contentbank_content_viewed_test.php index 191cdb45c18..8cdf1dff3f1 100644 --- a/lib/tests/event/contentbank_content_viewed_test.php +++ b/lib/tests/event/contentbank_content_viewed_test.php @@ -51,7 +51,7 @@ class contentbank_content_viewed_test extends \advanced_testcase { * * @covers ::create_from_record */ - public function test_content_viewed() { + public function test_content_viewed(): void { $this->resetAfterTest(); $this->setAdminUser(); diff --git a/lib/tests/event/context_locked_test.php b/lib/tests/event/context_locked_test.php index 05a875beea3..b0964c5a41f 100644 --- a/lib/tests/event/context_locked_test.php +++ b/lib/tests/event/context_locked_test.php @@ -51,7 +51,7 @@ class context_locked_test extends \advanced_testcase { /** * Tests that events are created when contexts are locked and unlocked. */ - public function test_creation() { + public function test_creation(): void { $this->resetAfterTest(); $category = self::getDataGenerator()->create_category(); diff --git a/lib/tests/event/deprecated_test.php b/lib/tests/event/deprecated_test.php index 57aa7a8af89..feb812890ab 100644 --- a/lib/tests/event/deprecated_test.php +++ b/lib/tests/event/deprecated_test.php @@ -29,7 +29,7 @@ class deprecated_test extends \advanced_testcase { /** * Test event properties and methods. */ - public function test_deprecated_course_module_instances_list_viewed_events() { + public function test_deprecated_course_module_instances_list_viewed_events(): void { // Make sure the abstract class course_module_instances_list_viewed generates a debugging notice. require_once(__DIR__ . '/../fixtures/event_mod_badfixtures.php'); diff --git a/lib/tests/event/draft_file_added_test.php b/lib/tests/event/draft_file_added_test.php index e5c9eab0d30..b1b950ca06d 100644 --- a/lib/tests/event/draft_file_added_test.php +++ b/lib/tests/event/draft_file_added_test.php @@ -38,7 +38,7 @@ class draft_file_added_test extends \advanced_testcase { /** * Test draft file added event. */ - public function test_event() { + public function test_event(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); $this->setUser($user); diff --git a/lib/tests/event/draft_file_deleted_test.php b/lib/tests/event/draft_file_deleted_test.php index 32034a508be..cab18b8e33b 100644 --- a/lib/tests/event/draft_file_deleted_test.php +++ b/lib/tests/event/draft_file_deleted_test.php @@ -38,7 +38,7 @@ class draft_file_deleted_test extends \advanced_testcase { /** * Test draft file deleted event. */ - public function test_event() { + public function test_event(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); $this->setUser($user); diff --git a/lib/tests/event/events_test.php b/lib/tests/event/events_test.php index e385981ac07..089a4154217 100644 --- a/lib/tests/event/events_test.php +++ b/lib/tests/event/events_test.php @@ -43,7 +43,7 @@ class events_test extends \advanced_testcase { /** * Test the course category created event. */ - public function test_course_category_created() { + public function test_course_category_created(): void { // Trigger and capture the event. $sink = $this->redirectEvents(); $category = $this->getDataGenerator()->create_category(); @@ -61,7 +61,7 @@ class events_test extends \advanced_testcase { /** * Test the course category updated event. */ - public function test_course_category_updated() { + public function test_course_category_updated(): void { // Create a category. $category = $this->getDataGenerator()->create_category(); @@ -143,7 +143,7 @@ class events_test extends \advanced_testcase { * It's not possible to use the moodle API to simulate the failure of sending * an email, so here we simply create the event and trigger it. */ - public function test_email_failed() { + public function test_email_failed(): void { // Trigger event for failing to send email. $event = \core\event\email_failed::create(array( 'context' => \context_system::instance(), @@ -170,7 +170,7 @@ class events_test extends \advanced_testcase { /** * There is no api involved so the best we can do is test legacy data by triggering event manually. */ - public function test_course_user_report_viewed() { + public function test_course_user_report_viewed(): void { $user = $this->getDataGenerator()->create_user(); $course = $this->getDataGenerator()->create_course(); @@ -197,7 +197,7 @@ class events_test extends \advanced_testcase { /** * There is no api involved so the best we can do is test legacy data by triggering event manually. */ - public function test_course_viewed() { + public function test_course_viewed(): void { $user = $this->getDataGenerator()->create_user(); $course = $this->getDataGenerator()->create_course(); @@ -243,7 +243,7 @@ class events_test extends \advanced_testcase { $this->assertNull($restored->get_url()); } - public function test_recent_capability_viewed() { + public function test_recent_capability_viewed(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -266,7 +266,7 @@ class events_test extends \advanced_testcase { $event->get_name(); } - public function test_user_profile_viewed() { + public function test_user_profile_viewed(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -316,7 +316,7 @@ class events_test extends \advanced_testcase { /** * There is no API associated with this event, so we will just test standard features. */ - public function test_grade_viewed() { + public function test_grade_viewed(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -347,7 +347,7 @@ class events_test extends \advanced_testcase { /** * Test the database text field content replaced event. */ - public function test_database_text_field_content_replaced() { + public function test_database_text_field_content_replaced(): void { global $CFG; require_once($CFG->dirroot . '/lib/adminlib.php'); diff --git a/lib/tests/event/grade_deleted_test.php b/lib/tests/event/grade_deleted_test.php index b23d832b5f7..a6e56c5abaf 100644 --- a/lib/tests/event/grade_deleted_test.php +++ b/lib/tests/event/grade_deleted_test.php @@ -31,7 +31,7 @@ class grade_deleted_test extends \advanced_testcase { /** * Tests the event details. */ - public function test_event() { + public function test_event(): void { global $CFG; require_once("$CFG->libdir/gradelib.php"); diff --git a/lib/tests/event/grade_item_deleted_test.php b/lib/tests/event/grade_item_deleted_test.php index d1b0c160c14..e3407c3b44e 100644 --- a/lib/tests/event/grade_item_deleted_test.php +++ b/lib/tests/event/grade_item_deleted_test.php @@ -41,7 +41,7 @@ class grade_item_deleted_test extends \advanced_testcase { * * @covers ::create_from_grade_item */ - public function test_grade_item_deleted() { + public function test_grade_item_deleted(): void { global $DB; $this->resetAfterTest(); diff --git a/lib/tests/event/profile_field_test.php b/lib/tests/event/profile_field_test.php index 4af04703791..ac066d445b2 100644 --- a/lib/tests/event/profile_field_test.php +++ b/lib/tests/event/profile_field_test.php @@ -44,7 +44,7 @@ class profile_field_test extends \advanced_testcase { /** * Test that triggering the user_info_category_created event works as expected. */ - public function test_user_info_category_created_event() { + public function test_user_info_category_created_event(): void { // Create a new profile category. $cat1 = $this->getDataGenerator()->create_custom_profile_field_category(['name' => 'Example category']); @@ -67,7 +67,7 @@ class profile_field_test extends \advanced_testcase { /** * Test that moving a user info category triggers an updated event. */ - public function test_user_info_category_updated_event() { + public function test_user_info_category_updated_event(): void { global $DB; // Create new profile categories. @@ -98,7 +98,7 @@ class profile_field_test extends \advanced_testcase { /** * Test that deleting a user info category triggers a delete event. */ - public function test_user_info_category_deleted_event() { + public function test_user_info_category_deleted_event(): void { // Create new profile categories. $cat1 = $this->getDataGenerator()->create_custom_profile_field_category(['name' => 'Example category']); $cat2 = $this->getDataGenerator()->create_custom_profile_field_category(['name' => 'Example category 2']); @@ -122,7 +122,7 @@ class profile_field_test extends \advanced_testcase { /** * Test that creating a user info field triggers a create event. */ - public function test_user_info_field_created_event() { + public function test_user_info_field_created_event(): void { global $DB; // Create a new profile category. @@ -166,7 +166,7 @@ class profile_field_test extends \advanced_testcase { /** * Test that updating a user info field triggers an update event. */ - public function test_user_info_field_updated_event() { + public function test_user_info_field_updated_event(): void { // Create a new profile category. $cat1 = $this->getDataGenerator()->create_custom_profile_field_category(['name' => 'Example category']); @@ -201,7 +201,7 @@ class profile_field_test extends \advanced_testcase { /** * Test that moving a field triggers update events. */ - public function test_user_info_field_updated_event_move_field() { + public function test_user_info_field_updated_event_move_field(): void { // Create a new profile category. $cat1 = $this->getDataGenerator()->create_custom_profile_field_category(['name' => 'Example category']); @@ -251,7 +251,7 @@ class profile_field_test extends \advanced_testcase { * Test that when we delete a category that contains a field, that the field being moved to * another category triggers an update event. */ - public function test_user_info_field_updated_event_delete_category() { + public function test_user_info_field_updated_event_delete_category(): void { // Create profile categories. $cat1 = $this->getDataGenerator()->create_custom_profile_field_category(['name' => 'Example category']); $cat2 = $this->getDataGenerator()->create_custom_profile_field_category(['name' => 'Example category']); @@ -286,7 +286,7 @@ class profile_field_test extends \advanced_testcase { /** * Test that deleting a user info field triggers a delete event. */ - public function test_user_info_field_deleted_event() { + public function test_user_info_field_deleted_event(): void { // Create a new profile category. $cat1 = $this->getDataGenerator()->create_custom_profile_field_category(['name' => 'Example category']); diff --git a/lib/tests/event/unknown_logged_test.php b/lib/tests/event/unknown_logged_test.php index 8e40b9b1c1f..b8bc3512094 100644 --- a/lib/tests/event/unknown_logged_test.php +++ b/lib/tests/event/unknown_logged_test.php @@ -30,7 +30,7 @@ require_once(__DIR__.'/../fixtures/event_fixtures.php'); */ class unknown_logged_test extends \advanced_testcase { - public function test_restore_event() { + public function test_restore_event(): void { $event1 = \core_tests\event\unittest_executed::create(array('context' => \context_system::instance(), 'other' => array('sample' => 1, 'xx' => 10))); $data1 = $event1->get_data(); diff --git a/lib/tests/event/user_graded_test.php b/lib/tests/event/user_graded_test.php index 6c36d7bbcde..ab0dbcb608c 100644 --- a/lib/tests/event/user_graded_test.php +++ b/lib/tests/event/user_graded_test.php @@ -42,7 +42,7 @@ class user_graded_test extends \advanced_testcase { /** * Tests the event details. */ - public function test_event() { + public function test_event(): void { global $CFG; require_once("$CFG->libdir/gradelib.php"); @@ -87,7 +87,7 @@ class user_graded_test extends \advanced_testcase { /** * Tests that the event is fired in the correct locations in core. */ - public function test_event_is_triggered() { + public function test_event_is_triggered(): void { global $DB; // Create the items we need to test with. diff --git a/lib/tests/event/user_password_updated_test.php b/lib/tests/event/user_password_updated_test.php index f9069a9e6bb..f19755a21e8 100644 --- a/lib/tests/event/user_password_updated_test.php +++ b/lib/tests/event/user_password_updated_test.php @@ -28,7 +28,7 @@ class user_password_updated_test extends \advanced_testcase { /** * Test the event. */ - public function test_event() { + public function test_event(): void { $this->resetAfterTest(); $user1 = $this->getDataGenerator()->create_user(); diff --git a/lib/tests/exporter_test.php b/lib/tests/exporter_test.php index 44d6cf8ef28..e835ad8a10c 100644 --- a/lib/tests/exporter_test.php +++ b/lib/tests/exporter_test.php @@ -71,7 +71,7 @@ class exporter_test extends \advanced_testcase { $this->invaliddata = array('stringA' => 'A string'); } - public function test_get_read_structure() { + public function test_get_read_structure(): void { $structure = core_testable_exporter::get_read_structure(); $this->assertInstanceOf(external_single_structure::class, $structure); @@ -82,7 +82,7 @@ class exporter_test extends \advanced_testcase { $this->assertInstanceOf(external_multiple_structure::class, $structure->keys['otherstrings']); } - public function test_get_create_structure() { + public function test_get_create_structure(): void { $structure = core_testable_exporter::get_create_structure(); $this->assertInstanceOf(external_single_structure::class, $structure); @@ -93,7 +93,7 @@ class exporter_test extends \advanced_testcase { $this->assertArrayNotHasKey('otherstrings', $structure->keys); } - public function test_get_update_structure() { + public function test_get_update_structure(): void { $structure = core_testable_exporter::get_update_structure(); $this->assertInstanceOf(external_single_structure::class, $structure); @@ -104,7 +104,7 @@ class exporter_test extends \advanced_testcase { $this->assertArrayNotHasKey('otherstrings', $structure->keys); } - public function test_invalid_data() { + public function test_invalid_data(): void { global $PAGE; $exporter = new core_testable_exporter($this->invaliddata, $this->validrelated); $output = $PAGE->get_renderer('core'); @@ -115,14 +115,14 @@ class exporter_test extends \advanced_testcase { $result = $exporter->export($output); } - public function test_invalid_related() { + public function test_invalid_related(): void { $this->expectException(\coding_exception::class); $this->expectExceptionMessage('Exporter class is missing required related data: (core\core_testable_exporter) ' . 'simplestdClass => stdClass'); $exporter = new core_testable_exporter($this->validdata, $this->invalidrelated); } - public function test_invalid_related_all_cases() { + public function test_invalid_related_all_cases(): void { global $PAGE; foreach ($this->invalidrelated as $key => $value) { @@ -139,7 +139,7 @@ class exporter_test extends \advanced_testcase { } } - public function test_valid_data_and_related() { + public function test_valid_data_and_related(): void { global $PAGE; $output = $PAGE->get_renderer('core'); $exporter = new core_testable_exporter($this->validdata, $this->validrelated); @@ -148,7 +148,7 @@ class exporter_test extends \advanced_testcase { $this->assertSame(array('String >a', 'String b'), $result->otherstrings); } - public function test_format_text() { + public function test_format_text(): void { global $PAGE; $this->resetAfterTest(); @@ -189,7 +189,7 @@ class exporter_test extends \advanced_testcase { $this->assertEquals(FORMAT_HTML, $result->stringAformat); } - public function test_properties_description() { + public function test_properties_description(): void { $properties = core_testable_exporter::read_properties_definition(); // Properties default description. $this->assertEquals('stringA', $properties['stringA']['description']); diff --git a/lib/tests/external/moodlenet_auth_check_test.php b/lib/tests/external/moodlenet_auth_check_test.php index 049359892c8..01bea520ed0 100644 --- a/lib/tests/external/moodlenet_auth_check_test.php +++ b/lib/tests/external/moodlenet_auth_check_test.php @@ -43,7 +43,7 @@ class moodlenet_auth_check_test extends externallib_advanced_testcase { * * @covers ::execute */ - public function test_moodlenet_auth_check() { + public function test_moodlenet_auth_check(): void { global $CFG; $this->resetAfterTest(); $this->setAdminUser(); diff --git a/lib/tests/external/moodlenet_get_share_info_activity_test.php b/lib/tests/external/moodlenet_get_share_info_activity_test.php index ec0abbded39..5ffc7de919c 100644 --- a/lib/tests/external/moodlenet_get_share_info_activity_test.php +++ b/lib/tests/external/moodlenet_get_share_info_activity_test.php @@ -42,7 +42,7 @@ class moodlenet_get_share_info_activity_test extends externallib_advanced_testca * Test the behaviour of moodlenet_get_share_info_activity(). * @covers ::execute */ - public function test_moodlenet_get_share_info_activity() { + public function test_moodlenet_get_share_info_activity(): void { global $CFG; $this->resetAfterTest(); $this->setAdminUser(); diff --git a/lib/tests/external/moodlenet_get_shared_course_info_test.php b/lib/tests/external/moodlenet_get_shared_course_info_test.php index cf66de4cc8f..3f3dfcb2497 100644 --- a/lib/tests/external/moodlenet_get_shared_course_info_test.php +++ b/lib/tests/external/moodlenet_get_shared_course_info_test.php @@ -43,7 +43,7 @@ class moodlenet_get_shared_course_info_test extends externallib_advanced_testcas * * @covers ::execute */ - public function test_moodlenet_get_shared_course_info() { + public function test_moodlenet_get_shared_course_info(): void { global $CFG; $this->resetAfterTest(); $this->setAdminUser(); diff --git a/lib/tests/external/moodlenet_send_activity_test.php b/lib/tests/external/moodlenet_send_activity_test.php index fdaebf8726d..02ca05fee99 100644 --- a/lib/tests/external/moodlenet_send_activity_test.php +++ b/lib/tests/external/moodlenet_send_activity_test.php @@ -43,7 +43,7 @@ class moodlenet_send_activity_test extends externallib_advanced_testcase { * * @covers ::execute */ - public function test_moodlenet_send_activity() { + public function test_moodlenet_send_activity(): void { global $CFG; $this->resetAfterTest(); $this->setAdminUser(); @@ -118,7 +118,7 @@ class moodlenet_send_activity_test extends externallib_advanced_testcase { * @dataProvider return_resource_url_provider * @covers ::execute_returns */ - public function test_moodlenet_send_activity_return_resource_url(bool $state, string $resourceurl) { + public function test_moodlenet_send_activity_return_resource_url(bool $state, string $resourceurl): void { $this->resetAfterTest(); // Create dummy result with the resourceurl. $result = [ diff --git a/lib/tests/external/moodlenet_send_course_test.php b/lib/tests/external/moodlenet_send_course_test.php index 85d2c0483bb..f622ab3c957 100644 --- a/lib/tests/external/moodlenet_send_course_test.php +++ b/lib/tests/external/moodlenet_send_course_test.php @@ -43,7 +43,7 @@ class moodlenet_send_course_test extends externallib_advanced_testcase { * * @covers ::execute */ - public function test_moodlenet_send_course() { + public function test_moodlenet_send_course(): void { global $CFG; $this->resetAfterTest(); $this->setAdminUser(); @@ -124,7 +124,7 @@ class moodlenet_send_course_test extends externallib_advanced_testcase { * @dataProvider return_resource_url_provider * @covers ::execute_returns */ - public function test_moodlenet_send_course_return_resource_url(bool $state, string $resourceurl) { + public function test_moodlenet_send_course_return_resource_url(bool $state, string $resourceurl): void { $this->resetAfterTest(); // Create dummy result with the resourceurl. $result = [ diff --git a/lib/tests/external/record_userfeedback_action_test.php b/lib/tests/external/record_userfeedback_action_test.php index fa99bebe79d..22e454c4518 100644 --- a/lib/tests/external/record_userfeedback_action_test.php +++ b/lib/tests/external/record_userfeedback_action_test.php @@ -63,7 +63,7 @@ class record_userfeedback_action_test extends externallib_advanced_testcase { * * @covers ::execute */ - public function test_record_userfeedback_action(string $action) { + public function test_record_userfeedback_action(string $action): void { $this->resetAfterTest(); $context = context_system::instance(); diff --git a/lib/tests/filelib_test.php b/lib/tests/filelib_test.php index 6ed87509a20..ff7fdf3256f 100644 --- a/lib/tests/filelib_test.php +++ b/lib/tests/filelib_test.php @@ -44,7 +44,7 @@ require_once($CFG->dirroot . '/repository/lib.php'); * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class filelib_test extends \advanced_testcase { - public function test_format_postdata_for_curlcall() { + public function test_format_postdata_for_curlcall(): void { // POST params with just simple types. $postdatatoconvert = array( 'userid' => 1, 'roleid' => 22, 'name' => 'john'); @@ -94,7 +94,7 @@ class filelib_test extends \advanced_testcase { $this->assertEquals($expectedresult, $postdata); } - public function test_download_file_content() { + public function test_download_file_content(): void { global $CFG; // Test http success first. @@ -204,7 +204,7 @@ class filelib_test extends \advanced_testcase { /** * Test curl basics. */ - public function test_curl_basics() { + public function test_curl_basics(): void { global $CFG; // Test HTTP success. @@ -246,7 +246,7 @@ class filelib_test extends \advanced_testcase { /** * Test a curl basic request with security enabled. */ - public function test_curl_basics_with_security_helper() { + public function test_curl_basics_with_security_helper(): void { global $USER; $this->resetAfterTest(); @@ -307,7 +307,7 @@ class filelib_test extends \advanced_testcase { $this->assertCount(2, $events); } - public function test_curl_redirects() { + public function test_curl_redirects(): void { global $CFG; $testurl = $this->getExternalTestFileUrl('/test_redir.php'); @@ -408,7 +408,7 @@ class filelib_test extends \advanced_testcase { /** * Test that redirects to blocked hosts are blocked. */ - public function test_curl_blocked_redirect() { + public function test_curl_blocked_redirect(): void { $this->resetAfterTest(); $testurl = $this->getExternalTestFileUrl('/test_redir.php'); @@ -440,7 +440,7 @@ class filelib_test extends \advanced_testcase { $this->assertDebuggingCalled(); } - public function test_curl_relative_redirects() { + public function test_curl_relative_redirects(): void { // Test relative location redirects. $testurl = $this->getExternalTestFileUrl('/test_relative_redir.php'); @@ -496,7 +496,7 @@ class filelib_test extends \advanced_testcase { $this->assertSame('done', $contents); } - public function test_curl_proxybypass() { + public function test_curl_proxybypass(): void { global $CFG; $testurl = $this->getExternalTestFileUrl('/test.html'); @@ -526,7 +526,7 @@ class filelib_test extends \advanced_testcase { /** * Test that duplicate lines in the curl header are removed. */ - public function test_duplicate_curl_header() { + public function test_duplicate_curl_header(): void { $testurl = $this->getExternalTestFileUrl('/test_post.php'); $curl = new \curl(); @@ -538,7 +538,7 @@ class filelib_test extends \advanced_testcase { $this->assertEquals($headerdata, $curl->header[0]); } - public function test_curl_post() { + public function test_curl_post(): void { $testurl = $this->getExternalTestFileUrl('/test_post.php'); // Test post request. @@ -559,7 +559,7 @@ class filelib_test extends \advanced_testcase { $this->assertSame('OK', $contents); } - public function test_curl_file() { + public function test_curl_file(): void { $this->resetAfterTest(); $testurl = $this->getExternalTestFileUrl('/test_file.php'); @@ -582,7 +582,7 @@ class filelib_test extends \advanced_testcase { $this->assertSame('OK', $contents); } - public function test_curl_file_name() { + public function test_curl_file_name(): void { $this->resetAfterTest(); $testurl = $this->getExternalTestFileUrl('/test_file_name.php'); @@ -605,7 +605,7 @@ class filelib_test extends \advanced_testcase { $this->assertSame('OK', $contents); } - public function test_curl_protocols() { + public function test_curl_protocols(): void { // HTTP and HTTPS requests were verified in previous requests. Now check // that we can selectively disable some protocols. @@ -650,7 +650,7 @@ class filelib_test extends \advanced_testcase { * @copyright 2012 Dongsheng Cai {@link http://dongsheng.org} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - public function test_prepare_draft_area() { + public function test_prepare_draft_area(): void { global $USER, $DB; $this->resetAfterTest(true); @@ -761,7 +761,7 @@ class filelib_test extends \advanced_testcase { * @copyright 2012 Dongsheng Cai {@link http://dongsheng.org} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - public function test_delete_original_file_from_draft() { + public function test_delete_original_file_from_draft(): void { global $USER, $DB; $this->resetAfterTest(true); @@ -832,7 +832,7 @@ class filelib_test extends \advanced_testcase { /** * Test avoid file merging when working with draft areas. */ - public function test_ignore_file_merging_in_draft_area() { + public function test_ignore_file_merging_in_draft_area(): void { global $USER, $DB; $this->resetAfterTest(true); @@ -901,7 +901,7 @@ class filelib_test extends \advanced_testcase { /** * Testing deleting file_save_draft_area_files won't accidentally wipe unintended files. */ - public function test_file_save_draft_area_files_itemid_cannot_be_false() { + public function test_file_save_draft_area_files_itemid_cannot_be_false(): void { global $USER, $DB; $this->resetAfterTest(); @@ -923,7 +923,7 @@ class filelib_test extends \advanced_testcase { /** * Tests the strip_double_headers function in the curl class. */ - public function test_curl_strip_double_headers() { + public function test_curl_strip_double_headers(): void { // Example from issue tracker. $mdl30648example = <<resetAfterTest(); // Test example type (.doc). @@ -1204,7 +1204,7 @@ EOF; /** * Tests the get_mimetypes_array function. */ - public function test_get_mimetypes_array() { + public function test_get_mimetypes_array(): void { $mimeinfo = get_mimetypes_array(); // Test example MIME type (doc). @@ -1223,7 +1223,7 @@ EOF; /** * Tests for get_mimetype_for_sending function. */ - public function test_get_mimetype_for_sending() { + public function test_get_mimetype_for_sending(): void { // Without argument. $this->assertEquals('application/octet-stream', get_mimetype_for_sending()); @@ -1247,7 +1247,7 @@ EOF; /** * Test curl agent settings. */ - public function test_curl_useragent() { + public function test_curl_useragent(): void { $curl = new testable_curl(); $options = $curl->get_options(); $this->assertNotEmpty($options); @@ -1296,7 +1296,7 @@ EOF; /** * Test file_rewrite_pluginfile_urls. */ - public function test_file_rewrite_pluginfile_urls() { + public function test_file_rewrite_pluginfile_urls(): void { $syscontext = \context_system::instance(); $originaltext = 'Fake test with an image '; @@ -1316,7 +1316,7 @@ EOF; /** * Test file_rewrite_pluginfile_urls with includetoken. */ - public function test_file_rewrite_pluginfile_urls_includetoken() { + public function test_file_rewrite_pluginfile_urls_includetoken(): void { global $USER, $CFG; $CFG->slasharguments = true; @@ -1365,7 +1365,7 @@ EOF; /** * Test file_rewrite_pluginfile_urls with includetoken with slasharguments disabled.. */ - public function test_file_rewrite_pluginfile_urls_includetoken_no_slashargs() { + public function test_file_rewrite_pluginfile_urls_includetoken_no_slashargs(): void { global $USER, $CFG; $CFG->slasharguments = false; @@ -1437,7 +1437,7 @@ EOF; /** * Test file_merge_files_from_draft_area_into_filearea */ - public function test_file_merge_files_from_draft_area_into_filearea() { + public function test_file_merge_files_from_draft_area_into_filearea(): void { global $USER, $CFG; $this->resetAfterTest(true); @@ -1542,7 +1542,7 @@ EOF; /** * Test max area bytes for file_merge_files_from_draft_area_into_filearea */ - public function test_file_merge_files_from_draft_area_into_filearea_max_area_bytes() { + public function test_file_merge_files_from_draft_area_into_filearea_max_area_bytes(): void { global $USER; $this->resetAfterTest(true); @@ -1565,7 +1565,7 @@ EOF; /** * Test max file bytes for file_merge_files_from_draft_area_into_filearea */ - public function test_file_merge_files_from_draft_area_into_filearea_max_file_bytes() { + public function test_file_merge_files_from_draft_area_into_filearea_max_file_bytes(): void { global $USER; $this->resetAfterTest(true); @@ -1593,7 +1593,7 @@ EOF; /** * Test max file number for file_merge_files_from_draft_area_into_filearea */ - public function test_file_merge_files_from_draft_area_into_filearea_max_files() { + public function test_file_merge_files_from_draft_area_into_filearea_max_files(): void { global $USER; $this->resetAfterTest(true); @@ -1619,7 +1619,7 @@ EOF; /** * Test file_get_draft_area_info. */ - public function test_file_get_draft_area_info() { + public function test_file_get_draft_area_info(): void { global $USER; $this->resetAfterTest(true); @@ -1676,7 +1676,7 @@ EOF; /** * Test file_get_file_area_info. */ - public function test_file_get_file_area_info() { + public function test_file_get_file_area_info(): void { global $USER; $this->resetAfterTest(true); @@ -1730,7 +1730,7 @@ EOF; /** * Test confirming that draft files not referenced in the editor text are removed. */ - public function test_file_remove_editor_orphaned_files() { + public function test_file_remove_editor_orphaned_files(): void { global $USER, $CFG; $this->resetAfterTest(true); $this->setAdminUser(); @@ -1780,7 +1780,7 @@ EOF; /** * Test that all files in the draftarea are returned. */ - public function test_file_get_all_files_in_draftarea() { + public function test_file_get_all_files_in_draftarea(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -1826,7 +1826,7 @@ EOF; $this->assertEquals($fifthrecord['filename'], $allfiles[4]->filename); } - public function test_file_copy_file_to_file_area() { + public function test_file_copy_file_to_file_area(): void { // Create two files in different draft areas but owned by the same user. global $USER; $this->resetAfterTest(true); @@ -1866,7 +1866,7 @@ EOF; /** * Test file_is_draft_areas_limit_reached */ - public function test_file_is_draft_areas_limit_reached() { + public function test_file_is_draft_areas_limit_reached(): void { global $CFG; $this->resetAfterTest(true); @@ -1935,7 +1935,7 @@ EOF; * * @covers ::file_prepare_standard_editor */ - public function test_file_prepare_standard_editor_clean_text() { + public function test_file_prepare_standard_editor_clean_text(): void { $text = "lala xx"; $syscontext = \context_system::instance(); diff --git a/lib/tests/filestorage_zip_archive_test.php b/lib/tests/filestorage_zip_archive_test.php index 7ed42499503..db83e8111b9 100644 --- a/lib/tests/filestorage_zip_archive_test.php +++ b/lib/tests/filestorage_zip_archive_test.php @@ -40,7 +40,7 @@ class filestorage_zip_archive_test extends \advanced_testcase { * @param string $string Parameter sent to mangle_pathname method. * @param string $expected Expected return value. */ - public function test_mangle_pathname($string, $expected) { + public function test_mangle_pathname($string, $expected): void { $ziparchive = new zip_archive(); $method = new \ReflectionMethod('zip_archive', 'mangle_pathname'); diff --git a/lib/tests/filetypes_test.php b/lib/tests/filetypes_test.php index 7f3bf48ec2c..224caaccd62 100644 --- a/lib/tests/filetypes_test.php +++ b/lib/tests/filetypes_test.php @@ -32,7 +32,7 @@ require_once($CFG->libdir . '/filelib.php'); */ class filetypes_test extends \advanced_testcase { - public function test_add_type() { + public function test_add_type(): void { $this->resetAfterTest(); // Check the filetypes to be added do not exist yet (basically this @@ -91,7 +91,7 @@ class filetypes_test extends \advanced_testcase { } } - public function test_update_type() { + public function test_update_type(): void { $this->resetAfterTest(); // Check previous value for the MIME type of Word documents. @@ -148,7 +148,7 @@ class filetypes_test extends \advanced_testcase { } } - public function test_delete_type() { + public function test_delete_type(): void { $this->resetAfterTest(); // Filetype exists. @@ -178,7 +178,7 @@ class filetypes_test extends \advanced_testcase { $this->assertArrayNotHasKey('frog', $types); } - public function test_revert_type_to_default() { + public function test_revert_type_to_default(): void { $this->resetAfterTest(); // Delete and then revert. @@ -209,7 +209,7 @@ class filetypes_test extends \advanced_testcase { * Check that the logic cleans up the variable by deleting parts that are * no longer needed. */ - public function test_cleanup() { + public function test_cleanup(): void { global $CFG; $this->resetAfterTest(); diff --git a/lib/tests/filter_manager_test.php b/lib/tests/filter_manager_test.php index 061f2328027..96a098caebf 100644 --- a/lib/tests/filter_manager_test.php +++ b/lib/tests/filter_manager_test.php @@ -45,7 +45,7 @@ class filter_manager_test extends \advanced_testcase { return $filtermanager->filter_text($text, $PAGE->context, $filteroptions, $skipfilters); } - public function test_filter_normal() { + public function test_filter_normal(): void { $this->resetAfterTest(); filter_set_global_state('emoticon', TEXTFILTER_ON); $this->assertMatchesRegularExpression( @@ -54,14 +54,14 @@ class filter_manager_test extends \advanced_testcase { $this->filter_text('

:-)

', array())); } - public function test_one_filter_disabled() { + public function test_one_filter_disabled(): void { $this->resetAfterTest(); filter_set_global_state('emoticon', TEXTFILTER_ON); $this->assertEquals('

:-)

', $this->filter_text('

:-)

', array('emoticon'))); } - public function test_disabling_other_filter_does_not_break_it() { + public function test_disabling_other_filter_does_not_break_it(): void { $this->resetAfterTest(); filter_set_global_state('emoticon', TEXTFILTER_ON); $this->assertMatchesRegularExpression('~^

smilefilter_text('

:-)

', array('urltolink'))); } - public function test_one_filter_of_two_disabled() { + public function test_one_filter_of_two_disabled(): void { $this->resetAfterTest(); filter_set_global_state('emoticon', TEXTFILTER_ON); filter_set_global_state('urltolink', TEXTFILTER_ON); diff --git a/lib/tests/filterlib_test.php b/lib/tests/filterlib_test.php index 29bd34c74ef..84232e27434 100644 --- a/lib/tests/filterlib_test.php +++ b/lib/tests/filterlib_test.php @@ -63,7 +63,7 @@ class filterlib_test extends \advanced_testcase { $this->assertEquals($testarray, $sortedfilters); } - public function test_set_filter_globally_on() { + public function test_set_filter_globally_on(): void { $this->resetAfterTest(); $this->remove_all_filters_from_config(); // Remove all filters. // Setup fixture. @@ -73,7 +73,7 @@ class filterlib_test extends \advanced_testcase { $this->assert_only_one_filter_globally('name', TEXTFILTER_ON); } - public function test_set_filter_globally_off() { + public function test_set_filter_globally_off(): void { $this->resetAfterTest(); $this->remove_all_filters_from_config(); // Remove all filters. // Setup fixture. @@ -83,7 +83,7 @@ class filterlib_test extends \advanced_testcase { $this->assert_only_one_filter_globally('name', TEXTFILTER_OFF); } - public function test_set_filter_globally_disabled() { + public function test_set_filter_globally_disabled(): void { $this->resetAfterTest(); $this->remove_all_filters_from_config(); // Remove all filters. // Setup fixture. @@ -93,13 +93,13 @@ class filterlib_test extends \advanced_testcase { $this->assert_only_one_filter_globally('name', TEXTFILTER_DISABLED); } - public function test_global_config_exception_on_invalid_state() { + public function test_global_config_exception_on_invalid_state(): void { $this->resetAfterTest(); $this->expectException(\coding_exception::class); filter_set_global_state('name', 0); } - public function test_auto_sort_order() { + public function test_auto_sort_order(): void { $this->resetAfterTest(); $this->remove_all_filters_from_config(); // Remove all filters. // Setup fixture. @@ -110,7 +110,7 @@ class filterlib_test extends \advanced_testcase { $this->assert_global_sort_order(array('one', 'two')); } - public function test_auto_sort_order_enabled() { + public function test_auto_sort_order_enabled(): void { $this->resetAfterTest(); $this->remove_all_filters_from_config(); // Remove all filters. // Setup fixture. @@ -121,7 +121,7 @@ class filterlib_test extends \advanced_testcase { $this->assert_global_sort_order(array('one', 'two')); } - public function test_update_existing_dont_duplicate() { + public function test_update_existing_dont_duplicate(): void { $this->resetAfterTest(); $this->remove_all_filters_from_config(); // Remove all filters. // Setup fixture. @@ -132,7 +132,7 @@ class filterlib_test extends \advanced_testcase { $this->assert_only_one_filter_globally('name', TEXTFILTER_OFF); } - public function test_update_reorder_down() { + public function test_update_reorder_down(): void { global $DB; $this->resetAfterTest(); @@ -155,7 +155,7 @@ class filterlib_test extends \advanced_testcase { $this->assertEquals('one, two, three', $log->oldvalue); } - public function test_update_reorder_up() { + public function test_update_reorder_up(): void { global $DB; $this->resetAfterTest(); @@ -179,7 +179,7 @@ class filterlib_test extends \advanced_testcase { $this->assertEquals('one, two, three, four', $log->oldvalue); } - public function test_auto_sort_order_change_to_enabled() { + public function test_auto_sort_order_change_to_enabled(): void { $this->resetAfterTest(); $this->remove_all_filters_from_config(); // Remove all filters. // Setup fixture. @@ -192,7 +192,7 @@ class filterlib_test extends \advanced_testcase { $this->assert_global_sort_order(array('one', 'three', 'two')); } - public function test_auto_sort_order_change_to_disabled() { + public function test_auto_sort_order_change_to_disabled(): void { $this->resetAfterTest(); $this->remove_all_filters_from_config(); // Remove all filters. // Setup fixture. @@ -205,7 +205,7 @@ class filterlib_test extends \advanced_testcase { $this->assert_global_sort_order(array('two', 'one', 'three')); } - public function test_filter_get_global_states() { + public function test_filter_get_global_states(): void { $this->resetAfterTest(); $this->remove_all_filters_from_config(); // Remove all filters. // Setup fixture. @@ -241,7 +241,7 @@ class filterlib_test extends \advanced_testcase { $this->assertEquals(0, $DB->count_records('filter_active')); } - public function test_local_on() { + public function test_local_on(): void { $this->resetAfterTest(); $this->remove_all_filters_from_config(); // Remove all filters. // Exercise SUT. @@ -250,7 +250,7 @@ class filterlib_test extends \advanced_testcase { $this->assert_only_one_local_setting('name', 123, TEXTFILTER_ON); } - public function test_local_off() { + public function test_local_off(): void { $this->resetAfterTest(); $this->remove_all_filters_from_config(); // Remove all filters. // Exercise SUT. @@ -259,7 +259,7 @@ class filterlib_test extends \advanced_testcase { $this->assert_only_one_local_setting('name', 123, TEXTFILTER_OFF); } - public function test_local_inherit() { + public function test_local_inherit(): void { $this->resetAfterTest(); $this->remove_all_filters_from_config(); // Remove all filters. // Exercise SUT. @@ -268,21 +268,21 @@ class filterlib_test extends \advanced_testcase { $this->assert_no_local_setting(); } - public function test_local_invalid_state_throws_exception() { + public function test_local_invalid_state_throws_exception(): void { $this->resetAfterTest(); // Exercise SUT. $this->expectException(\coding_exception::class); filter_set_local_state('name', 123, -9999); } - public function test_throws_exception_when_setting_global() { + public function test_throws_exception_when_setting_global(): void { $this->resetAfterTest(); // Exercise SUT. $this->expectException(\coding_exception::class); filter_set_local_state('name', \context_system::instance()->id, TEXTFILTER_INHERIT); } - public function test_local_inherit_deletes_existing() { + public function test_local_inherit_deletes_existing(): void { $this->resetAfterTest(); $this->remove_all_filters_from_config(); // Remove all filters. // Setup fixture. @@ -307,7 +307,7 @@ class filterlib_test extends \advanced_testcase { $this->assertEquals($expectedrec, $rec); } - public function test_set_new_config() { + public function test_set_new_config(): void { $this->resetAfterTest(); $this->remove_all_filters_from_config(); // Remove all filters. // Exercise SUT. @@ -316,7 +316,7 @@ class filterlib_test extends \advanced_testcase { $this->assert_only_one_config('name', 123, 'settingname', 'An arbitrary value'); } - public function test_update_existing_config() { + public function test_update_existing_config(): void { $this->resetAfterTest(); $this->remove_all_filters_from_config(); // Remove all filters. // Setup fixture. @@ -327,7 +327,7 @@ class filterlib_test extends \advanced_testcase { $this->assert_only_one_config('name', 123, 'settingname', 'A changed value'); } - public function test_filter_get_local_config() { + public function test_filter_get_local_config(): void { $this->resetAfterTest(); // Setup fixture. filter_set_local_config('name', 123, 'setting1', 'An arbitrary value'); @@ -364,7 +364,7 @@ class filterlib_test extends \advanced_testcase { $this->assertEqualsCanonicalizing($expectedfilters, array_keys($filters)); } - public function test_globally_on_is_returned() { + public function test_globally_on_is_returned(): void { $this->resetAfterTest(); $this->remove_all_filters_from_config(); // Remove all filters. [ @@ -380,7 +380,7 @@ class filterlib_test extends \advanced_testcase { $this->assertEquals(array(), $filters['name']); } - public function test_globally_off_not_returned() { + public function test_globally_off_not_returned(): void { $this->resetAfterTest(); $this->remove_all_filters_from_config(); // Remove all filters. [ @@ -394,7 +394,7 @@ class filterlib_test extends \advanced_testcase { $this->assert_filter_list(array(), $filters); } - public function test_globally_off_overridden() { + public function test_globally_off_overridden(): void { $this->resetAfterTest(); $this->remove_all_filters_from_config(); // Remove all filters. [ @@ -410,7 +410,7 @@ class filterlib_test extends \advanced_testcase { $this->assert_filter_list(array('name'), $filters); } - public function test_globally_on_overridden() { + public function test_globally_on_overridden(): void { $this->resetAfterTest(); $this->remove_all_filters_from_config(); // Remove all filters. [ @@ -426,7 +426,7 @@ class filterlib_test extends \advanced_testcase { $this->assert_filter_list(array(), $filters); } - public function test_globally_disabled_not_overridden() { + public function test_globally_disabled_not_overridden(): void { $this->resetAfterTest(); $this->remove_all_filters_from_config(); // Remove all filters. [ @@ -442,7 +442,7 @@ class filterlib_test extends \advanced_testcase { $this->assert_filter_list(array(), $filters); } - public function test_single_config_returned() { + public function test_single_config_returned(): void { $this->resetAfterTest(); [ 'childcontext' => $childcontext @@ -456,7 +456,7 @@ class filterlib_test extends \advanced_testcase { $this->assertEquals(array('settingname' => 'A value'), $filters['name']); } - public function test_multi_config_returned() { + public function test_multi_config_returned(): void { $this->resetAfterTest(); [ 'childcontext' => $childcontext @@ -471,7 +471,7 @@ class filterlib_test extends \advanced_testcase { $this->assertEquals(array('settingname' => 'A value', 'anothersettingname' => 'Another value'), $filters['name']); } - public function test_config_from_other_context_not_returned() { + public function test_config_from_other_context_not_returned(): void { $this->resetAfterTest(); [ 'childcontext' => $childcontext, @@ -487,7 +487,7 @@ class filterlib_test extends \advanced_testcase { $this->assertEquals(array('anothersettingname' => 'Another value'), $filters['name']); } - public function test_config_from_other_filter_not_returned() { + public function test_config_from_other_filter_not_returned(): void { $this->resetAfterTest(); [ 'childcontext' => $childcontext @@ -513,7 +513,7 @@ class filterlib_test extends \advanced_testcase { $this->assertEquals($expectedrec, $rec); } - public function test_available_in_context_localoverride() { + public function test_available_in_context_localoverride(): void { $this->resetAfterTest(); $this->remove_all_filters_from_config(); // Remove all filters. [ @@ -528,7 +528,7 @@ class filterlib_test extends \advanced_testcase { $this->assert_one_available_filter('name', TEXTFILTER_OFF, TEXTFILTER_ON, $filters); } - public function test_available_in_context_nolocaloverride() { + public function test_available_in_context_nolocaloverride(): void { $this->resetAfterTest(); $this->remove_all_filters_from_config(); // Remove all filters. [ @@ -544,7 +544,7 @@ class filterlib_test extends \advanced_testcase { $this->assert_one_available_filter('name', TEXTFILTER_INHERIT, TEXTFILTER_OFF, $filters); } - public function test_available_in_context_disabled_not_returned() { + public function test_available_in_context_disabled_not_returned(): void { $this->resetAfterTest(); $this->remove_all_filters_from_config(); // Remove all filters. [ @@ -559,7 +559,7 @@ class filterlib_test extends \advanced_testcase { $this->assertEquals(array(), $filters); } - public function test_available_in_context_exception_with_syscontext() { + public function test_available_in_context_exception_with_syscontext(): void { $this->resetAfterTest(); [ 'syscontext' => $syscontext @@ -615,7 +615,7 @@ class filterlib_test extends \advanced_testcase { $this->assertEquals($plfilters2, $filters2); } - public function test_preload() { + public function test_preload(): void { $this->resetAfterTest(); [ 'catcontext' => $catcontext, @@ -675,7 +675,7 @@ class filterlib_test extends \advanced_testcase { $this->assert_matches($modinfo, $activity1context, $activity2context); } - public function test_filter_delete_all_for_filter() { + public function test_filter_delete_all_for_filter(): void { global $DB; $this->resetAfterTest(); $this->remove_all_filters_from_config(); // Remove all filters. @@ -700,7 +700,7 @@ class filterlib_test extends \advanced_testcase { $this->assertEquals(get_config('filter_name'), new \stdClass()); } - public function test_filter_delete_all_for_context() { + public function test_filter_delete_all_for_context(): void { global $DB; $this->resetAfterTest(); $this->remove_all_filters_from_config(); // Remove all filters. @@ -720,7 +720,7 @@ class filterlib_test extends \advanced_testcase { $this->assertTrue($DB->record_exists('filter_config', array('filter' => 'other'))); } - public function test_set() { + public function test_set(): void { global $CFG; $this->resetAfterTest(); @@ -746,7 +746,7 @@ class filterlib_test extends \advanced_testcase { $this->assertEquals(1, $CFG->filterall); } - public function test_unset_to_empty() { + public function test_unset_to_empty(): void { global $CFG; $this->resetAfterTest(); @@ -762,7 +762,7 @@ class filterlib_test extends \advanced_testcase { $this->assertEquals('', $CFG->filterall); } - public function test_unset_multi() { + public function test_unset_multi(): void { global $CFG; $this->resetAfterTest(); @@ -780,7 +780,7 @@ class filterlib_test extends \advanced_testcase { $this->assertEquals(1, $CFG->filterall); } - public function test_filter_manager_instance() { + public function test_filter_manager_instance(): void { $this->resetAfterTest(); set_config('perfdebug', 7); @@ -796,7 +796,7 @@ class filterlib_test extends \advanced_testcase { $this->assertInstanceOf('performance_measuring_filter_manager', $filterman); } - public function test_filter_get_active_state_contextid_parameter() { + public function test_filter_get_active_state_contextid_parameter(): void { $this->resetAfterTest(); filter_set_global_state('glossary', TEXTFILTER_ON); @@ -819,7 +819,7 @@ class filterlib_test extends \advanced_testcase { $this->assertEquals($active, TEXTFILTER_ON); } - public function test_filter_get_active_state_filtername_parameter() { + public function test_filter_get_active_state_filtername_parameter(): void { $this->resetAfterTest(); filter_set_global_state('glossary', TEXTFILTER_ON); @@ -832,7 +832,7 @@ class filterlib_test extends \advanced_testcase { $active = filter_get_active_state('mod/glossary'); } - public function test_filter_get_active_state_after_change() { + public function test_filter_get_active_state_after_change(): void { $this->resetAfterTest(); filter_set_global_state('glossary', TEXTFILTER_ON); @@ -851,20 +851,20 @@ class filterlib_test extends \advanced_testcase { $this->assertEquals($active, TEXTFILTER_DISABLED); } - public function test_filter_get_globally_enabled_default() { + public function test_filter_get_globally_enabled_default(): void { $this->resetAfterTest(); $enabledfilters = filter_get_globally_enabled(); $this->assertArrayNotHasKey('glossary', $enabledfilters); } - public function test_filter_get_globally_enabled_after_change() { + public function test_filter_get_globally_enabled_after_change(): void { $this->resetAfterTest(); filter_set_global_state('glossary', TEXTFILTER_ON); $enabledfilters = filter_get_globally_enabled(); $this->assertArrayHasKey('glossary', $enabledfilters); } - public function test_filter_get_globally_enabled_filters_with_config() { + public function test_filter_get_globally_enabled_filters_with_config(): void { $this->resetAfterTest(); $this->remove_all_filters_from_config(); // Remove all filters. [ diff --git a/lib/tests/formslib_test.php b/lib/tests/formslib_test.php index 08c3d42eb9c..d319dc7c1e2 100644 --- a/lib/tests/formslib_test.php +++ b/lib/tests/formslib_test.php @@ -50,7 +50,7 @@ require_once($CFG->libdir . '/form/text.php'); */ class formslib_test extends \advanced_testcase { - public function test_require_rule() { + public function test_require_rule(): void { global $CFG; $strictformsrequired = null; @@ -141,7 +141,7 @@ class formslib_test extends \advanced_testcase { } } - public function test_range_rule() { + public function test_range_rule(): void { global $CFG; require_once('HTML/QuickForm/Rule/Range.php'); // Requires this pear stuff. @@ -224,46 +224,46 @@ class formslib_test extends \advanced_testcase { } } - public function test_generate_id_select() { + public function test_generate_id_select(): void { $el = new MoodleQuickForm_select('choose_one', 'Choose one', array(1 => 'One', '2' => 'Two')); $el->_generateId(); $this->assertSame('id_choose_one', $el->getAttribute('id')); } - public function test_generate_id_like_repeat() { + public function test_generate_id_like_repeat(): void { $el = new MoodleQuickForm_text('text[7]', 'Type something'); $el->_generateId(); $this->assertSame('id_text_7', $el->getAttribute('id')); } - public function test_can_manually_set_id() { + public function test_can_manually_set_id(): void { $el = new MoodleQuickForm_text('elementname', 'Type something', array('id' => 'customelementid')); $el->_generateId(); $this->assertSame('customelementid', $el->getAttribute('id')); } - public function test_generate_id_radio() { + public function test_generate_id_radio(): void { $el = new MoodleQuickForm_radio('radio', 'Label', 'Choice label', 'choice_value'); $el->_generateId(); $this->assertSame('id_radio_choice_value', $el->getAttribute('id')); } - public function test_radio_can_manually_set_id() { + public function test_radio_can_manually_set_id(): void { $el = new MoodleQuickForm_radio('radio2', 'Label', 'Choice label', 'choice_value', array('id' => 'customelementid2')); $el->_generateId(); $this->assertSame('customelementid2', $el->getAttribute('id')); } - public function test_generate_id_radio_like_repeat() { + public function test_generate_id_radio_like_repeat(): void { $el = new MoodleQuickForm_radio('repeatradio[2]', 'Label', 'Choice label', 'val'); $el->_generateId(); $this->assertSame('id_repeatradio_2_val', $el->getAttribute('id')); } - public function test_rendering() { + public function test_rendering(): void { $form = new formslib_test_form(); ob_start(); $form->display(); @@ -294,7 +294,7 @@ class formslib_test extends \advanced_testcase { 'attributes'=>array('type'=>'radio', 'name'=>'repeatradio[2]', 'value'=>'2')), $html); } - public function test_settype_debugging_text() { + public function test_settype_debugging_text(): void { $mform = new formslib_settype_debugging_text(); $this->assertDebuggingCalled("Did you remember to call setType() for 'texttest'? Defaulting to PARAM_RAW cleaning."); @@ -303,7 +303,7 @@ class formslib_test extends \advanced_testcase { $mform->display(); } - public function test_settype_debugging_hidden() { + public function test_settype_debugging_hidden(): void { $mform = new formslib_settype_debugging_hidden(); $this->assertDebuggingCalled("Did you remember to call setType() for 'hiddentest'? Defaulting to PARAM_RAW cleaning."); @@ -312,7 +312,7 @@ class formslib_test extends \advanced_testcase { $mform->display(); } - public function test_settype_debugging_url() { + public function test_settype_debugging_url(): void { $this->resetAfterTest(true); $this->setAdminUser(); $mform = new formslib_settype_debugging_url(); @@ -323,7 +323,7 @@ class formslib_test extends \advanced_testcase { $mform->display(); } - public function test_settype_debugging_repeat() { + public function test_settype_debugging_repeat(): void { $mform = new formslib_settype_debugging_repeat(); $this->assertDebuggingCalled("Did you remember to call setType() for 'repeattest[0]'? Defaulting to PARAM_RAW cleaning."); @@ -332,7 +332,7 @@ class formslib_test extends \advanced_testcase { $mform->display(); } - public function test_settype_debugging_repeat_ok() { + public function test_settype_debugging_repeat_ok(): void { $mform = new formslib_settype_debugging_repeat_ok(); // No debugging expected here. @@ -340,7 +340,7 @@ class formslib_test extends \advanced_testcase { $mform->display(); } - public function test_settype_debugging_group() { + public function test_settype_debugging_group(): void { $mform = new formslib_settype_debugging_group(); $this->assertDebuggingCalled("Did you remember to call setType() for 'groupel1'? Defaulting to PARAM_RAW cleaning."); $this->expectOutputRegex('/]*type="text[^>]*name="groupel1"/'); @@ -348,7 +348,7 @@ class formslib_test extends \advanced_testcase { $mform->display(); } - public function test_settype_debugging_namedgroup() { + public function test_settype_debugging_namedgroup(): void { $mform = new formslib_settype_debugging_namedgroup(); $this->assertDebuggingCalled("Did you remember to call setType() for 'namedgroup[groupel1]'? Defaulting to PARAM_RAW cleaning."); $this->expectOutputRegex('/]*type="text[^>]*name="namedgroup\[groupel1\]"/'); @@ -356,7 +356,7 @@ class formslib_test extends \advanced_testcase { $mform->display(); } - public function test_settype_debugging_funky_name() { + public function test_settype_debugging_funky_name(): void { $mform = new formslib_settype_debugging_funky_name(); $this->assertDebuggingCalled("Did you remember to call setType() for 'blah[foo][bar][1]'? Defaulting to PARAM_RAW cleaning."); $this->expectOutputRegex('/]*type="text[^>]*name="blah\[foo\]\[bar\]\[0\]"/'); @@ -364,7 +364,7 @@ class formslib_test extends \advanced_testcase { $mform->display(); } - public function test_settype_debugging_type_inheritance() { + public function test_settype_debugging_type_inheritance(): void { $mform = new formslib_settype_debugging_type_inheritance(); $this->expectOutputRegex('/]*type="text[^>]*name="blah\[foo\]\[bar\]\[0\]"/'); $this->expectOutputRegex('/]*type="text[^>]*name="blah\[bar\]\[foo\]\[1\]"/'); @@ -372,7 +372,7 @@ class formslib_test extends \advanced_testcase { $mform->display(); } - public function test_settype_debugging_type_group_in_repeat() { + public function test_settype_debugging_type_group_in_repeat(): void { $mform = new formslib_settype_debugging_type_group_in_repeat(); $this->assertDebuggingCalled("Did you remember to call setType() for 'test2[0]'? Defaulting to PARAM_RAW cleaning."); $this->expectOutputRegex('/]*type="text[^>]*name="test1\[0\]"/'); @@ -380,7 +380,7 @@ class formslib_test extends \advanced_testcase { $mform->display(); } - public function test_settype_debugging_type_namedgroup_in_repeat() { + public function test_settype_debugging_type_namedgroup_in_repeat(): void { $mform = new formslib_settype_debugging_type_namedgroup_in_repeat(); $this->assertDebuggingCalled("Did you remember to call setType() for 'namedgroup[0][test2]'? Defaulting to PARAM_RAW cleaning."); $this->expectOutputRegex('/]*type="text[^>]*name="namedgroup\[0\]\[test1\]"/'); @@ -388,7 +388,7 @@ class formslib_test extends \advanced_testcase { $mform->display(); } - public function test_type_cleaning() { + public function test_type_cleaning(): void { $expectedtypes = array( 'simpleel' => PARAM_INT, 'groupel1' => PARAM_INT, @@ -570,7 +570,7 @@ class formslib_test extends \advanced_testcase { /** * MDL-52873 */ - public function test_multiple_modgrade_fields() { + public function test_multiple_modgrade_fields(): void { global $CFG; $this->resetAfterTest(true); @@ -599,7 +599,7 @@ class formslib_test extends \advanced_testcase { /** * Test persistant freeze elements have different id's. */ - public function test_persistantrreeze_element() { + public function test_persistantrreeze_element(): void { global $CFG; $this->resetAfterTest(true); $CFG->theme = 'classic'; @@ -627,7 +627,7 @@ class formslib_test extends \advanced_testcase { /** * Ensure a validation can run at least once per object. See MDL-56259. */ - public function test_multiple_validation() { + public function test_multiple_validation(): void { $this->resetAfterTest(true); // It should be valid. @@ -646,7 +646,7 @@ class formslib_test extends \advanced_testcase { /** * MDL-56233 - Tests mocking a form inside a namespace. */ - public function test_mock_submit() { + public function test_mock_submit(): void { require_once(__DIR__.'/fixtures/namespaced_form.php'); \local_unittests\namespaced_form\exampleform::mock_submit(['title' => 'Mocked Value']); $form = new \local_unittests\namespaced_form\exampleform(); diff --git a/lib/tests/gdlib_test.php b/lib/tests/gdlib_test.php index f0401f974e1..da7d57bfedb 100644 --- a/lib/tests/gdlib_test.php +++ b/lib/tests/gdlib_test.php @@ -32,7 +32,7 @@ class gdlib_test extends \basic_testcase { $this->fixturepath = __DIR__ . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR; } - public function test_generate_image_thumbnail() { + public function test_generate_image_thumbnail(): void { global $CFG; require_once($CFG->libdir . '/gdlib.php'); @@ -50,7 +50,7 @@ class gdlib_test extends \basic_testcase { $this->assertEquals('image/png', $imageinfo['mime']); } - public function test_generate_image_thumbnail_from_string() { + public function test_generate_image_thumbnail_from_string(): void { global $CFG; require_once($CFG->libdir . '/gdlib.php'); @@ -77,7 +77,7 @@ class gdlib_test extends \basic_testcase { $this->assertEquals('image/png', $imageinfo['mime']); } - public function test_resize_image() { + public function test_resize_image(): void { global $CFG; require_once($CFG->libdir . '/gdlib.php'); @@ -108,7 +108,7 @@ class gdlib_test extends \basic_testcase { $this->assertEquals('image/png', $imageinfo['mime']); } - public function test_resize_image_from_image() { + public function test_resize_image_from_image(): void { global $CFG; require_once($CFG->libdir . '/gdlib.php'); diff --git a/lib/tests/googlelib_test.php b/lib/tests/googlelib_test.php index 59241e76cd9..e499c0d19e0 100644 --- a/lib/tests/googlelib_test.php +++ b/lib/tests/googlelib_test.php @@ -28,7 +28,7 @@ use Google_Service_YouTube; */ class googlelib_test extends \advanced_testcase { - public function test_invalid_google_api_key() { + public function test_invalid_google_api_key(): void { global $CFG; require_once($CFG->libdir . '/google/lib.php'); $client = get_google_client(); diff --git a/lib/tests/gradelib_test.php b/lib/tests/gradelib_test.php index b35cf5f94a6..a00947e5097 100644 --- a/lib/tests/gradelib_test.php +++ b/lib/tests/gradelib_test.php @@ -31,7 +31,7 @@ require_once($CFG->libdir . '/gradelib.php'); */ class gradelib_test extends \advanced_testcase { - public function test_grade_update_mod_grades() { + public function test_grade_update_mod_grades(): void { $this->resetAfterTest(true); @@ -61,7 +61,7 @@ class gradelib_test extends \advanced_testcase { /** * Tests the function remove_grade_letters(). */ - public function test_remove_grade_letters() { + public function test_remove_grade_letters(): void { global $DB; $this->resetAfterTest(); @@ -104,7 +104,7 @@ class gradelib_test extends \advanced_testcase { /** * Tests the function grade_course_category_delete(). */ - public function test_grade_course_category_delete() { + public function test_grade_course_category_delete(): void { global $DB; $this->resetAfterTest(); @@ -127,7 +127,7 @@ class gradelib_test extends \advanced_testcase { /** * Tests the function grade_regrade_final_grades(). */ - public function test_grade_regrade_final_grades() { + public function test_grade_regrade_final_grades(): void { global $DB; $this->resetAfterTest(); @@ -251,7 +251,7 @@ class gradelib_test extends \advanced_testcase { /** * Test the caching of grade letters. */ - public function test_get_grade_letters() { + public function test_get_grade_letters(): void { $this->resetAfterTest(); @@ -276,7 +276,7 @@ class gradelib_test extends \advanced_testcase { /** * Test custom letters. */ - public function test_get_grade_letters_custom() { + public function test_get_grade_letters_custom(): void { global $DB; $this->resetAfterTest(); @@ -309,7 +309,7 @@ class gradelib_test extends \advanced_testcase { * @covers \grade_get_grades() * @return void */ - public function test_grade_get_grades_errors() { + public function test_grade_get_grades_errors(): void { $this->resetAfterTest(); // Setup some basics. diff --git a/lib/tests/grades_external_test.php b/lib/tests/grades_external_test.php index cdc0be91e4f..72b0787dc9c 100644 --- a/lib/tests/grades_external_test.php +++ b/lib/tests/grades_external_test.php @@ -134,7 +134,7 @@ class grades_external_test extends \externallib_advanced_testcase { /** * Test update_grades() */ - public function test_update_grades() { + public function test_update_grades(): void { global $DB; $this->resetAfterTest(true); diff --git a/lib/tests/grading_external_test.php b/lib/tests/grading_external_test.php index 1b9d4cfabf8..3c455dafd00 100644 --- a/lib/tests/grading_external_test.php +++ b/lib/tests/grading_external_test.php @@ -38,7 +38,7 @@ class grading_external_test extends \externallib_advanced_testcase { /** * Test get_definitions */ - public function test_get_definitions() { + public function test_get_definitions(): void { global $DB, $CFG, $USER; $this->resetAfterTest(true); @@ -182,7 +182,7 @@ class grading_external_test extends \externallib_advanced_testcase { /** * Test get_gradingform_instances */ - public function test_get_gradingform_instances() { + public function test_get_gradingform_instances(): void { global $DB, $USER; $this->resetAfterTest(true); @@ -310,7 +310,7 @@ class grading_external_test extends \externallib_advanced_testcase { * * Test save_definitions for rubric grading method */ - public function test_save_definitions_rubric() { + public function test_save_definitions_rubric(): void { global $DB, $CFG, $USER; $this->resetAfterTest(true); @@ -549,7 +549,7 @@ class grading_external_test extends \externallib_advanced_testcase { * * Tests save_definitions for the marking guide grading method */ - public function test_save_definitions_marking_guide() { + public function test_save_definitions_marking_guide(): void { global $DB, $CFG, $USER; $this->resetAfterTest(true); diff --git a/lib/tests/graphlib_test.php b/lib/tests/graphlib_test.php index a8838cebc64..09dd712f8a1 100644 --- a/lib/tests/graphlib_test.php +++ b/lib/tests/graphlib_test.php @@ -77,7 +77,7 @@ class graphlib_test extends \basic_testcase { * @param array $mock * @return void */ - public function test_graphlib($mock) { + public function test_graphlib($mock): void { $graph = new \graph(300, 200); ob_start(); $graph->parameter['title'] = strip_tags(format_string($mock['survey_name'], true)); diff --git a/lib/tests/grouplib_test.php b/lib/tests/grouplib_test.php index b801ab986e6..ac363b42cc2 100644 --- a/lib/tests/grouplib_test.php +++ b/lib/tests/grouplib_test.php @@ -28,7 +28,7 @@ use core_group\visibility; */ class grouplib_test extends \advanced_testcase { - public function test_groups_get_group_by_idnumber() { + public function test_groups_get_group_by_idnumber(): void { $this->resetAfterTest(true); $generator = $this->getDataGenerator(); @@ -100,7 +100,7 @@ class grouplib_test extends \advanced_testcase { $this->assertEquals($group, groups_get_group_by_idnumber($course->id, $idnumber2)); } - public function test_groups_get_grouping_by_idnumber() { + public function test_groups_get_grouping_by_idnumber(): void { $this->resetAfterTest(true); $generator = $this->getDataGenerator(); @@ -172,7 +172,7 @@ class grouplib_test extends \advanced_testcase { $this->assertEquals($grouping, groups_get_grouping_by_idnumber($course->id, $idnumber2)); } - public function test_groups_get_members_ids_sql() { + public function test_groups_get_members_ids_sql(): void { global $DB; $this->resetAfterTest(true); @@ -209,7 +209,7 @@ class grouplib_test extends \advanced_testcase { $this->assertTrue(array_key_exists($student1->id, $users)); } - public function test_groups_get_members_ids_sql_multiple_groups() { + public function test_groups_get_members_ids_sql_multiple_groups(): void { global $DB; $this->resetAfterTest(true); @@ -256,7 +256,7 @@ class grouplib_test extends \advanced_testcase { $this->assertTrue(array_key_exists($student2->id, $users)); } - public function test_groups_get_members_ids_sql_multiple_groups_join_types() { + public function test_groups_get_members_ids_sql_multiple_groups_join_types(): void { global $DB; $this->resetAfterTest(true); @@ -364,7 +364,7 @@ class grouplib_test extends \advanced_testcase { $this->assertFalse(array_key_exists($student4->id, $users)); } - public function test_groups_get_members_ids_sql_valid_context() { + public function test_groups_get_members_ids_sql_valid_context(): void { global $DB; $this->resetAfterTest(true); @@ -399,7 +399,7 @@ class grouplib_test extends \advanced_testcase { $this->assertTrue(array_key_exists($student2->id, $users)); } - public function test_groups_get_members_ids_sql_empty_context() { + public function test_groups_get_members_ids_sql_empty_context(): void { global $DB; $this->resetAfterTest(true); @@ -432,7 +432,7 @@ class grouplib_test extends \advanced_testcase { list($sql, $params) = groups_get_members_ids_sql(USERSWITHOUTGROUP); } - public function test_groups_get_members_ids_sql_invalid_context() { + public function test_groups_get_members_ids_sql_invalid_context(): void { global $DB; $this->resetAfterTest(true); @@ -504,7 +504,7 @@ class grouplib_test extends \advanced_testcase { ], $records); } - public function test_groups_get_group_by_name() { + public function test_groups_get_group_by_name(): void { $this->resetAfterTest(true); $generator = $this->getDataGenerator(); @@ -568,7 +568,7 @@ class grouplib_test extends \advanced_testcase { $this->assertEquals($group2->id, groups_get_group_by_name($course->id, $name2)); } - public function test_groups_get_grouping() { + public function test_groups_get_grouping(): void { $this->resetAfterTest(true); $generator = $this->getDataGenerator(); @@ -632,7 +632,7 @@ class grouplib_test extends \advanced_testcase { $this->assertEquals($group2->id, groups_get_grouping_by_name($course->id, $name2)); } - public function test_groups_get_course_data() { + public function test_groups_get_course_data(): void { $this->resetAfterTest(true); $generator = $this->getDataGenerator(); @@ -745,7 +745,7 @@ class grouplib_test extends \advanced_testcase { /** * Tests for groups_group_visible. */ - public function test_groups_group_visible() { + public function test_groups_group_visible(): void { global $CFG, $DB; $generator = $this->getDataGenerator(); @@ -929,7 +929,7 @@ class grouplib_test extends \advanced_testcase { $this->assertTrue($result); // Cm with visible groups. } - function test_groups_get_groupmode() { + function test_groups_get_groupmode(): void { global $DB; $generator = $this->getDataGenerator(); $this->resetAfterTest(); @@ -1000,7 +1000,7 @@ class grouplib_test extends \advanced_testcase { /** * Tests for groups_allgroups_course_menu() . */ - public function test_groups_allgroups_course_menu() { + public function test_groups_allgroups_course_menu(): void { global $SESSION; $this->resetAfterTest(); @@ -1064,7 +1064,7 @@ class grouplib_test extends \advanced_testcase { * This unit test checks that groups_get_all_groups returns groups in * alphabetical order even if they are in a grouping. */ - public function test_groups_ordering() { + public function test_groups_ordering(): void { $generator = $this->getDataGenerator(); $this->resetAfterTest(); @@ -1095,7 +1095,7 @@ class grouplib_test extends \advanced_testcase { /** * Tests for groups_get_all_groups when grouping is set and we want members as well. */ - public function test_groups_get_all_groups_in_grouping_with_members() { + public function test_groups_get_all_groups_in_grouping_with_members(): void { $generator = $this->getDataGenerator(); $this->resetAfterTest(); @@ -1165,7 +1165,7 @@ class grouplib_test extends \advanced_testcase { /** * Tests for groups_get_user_groups() method. */ - public function test_groups_get_user_groups() { + public function test_groups_get_user_groups(): void { $this->resetAfterTest(true); $generator = $this->getDataGenerator(); @@ -1249,25 +1249,25 @@ class grouplib_test extends \advanced_testcase { return $testgroups; } - public function test_groups_sort_menu_options_empty() { + public function test_groups_sort_menu_options_empty(): void { $this->assertEquals(array(), groups_sort_menu_options(array(), array())); } - public function test_groups_sort_menu_options_allowed_goups_only() { + public function test_groups_sort_menu_options_allowed_goups_only(): void { $this->assertEquals(array( 100 => 'test group 100', 101 => 'test group 101', ), groups_sort_menu_options($this->make_group_list(2), array())); } - public function test_groups_sort_menu_options_user_goups_only() { + public function test_groups_sort_menu_options_user_goups_only(): void { $this->assertEquals(array( 100 => 'test group 100', 101 => 'test group 101', ), groups_sort_menu_options(array(), $this->make_group_list(2))); } - public function test_groups_sort_menu_options_user_both() { + public function test_groups_sort_menu_options_user_both(): void { $this->assertEquals(array( 1 => array(get_string('mygroups', 'group') => array( 100 => 'test group 100', @@ -1280,7 +1280,7 @@ class grouplib_test extends \advanced_testcase { ), groups_sort_menu_options($this->make_group_list(4), $this->make_group_list(2))); } - public function test_groups_sort_menu_options_user_both_many_groups() { + public function test_groups_sort_menu_options_user_both_many_groups(): void { $this->assertEquals(array( 1 => array(get_string('mygroups', 'group') => array( 100 => 'test group 100', @@ -1305,7 +1305,7 @@ class grouplib_test extends \advanced_testcase { /** * Tests for groups_user_groups_visible. */ - public function test_groups_user_groups_visible() { + public function test_groups_user_groups_visible(): void { global $DB; $generator = $this->getDataGenerator(); @@ -1758,7 +1758,7 @@ class grouplib_test extends \advanced_testcase { * * @covers ::groups_get_groups_members */ - public function test_groups_get_groups_members() { + public function test_groups_get_groups_members(): void { $this->resetAfterTest(true); $generator = $this->getDataGenerator(); @@ -1839,7 +1839,7 @@ class grouplib_test extends \advanced_testcase { /** * Tests for groups_get_activity_shared_group_members() method. */ - public function test_groups_get_activity_shared_group_members() { + public function test_groups_get_activity_shared_group_members(): void { $this->resetAfterTest(true); $generator = $this->getDataGenerator(); @@ -1963,7 +1963,7 @@ class grouplib_test extends \advanced_testcase { * * @covers \groups_get_all_groups() */ - public function test_get_all_groups_with_visibility() { + public function test_get_all_groups_with_visibility(): void { list($users, $groups, $course) = $this->create_groups_with_visibilty(); // Assign users to groups. @@ -2091,7 +2091,7 @@ class grouplib_test extends \advanced_testcase { * * @covers \groups_get_user_groups() */ - public function test_get_user_groups_with_visibility() { + public function test_get_user_groups_with_visibility(): void { list($users, $groups, $course) = $this->create_groups_with_visibilty(); // Assign users to groups. diff --git a/lib/tests/hook/navigation/primary_extend_test.php b/lib/tests/hook/navigation/primary_extend_test.php index 6bb27fc8a43..8ceaf7c1dd4 100644 --- a/lib/tests/hook/navigation/primary_extend_test.php +++ b/lib/tests/hook/navigation/primary_extend_test.php @@ -31,7 +31,7 @@ class primary_extend_test extends \advanced_testcase { * Test stoppable_trait. * @covers ::stop_propagation */ - public function test_stop_propagation() { + public function test_stop_propagation(): void { global $PAGE; $this->resetAfterTest(); @@ -51,7 +51,7 @@ class primary_extend_test extends \advanced_testcase { * Test hook is triggered when initialising primary navigation menu. * @covers \core\navigation\views\primary::initialise */ - public function test_trigggering() { + public function test_trigggering(): void { global $PAGE; $this->resetAfterTest(); @@ -79,7 +79,7 @@ class primary_extend_test extends \advanced_testcase { * Verify that nothing except this hook modifies the primary menu. * @covers \core\navigation\views\primary::initialise */ - public function test_unsupported_hacks() { + public function test_unsupported_hacks(): void { global $PAGE; $this->resetAfterTest(); @@ -107,7 +107,7 @@ class primary_extend_test extends \advanced_testcase { * Test adding of primary menu items via hook. * @covers \core\navigation\views\primary::initialise */ - public function test_primary_menu_extending() { + public function test_primary_menu_extending(): void { global $PAGE; $this->resetAfterTest(); @@ -137,7 +137,7 @@ class primary_extend_test extends \advanced_testcase { * Test replacing of the whole primary menu. * @covers \core\navigation\views\primary::initialise */ - public function test_primary_menu_replacing() { + public function test_primary_menu_replacing(): void { global $PAGE; $this->resetAfterTest(); diff --git a/lib/tests/html2text_test.php b/lib/tests/html2text_test.php index af027171ecc..51d462d5473 100644 --- a/lib/tests/html2text_test.php +++ b/lib/tests/html2text_test.php @@ -31,7 +31,7 @@ class html2text_test extends \basic_testcase { /** * ALT as image replacements. */ - public function test_images() { + public function test_images(): void { $this->assertSame('[edit]', html_to_text('edit')); $text = 'xxsome gifxx'; @@ -42,7 +42,7 @@ class html2text_test extends \basic_testcase { /** * No magic quotes messing. */ - public function test_no_strip_slashes() { + public function test_no_strip_slashes(): void { $this->assertSame('[\edit]', html_to_text('\edit')); $text = '\\magic\\quotes\\are\\\\horrible'; @@ -53,7 +53,7 @@ class html2text_test extends \basic_testcase { /** * core_text integration. */ - public function test_core_text() { + public function test_core_text(): void { $text = 'Žluťoučký koníček'; $result = html_to_text($text, null, false, false); $this->assertSame($result, 'ŽLUŤOUČKÝ KONÍČEK'); @@ -62,7 +62,7 @@ class html2text_test extends \basic_testcase { /** * Protect 0. */ - public function test_zero() { + public function test_zero(): void { $text = '0'; $result = html_to_text($text, null, false, false); $this->assertSame($result, $text); @@ -73,7 +73,7 @@ class html2text_test extends \basic_testcase { /** * Test the links list enumeration. */ - public function test_build_link_list() { + public function test_build_link_list(): void { // Note the trailing whitespace left intentionally in the text after first link. $text = 'Total of
last weekassertSame($result, $text); @@ -129,7 +129,7 @@ have been fixed last weekassertSame("_Hello_ WORLD!\n", html_to_text('

Hello world!

')); $this->assertSame("All the WORLD’S a stage.\n\n-- William Shakespeare\n", html_to_text('

All the world’s a stage.

-- William Shakespeare

')); $this->assertSame("HELLO WORLD!\n\n", html_to_text('

Hello world!

')); @@ -139,7 +139,7 @@ have been fixed last weekassertSame($long, html_to_text($long, 0)); @@ -149,14 +149,14 @@ have been fixed last weekassertSame('With trailing whitespace and some more text', html_to_text("With trailing whitespace \nand some more text", 0)); } /** * PRE parsing. */ - public function test_html_to_text_pre_parsing_problem() { + public function test_html_to_text_pre_parsing_problem(): void { $strorig = 'Consider the following function:
void FillMeUp(char* in_string) {'.
             '
int i = 0;
while (in_string[i] != \'\0\') {
in_string[i] = \'X\';
i++;
}
'. '}
What would happen if a non-terminated string were input to this function?

'; @@ -181,7 +181,7 @@ What would happen if a non-terminated string were input to this function? /** * Scripts should be stripped. */ - public function test_strip_scripts() { + public function test_strip_scripts(): void { $this->assertSame('Interesting text', html_to_text('Interesting text', 0)); } diff --git a/lib/tests/html_writer_test.php b/lib/tests/html_writer_test.php index 623078eaa57..f40b823ee7b 100644 --- a/lib/tests/html_writer_test.php +++ b/lib/tests/html_writer_test.php @@ -41,14 +41,14 @@ class html_writer_test extends basic_testcase { /** * @covers ::start_tag */ - public function test_start_tag() { + public function test_start_tag(): void { $this->assertSame('
', html_writer::start_tag('div')); } /** * @covers ::start_tag */ - public function test_start_tag_with_attr() { + public function test_start_tag_with_attr(): void { $this->assertSame('
', html_writer::start_tag('div', array('class' => 'frog'))); } @@ -56,7 +56,7 @@ class html_writer_test extends basic_testcase { /** * @covers ::start_tag */ - public function test_start_tag_with_attrs() { + public function test_start_tag_with_attrs(): void { $this->assertSame('
', html_writer::start_tag('div', array('class' => 'frog', 'id' => 'mydiv'))); } @@ -64,21 +64,21 @@ class html_writer_test extends basic_testcase { /** * @covers ::end_tag */ - public function test_end_tag() { + public function test_end_tag(): void { $this->assertSame('
', html_writer::end_tag('div')); } /** * @covers ::empty_Tag */ - public function test_empty_tag() { + public function test_empty_tag(): void { $this->assertSame('
', html_writer::empty_tag('br')); } /** * @covers ::empty_Tag */ - public function test_empty_tag_with_attrs() { + public function test_empty_tag_with_attrs(): void { $this->assertSame('', html_writer::empty_tag('input', array('type' => 'submit', 'value' => 'frog'))); } @@ -86,7 +86,7 @@ class html_writer_test extends basic_testcase { /** * @covers ::nonempty_tag */ - public function test_nonempty_tag_with_content() { + public function test_nonempty_tag_with_content(): void { $this->assertSame('
Hello world!
', html_writer::nonempty_tag('div', 'Hello world!')); } @@ -94,7 +94,7 @@ class html_writer_test extends basic_testcase { /** * @covers ::nonempty_tag */ - public function test_nonempty_tag_empty() { + public function test_nonempty_tag_empty(): void { $this->assertSame('', html_writer::nonempty_tag('div', '')); } @@ -102,7 +102,7 @@ class html_writer_test extends basic_testcase { /** * @covers ::nonempty_tag */ - public function test_nonempty_tag_null() { + public function test_nonempty_tag_null(): void { $this->assertSame('', html_writer::nonempty_tag('div', null)); } @@ -110,7 +110,7 @@ class html_writer_test extends basic_testcase { /** * @covers ::nonempty_tag */ - public function test_nonempty_tag_zero() { + public function test_nonempty_tag_zero(): void { $this->assertSame('
0
', html_writer::nonempty_tag('div', 0, array('class' => 'score'))); } @@ -118,7 +118,7 @@ class html_writer_test extends basic_testcase { /** * @covers ::nonempty_tag */ - public function test_nonempty_tag_zero_string() { + public function test_nonempty_tag_zero_string(): void { $this->assertSame('
0
', html_writer::nonempty_tag('div', '0', array('class' => 'score'))); } @@ -126,7 +126,7 @@ class html_writer_test extends basic_testcase { /** * @covers ::div */ - public function test_div() { + public function test_div(): void { // All options. $this->assertSame('
ribbit
', html_writer::div('ribbit', 'frog', array('id' => 'kermit'))); @@ -147,7 +147,7 @@ class html_writer_test extends basic_testcase { /** * @covers ::start_div */ - public function test_start_div() { + public function test_start_div(): void { // All options. $this->assertSame('
', html_writer::start_div('frog', array('id' => 'kermit'))); @@ -168,14 +168,14 @@ class html_writer_test extends basic_testcase { /** * @covers ::end_div */ - public function test_end_div() { + public function test_end_div(): void { $this->assertSame('
', html_writer::end_div()); } /** * @covers ::span */ - public function test_span() { + public function test_span(): void { // All options. $this->assertSame('ribbit', html_writer::span('ribbit', 'frog', array('id' => 'kermit'))); @@ -196,7 +196,7 @@ class html_writer_test extends basic_testcase { /** * @covers ::start_span */ - public function test_start_span() { + public function test_start_span(): void { // All options. $this->assertSame('', html_writer::start_span('frog', array('id' => 'kermit'))); @@ -217,7 +217,7 @@ class html_writer_test extends basic_testcase { /** * @covers ::end_span */ - public function test_end_span() { + public function test_end_span(): void { $this->assertSame('', html_writer::end_span()); } @@ -227,7 +227,7 @@ class html_writer_test extends basic_testcase { * @covers \html_table_cell * @covers \html_table */ - public function test_table() { + public function test_table(): void { $row = new html_table_row(); // The attribute will get overwritten by the ID. @@ -279,7 +279,7 @@ EOF; /** * @covers ::table */ - public function test_table_hidden_caption() { + public function test_table_hidden_caption(): void { $table = new html_table(); $table->id = "whodat"; diff --git a/lib/tests/htmlpurifier_test.php b/lib/tests/htmlpurifier_test.php index 0ed95641d55..828fa0037ad 100644 --- a/lib/tests/htmlpurifier_test.php +++ b/lib/tests/htmlpurifier_test.php @@ -29,7 +29,7 @@ class htmlpurifier_test extends \basic_testcase { /** * Verify _blank target is allowed. */ - public function test_allow_blank_target() { + public function test_allow_blank_target(): void { // See MDL-52651 for an explanation as to why the rel="noreferrer" attribute is expected here. // Also note we do not need to test links with an existing rel attribute as the HTML Purifier is configured to remove // the rel attribute. @@ -45,7 +45,7 @@ class htmlpurifier_test extends \basic_testcase { /** * Verify our nolink tag accepted. */ - public function test_nolink() { + public function test_nolink(): void { // We can not use format text because nolink changes result. $text = '
no filters
'; $result = purify_html($text, array()); @@ -64,7 +64,7 @@ class htmlpurifier_test extends \basic_testcase { /** * Verify our tex tag accepted. */ - public function test_tex() { + public function test_tex(): void { $text = 'a+b=c'; $result = purify_html($text, array()); $this->assertSame($text, $result); @@ -73,7 +73,7 @@ class htmlpurifier_test extends \basic_testcase { /** * Verify our algebra tag accepted. */ - public function test_algebra() { + public function test_algebra(): void { $text = 'a+b=c'; $result = purify_html($text, array()); $this->assertSame($text, $result); @@ -82,7 +82,7 @@ class htmlpurifier_test extends \basic_testcase { /** * Verify our hacky multilang works. */ - public function test_multilang() { + public function test_multilang(): void { $text = 'hmmmhm'; $result = purify_html($text, array()); $this->assertSame($text, $result); @@ -109,7 +109,7 @@ class htmlpurifier_test extends \basic_testcase { /** * Tests the 'allowid' option for format_text. */ - public function test_format_text_allowid() { + public function test_format_text_allowid(): void { // Start off by not allowing ids (default). $options = [ 'allowid' => false, @@ -123,7 +123,7 @@ class htmlpurifier_test extends \basic_testcase { $this->assertSame('
Frog
', $result); } - public function test_allowobjectembed() { + public function test_allowobjectembed(): void { global $CFG; $this->assertSame('0', $CFG->allowobjectembed); @@ -157,7 +157,7 @@ class htmlpurifier_test extends \basic_testcase { /** * Test if linebreaks kept unchanged. */ - public function test_line_breaking() { + public function test_line_breaking(): void { $text = "\n\raa\rsss\nsss\r"; $this->assertSame($text, purify_html($text)); } @@ -165,7 +165,7 @@ class htmlpurifier_test extends \basic_testcase { /** * Test fixing of strict problems. */ - public function test_tidy() { + public function test_tidy(): void { $text = "

xx"; $this->assertSame('

xx

', purify_html($text)); @@ -179,7 +179,7 @@ class htmlpurifier_test extends \basic_testcase { /** * Test nesting - this used to cause problems in earlier versions. */ - public function test_nested_lists() { + public function test_nested_lists(): void { $text = "
  • One
    • Two
  • Three
"; $this->assertSame($text, purify_html($text)); } @@ -187,7 +187,7 @@ class htmlpurifier_test extends \basic_testcase { /** * Test that XSS protection works, complete smoke tests are in htmlpurifier itself. */ - public function test_cleaning_nastiness() { + public function test_cleaning_nastiness(): void { $text = "xx"; $this->assertSame('xx', purify_html($text)); @@ -213,7 +213,7 @@ class htmlpurifier_test extends \basic_testcase { /** * Test internal function used for clean_text() speedup. */ - public function test_is_purify_html_necessary() { + public function test_is_purify_html_necessary(): void { // First our shortcuts. $text = ""; $this->assertFalse(is_purify_html_necessary($text)); @@ -267,7 +267,7 @@ class htmlpurifier_test extends \basic_testcase { $this->assertTrue(is_purify_html_necessary($text)); } - public function test_allowed_schemes() { + public function test_allowed_schemes(): void { // First standard schemas. $text = 'link'; $this->assertSame($text, purify_html($text)); @@ -317,7 +317,7 @@ class htmlpurifier_test extends \basic_testcase { /** * Test non-ascii domain names */ - public function test_idn() { + public function test_idn(): void { // Example of domain that gives the same result in IDNA2003 and IDNA2008 . $text = 'правительство.рф'; @@ -345,7 +345,7 @@ class htmlpurifier_test extends \basic_testcase { * @param string $mediatag HTML media tag * @param string $expected expected result */ - public function test_media_tags($mediatag, $expected) { + public function test_media_tags($mediatag, $expected): void { $actual = format_text($mediatag, FORMAT_MOODLE, ['filter' => false]); $this->assertEquals($expected, $actual); } diff --git a/lib/tests/http_client_test.php b/lib/tests/http_client_test.php index b5cb24b97c5..765dfa7455f 100644 --- a/lib/tests/http_client_test.php +++ b/lib/tests/http_client_test.php @@ -75,7 +75,7 @@ class http_client_test extends \advanced_testcase { * * @covers \core\http_client */ - public function test_http_client_can_send_synchronously() { + public function test_http_client_can_send_synchronously(): void { $testhtml = $this->getExternalTestFileUrl('/test.html'); $client = new \core\http_client(['handler' => new MockHandler([new Response()])]); @@ -90,7 +90,7 @@ class http_client_test extends \advanced_testcase { * * @covers \core\http_client */ - public function test_http_client_has_options() { + public function test_http_client_has_options(): void { $testhtml = $this->getExternalTestFileUrl('/test.html'); $client = new \core\http_client([ @@ -115,7 +115,7 @@ class http_client_test extends \advanced_testcase { * * @covers \core\http_client */ - public function test_http_client_can_modify_the_header_for_each_request() { + public function test_http_client_can_modify_the_header_for_each_request(): void { $testhtml = $this->getExternalTestFileUrl('/test.html'); $mock = new MockHandler([new Response()]); @@ -132,7 +132,7 @@ class http_client_test extends \advanced_testcase { * * @covers \core\http_client */ - public function test_can_unset_request_option_with_null() { + public function test_can_unset_request_option_with_null(): void { $testhtml = $this->getExternalTestFileUrl('/test.html'); $mock = new MockHandler([new Response()]); @@ -150,7 +150,7 @@ class http_client_test extends \advanced_testcase { * * @covers \core\http_client */ - public function test_basic_cookie_jar() { + public function test_basic_cookie_jar(): void { $mock = new MockHandler([ new Response(200, ['Set-Cookie' => 'foo=bar']), new Response() @@ -167,7 +167,7 @@ class http_client_test extends \advanced_testcase { * * @covers \core\http_client */ - public function test_shared_cookie_jar() { + public function test_shared_cookie_jar(): void { $mock = new MockHandler([ new Response(200, ['Set-Cookie' => 'foo=bar']), new Response() @@ -184,7 +184,7 @@ class http_client_test extends \advanced_testcase { * @covers \core\http_client * @covers \core\local\guzzle\check_request */ - public function test_guzzle_basics_with_security_helper() { + public function test_guzzle_basics_with_security_helper(): void { $this->resetAfterTest(); // Test a request with a basic hostname filter applied. @@ -229,7 +229,7 @@ class http_client_test extends \advanced_testcase { * @covers \core\http_client * @covers \core\local\guzzle\check_request */ - public function test_http_client_proxy_bypass() { + public function test_http_client_proxy_bypass(): void { $this->resetAfterTest(); global $CFG; @@ -260,7 +260,7 @@ class http_client_test extends \advanced_testcase { * @covers \core\http_client * @covers \core\local\guzzle\redirect_middleware */ - public function test_moodle_allow_redirects_can_be_true() { + public function test_moodle_allow_redirects_can_be_true(): void { $testurl = $this->getExternalTestFileUrl('/test_redir.php'); $mock = new MockHandler([new Response(200, [], 'foo')]); @@ -276,7 +276,7 @@ class http_client_test extends \advanced_testcase { * @covers \core\http_client * @covers \core\local\guzzle\redirect_middleware */ - public function test_redirects_with_absolute_uri() { + public function test_redirects_with_absolute_uri(): void { $testurl = $this->getExternalTestFileUrl('/test_redir.php'); $mock = new MockHandler([ @@ -297,7 +297,7 @@ class http_client_test extends \advanced_testcase { * @covers \core\http_client * @covers \core\local\guzzle\redirect_middleware */ - public function test_redirects_with_relative_uri() { + public function test_redirects_with_relative_uri(): void { $testurl = $this->getExternalTestFileUrl('/test_relative_redir.php'); $mock = new MockHandler([ @@ -369,7 +369,7 @@ class http_client_test extends \advanced_testcase { * @covers \core\local\guzzle\cache_handler * @covers \core\local\guzzle\cache_storage */ - public function test_http_client_cache_item() { + public function test_http_client_cache_item(): void { global $CFG, $USER; $module = 'core_guzzle'; $cachedir = "$CFG->cachedir/$module/"; diff --git a/lib/tests/ip_utils_test.php b/lib/tests/ip_utils_test.php index f189857607d..967ed2f12b5 100644 --- a/lib/tests/ip_utils_test.php +++ b/lib/tests/ip_utils_test.php @@ -32,7 +32,7 @@ class ip_utils_test extends \basic_testcase { * @param bool $expected the expected result. * @dataProvider domain_name_data_provider */ - public function test_is_domain_name($domainname, $expected) { + public function test_is_domain_name($domainname, $expected): void { $this->assertEquals($expected, \core\ip_utils::is_domain_name($domainname)); } @@ -82,7 +82,7 @@ class ip_utils_test extends \basic_testcase { * @param bool $expected the expected result. * @dataProvider domain_matching_patterns_data_provider */ - public function test_is_domain_matching_pattern($str, $expected) { + public function test_is_domain_matching_pattern($str, $expected): void { $this->assertEquals($expected, \core\ip_utils::is_domain_matching_pattern($str)); } @@ -127,7 +127,7 @@ class ip_utils_test extends \basic_testcase { * @param bool $expected the expected result. * @dataProvider ip_address_data_provider */ - public function test_is_ip_address($address, $expected) { + public function test_is_ip_address($address, $expected): void { $this->assertEquals($expected, \core\ip_utils::is_ip_address($address)); } @@ -174,7 +174,7 @@ class ip_utils_test extends \basic_testcase { * @param bool $expected the expected result. * @dataProvider ipv4_address_data_provider */ - public function test_is_ipv4_address($address, $expected) { + public function test_is_ipv4_address($address, $expected): void { $this->assertEquals($expected, \core\ip_utils::is_ipv4_address($address)); } @@ -210,7 +210,7 @@ class ip_utils_test extends \basic_testcase { * @param bool $expected the expected result. * @dataProvider ipv4_range_data_provider */ - public function test_is_ipv4_range($addressrange, $expected) { + public function test_is_ipv4_range($addressrange, $expected): void { $this->assertEquals($expected, \core\ip_utils::is_ipv4_range($addressrange)); } @@ -251,7 +251,7 @@ class ip_utils_test extends \basic_testcase { * @param bool $expected the expected result. * @dataProvider ipv6_address_data_provider */ - public function test_is_ipv6_address($address, $expected) { + public function test_is_ipv6_address($address, $expected): void { $this->assertEquals($expected, \core\ip_utils::is_ipv6_address($address)); } @@ -291,7 +291,7 @@ class ip_utils_test extends \basic_testcase { * @param bool $expected the expected result. * @dataProvider ipv6_range_data_provider */ - public function test_is_ipv6_range($addressrange, $expected) { + public function test_is_ipv6_range($addressrange, $expected): void { $this->assertEquals($expected, \core\ip_utils::is_ipv6_range($addressrange)); } @@ -338,7 +338,7 @@ class ip_utils_test extends \basic_testcase { * @param string $domain domain address * @dataProvider data_domain_addresses */ - public function test_check_domain_against_allowed_domains($expected, $domain) { + public function test_check_domain_against_allowed_domains($expected, $domain): void { $alloweddomains = ['example.com', '*.moodle.com', '*.per.this.penny-arcade.com', @@ -396,7 +396,7 @@ class ip_utils_test extends \basic_testcase { * @param string $delim delimiter of list * @dataProvider data_is_ip_in_subnet_list */ - public function test_is_ip_in_subnet_list($expected, $ip, $list, $delim) { + public function test_is_ip_in_subnet_list($expected, $ip, $list, $delim): void { $this->assertEquals($expected, \core\ip_utils::is_ip_in_subnet_list($ip, $list, $delim)); } diff --git a/lib/tests/jquery_test.php b/lib/tests/jquery_test.php index b56226bfa88..b13fc495170 100644 --- a/lib/tests/jquery_test.php +++ b/lib/tests/jquery_test.php @@ -32,7 +32,7 @@ namespace core; */ class jquery_test extends \basic_testcase { - public function test_plugins_file() { + public function test_plugins_file(): void { global $CFG; $plugins = null; diff --git a/lib/tests/ldaplib_test.php b/lib/tests/ldaplib_test.php index c0e33b1bd3f..67dc8cf738d 100644 --- a/lib/tests/ldaplib_test.php +++ b/lib/tests/ldaplib_test.php @@ -31,7 +31,7 @@ require_once($CFG->libdir . '/ldaplib.php'); */ class ldaplib_test extends \advanced_testcase { - public function test_ldap_addslashes() { + public function test_ldap_addslashes(): void { // See http://tools.ietf.org/html/rfc4514#section-5.2 if you want // to add additional tests. @@ -76,7 +76,7 @@ class ldaplib_test extends \advanced_testcase { } } - public function test_ldap_stripslashes() { + public function test_ldap_stripslashes(): void { // See http://tools.ietf.org/html/rfc4514#section-5.2 if you want // to add additional tests. @@ -175,7 +175,7 @@ class ldaplib_test extends \advanced_testcase { * @param array $args Arguments passed to ldap_normalise_objectclass * @param string $expected The expected objectclass filter */ - public function test_ldap_normalise_objectclass($args, $expected) { + public function test_ldap_normalise_objectclass($args, $expected): void { $this->assertEquals($expected, call_user_func_array('ldap_normalise_objectclass', $args)); } @@ -223,7 +223,7 @@ class ldaplib_test extends \advanced_testcase { * define('TEST_LDAPLIB_DOMAIN', 'dc=example,dc=local'); * */ - public function test_ldap_get_entries_moodle() { + public function test_ldap_get_entries_moodle(): void { $this->resetAfterTest(); if (!defined('TEST_LDAPLIB_HOST_URL') or !defined('TEST_LDAPLIB_BIND_DN') or diff --git a/lib/tests/licenselib_test.php b/lib/tests/licenselib_test.php index 15c152f4c1d..c374549a392 100644 --- a/lib/tests/licenselib_test.php +++ b/lib/tests/licenselib_test.php @@ -38,7 +38,7 @@ class licenselib_test extends advanced_testcase { /** * Test getting licenses from database or cache. */ - public function test_get_licenses() { + public function test_get_licenses(): void { $this->resetAfterTest(); // Reset the cache, to make sure we are not getting cached licenses. @@ -74,7 +74,7 @@ class licenselib_test extends advanced_testcase { /** * Test saving a license. */ - public function test_save() { + public function test_save(): void { global $DB; $this->resetAfterTest(); @@ -120,7 +120,7 @@ class licenselib_test extends advanced_testcase { /** * Test ability to get a license by it's short name. */ - public function test_get_license_by_shortname() { + public function test_get_license_by_shortname(): void { $license = license_manager::get_license_by_shortname('cc-nc-4.0'); $actual = $license->fullname; @@ -132,7 +132,7 @@ class licenselib_test extends advanced_testcase { /** * Test disabling a license. */ - public function test_disable_license() { + public function test_disable_license(): void { global $DB; $this->resetAfterTest(); @@ -151,7 +151,7 @@ class licenselib_test extends advanced_testcase { /** * Test enabling a license. */ - public function test_enable_license() { + public function test_enable_license(): void { global $DB; $this->resetAfterTest(); @@ -170,7 +170,7 @@ class licenselib_test extends advanced_testcase { /** * Test deleting a custom license. */ - public function test_delete() { + public function test_delete(): void { $this->resetAfterTest(); // Create a custom license. @@ -191,7 +191,7 @@ class licenselib_test extends advanced_testcase { /** * Test trying to delete a license currently in use by a file. */ - public function test_delete_license_in_use_by_file() { + public function test_delete_license_in_use_by_file(): void { $this->resetAfterTest(); // Create a custom license. @@ -226,7 +226,7 @@ class licenselib_test extends advanced_testcase { /** * Test trying to delete a core license. */ - public function test_delete_license_core() { + public function test_delete_license_core(): void { // Should not be able to delete a standard/core license. $this->expectException(moodle_exception::class); license_manager::delete('cc-nc-4.0'); @@ -235,7 +235,7 @@ class licenselib_test extends advanced_testcase { /** * Test trying to delete a license which doesn't exist. */ - public function test_delete_license_not_exists() { + public function test_delete_license_not_exists(): void { // Should throw an exception if license with shortname doesn't exist. $this->expectException(moodle_exception::class); license_manager::delete('somefakelicense'); @@ -244,7 +244,7 @@ class licenselib_test extends advanced_testcase { /** * Test setting active licenses. */ - public function test_set_active_licenses() { + public function test_set_active_licenses(): void { $this->resetAfterTest(); // Private method used internally, test through disable and enable public methods. @@ -258,7 +258,7 @@ class licenselib_test extends advanced_testcase { /** * Test getting active licenses. */ - public function test_get_active_licenses() { + public function test_get_active_licenses(): void { $this->resetAfterTest(); license_manager::disable('allrightsreserved'); @@ -277,7 +277,7 @@ class licenselib_test extends advanced_testcase { /** * Test getting active licenses as array. */ - public function test_get_active_licenses_as_array() { + public function test_get_active_licenses_as_array(): void { $this->resetAfterTest(); license_manager::disable('allrightsreserved'); @@ -298,7 +298,7 @@ class licenselib_test extends advanced_testcase { /** * Test resetting the license cache. */ - public function test_reset_license_cache() { + public function test_reset_license_cache(): void { global $DB; $this->resetAfterTest(); @@ -326,7 +326,7 @@ class licenselib_test extends advanced_testcase { /** * Test that all licenses are installed correctly. */ - public function test_install_licenses() { + public function test_install_licenses(): void { global $DB; $this->resetAfterTest(); diff --git a/lib/tests/lock_config_test.php b/lib/tests/lock_config_test.php index adc689a1607..b0c1ac68963 100644 --- a/lib/tests/lock_config_test.php +++ b/lib/tests/lock_config_test.php @@ -30,7 +30,7 @@ class lock_config_test extends \advanced_testcase { * Tests the static parse charset method * @return void */ - public function test_lock_config() { + public function test_lock_config(): void { global $CFG; $original = null; if (isset($CFG->lock_factory)) { diff --git a/lib/tests/lock_test.php b/lib/tests/lock_test.php index 39ec94b9a53..835734aa429 100644 --- a/lib/tests/lock_test.php +++ b/lib/tests/lock_test.php @@ -119,7 +119,7 @@ class lock_test extends \advanced_testcase { * Tests the testable lock factories classes. * @return void */ - public function test_locks() { + public function test_locks(): void { // Run the suite on the current configured default (may be non-core). $this->run_on_lock_factory(\core\lock\lock_config::get_lock_factory_class()); diff --git a/lib/tests/markdown_test.php b/lib/tests/markdown_test.php index 3f75534e99b..5e3c053c2c4 100644 --- a/lib/tests/markdown_test.php +++ b/lib/tests/markdown_test.php @@ -32,31 +32,31 @@ namespace core; */ class markdown_test extends \basic_testcase { - public function test_paragraphs() { + public function test_paragraphs(): void { $text = "one\n\ntwo"; $result = "

one

\n\n

two

\n"; $this->assertSame($result, markdown_to_html($text)); } - public function test_headings() { + public function test_headings(): void { $text = "Header 1\n====================\n\n## Header 2"; $result = "

Header 1

\n\n

Header 2

\n"; $this->assertSame($result, markdown_to_html($text)); } - public function test_lists() { + public function test_lists(): void { $text = "* one\n* two\n* three\n"; $result = "
    \n
  • one
  • \n
  • two
  • \n
  • three
  • \n
\n"; $this->assertSame($result, markdown_to_html($text)); } - public function test_links() { + public function test_links(): void { $text = "some [example link](http://example.com/)"; $result = "

some example link

\n"; $this->assertSame($result, markdown_to_html($text)); } - public function test_tabs() { + public function test_tabs(): void { $text = "a\tbb\tccc\tя\tюэ\t水\tabcd\tabcde\tabcdef"; $result = "

a bb ccc я юэ 水 abcd abcde abcdef

\n"; $this->assertSame($result, markdown_to_html($text)); diff --git a/lib/tests/mathslib_test.php b/lib/tests/mathslib_test.php index 5994e2fffdf..3cecccd7d77 100644 --- a/lib/tests/mathslib_test.php +++ b/lib/tests/mathslib_test.php @@ -36,7 +36,7 @@ class mathslib_test extends \basic_testcase { /** * Tests the basic formula evaluation. */ - public function test__basic() { + public function test__basic(): void { $formula = new calc_formula('=1+2'); $res = $formula->evaluate(); $this->assertSame($res, 3, '3+1 is: %s'); @@ -45,7 +45,7 @@ class mathslib_test extends \basic_testcase { /** * Tests the formula params. */ - public function test__params() { + public function test__params(): void { $formula = new calc_formula('=a+b+c', array('a'=>10, 'b'=>20, 'c'=>30)); $res = $formula->evaluate(); $this->assertSame(60, $res, '10+20+30 is: %s'); @@ -54,7 +54,7 @@ class mathslib_test extends \basic_testcase { /** * Tests the changed params. */ - public function test__changing_params() { + public function test__changing_params(): void { $formula = new calc_formula('=a+b+c', array('a'=>10, 'b'=>20, 'c'=>30)); $res = $formula->evaluate(); $this->assertSame(60, $res, '10+20+30 is: %s'); @@ -66,13 +66,13 @@ class mathslib_test extends \basic_testcase { /** * Tests the spreadsheet emulation function in formula. */ - public function test__calc_function() { + public function test__calc_function(): void { $formula = new calc_formula('=sum(a, b, c)', array('a'=>10, 'b'=>20, 'c'=>30)); $res = $formula->evaluate(); $this->assertSame(60, $res, 'sum(a, b, c) is: %s'); } - public function test_other_functions() { + public function test_other_functions(): void { $formula = new calc_formula('=average(1,2,3)'); $this->assertSame(2, $formula->evaluate()); @@ -83,7 +83,7 @@ class mathslib_test extends \basic_testcase { $this->assertSame(8, $formula->evaluate()); } - public function test_conditional_functions() { + public function test_conditional_functions(): void { // Test ifthenelse. $formula = new calc_formula('=ifthenelse(1,2,3)'); $this->assertSame(2, (int)$formula->evaluate()); @@ -145,7 +145,7 @@ class mathslib_test extends \basic_testcase { $this->assertSame(0, (int) $formula->evaluate()); } - public function test_conditional_operators() { + public function test_conditional_operators(): void { $formula = new calc_formula('=2==2'); $this->assertSame(1, $formula->evaluate()); @@ -168,7 +168,7 @@ class mathslib_test extends \basic_testcase { /** * Tests the min and max functions. */ - public function test__minmax_function() { + public function test__minmax_function(): void { $formula = new calc_formula('=min(a, b, c)', array('a'=>10, 'b'=>20, 'c'=>30)); $res = $formula->evaluate(); $this->assertSame(10, $res, 'minimum is: %s'); @@ -180,7 +180,7 @@ class mathslib_test extends \basic_testcase { /** * Tests special chars. */ - public function test__specialchars() { + public function test__specialchars(): void { $formula = new calc_formula('=gi1 + gi2 + gi11', array('gi1'=>10, 'gi2'=>20, 'gi11'=>30)); $res = $formula->evaluate(); $this->assertSame(60, $res, 'sum is: %s'); @@ -189,7 +189,7 @@ class mathslib_test extends \basic_testcase { /** * Tests some slightly more complex expressions. */ - public function test__more_complex_expressions() { + public function test__more_complex_expressions(): void { $formula = new calc_formula('=pi() + a', array('a'=>10)); $res = $formula->evaluate(); $this->assertSame(pi()+10, $res); @@ -204,7 +204,7 @@ class mathslib_test extends \basic_testcase { /** * Tests some slightly more complex expressions. */ - public function test__error_handling() { + public function test__error_handling(): void { $formula = new calc_formula('=pi( + a', array('a'=>10)); $res = $formula->evaluate(); $this->assertFalse($res); @@ -222,7 +222,7 @@ class mathslib_test extends \basic_testcase { } - public function test_rounding_function() { + public function test_rounding_function(): void { // Rounding to the default number of decimal places. // The default == 0. @@ -295,7 +295,7 @@ class mathslib_test extends \basic_testcase { $this->assertSame(120.0, $formula->evaluate()); } - public function test_scientific_notation() { + public function test_scientific_notation(): void { $formula = new calc_formula('=10e10'); $this->assertEqualsWithDelta(1e11, $formula->evaluate(), 1e11 * 1e-15); @@ -312,7 +312,7 @@ class mathslib_test extends \basic_testcase { $this->assertEqualsWithDelta(1e22, $formula->evaluate(), 1e22 * 1e-15); } - public function test_rand_float() { + public function test_rand_float(): void { $formula = new calc_formula('=rand_float()'); $result = $formula->evaluate(); $this->assertTrue(is_float($result)); diff --git a/lib/tests/medialib_test.php b/lib/tests/medialib_test.php index c5eddec9fe7..065e2ba3ca8 100644 --- a/lib/tests/medialib_test.php +++ b/lib/tests/medialib_test.php @@ -71,7 +71,7 @@ class medialib_test extends \advanced_testcase { /** * Test for core_media::get_filename. */ - public function test_get_filename() { + public function test_get_filename(): void { $manager = core_media_manager::instance(); $this->assertSame('frog.mp4', $manager->get_filename(new \moodle_url( @@ -85,7 +85,7 @@ class medialib_test extends \advanced_testcase { /** * Test for core_media::get_extension. */ - public function test_get_extension() { + public function test_get_extension(): void { $manager = core_media_manager::instance(); $this->assertSame('mp4', $manager->get_extension(new \moodle_url( @@ -101,7 +101,7 @@ class medialib_test extends \advanced_testcase { /** * Test for the core_media_player list_supported_urls. */ - public function test_list_supported_urls() { + public function test_list_supported_urls(): void { $test = new media_test_plugin(1, 13, ['tst', 'test']); // Some example URLs. @@ -133,7 +133,7 @@ class medialib_test extends \advanced_testcase { /** * Test for get_players */ - public function test_get_players() { + public function test_get_players(): void { // All players are initially disabled (except link, which you can't). $manager = core_media_manager::instance(); $this->assertEmpty($this->get_players_test($manager)); @@ -162,7 +162,7 @@ class medialib_test extends \advanced_testcase { /** * Test for can_embed_url */ - public function test_can_embed_url() { + public function test_can_embed_url(): void { // All players are initially disabled, so mp4 cannot be rendered. $url = new \moodle_url('http://example.org/test.mp4'); $manager = core_media_manager::instance(); @@ -188,7 +188,7 @@ class medialib_test extends \advanced_testcase { * Test for embed_url. * Checks multiple format/fallback support. */ - public function test_embed_url_fallbacks() { + public function test_embed_url_fallbacks(): void { // Key strings in the embed code that identify with the media formats being tested. $html5video = ''; @@ -259,7 +259,7 @@ class medialib_test extends \advanced_testcase { * Test for embed_url. * SWF shouldn't be converted to objects because media_swf has been removed. */ - public function test_embed_url_swf() { + public function test_embed_url_swf(): void { $manager = core_media_manager::instance(); // Without any options... @@ -276,7 +276,7 @@ class medialib_test extends \advanced_testcase { /** * Same as test_embed_url MP3 test, but for slash arguments. */ - public function test_slash_arguments() { + public function test_slash_arguments(): void { // Again we do not turn slasharguments actually on, because it has to // work regardless of the setting of that variable in case of handling @@ -296,7 +296,7 @@ class medialib_test extends \advanced_testcase { * Test for embed_url. * Checks the EMBED_OR_BLANK option. */ - public function test_embed_or_blank() { + public function test_embed_or_blank(): void { \core\plugininfo\media::set_enabled_plugins('html5audio'); $manager = core_media_manager::instance(); $this->pretend_to_be_firefox(); @@ -320,7 +320,7 @@ class medialib_test extends \advanced_testcase { * Checks that size is passed through correctly to player objects and tests * size support in html5video output. */ - public function test_embed_url_size() { + public function test_embed_url_size(): void { global $CFG; // Technically this could break in every format and they handle size @@ -353,7 +353,7 @@ class medialib_test extends \advanced_testcase { * Checks that name is passed through correctly to player objects and tests * name support in html5video output. */ - public function test_embed_url_name() { + public function test_embed_url_name(): void { // As for size this could break in every format but I'm only testing // html5video. \core\plugininfo\media::set_enabled_plugins('html5video'); @@ -372,7 +372,7 @@ class medialib_test extends \advanced_testcase { /** * Test for split_alternatives. */ - public function test_split_alternatives() { + public function test_split_alternatives(): void { $mediamanager = core_media_manager::instance(); // Single URL - identical moodle_url. @@ -409,7 +409,7 @@ class medialib_test extends \advanced_testcase { /** * Test for embed_alternatives (with multiple urls) */ - public function test_embed_alternatives() { + public function test_embed_alternatives(): void { // Most aspects of this are same as single player so let's just try // a single typical / complicated scenario. @@ -452,7 +452,7 @@ class medialib_test extends \advanced_testcase { /** * Make sure the instance() method returns singleton for the same page and different object for another page */ - public function test_initialise() { + public function test_initialise(): void { $moodlepage1 = new \moodle_page(); $mediamanager1 = core_media_manager::instance($moodlepage1); diff --git a/lib/tests/message_test.php b/lib/tests/message_test.php index c9a76c862dc..9361f9b1994 100644 --- a/lib/tests/message_test.php +++ b/lib/tests/message_test.php @@ -31,7 +31,7 @@ class message_test extends \advanced_testcase { /** * Test the method get_eventobject_for_processor(). */ - public function test_get_eventobject_for_processor() { + public function test_get_eventobject_for_processor(): void { global $USER; $this->resetAfterTest(); $this->setAdminUser(); @@ -121,7 +121,7 @@ class message_test extends \advanced_testcase { /** * Test sending messages as email works with the new class. */ - public function test_send_message() { + public function test_send_message(): void { global $DB, $CFG; $this->preventResetByRollback(); $this->resetAfterTest(); @@ -217,7 +217,7 @@ class message_test extends \advanced_testcase { $sink->close(); } - public function test_send_message_with_prefix() { + public function test_send_message_with_prefix(): void { global $DB, $CFG; $this->preventResetByRollback(); $this->resetAfterTest(); diff --git a/lib/tests/messagelib_test.php b/lib/tests/messagelib_test.php index ee04a68c271..62db8e9c5c0 100644 --- a/lib/tests/messagelib_test.php +++ b/lib/tests/messagelib_test.php @@ -26,7 +26,7 @@ namespace core; */ class messagelib_test extends \advanced_testcase { - public function test_message_provider_disabled() { + public function test_message_provider_disabled(): void { $this->resetAfterTest(); $this->preventResetByRollback(); @@ -66,7 +66,7 @@ class messagelib_test extends \advanced_testcase { $email = reset($emails); $this->assertEquals(get_string('unreadnewmessage', 'message', fullname(get_admin())), $email->subject); } - public function test_message_get_providers_for_user() { + public function test_message_get_providers_for_user(): void { global $CFG, $DB; $this->resetAfterTest(); @@ -119,7 +119,7 @@ class messagelib_test extends \advanced_testcase { $this->assertFalse($this->message_type_present('mod_quiz', 'submission', $providers)); } - public function test_message_get_providers_for_user_more() { + public function test_message_get_providers_for_user_more(): void { global $DB; $this->resetAfterTest(); @@ -180,7 +180,7 @@ class messagelib_test extends \advanced_testcase { // $this->assertFalse($this->message_type_present('moodle', 'backup', $providers)); } - public function test_send_message_redirection() { + public function test_send_message_redirection(): void { global $DB; $this->resetAfterTest(); @@ -392,7 +392,7 @@ class messagelib_test extends \advanced_testcase { $user2->emailstop = '0'; } - public function test_send_message() { + public function test_send_message(): void { global $DB, $CFG; $this->preventResetByRollback(); $this->resetAfterTest(); @@ -750,7 +750,7 @@ class messagelib_test extends \advanced_testcase { * processors and events code is called. We need to test this code here, as we generally redirect messages elsewhere and we * need to be sure this is covered. */ - public function test_message_send_to_conversation_individual() { + public function test_message_send_to_conversation_individual(): void { global $DB; $this->preventResetByRollback(); $this->resetAfterTest(); @@ -837,7 +837,7 @@ class messagelib_test extends \advanced_testcase { * processors and events code is called. We need to test this code here, as we generally redirect messages elsewhere and we * need to be sure this is covered. */ - public function test_message_send_to_self_conversation() { + public function test_message_send_to_self_conversation(): void { global $DB; $this->preventResetByRollback(); $this->resetAfterTest(); @@ -890,7 +890,7 @@ class messagelib_test extends \advanced_testcase { * processors and events code is called. We need to test this code here, as we generally redirect messages elsewhere and we * need to be sure this is covered. */ - public function test_message_send_to_conversation_group() { + public function test_message_send_to_conversation_group(): void { global $DB; $this->preventResetByRollback(); $this->resetAfterTest(); @@ -976,7 +976,7 @@ class messagelib_test extends \advanced_testcase { * * This should defer all processor calls (for 2 members in this case), and event creation (1 event). */ - public function test_send_message_to_conversation_group_with_buffering() { + public function test_send_message_to_conversation_group_with_buffering(): void { global $DB, $CFG; $this->preventResetByRollback(); $this->resetAfterTest(); @@ -1051,7 +1051,7 @@ class messagelib_test extends \advanced_testcase { $this->assertInstanceOf('\core\event\group_message_sent', $events[0]); } - public function test_rollback() { + public function test_rollback(): void { global $DB; $this->resetAfterTest(); @@ -1113,7 +1113,7 @@ class messagelib_test extends \advanced_testcase { $this->assertEquals(1, $mailsink->count()); } - public function test_forced_rollback() { + public function test_forced_rollback(): void { global $DB; $this->resetAfterTest(); @@ -1157,7 +1157,7 @@ class messagelib_test extends \advanced_testcase { $this->assertDebuggingCalled('Not sending email due to $CFG->noemailever config setting'); } - public function test_message_attachment_send() { + public function test_message_attachment_send(): void { global $CFG; $this->preventResetByRollback(); $this->resetAfterTest(); @@ -1212,7 +1212,7 @@ class messagelib_test extends \advanced_testcase { $this->assertTrue($storedfileexists); } - public function test_send_message_when_muted() { + public function test_send_message_when_muted(): void { $this->preventResetByRollback(); $this->resetAfterTest(); diff --git a/lib/tests/minify_test.php b/lib/tests/minify_test.php index 679c19b3be9..7232fd3c405 100644 --- a/lib/tests/minify_test.php +++ b/lib/tests/minify_test.php @@ -29,7 +29,7 @@ use core_minify; * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class minify_test extends \advanced_testcase { - public function test_css() { + public function test_css(): void { $css = " body { background: #fff; @@ -41,7 +41,7 @@ color: #281f18; $this->assertSame("body{background:#fff;margin:0;padding:0;color:#281f18}", core_minify::css($css)); } - public function test_css_files() { + public function test_css_files(): void { global $CFG; $testfile1 = "$CFG->tempdir/test1.css"; @@ -75,7 +75,7 @@ color: #281f18; unlink($testfile2); } - public function test_js() { + public function test_js(): void { $js = " function hm() { @@ -89,7 +89,7 @@ function hm() $this->assertStringContainsString($js, $result); } - public function test_js_files() { + public function test_js_files(): void { global $CFG; $testfile1 = "$CFG->tempdir/test1.js"; diff --git a/lib/tests/modinfolib_test.php b/lib/tests/modinfolib_test.php index 2f28e1ac58d..852002f295b 100644 --- a/lib/tests/modinfolib_test.php +++ b/lib/tests/modinfolib_test.php @@ -46,7 +46,7 @@ class modinfolib_test extends advanced_testcase { require_once($CFG->libdir . '/tests/fixtures/sectiondelegatetest.php'); } - public function test_section_info_properties() { + public function test_section_info_properties(): void { global $DB, $CFG; $this->resetAfterTest(); @@ -114,7 +114,7 @@ class modinfolib_test extends advanced_testcase { set_config('enablecompletion', $oldcfgenablecompletion); } - public function test_cm_info_properties() { + public function test_cm_info_properties(): void { global $DB, $CFG; $this->resetAfterTest(); @@ -248,7 +248,7 @@ class modinfolib_test extends advanced_testcase { set_config('enablecompletion', $oldcfgenablecompletion); } - public function test_matching_cacherev() { + public function test_matching_cacherev(): void { global $DB, $CFG; $this->resetAfterTest(); @@ -407,7 +407,7 @@ class modinfolib_test extends advanced_testcase { $this->assertEquals($newcourse->cacherev, $SITE->cacherev); } - public function test_course_modinfo_properties() { + public function test_course_modinfo_properties(): void { global $USER, $DB; $this->resetAfterTest(); @@ -491,7 +491,7 @@ class modinfolib_test extends advanced_testcase { $this->assertNotEquals('Illegal overwriting', $modinfo->cms); } - public function test_is_user_access_restricted_by_capability() { + public function test_is_user_access_restricted_by_capability(): void { global $DB; $this->resetAfterTest(); @@ -549,7 +549,7 @@ class modinfolib_test extends advanced_testcase { /** * Tests for function cm_info::get_course_module_record() */ - public function test_cm_info_get_course_module_record() { + public function test_cm_info_get_course_module_record(): void { global $DB; $this->resetAfterTest(); @@ -693,7 +693,7 @@ class modinfolib_test extends advanced_testcase { * Tests the availability property that has been added to course modules * and sections (just to see that it is correctly saved and accessed). */ - public function test_availability_property() { + public function test_availability_property(): void { global $DB, $CFG; $this->resetAfterTest(); @@ -739,7 +739,7 @@ class modinfolib_test extends advanced_testcase { /** * Tests for get_groups() method. */ - public function test_get_groups() { + public function test_get_groups(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator(); @@ -802,7 +802,7 @@ class modinfolib_test extends advanced_testcase { /** * Tests the function for constructing a cm_info from mixed data. */ - public function test_create() { + public function test_create(): void { global $CFG, $DB; $this->resetAfterTest(); @@ -861,7 +861,7 @@ class modinfolib_test extends advanced_testcase { * Tests function for getting $course and $cm at once quickly from modinfo * based on cmid or cm record. */ - public function test_get_course_and_cm_from_cmid() { + public function test_get_course_and_cm_from_cmid(): void { global $CFG, $DB; $this->resetAfterTest(); @@ -954,7 +954,7 @@ class modinfolib_test extends advanced_testcase { * Tests function for getting $course and $cm at once quickly from modinfo * based on instance id or record. */ - public function test_get_course_and_cm_from_instance() { + public function test_get_course_and_cm_from_instance(): void { global $CFG, $DB; $this->resetAfterTest(); @@ -1084,7 +1084,7 @@ class modinfolib_test extends advanced_testcase { int $strictness = IGNORE_MISSING, bool $expectnull = false, bool $expectexception = false - ) { + ): void { global $DB; $this->resetAfterTest(); diff --git a/lib/tests/moodle_page_test.php b/lib/tests/moodle_page_test.php index a74dabcc7b5..a8d6265c315 100644 --- a/lib/tests/moodle_page_test.php +++ b/lib/tests/moodle_page_test.php @@ -55,13 +55,13 @@ class moodle_page_test extends \advanced_testcase { $this->testpage = new testable_moodle_page(); } - public function test_course_returns_site_before_set() { + public function test_course_returns_site_before_set(): void { global $SITE; // Validated. $this->assertSame($SITE, $this->testpage->course); } - public function test_setting_course_works() { + public function test_setting_course_works(): void { // Setup fixture. $course = $this->getDataGenerator()->create_course(); $this->testpage->set_context(\context_system::instance()); // Avoid trying to set the context. @@ -71,7 +71,7 @@ class moodle_page_test extends \advanced_testcase { $this->assertEquals($course, $this->testpage->course); } - public function test_global_course_and_page_course_are_same_with_global_page() { + public function test_global_course_and_page_course_are_same_with_global_page(): void { global $COURSE, $PAGE; // Setup fixture. $course = $this->getDataGenerator()->create_course(); @@ -83,7 +83,7 @@ class moodle_page_test extends \advanced_testcase { $this->assertSame($COURSE, $this->testpage->course); } - public function test_global_course_not_changed_with_non_global_page() { + public function test_global_course_not_changed_with_non_global_page(): void { global $COURSE; $originalcourse = $COURSE; // Setup fixture. @@ -95,7 +95,7 @@ class moodle_page_test extends \advanced_testcase { $this->assertSame($originalcourse, $COURSE); } - public function test_cannot_set_course_once_theme_set() { + public function test_cannot_set_course_once_theme_set(): void { // Setup fixture. $this->testpage->force_theme(\theme_config::DEFAULT_THEME); $course = $this->getDataGenerator()->create_course(); @@ -105,7 +105,7 @@ class moodle_page_test extends \advanced_testcase { $this->testpage->set_course($course); } - public function test_cannot_set_category_once_theme_set() { + public function test_cannot_set_category_once_theme_set(): void { // Setup fixture. $this->testpage->force_theme(\theme_config::DEFAULT_THEME); @@ -114,7 +114,7 @@ class moodle_page_test extends \advanced_testcase { $this->testpage->set_category_by_id(123); } - public function test_cannot_set_category_once_course_set() { + public function test_cannot_set_category_once_course_set(): void { // Setup fixture. $course = $this->getDataGenerator()->create_course(); $this->testpage->set_context(\context_system::instance()); // Avoid trying to set the context. @@ -125,7 +125,7 @@ class moodle_page_test extends \advanced_testcase { $this->testpage->set_category_by_id(123); } - public function test_categories_array_empty_for_front_page() { + public function test_categories_array_empty_for_front_page(): void { global $SITE; // Setup fixture. $this->testpage->set_context(\context_system::instance()); // Avoid trying to set the context. @@ -134,7 +134,7 @@ class moodle_page_test extends \advanced_testcase { $this->assertEquals(array(), $this->testpage->categories); } - public function test_set_state_normal_path() { + public function test_set_state_normal_path(): void { $course = $this->getDataGenerator()->create_course(); $this->testpage->set_context(\context_system::instance()); $this->testpage->set_course($course); @@ -151,18 +151,18 @@ class moodle_page_test extends \advanced_testcase { $this->assertEquals(\moodle_page::STATE_DONE, $this->testpage->state); } - public function test_set_state_cannot_skip_one() { + public function test_set_state_cannot_skip_one(): void { // Exercise SUT. $this->expectException(\coding_exception::class); $this->testpage->set_state(\moodle_page::STATE_IN_BODY); } - public function test_header_printed_false_initially() { + public function test_header_printed_false_initially(): void { // Validated. $this->assertFalse($this->testpage->headerprinted); } - public function test_header_printed_becomes_true() { + public function test_header_printed_becomes_true(): void { $course = $this->getDataGenerator()->create_course(); $this->testpage->set_context(\context_system::instance()); $this->testpage->set_course($course); @@ -174,7 +174,7 @@ class moodle_page_test extends \advanced_testcase { $this->assertTrue($this->testpage->headerprinted); } - public function test_set_context() { + public function test_set_context(): void { // Setup fixture. $course = $this->getDataGenerator()->create_course(); $context = \context_course::instance($course->id); @@ -184,7 +184,7 @@ class moodle_page_test extends \advanced_testcase { $this->assertSame($context, $this->testpage->context); } - public function test_pagetype_defaults_to_script() { + public function test_pagetype_defaults_to_script(): void { global $SCRIPT; // Exercise SUT and validate. $SCRIPT = '/index.php'; @@ -192,68 +192,68 @@ class moodle_page_test extends \advanced_testcase { $this->assertSame('site-index', $this->testpage->pagetype); } - public function test_set_pagetype() { + public function test_set_pagetype(): void { // Exercise SUT. $this->testpage->set_pagetype('a-page-type'); // Validated. $this->assertSame('a-page-type', $this->testpage->pagetype); } - public function test_initialise_default_pagetype() { + public function test_initialise_default_pagetype(): void { // Exercise SUT. $this->testpage->initialise_default_pagetype('admin/tool/unittest/index.php'); // Validated. $this->assertSame('admin-tool-unittest-index', $this->testpage->pagetype); } - public function test_initialise_default_pagetype_fp() { + public function test_initialise_default_pagetype_fp(): void { // Exercise SUT. $this->testpage->initialise_default_pagetype('index.php'); // Validated. $this->assertSame('site-index', $this->testpage->pagetype); } - public function test_get_body_classes_empty() { + public function test_get_body_classes_empty(): void { // Validated. $this->assertSame('', $this->testpage->bodyclasses); } - public function test_get_body_classes_single() { + public function test_get_body_classes_single(): void { // Exercise SUT. $this->testpage->add_body_class('aclassname'); // Validated. $this->assertSame('aclassname', $this->testpage->bodyclasses); } - public function test_get_body_classes() { + public function test_get_body_classes(): void { // Exercise SUT. $this->testpage->add_body_classes(array('aclassname', 'anotherclassname')); // Validated. $this->assertSame('aclassname anotherclassname', $this->testpage->bodyclasses); } - public function test_url_to_class_name() { + public function test_url_to_class_name(): void { $this->assertSame('example-com', $this->testpage->url_to_class_name('http://example.com')); $this->assertSame('example-com--80', $this->testpage->url_to_class_name('http://example.com:80')); $this->assertSame('example-com--moodle', $this->testpage->url_to_class_name('https://example.com/moodle')); $this->assertSame('example-com--8080--nested-moodle', $this->testpage->url_to_class_name('https://example.com:8080/nested/moodle')); } - public function test_set_docs_path() { + public function test_set_docs_path(): void { // Exercise SUT. $this->testpage->set_docs_path('a/file/path'); // Validated. $this->assertSame('a/file/path', $this->testpage->docspath); } - public function test_docs_path_defaults_from_pagetype() { + public function test_docs_path_defaults_from_pagetype(): void { // Exercise SUT. $this->testpage->set_pagetype('a-page-type'); // Validated. $this->assertSame('a/page/type', $this->testpage->docspath); } - public function test_set_url_root() { + public function test_set_url_root(): void { global $CFG; // Exercise SUT. $this->testpage->set_url('/'); @@ -261,7 +261,7 @@ class moodle_page_test extends \advanced_testcase { $this->assertSame($CFG->wwwroot . '/', $this->testpage->url->out()); } - public function test_set_url_one_param() { + public function test_set_url_one_param(): void { global $CFG; // Exercise SUT. $this->testpage->set_url('/mod/quiz/attempt.php', array('attempt' => 123)); @@ -269,7 +269,7 @@ class moodle_page_test extends \advanced_testcase { $this->assertSame($CFG->wwwroot . '/mod/quiz/attempt.php?attempt=123', $this->testpage->url->out()); } - public function test_set_url_two_params() { + public function test_set_url_two_params(): void { global $CFG; // Exercise SUT. $this->testpage->set_url('/mod/quiz/attempt.php', array('attempt' => 123, 'page' => 7)); @@ -277,7 +277,7 @@ class moodle_page_test extends \advanced_testcase { $this->assertSame($CFG->wwwroot . '/mod/quiz/attempt.php?attempt=123&page=7', $this->testpage->url->out()); } - public function test_set_url_using_moodle_url() { + public function test_set_url_using_moodle_url(): void { global $CFG; // Fixture setup. $url = new \moodle_url('/mod/workshop/allocation.php', array('cmid' => 29, 'method' => 'manual')); @@ -287,14 +287,14 @@ class moodle_page_test extends \advanced_testcase { $this->assertSame($CFG->wwwroot . '/mod/workshop/allocation.php?cmid=29&method=manual', $this->testpage->url->out()); } - public function test_set_url_sets_page_type() { + public function test_set_url_sets_page_type(): void { // Exercise SUT. $this->testpage->set_url('/mod/quiz/attempt.php', array('attempt' => 123, 'page' => 7)); // Validated. $this->assertSame('mod-quiz-attempt', $this->testpage->pagetype); } - public function test_set_url_does_not_change_explicit_page_type() { + public function test_set_url_does_not_change_explicit_page_type(): void { // Setup fixture. $this->testpage->set_pagetype('a-page-type'); // Exercise SUT. @@ -303,14 +303,14 @@ class moodle_page_test extends \advanced_testcase { $this->assertSame('a-page-type', $this->testpage->pagetype); } - public function test_set_subpage() { + public function test_set_subpage(): void { // Exercise SUT. $this->testpage->set_subpage('somestring'); // Validated. $this->assertSame('somestring', $this->testpage->subpage); } - public function test_set_heading() { + public function test_set_heading(): void { // Exercise SUT. $this->testpage->set_heading('a heading'); // Validated. @@ -391,19 +391,19 @@ class moodle_page_test extends \advanced_testcase { $this->assertSame($expectedtitle, $this->testpage->title); } - public function test_default_pagelayout() { + public function test_default_pagelayout(): void { // Exercise SUT and Validate. $this->assertSame('base', $this->testpage->pagelayout); } - public function test_set_pagelayout() { + public function test_set_pagelayout(): void { // Exercise SUT. $this->testpage->set_pagelayout('type'); // Validated. $this->assertSame('type', $this->testpage->pagelayout); } - public function test_setting_course_sets_context() { + public function test_setting_course_sets_context(): void { // Setup fixture. $course = $this->getDataGenerator()->create_course(); $context = \context_course::instance($course->id); @@ -415,7 +415,7 @@ class moodle_page_test extends \advanced_testcase { $this->assertSame($context, $this->testpage->context); } - public function test_set_category_top_level() { + public function test_set_category_top_level(): void { global $DB; // Setup fixture. $cat = $this->getDataGenerator()->create_category(); @@ -427,7 +427,7 @@ class moodle_page_test extends \advanced_testcase { $this->assertSame(\context_coursecat::instance($cat->id), $this->testpage->context); } - public function test_set_nested_categories() { + public function test_set_nested_categories(): void { global $DB; // Setup fixture. $topcat = $this->getDataGenerator()->create_category(); @@ -443,12 +443,12 @@ class moodle_page_test extends \advanced_testcase { $this->assertEquals($subcatdbrecord, array_pop($categories)); } - public function test_cm_null_initially() { + public function test_cm_null_initially(): void { // Validated. $this->assertNull($this->testpage->cm); } - public function test_set_cm() { + public function test_set_cm(): void { // Setup fixture. $course = $this->getDataGenerator()->create_course(); $forum = $this->getDataGenerator()->create_module('forum', array('course'=>$course->id)); @@ -459,7 +459,7 @@ class moodle_page_test extends \advanced_testcase { $this->assertEquals($cm->id, $this->testpage->cm->id); } - public function test_cannot_set_activity_record_before_cm() { + public function test_cannot_set_activity_record_before_cm(): void { // Setup fixture. $course = $this->getDataGenerator()->create_course(); $forum = $this->getDataGenerator()->create_module('forum', array('course'=>$course->id)); @@ -469,7 +469,7 @@ class moodle_page_test extends \advanced_testcase { $this->testpage->set_activity_record($forum); } - public function test_setting_cm_sets_context() { + public function test_setting_cm_sets_context(): void { // Setup fixture. $course = $this->getDataGenerator()->create_course(); $forum = $this->getDataGenerator()->create_module('forum', array('course'=>$course->id)); @@ -480,7 +480,7 @@ class moodle_page_test extends \advanced_testcase { $this->assertSame(\context_module::instance($cm->id), $this->testpage->context); } - public function test_activity_record_loaded_if_not_set() { + public function test_activity_record_loaded_if_not_set(): void { // Setup fixture. $course = $this->getDataGenerator()->create_course(); $forum = $this->getDataGenerator()->create_module('forum', array('course'=>$course->id)); @@ -492,7 +492,7 @@ class moodle_page_test extends \advanced_testcase { $this->assertEquals($forum, $this->testpage->activityrecord); } - public function test_set_activity_record() { + public function test_set_activity_record(): void { // Setup fixture. $course = $this->getDataGenerator()->create_course(); $forum = $this->getDataGenerator()->create_module('forum', array('course'=>$course->id)); @@ -505,7 +505,7 @@ class moodle_page_test extends \advanced_testcase { $this->assertEquals($forum, $this->testpage->activityrecord); } - public function test_cannot_set_inconsistent_activity_record_course() { + public function test_cannot_set_inconsistent_activity_record_course(): void { // Setup fixture. $course = $this->getDataGenerator()->create_course(); $forum = $this->getDataGenerator()->create_module('forum', array('course'=>$course->id)); @@ -517,7 +517,7 @@ class moodle_page_test extends \advanced_testcase { $this->testpage->set_activity_record($forum); } - public function test_cannot_set_inconsistent_activity_record_instance() { + public function test_cannot_set_inconsistent_activity_record_instance(): void { // Setup fixture. $course = $this->getDataGenerator()->create_course(); $forum = $this->getDataGenerator()->create_module('forum', array('course'=>$course->id)); @@ -529,7 +529,7 @@ class moodle_page_test extends \advanced_testcase { $this->testpage->set_activity_record($forum); } - public function test_setting_cm_sets_course() { + public function test_setting_cm_sets_course(): void { // Setup fixture. $course = $this->getDataGenerator()->create_course(); $forum = $this->getDataGenerator()->create_module('forum', array('course'=>$course->id)); @@ -540,7 +540,7 @@ class moodle_page_test extends \advanced_testcase { $this->assertEquals($course->id, $this->testpage->course->id); } - public function test_set_cm_with_course_and_activity_no_db() { + public function test_set_cm_with_course_and_activity_no_db(): void { // Setup fixture. $course = $this->getDataGenerator()->create_course(); $forum = $this->getDataGenerator()->create_module('forum', array('course'=>$course->id)); @@ -555,7 +555,7 @@ class moodle_page_test extends \advanced_testcase { $this->assertEquals($forum, $this->testpage->activityrecord); } - public function test_cannot_set_cm_with_inconsistent_course() { + public function test_cannot_set_cm_with_inconsistent_course(): void { // Setup fixture. $course = $this->getDataGenerator()->create_course(); $forum = $this->getDataGenerator()->create_module('forum', array('course'=>$course->id)); @@ -566,7 +566,7 @@ class moodle_page_test extends \advanced_testcase { $this->testpage->set_cm($cm, $course); } - public function test_get_activity_name() { + public function test_get_activity_name(): void { // Setup fixture. $course = $this->getDataGenerator()->create_course(); $forum = $this->getDataGenerator()->create_module('forum', array('course'=>$course->id)); @@ -577,7 +577,7 @@ class moodle_page_test extends \advanced_testcase { $this->assertSame('forum', $this->testpage->activityname); } - public function test_user_is_editing_on() { + public function test_user_is_editing_on(): void { // We are relying on the fact that unit tests are always run by admin, to // ensure the user_allows_editing call returns true. @@ -592,7 +592,7 @@ class moodle_page_test extends \advanced_testcase { $this->assertTrue($this->testpage->user_is_editing()); } - public function test_user_is_editing_off() { + public function test_user_is_editing_off(): void { // We are relying on the fact that unit tests are always run by admin, to // ensure the user_allows_editing call returns true. @@ -607,7 +607,7 @@ class moodle_page_test extends \advanced_testcase { $this->assertFalse($this->testpage->user_is_editing()); } - public function test_default_editing_capabilities() { + public function test_default_editing_capabilities(): void { $this->testpage->set_context(\context_system::instance()); $this->setAdminUser(); @@ -615,7 +615,7 @@ class moodle_page_test extends \advanced_testcase { $this->assertEquals(array('moodle/site:manageblocks'), $this->testpage->all_editing_caps()); } - public function test_other_block_editing_cap() { + public function test_other_block_editing_cap(): void { $this->testpage->set_context(\context_system::instance()); $this->setAdminUser(); @@ -625,7 +625,7 @@ class moodle_page_test extends \advanced_testcase { $this->assertEquals(array('moodle/my:manageblocks'), $this->testpage->all_editing_caps()); } - public function test_other_editing_cap() { + public function test_other_editing_cap(): void { $this->testpage->set_context(\context_system::instance()); $this->setAdminUser(); @@ -637,7 +637,7 @@ class moodle_page_test extends \advanced_testcase { $this->assertEquals(array_values($expectedcaps), array_values($actualcaps)); } - public function test_other_editing_caps() { + public function test_other_editing_caps(): void { $this->testpage->set_context(\context_system::instance()); $this->setAdminUser(); @@ -652,7 +652,7 @@ class moodle_page_test extends \advanced_testcase { /** * Test getting a renderer. */ - public function test_get_renderer() { + public function test_get_renderer(): void { global $OUTPUT, $PAGE; $oldoutput = $OUTPUT; $oldpage = $PAGE; @@ -690,7 +690,7 @@ class moodle_page_test extends \advanced_testcase { * * This layout has special hacks in place in order to deliver a "maintenance" renderer. */ - public function test_get_renderer_maintenance() { + public function test_get_renderer_maintenance(): void { global $OUTPUT, $PAGE; $oldoutput = $OUTPUT; $oldpage = $PAGE; @@ -722,7 +722,7 @@ class moodle_page_test extends \advanced_testcase { $OUTPUT = $oldoutput; } - public function test_render_to_cli() { + public function test_render_to_cli(): void { global $OUTPUT; $footer = $OUTPUT->footer(); @@ -734,7 +734,7 @@ class moodle_page_test extends \advanced_testcase { * * @dataProvider get_user_theme_provider */ - public function test_cohort_get_user_theme($usertheme, $sitetheme, $cohortthemes, $expected) { + public function test_cohort_get_user_theme($usertheme, $sitetheme, $cohortthemes, $expected): void { global $DB, $PAGE, $USER; $this->resetAfterTest(); @@ -839,7 +839,7 @@ class moodle_page_test extends \advanced_testcase { * Tests user_can_edit_blocks() returns the expected response. * @covers ::user_can_edit_blocks() */ - public function test_user_can_edit_blocks() { + public function test_user_can_edit_blocks(): void { global $DB; $systemcontext = \context_system::instance(); @@ -864,7 +864,7 @@ class moodle_page_test extends \advanced_testcase { * Tests that calling force_lock_all_blocks() will cause user_can_edit_blocks() to return false, regardless of capabilities. * @covers ::force_lock_all_blocks() */ - public function test_force_lock_all_blocks() { + public function test_force_lock_all_blocks(): void { $this->testpage->set_context(\context_system::instance()); $this->setAdminUser(); diff --git a/lib/tests/moodle_url_test.php b/lib/tests/moodle_url_test.php index 2f1c1b6914c..9f2869428c5 100644 --- a/lib/tests/moodle_url_test.php +++ b/lib/tests/moodle_url_test.php @@ -30,7 +30,7 @@ final class moodle_url_test extends \advanced_testcase { /** * Test basic moodle_url construction. */ - public function test_moodle_url_constructor() { + public function test_moodle_url_constructor(): void { global $CFG; $url = new \moodle_url('/index.php'); @@ -59,7 +59,7 @@ final class moodle_url_test extends \advanced_testcase { /** * Tests \moodle_url::get_path(). */ - public function test_moodle_url_get_path() { + public function test_moodle_url_get_path(): void { $url = new \moodle_url('http://www.example.org:447/my/file/is/here.txt?really=1'); $this->assertSame('/my/file/is/here.txt', $url->get_path()); @@ -71,7 +71,7 @@ final class moodle_url_test extends \advanced_testcase { $this->assertSame('/pluginfile.php', $url->get_path(false)); } - public function test_moodle_url_round_trip() { + public function test_moodle_url_round_trip(): void { $strurl = 'http://moodle.org/course/view.php?id=5'; $url = new \moodle_url($strurl); $this->assertSame($strurl, $url->out(false)); @@ -84,7 +84,7 @@ final class moodle_url_test extends \advanced_testcase { /** * Test Moodle URL objects created with a param with empty value. */ - public function test_moodle_url_empty_param_values() { + public function test_moodle_url_empty_param_values(): void { $strurl = 'http://moodle.org/course/view.php?id=0'; $url = new \moodle_url($strurl, array('id' => 0)); $this->assertSame($strurl, $url->out(false)); @@ -109,7 +109,7 @@ final class moodle_url_test extends \advanced_testcase { /** * Test set good scheme on Moodle URL objects. */ - public function test_moodle_url_set_good_scheme() { + public function test_moodle_url_set_good_scheme(): void { $url = new \moodle_url('http://moodle.org/foo/bar'); $url->set_scheme('myscheme'); $this->assertSame('myscheme://moodle.org/foo/bar', $url->out()); @@ -118,13 +118,13 @@ final class moodle_url_test extends \advanced_testcase { /** * Test set bad scheme on Moodle URL objects. */ - public function test_moodle_url_set_bad_scheme() { + public function test_moodle_url_set_bad_scheme(): void { $url = new \moodle_url('http://moodle.org/foo/bar'); $this->expectException(\coding_exception::class); $url->set_scheme('not a valid $ scheme'); } - public function test_moodle_url_round_trip_array_params() { + public function test_moodle_url_round_trip_array_params(): void { $strurl = 'http://example.com/?a%5B1%5D=1&a%5B2%5D=2'; $url = new \moodle_url($strurl); $this->assertSame($strurl, $url->out(false)); @@ -138,7 +138,7 @@ final class moodle_url_test extends \advanced_testcase { $this->assertSame($strurl, $url->out(false)); } - public function test_compare_url() { + public function test_compare_url(): void { $url1 = new \moodle_url('index.php', array('var1' => 1, 'var2' => 2)); $url2 = new \moodle_url('index2.php', array('var1' => 1, 'var2' => 2, 'var3' => 3)); @@ -175,7 +175,7 @@ final class moodle_url_test extends \advanced_testcase { $this->assertTrue($url1->compare($url2, URL_MATCH_EXACT)); } - public function test_out_as_local_url() { + public function test_out_as_local_url(): void { global $CFG; // Test http url. $url1 = new \moodle_url('/lib/tests/weblib_test.php'); @@ -195,7 +195,7 @@ final class moodle_url_test extends \advanced_testcase { $this->assertSame('/', $url3->out_as_local_url()); } - public function test_out_as_local_url_error() { + public function test_out_as_local_url_error(): void { $url2 = new \moodle_url('http://www.google.com/lib/tests/weblib_test.php'); $this->expectException(\coding_exception::class); $url2->out_as_local_url(); @@ -204,7 +204,7 @@ final class moodle_url_test extends \advanced_testcase { /** * You should get error with modified url */ - public function test_modified_url_out_as_local_url_error() { + public function test_modified_url_out_as_local_url_error(): void { global $CFG; $modifiedurl = $CFG->wwwroot.'1'; @@ -216,13 +216,13 @@ final class moodle_url_test extends \advanced_testcase { /** * Try get local url from external https url and you should get error */ - public function test_https_out_as_local_url_error() { + public function test_https_out_as_local_url_error(): void { $url4 = new \moodle_url('https://www.google.com/lib/tests/weblib_test.php'); $this->expectException(\coding_exception::class); $url4->out_as_local_url(); } - public function test_moodle_url_get_scheme() { + public function test_moodle_url_get_scheme(): void { // Should return the scheme only. $url = new \moodle_url('http://www.example.org:447/my/file/is/here.txt?really=1'); $this->assertSame('http', $url->get_scheme()); @@ -236,13 +236,13 @@ final class moodle_url_test extends \advanced_testcase { $this->assertSame('', $url->get_scheme()); } - public function test_moodle_url_get_host() { + public function test_moodle_url_get_host(): void { // Should return the host part only. $url = new \moodle_url('http://www.example.org:447/my/file/is/here.txt?really=1'); $this->assertSame('www.example.org', $url->get_host()); } - public function test_moodle_url_get_port() { + public function test_moodle_url_get_port(): void { // Should return the port if one provided. $url = new \moodle_url('http://www.example.org:447/my/file/is/here.txt?really=1'); $this->assertSame(447, $url->get_port()); @@ -328,7 +328,7 @@ final class moodle_url_test extends \advanced_testcase { * @param array $args Args to be provided to make_pluginfile_url * @param string $expected The expected result */ - public function test_make_pluginfile_url($slashargs, $args, $expected) { + public function test_make_pluginfile_url($slashargs, $args, $expected): void { global $CFG; $this->resetAfterTest(); diff --git a/lib/tests/moodlelib_test.php b/lib/tests/moodlelib_test.php index a04c9e1faa8..fdf139beda0 100644 --- a/lib/tests/moodlelib_test.php +++ b/lib/tests/moodlelib_test.php @@ -55,7 +55,7 @@ class moodlelib_test extends \advanced_testcase { $stringmanager->reset_caches(true); } - public function test_cleanremoteaddr() { + public function test_cleanremoteaddr(): void { // IPv4. $this->assertNull(cleanremoteaddr('1023.121.234.1')); $this->assertSame('123.121.234.1', cleanremoteaddr('123.121.234.01 ')); @@ -74,7 +74,7 @@ class moodlelib_test extends \advanced_testcase { $this->assertSame('::ffff:c0a8:11', cleanremoteaddr('::ffff:192.168.1.1', true)); } - public function test_address_in_subnet() { + public function test_address_in_subnet(): void { // 1: xxx.xxx.xxx.xxx/nn or xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx/nnn (number of bits in net mask). $this->assertTrue(address_in_subnet('123.121.234.1', '123.121.234.1/32')); $this->assertFalse(address_in_subnet('123.121.23.1', '123.121.23.0/32')); @@ -159,7 +159,7 @@ class moodlelib_test extends \advanced_testcase { $this->assertFalse(address_in_subnet('123.123.123.123', '')); } - public function test_fix_utf8() { + public function test_fix_utf8(): void { // Make sure valid data including other types is not changed. $this->assertSame(null, fix_utf8(null)); $this->assertSame(1, fix_utf8(1)); @@ -182,7 +182,7 @@ class moodlelib_test extends \advanced_testcase { $this->assertSame('Hello ', fix_utf8('Hello ￿')); } - public function test_optional_param() { + public function test_optional_param(): void { global $CFG; $_POST['username'] = 'post_user'; @@ -204,7 +204,7 @@ class moodlelib_test extends \advanced_testcase { } } - public function test_optional_param_array() { + public function test_optional_param_array(): void { global $CFG; $_POST['username'] = array('a'=>'post_user'); @@ -237,7 +237,7 @@ class moodlelib_test extends \advanced_testcase { $this->assertDebuggingCalled(); } - public function test_required_param() { + public function test_required_param(): void { $_POST['username'] = 'post_user'; $_GET['username'] = 'get_user'; $this->assertSame('post_user', required_param('username', PARAM_RAW)); @@ -268,7 +268,7 @@ class moodlelib_test extends \advanced_testcase { } } - public function test_required_param_array() { + public function test_required_param_array(): void { global $CFG; $_POST['username'] = array('a'=>'post_user'); @@ -306,7 +306,7 @@ class moodlelib_test extends \advanced_testcase { * @covers \core\param * @covers \clean_param */ - public function test_clean_param() { + public function test_clean_param(): void { // Forbid objects and arrays. try { clean_param(array('x', 'y'), PARAM_RAW); @@ -336,7 +336,7 @@ class moodlelib_test extends \advanced_testcase { * @covers \core\param * @covers \clean_param */ - public function test_clean_param_array() { + public function test_clean_param_array(): void { $this->assertSame(array(), clean_param_array(null, PARAM_RAW)); $this->assertSame(array('a', 'b'), clean_param_array(array('a', 'b'), PARAM_RAW)); $this->assertSame(array('a', array('b')), clean_param_array(array('a', array('b')), PARAM_RAW, true)); @@ -363,7 +363,7 @@ class moodlelib_test extends \advanced_testcase { * @covers \core\param * @covers \clean_param */ - public function test_clean_param_raw() { + public function test_clean_param_raw(): void { $this->assertSame( '#()*#,9789\'".,<42897>assertSame('Frog toad', clean_param(" Frog toad \r\n ", PARAM_RAW_TRIMMED)); $this->assertSame('', clean_param(null, PARAM_RAW_TRIMMED)); } @@ -383,7 +383,7 @@ class moodlelib_test extends \advanced_testcase { * @covers \core\param * @covers \clean_param */ - public function test_clean_param_clean() { + public function test_clean_param_clean(): void { // PARAM_CLEAN is an ugly hack, do not use in new code (skodak), // instead use more specific type, or submit sothing that can be verified properly. $this->assertSame('xx', clean_param('xx'; $expected = ']]>'; @@ -138,7 +138,7 @@ class xmlformat_test extends \question_testcase { $this->assertEquals($input, $parsed->xpath('//div')[0]); } - public function test_xml_escape_code_that_looks_like_cdata_end_ok() { + public function test_xml_escape_code_that_looks_like_cdata_end_ok(): void { $exporter = new qformat_xml(); $input = "if (x[[0]]>a) print('hah');"; $expected = "a) print('hah');]]>"; @@ -149,7 +149,7 @@ class xmlformat_test extends \question_testcase { $this->assertEquals($input, $parsed->xpath('//div')[0]); } - public function test_write_hint_basic() { + public function test_write_hint_basic(): void { $q = $this->make_test_question(); $q->contextid = \context_system::instance()->id; $q->name = 'Short answer question'; @@ -179,7 +179,7 @@ class xmlformat_test extends \question_testcase { $this->assertDoesNotMatchRegularExpression('||', $xml); } - public function test_write_hint_with_parts() { + public function test_write_hint_with_parts(): void { $q = $this->make_test_question(); $q->contextid = \context_system::instance()->id; $q->name = 'Matching question'; @@ -219,7 +219,7 @@ class xmlformat_test extends \question_testcase { $this->assertDoesNotMatchRegularExpression('||', $xml); } - public function test_import_hints_no_parts() { + public function test_import_hints_no_parts(): void { $xml = << @@ -249,7 +249,7 @@ END; $this->assertFalse(isset($qo->hintshownumcorrect)); } - public function test_import_hints_with_parts() { + public function test_import_hints_with_parts(): void { $xml = << @@ -279,7 +279,7 @@ END; $this->assertEquals(array(0, 1), $qo->hintshownumcorrect); } - public function test_import_no_hints_no_error() { + public function test_import_no_hints_no_error(): void { $xml = << @@ -294,7 +294,7 @@ END; $this->assertFalse(isset($qo->hint)); } - public function test_import_description() { + public function test_import_description(): void { $xml = ' A description @@ -332,7 +332,7 @@ END; $this->assert(new question_check_specified_fields_expectation($expectedq), $q); } - public function test_export_description() { + public function test_export_description(): void { $qdata = new \stdClass(); $qdata->id = 123; $qdata->contextid = \context_system::instance()->id; @@ -372,7 +372,7 @@ END; $this->assert_same_xml($expectedxml, $xml); } - public function test_import_essay_20() { + public function test_import_essay_20(): void { $xml = ' An essay @@ -426,7 +426,7 @@ END; $this->assert(new question_check_specified_fields_expectation($expectedq), $q); } - public function test_import_essay_21() { + public function test_import_essay_21(): void { $xml = ' An essay @@ -491,7 +491,7 @@ END; $this->assert(new question_check_specified_fields_expectation($expectedq), $q); } - public function test_import_essay_311() { + public function test_import_essay_311(): void { $xml = ' An essay @@ -560,7 +560,7 @@ END; $this->assert(new question_check_specified_fields_expectation($expectedq), $q); } - public function test_export_essay() { + public function test_export_essay(): void { $qdata = new \stdClass(); $qdata->id = 123; $qdata->contextid = \context_system::instance()->id; @@ -630,7 +630,7 @@ END; $this->assert_same_xml($expectedxml, $xml); } - public function test_import_match_19() { + public function test_import_match_19(): void { $xml = ' Matching question @@ -732,7 +732,7 @@ END; $this->assert(new question_check_specified_fields_expectation($expectedq), $q); } - public function test_export_match() { + public function test_export_match(): void { $qdata = new \stdClass(); $qdata->id = 123; $qdata->contextid = \context_system::instance()->id; @@ -857,7 +857,7 @@ END; $this->assert_same_xml($expectedxml, $xml); } - public function test_import_multichoice_19() { + public function test_import_multichoice_19(): void { $xml = ' Multiple choice question @@ -965,7 +965,7 @@ END; $this->assert(new question_check_specified_fields_expectation($expectedq), $q); } - public function test_export_multichoice() { + public function test_export_multichoice(): void { $qdata = new \stdClass(); $qdata->id = 123; $qdata->contextid = \context_system::instance()->id; @@ -1074,7 +1074,7 @@ END; $this->assert_same_xml($expectedxml, $xml); } - public function test_import_numerical_19() { + public function test_import_numerical_19(): void { $xml = ' Numerical question @@ -1140,7 +1140,7 @@ END; $this->assert(new question_check_specified_fields_expectation($expectedq), $q); } - public function test_export_numerical() { + public function test_export_numerical(): void { question_bank::load_question_definition_classes('numerical'); $qdata = new \stdClass(); @@ -1215,7 +1215,7 @@ END; $this->assert_same_xml($expectedxml, $xml); } - public function test_import_shortanswer_19() { + public function test_import_shortanswer_19(): void { $xml = ' Short answer question @@ -1274,7 +1274,7 @@ END; $this->assert(new question_check_specified_fields_expectation($expectedq), $q); } - public function test_export_shortanswer() { + public function test_export_shortanswer(): void { $qdata = new \stdClass(); $qdata->id = 123; $qdata->contextid = \context_system::instance()->id; @@ -1346,7 +1346,7 @@ END; $this->assert_same_xml($expectedxml, $xml); } - public function test_import_truefalse_19() { + public function test_import_truefalse_19(): void { $xml = ' True false question @@ -1397,7 +1397,7 @@ END; $this->assert(new question_check_specified_fields_expectation($expectedq), $q); } - public function test_import_truefalse_with_idnumber() { + public function test_import_truefalse_with_idnumber(): void { $xml = ' True false question @@ -1450,7 +1450,7 @@ END; $this->assert(new question_check_specified_fields_expectation($expectedq), $q); } - public function test_export_truefalse() { + public function test_export_truefalse(): void { $qdata = new \stdClass(); $qdata->id = 12; $qdata->contextid = \context_system::instance()->id; @@ -1510,7 +1510,7 @@ END; $this->assert_same_xml($expectedxml, $xml); } - public function test_export_truefalse_with_idnumber() { + public function test_export_truefalse_with_idnumber(): void { $qdata = new \stdClass(); $qdata->id = 12; $qdata->contextid = \context_system::instance()->id; @@ -1570,7 +1570,7 @@ END; $this->assert_same_xml($expectedxml, $xml); } - public function test_import_multianswer() { + public function test_import_multianswer(): void { $xml = ' Simple multianswer @@ -1679,7 +1679,7 @@ END; $this->assert(new question_check_specified_fields_expectation($expectedqa), $q); } - public function test_export_multianswer() { + public function test_export_multianswer(): void { $qdata = \test_question_maker::get_question_data('multianswer', 'twosubq'); $qdata->contextid = \context_system::instance()->id; $exporter = new qformat_xml(); @@ -1711,7 +1711,7 @@ END; $this->assert_same_xml($expectedxml, $xml); } - public function test_export_multianswer_withdollars() { + public function test_export_multianswer_withdollars(): void { $qdata = \test_question_maker::get_question_data('multianswer', 'dollarsigns'); $qdata->contextid = \context_system::instance()->id; $exporter = new qformat_xml(); @@ -1737,7 +1737,7 @@ END; $this->assert_same_xml($expectedxml, $xml); } - public function test_import_files_as_draft() { + public function test_import_files_as_draft(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -1763,7 +1763,7 @@ END; $this->assertEquals(6, $file->size); } - public function test_import_truefalse_wih_files() { + public function test_import_truefalse_wih_files(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -1810,7 +1810,7 @@ END; $this->assertEquals(6, $file->size); } - public function test_create_dummy_question() { + public function test_create_dummy_question(): void { $testobject = new mock_qformat_xml(); $categoryname = 'name1'; diff --git a/question/tests/backup_test.php b/question/tests/backup_test.php index e7d954efd76..a0906b2b63a 100644 --- a/question/tests/backup_test.php +++ b/question/tests/backup_test.php @@ -95,7 +95,7 @@ class backup_test extends \advanced_testcase { /** * This function tests backup and restore of question tags and course level question tags. */ - public function test_backup_question_tags() { + public function test_backup_question_tags(): void { global $DB; $this->resetAfterTest(); @@ -217,7 +217,7 @@ class backup_test extends \advanced_testcase { /** * Test that the question author is retained when they are enrolled in to the course. */ - public function test_backup_question_author_retained_when_enrolled() { + public function test_backup_question_author_retained_when_enrolled(): void { global $DB, $USER, $CFG; $this->resetAfterTest(); $this->setAdminUser(); @@ -278,7 +278,7 @@ class backup_test extends \advanced_testcase { * Test that the question author is retained when they are not enrolled in to the course, * but we are restoring the backup at the same site. */ - public function test_backup_question_author_retained_when_not_enrolled() { + public function test_backup_question_author_retained_when_not_enrolled(): void { global $DB, $USER, $CFG; $this->resetAfterTest(); $this->setAdminUser(); @@ -335,7 +335,7 @@ class backup_test extends \advanced_testcase { * Test that the current user is set as a question author when we are restoring the backup * at the another site and the question author is not enrolled in to the course. */ - public function test_backup_question_author_reset() { + public function test_backup_question_author_reset(): void { global $DB, $USER, $CFG; $this->resetAfterTest(); $this->setAdminUser(); diff --git a/question/tests/calculated_question_summary_test.php b/question/tests/calculated_question_summary_test.php index b90dcf82366..00885c0cfbe 100644 --- a/question/tests/calculated_question_summary_test.php +++ b/question/tests/calculated_question_summary_test.php @@ -94,7 +94,7 @@ class calculated_question_summary_test extends \advanced_testcase { * * @dataProvider get_min_max_provider */ - public function test_get_min_max_of($subqstats, $expected) { + public function test_get_min_max_of($subqstats, $expected): void { $calculatedsummary = new calculated_question_summary(null, null, $subqstats); $res = $calculatedsummary->get_min_max_of('index'); $this->assertEquals($expected, $res); @@ -154,7 +154,7 @@ class calculated_question_summary_test extends \advanced_testcase { * * @dataProvider get_sd_min_max_provider */ - public function test_get_min_max_of_sd($subqstats, $expected) { + public function test_get_min_max_of_sd($subqstats, $expected): void { $calculatedsummary = new calculated_question_summary(null, null, $subqstats); $res = $calculatedsummary->get_min_max_of('sd'); $this->assertEquals($expected, $res); diff --git a/question/tests/event/events_test.php b/question/tests/event/events_test.php index 9e99976791c..371d4944082 100644 --- a/question/tests/event/events_test.php +++ b/question/tests/event/events_test.php @@ -50,7 +50,7 @@ class events_test extends \advanced_testcase { * There is no easy way to trigger this event using the API, so the unit test will simply * create and trigger the event and ensure data is returned as expected. */ - public function test_questions_imported() { + public function test_questions_imported(): void { $this->setAdminUser(); $course = $this->getDataGenerator()->create_course(); @@ -101,7 +101,7 @@ class events_test extends \advanced_testcase { * There is no easy way to trigger this event using the API, so the unit test will simply * create and trigger the event and ensure data is returned as expected. */ - public function test_questions_exported() { + public function test_questions_exported(): void { $this->setAdminUser(); $course = $this->getDataGenerator()->create_course(); @@ -150,7 +150,7 @@ class events_test extends \advanced_testcase { /** * Test the question created event. */ - public function test_question_created() { + public function test_question_created(): void { $this->setAdminUser(); $generator = $this->getDataGenerator()->get_plugin_generator('core_question'); @@ -176,7 +176,7 @@ class events_test extends \advanced_testcase { /** * Test the question deleted event. */ - public function test_question_deleted() { + public function test_question_deleted(): void { $this->setAdminUser(); $generator = $this->getDataGenerator()->get_plugin_generator('core_question'); @@ -203,7 +203,7 @@ class events_test extends \advanced_testcase { /** * Test the question updated event. */ - public function test_question_updated() { + public function test_question_updated(): void { global $CFG; require_once($CFG->dirroot . '/question/type/description/questiontype.php'); @@ -244,7 +244,7 @@ class events_test extends \advanced_testcase { /** * Test the question moved event. */ - public function test_question_moved() { + public function test_question_moved(): void { $this->setAdminUser(); $generator = $this->getDataGenerator()->get_plugin_generator('core_question'); @@ -278,7 +278,7 @@ class events_test extends \advanced_testcase { * There is no external API for viewing the question, so the unit test will simply * create and trigger the event and ensure data is returned as expected. */ - public function test_question_viewed() { + public function test_question_viewed(): void { $this->setAdminUser(); $generator = $this->getDataGenerator()->get_plugin_generator('core_question'); diff --git a/question/tests/externallib_test.php b/question/tests/externallib_test.php index c34ddc2d857..002c8734271 100644 --- a/question/tests/externallib_test.php +++ b/question/tests/externallib_test.php @@ -70,7 +70,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test update question flag */ - public function test_core_question_update_flag() { + public function test_core_question_update_flag(): void { $questiongenerator = $this->getDataGenerator()->get_plugin_generator('core_question'); @@ -257,7 +257,7 @@ class externallib_test extends externallib_advanced_testcase { * get_random_question_summaries should throw an invalid_parameter_exception if not * given an integer for the category id. */ - public function test_get_random_question_summaries_invalid_category_id_param() { + public function test_get_random_question_summaries_invalid_category_id_param(): void { $this->resetAfterTest(); $context = \context_system::instance(); @@ -269,7 +269,7 @@ class externallib_test extends externallib_advanced_testcase { * get_random_question_summaries should throw an invalid_parameter_exception if not * given a boolean for the $includesubcategories parameter. */ - public function test_get_random_question_summaries_invalid_includesubcategories_param() { + public function test_get_random_question_summaries_invalid_includesubcategories_param(): void { $this->resetAfterTest(); $context = \context_system::instance(); @@ -281,7 +281,7 @@ class externallib_test extends externallib_advanced_testcase { * get_random_question_summaries should throw an invalid_parameter_exception if not * given an array of integers for the tag ids parameter. */ - public function test_get_random_question_summaries_invalid_tagids_param() { + public function test_get_random_question_summaries_invalid_tagids_param(): void { $this->resetAfterTest(); $context = \context_system::instance(); @@ -293,7 +293,7 @@ class externallib_test extends externallib_advanced_testcase { * get_random_question_summaries should throw an invalid_parameter_exception if not * given a context. */ - public function test_get_random_question_summaries_invalid_context() { + public function test_get_random_question_summaries_invalid_context(): void { $this->resetAfterTest(); $this->expectException('\invalid_parameter_exception'); @@ -305,7 +305,7 @@ class externallib_test extends externallib_advanced_testcase { * if the given context is outside of the set of restricted contexts the user * is allowed to call external functions in. */ - public function test_get_random_question_summaries_restricted_context() { + public function test_get_random_question_summaries_restricted_context(): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); @@ -332,7 +332,7 @@ class externallib_test extends externallib_advanced_testcase { /** * get_random_question_summaries should return a question that is formatted correctly. */ - public function test_get_random_question_summaries_formats_returned_questions() { + public function test_get_random_question_summaries_formats_returned_questions(): void { $this->resetAfterTest(); list($category, $questions) = $this->create_category_and_questions(1); @@ -412,7 +412,7 @@ class externallib_test extends externallib_advanced_testcase { * get_random_question_summaries should throw an exception if the user doesn't * have the capability to use the questions in the requested category. */ - public function test_get_random_question_summaries_without_capability() { + public function test_get_random_question_summaries_without_capability(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator(); $user = $generator->create_user(); diff --git a/question/tests/generator_test.php b/question/tests/generator_test.php index 67de12f442e..34fea6a21c0 100644 --- a/question/tests/generator_test.php +++ b/question/tests/generator_test.php @@ -32,7 +32,7 @@ namespace core_question; * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class generator_test extends \advanced_testcase { - public function test_create() { + public function test_create(): void { global $DB; $this->resetAfterTest(); @@ -50,7 +50,7 @@ class generator_test extends \advanced_testcase { $this->assertSame(1, $cat->sortorder); } - public function test_idnumbers_in_categories_and_questions() { + public function test_idnumbers_in_categories_and_questions(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator()->get_plugin_generator('core_question'); list($category, $course, $qcat, $questions) = $generator->setup_course_and_questions(); diff --git a/question/tests/importexport_test.php b/question/tests/importexport_test.php index a3cd0e064d4..24a42dd008f 100644 --- a/question/tests/importexport_test.php +++ b/question/tests/importexport_test.php @@ -56,7 +56,7 @@ class testable_qformat extends qformat_default { * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class importexport_test extends \advanced_testcase { - public function test_assemble_category_path() { + public function test_assemble_category_path(): void { $format = new testable_qformat(); $pathsections = [ '$course$', @@ -70,7 +70,7 @@ class importexport_test extends \advanced_testcase { $format->assemble_category_path($pathsections)); } - public function test_split_category_path() { + public function test_split_category_path(): void { $format = new testable_qformat(); $path = '$course$/Tim\'s questions/Tricky things like // //// and so on/Category name ending in // / // and one that starts with one/Matematically Matematiskt (svenska)'; $this->assertEquals([ @@ -83,13 +83,13 @@ class importexport_test extends \advanced_testcase { ], $format->split_category_path($path)); } - public function test_split_category_path_cleans() { + public function test_split_category_path_cleans(): void { $format = new testable_qformat(); $path = 'Nasty thing'; $this->assertEquals(['Nasty thing'], $format->split_category_path($path)); } - public function test_clean_question_name() { + public function test_clean_question_name(): void { $format = new testable_qformat(); $name = 'Nice simple name'; @@ -121,7 +121,7 @@ class importexport_test extends \advanced_testcase { $this->assertEquals(shorten_text($name, 1), $format->clean_question_name($name)); } - public function test_create_default_question_name() { + public function test_create_default_question_name(): void { $format = new testable_qformat(); $text = 'Nice simple name'; diff --git a/question/tests/least_used_variant_strategy_test.php b/question/tests/least_used_variant_strategy_test.php index 4a76d11e65f..c30349c62f1 100644 --- a/question/tests/least_used_variant_strategy_test.php +++ b/question/tests/least_used_variant_strategy_test.php @@ -35,7 +35,7 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php'); */ class least_used_variant_strategy_test extends \advanced_testcase { - public function test_question_with_one_variant_always_picks_that() { + public function test_question_with_one_variant_always_picks_that(): void { $question = \test_question_maker::make_question('shortanswer'); $quba = question_engine::make_questions_usage_by_activity('test', \context_system::instance()); $quba->set_preferred_behaviour('deferredfeedback'); @@ -45,7 +45,7 @@ class least_used_variant_strategy_test extends \advanced_testcase { $this->assertEquals(1, $quba->get_variant($slot)); } - public function test_synchronised_question_should_use_the_same_dataset() { + public function test_synchronised_question_should_use_the_same_dataset(): void { // Actually, we cheat here. We use the same question twice, not two different synchronised questions. $question = \test_question_maker::make_question('calculated'); $quba = question_engine::make_questions_usage_by_activity('test', \context_system::instance()); @@ -57,7 +57,7 @@ class least_used_variant_strategy_test extends \advanced_testcase { $this->assertEquals($quba->get_variant($slot1), $quba->get_variant($slot2)); } - public function test_second_attempt_uses_other_dataset() { + public function test_second_attempt_uses_other_dataset(): void { global $DB; $this->resetAfterTest(); $generator = $this->getDataGenerator()->get_plugin_generator('core_question'); diff --git a/question/tests/local/bank/context_to_string_translator_test.php b/question/tests/local/bank/context_to_string_translator_test.php index d761861d752..2e2a0f90c66 100644 --- a/question/tests/local/bank/context_to_string_translator_test.php +++ b/question/tests/local/bank/context_to_string_translator_test.php @@ -33,7 +33,7 @@ use context_user; */ class context_to_string_translator_test extends \advanced_testcase { - public function test_context_to_string_translator_test_good_case() { + public function test_context_to_string_translator_test_good_case(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator(); @@ -66,7 +66,7 @@ class context_to_string_translator_test extends \advanced_testcase { $this->assertEquals($systemcontext->id, $translator->string_to_context('system')); } - public function test_context_to_string_translator_throws_exception_with_bad_context() { + public function test_context_to_string_translator_throws_exception_with_bad_context(): void { global $USER; $this->resetAfterTest(); $this->setAdminUser(); diff --git a/question/tests/privacy/provider_test.php b/question/tests/privacy/provider_test.php index 78dd9360b61..059a8e29d17 100644 --- a/question/tests/privacy/provider_test.php +++ b/question/tests/privacy/provider_test.php @@ -72,7 +72,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { * Test that calling export_question_usage on a usage belonging to a * different user does not export any data. */ - public function test_export_question_usage_no_usage() { + public function test_export_question_usage_no_usage(): void { $this->resetAfterTest(); $quba = $this->prepare_question_attempt(); @@ -106,7 +106,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { * Test that calling export_question_usage on a usage belonging to a * different user but ignoring the user match */ - public function test_export_question_usage_with_usage() { + public function test_export_question_usage_with_usage(): void { $this->resetAfterTest(); $quba = $this->prepare_question_attempt(); @@ -184,7 +184,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test that questions owned by a user are exported and never deleted. */ - public function test_question_owned_is_handled() { + public function test_question_owned_is_handled(): void { global $DB; $this->resetAfterTest(); @@ -281,7 +281,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Deleting questions should only unset their created and modified user. */ - public function test_question_delete_data_for_user_anonymised() { + public function test_question_delete_data_for_user_anonymised(): void { global $DB; $this->resetAfterTest(true); @@ -362,7 +362,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Deleting questions should only unset their created and modified user for all questions in a context. */ - public function test_question_delete_data_for_all_users_in_context_anonymised() { + public function test_question_delete_data_for_all_users_in_context_anonymised(): void { global $DB; $this->resetAfterTest(true); @@ -435,7 +435,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::get_users_in_context(). */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { $this->resetAfterTest(); $questiongenerator = $this->getDataGenerator()->get_plugin_generator('core_question'); @@ -472,7 +472,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::delete_data_for_users(). */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { global $DB; $this->resetAfterTest(); diff --git a/question/tests/question_bank_column_test.php b/question/tests/question_bank_column_test.php index ea8bfce8445..e659a76d12a 100644 --- a/question/tests/question_bank_column_test.php +++ b/question/tests/question_bank_column_test.php @@ -39,7 +39,7 @@ class question_bank_column_test extends \advanced_testcase { * Test function display_header multiple sorts with no custom tooltips. * */ - public function test_column_header_multi_sort_no_tooltips() { + public function test_column_header_multi_sort_no_tooltips(): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); $questionbank = new view( @@ -73,7 +73,7 @@ class question_bank_column_test extends \advanced_testcase { * Test function display_header multiple sorts with custom tooltips. * */ - public function test_column_header_multi_sort_with_tooltips() { + public function test_column_header_multi_sort_with_tooltips(): void { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course(); $questionbank = new view( diff --git a/question/tests/version_test.php b/question/tests/version_test.php index 516e7290a19..ca98a234ac6 100644 --- a/question/tests/version_test.php +++ b/question/tests/version_test.php @@ -76,7 +76,7 @@ class version_test extends \advanced_testcase { * * @covers ::load_question */ - public function test_make_question_create_version_and_bank_entry() { + public function test_make_question_create_version_and_bank_entry(): void { global $DB; $qcategory = $this->qgenerator->create_question_category(['contextid' => $this->context->id]); @@ -111,7 +111,7 @@ class version_test extends \advanced_testcase { * @covers ::load_question * @covers ::question_delete_question */ - public function test_delete_question_delete_versions() { + public function test_delete_question_delete_versions(): void { global $DB; $qcategory = $this->qgenerator->create_question_category(['contextid' => $this->context->id]); @@ -164,7 +164,7 @@ class version_test extends \advanced_testcase { * @covers ::quiz_add_quiz_question * @covers ::question_delete_question */ - public function test_delete_question_in_use() { + public function test_delete_question_in_use(): void { global $DB; $qcategory = $this->qgenerator->create_question_category(['contextid' => $this->context->id]); @@ -197,7 +197,7 @@ class version_test extends \advanced_testcase { * @covers ::load_question * @covers ::quiz_add_quiz_question */ - public function test_move_category_with_questions() { + public function test_move_category_with_questions(): void { global $DB; $qcategory = $this->qgenerator->create_question_category(['contextid' => $this->context->id]); @@ -232,7 +232,7 @@ class version_test extends \advanced_testcase { * * @covers ::load_question */ - public function test_id_number_in_bank_entry() { + public function test_id_number_in_bank_entry(): void { global $DB; $qcategory = $this->qgenerator->create_question_category(['contextid' => $this->context->id]); @@ -271,7 +271,7 @@ class version_test extends \advanced_testcase { * * @covers ::get_all_versions_of_question */ - public function test_get_all_versions_of_question() { + public function test_get_all_versions_of_question(): void { $qcategory = $this->qgenerator->create_question_category(['contextid' => $this->context->id]); $question = $this->qgenerator->create_question('shortanswer', null, [ @@ -300,7 +300,7 @@ class version_test extends \advanced_testcase { * * @covers ::get_all_versions_of_questions */ - public function test_get_all_versions_of_questions() { + public function test_get_all_versions_of_questions(): void { global $DB; $questionversions = []; @@ -337,7 +337,7 @@ class version_test extends \advanced_testcase { * @covers \core_question\output\question_version_info::populate_latest_versions() * @return void */ - public function test_populate_definition_latestversions() { + public function test_populate_definition_latestversions(): void { $qcategory = $this->qgenerator->create_question_category(['contextid' => $this->context->id]); $question1 = $this->qgenerator->create_question('shortanswer', null, ['category' => $qcategory->id]); $question2 = $this->qgenerator->create_question('shortanswer', null, ['category' => $qcategory->id]); diff --git a/question/type/calculated/tests/formula_validation_test.php b/question/type/calculated/tests/formula_validation_test.php index a0bbc88460b..23ac14058c7 100644 --- a/question/type/calculated/tests/formula_validation_test.php +++ b/question/type/calculated/tests/formula_validation_test.php @@ -34,7 +34,7 @@ class formula_validation_test extends \basic_testcase { $this->assertNotEquals('', $actual); } - public function test_simple_equations_ok() { + public function test_simple_equations_ok(): void { $this->assertFalse(qtype_calculated_find_formula_errors(1)); $this->assertFalse(qtype_calculated_find_formula_errors('1 + 1')); $this->assertFalse(qtype_calculated_find_formula_errors('{x} + {y}')); @@ -42,14 +42,14 @@ class formula_validation_test extends \basic_testcase { $this->assertFalse(qtype_calculated_find_formula_errors('{x}*({y}+1)')); } - public function test_simple_equations_errors() { + public function test_simple_equations_errors(): void { $this->assert_nonempty_string(qtype_calculated_find_formula_errors('{a{b}}')); $this->assert_nonempty_string(qtype_calculated_find_formula_errors('{a{b}}')); $this->assert_nonempty_string(qtype_calculated_find_formula_errors('{a}({b})')); $this->assert_nonempty_string(qtype_calculated_find_formula_errors('2({b})')); } - public function test_safe_functions_ok() { + public function test_safe_functions_ok(): void { $this->assertFalse(qtype_calculated_find_formula_errors('abs(-1)')); $this->assertFalse(qtype_calculated_find_formula_errors('tan(pi())')); $this->assertFalse(qtype_calculated_find_formula_errors('log(10)')); @@ -60,7 +60,7 @@ class formula_validation_test extends \basic_testcase { $this->assertFalse(qtype_calculated_find_formula_errors('max(1.0, 1.0, 2, 3)')); } - public function test_php_comments_blocked() { + public function test_php_comments_blocked(): void { $this->assert_nonempty_string(qtype_calculated_find_formula_errors('# No need for this.')); $this->assert_nonempty_string(qtype_calculated_find_formula_errors('/* Also blocked. */')); $this->assert_nonempty_string(qtype_calculated_find_formula_errors('1 + 1 /* Blocked too. */')); @@ -69,7 +69,7 @@ class formula_validation_test extends \basic_testcase { $this->assert_nonempty_string(qtype_calculated_find_formula_errors('/*{a*///{x}}')); } - public function test_dangerous_functions_blocked() { + public function test_dangerous_functions_blocked(): void { $this->assert_nonempty_string(qtype_calculated_find_formula_errors('eval(1)')); $this->assert_nonempty_string(qtype_calculated_find_formula_errors('system(1)')); $this->assert_nonempty_string(qtype_calculated_find_formula_errors('base64_decode(1)')); @@ -83,7 +83,7 @@ class formula_validation_test extends \basic_testcase { $this->assert_nonempty_string(qtype_calculated_find_formula_errors('?>assert_nonempty_string(qtype_calculated_find_formula_errors('abs(-1, 1)')); $this->assert_nonempty_string(qtype_calculated_find_formula_errors('abs()')); $this->assert_nonempty_string(qtype_calculated_find_formula_errors('pi(1)')); @@ -94,7 +94,7 @@ class formula_validation_test extends \basic_testcase { $this->assert_nonempty_string(qtype_calculated_find_formula_errors('max(1.0)')); } - public function test_validation_of_formulas_in_text_ok() { + public function test_validation_of_formulas_in_text_ok(): void { $this->assertFalse(qtype_calculated_find_formula_errors_in_text( '

Look no equations.

')); $this->assertFalse(qtype_calculated_find_formula_errors_in_text( @@ -104,7 +104,7 @@ class formula_validation_test extends \basic_testcase { '

Here is a more complex one: {=sin(2*pi()*{theta})}.

')); } - public function test_validation_of_formulas_in_text_bad_function() { + public function test_validation_of_formulas_in_text_bad_function(): void { $this->assert_nonempty_string(qtype_calculated_find_formula_errors_in_text( '

This is an equation: {=eval(1)}.

')); $this->assert_nonempty_string(qtype_calculated_find_formula_errors_in_text( diff --git a/question/type/calculated/tests/question_type_test.php b/question/type/calculated/tests/question_type_test.php index d1504b535d7..271c60792b1 100644 --- a/question/type/calculated/tests/question_type_test.php +++ b/question/type/calculated/tests/question_type_test.php @@ -50,15 +50,15 @@ class question_type_test extends \advanced_testcase { $this->qtype = null; } - public function test_name() { + public function test_name(): void { $this->assertEquals($this->qtype->name(), 'calculated'); } - public function test_can_analyse_responses() { + public function test_can_analyse_responses(): void { $this->assertTrue($this->qtype->can_analyse_responses()); } - public function test_get_random_guess_score() { + public function test_get_random_guess_score(): void { $q = \test_question_maker::get_question_data('calculated'); $q->options->answers[17]->fraction = 0.1; $this->assertEquals(0.1, $this->qtype->get_random_guess_score($q)); @@ -150,7 +150,7 @@ class question_type_test extends \advanced_testcase { return get_string('answerwithtolerance', 'qtype_calculated', $a); } - public function test_get_possible_responses() { + public function test_get_possible_responses(): void { $q = \test_question_maker::get_question_data('calculated'); $this->assertEquals(array( @@ -165,7 +165,7 @@ class question_type_test extends \advanced_testcase { ), $this->qtype->get_possible_responses($q)); } - public function test_get_possible_responses_no_star() { + public function test_get_possible_responses_no_star(): void { $q = \test_question_maker::get_question_data('calculated'); unset($q->options->answers[17]); @@ -182,7 +182,7 @@ class question_type_test extends \advanced_testcase { ), $this->qtype->get_possible_responses($q)); } - public function test_get_short_question_name() { + public function test_get_short_question_name(): void { $this->resetAfterTest(); // Enable multilang filter to on content and heading. @@ -203,17 +203,17 @@ class question_type_test extends \advanced_testcase { $this->assertEquals("Lorem ipsum", $this->qtype->get_short_question_name($shortquestionname, 20)); } - public function test_placehodler_regex() { + public function test_placehodler_regex(): void { preg_match_all(qtype_calculated::PLACEHODLER_REGEX, '= {={a} + {b}}', $matches); $this->assertEquals([['{a}', '{b}'], ['a', 'b']], $matches); } - public function test_formulas_in_text_regex() { + public function test_formulas_in_text_regex(): void { preg_match_all(qtype_calculated::FORMULAS_IN_TEXT_REGEX, '= {={a} + {b}}', $matches); $this->assertEquals([['{={a} + {b}}'], ['{a} + {b}']], $matches); } - public function test_find_dataset_names() { + public function test_find_dataset_names(): void { $this->assertEquals([], $this->qtype->find_dataset_names('Frog.')); $this->assertEquals(['a' => 'a', 'b' => 'b'], @@ -236,7 +236,7 @@ class question_type_test extends \advanced_testcase { ')); } - public function test_calculate_answer_nan_inf() { + public function test_calculate_answer_nan_inf(): void { $answer = qtype_calculated_calculate_answer('acos(1.1)', [], 0.1, 1, 2, 2); $this->assertIsObject($answer); $this->assertNan($answer->answer); diff --git a/question/type/calculated/tests/upgrade_old_attempt_data_test.php b/question/type/calculated/tests/upgrade_old_attempt_data_test.php index 7a0a3586e2e..f3b4230f56f 100644 --- a/question/type/calculated/tests/upgrade_old_attempt_data_test.php +++ b/question/type/calculated/tests/upgrade_old_attempt_data_test.php @@ -30,7 +30,7 @@ require_once($CFG->dirroot . '/question/engine/upgrade/tests/helper.php'); * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base { - public function test_calculated_adaptive_qsession97() { + public function test_calculated_adaptive_qsession97(): void { $quiz = (object) array( 'id' => '4', 'course' => '2', @@ -228,7 +228,7 @@ Remember to type a unit.', $this->compare_qas($expectedqa, $qa); } - public function test_calculated_adaptive_qsession100() { + public function test_calculated_adaptive_qsession100(): void { $quiz = (object) array( 'id' => '4', 'course' => '2', @@ -469,7 +469,7 @@ Remember to type a unit.', $this->compare_qas($expectedqa, $qa); } - public function test_calculated_adaptive_qsession103() { + public function test_calculated_adaptive_qsession103(): void { $quiz = (object) array( 'id' => '4', 'course' => '2', diff --git a/question/type/calculated/tests/variablesubstituter_test.php b/question/type/calculated/tests/variablesubstituter_test.php index 453f8b490ef..298b1d4648a 100644 --- a/question/type/calculated/tests/variablesubstituter_test.php +++ b/question/type/calculated/tests/variablesubstituter_test.php @@ -32,34 +32,34 @@ require_once($CFG->dirroot . '/question/type/calculated/questiontype.php'); * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class variablesubstituter_test extends \advanced_testcase { - public function test_simple_expression() { + public function test_simple_expression(): void { $vs = new qtype_calculated_variable_substituter(array('a' => 1, 'b' => 2), '.'); $this->assertEquals(3, $vs->calculate('{a} + {b}')); } - public function test_simple_expression_negatives() { + public function test_simple_expression_negatives(): void { $vs = new qtype_calculated_variable_substituter(array('a' => -1, 'b' => -2), '.'); $this->assertEquals(1, $vs->calculate('{a}-{b}')); } - public function test_cannot_use_nonnumbers() { + public function test_cannot_use_nonnumbers(): void { $this->expectException(\moodle_exception::class); $vs = new qtype_calculated_variable_substituter(array('a' => 'frog', 'b' => -2), '.'); } - public function test_invalid_expression() { + public function test_invalid_expression(): void { $vs = new qtype_calculated_variable_substituter(array('a' => 1, 'b' => 2), '.'); $this->expectException(\moodle_exception::class); $vs->calculate('{a} + {b}?'); } - public function test_tricky_invalid_expression() { + public function test_tricky_invalid_expression(): void { $vs = new qtype_calculated_variable_substituter(array('a' => 1, 'b' => 2), '.'); $this->expectException(\moodle_exception::class); $vs->calculate('{a}{b}'); // Have to make sure this does not just evaluate to 12. } - public function test_division_by_zero_expression() { + public function test_division_by_zero_expression(): void { if (intval(PHP_VERSION) < 7) { $this->markTestSkipped('Division by zero triggers a PHP warning before PHP 7.'); @@ -70,42 +70,42 @@ class variablesubstituter_test extends \advanced_testcase { $vs->calculate('{a} / {b}'); } - public function test_replace_expressions_in_text_simple_var() { + public function test_replace_expressions_in_text_simple_var(): void { $vs = new qtype_calculated_variable_substituter(array('a' => 1, 'b' => 2), '.'); $this->assertEquals('1 + 2', $vs->replace_expressions_in_text('{a} + {b}')); } - public function test_replace_expressions_in_confusing_text() { + public function test_replace_expressions_in_confusing_text(): void { $vs = new qtype_calculated_variable_substituter(array('a' => 1, 'b' => 2), '.'); $this->assertEquals("(1) 1\n(2) 2", $vs->replace_expressions_in_text("(1) {a}\n(2) {b}")); } - public function test_replace_expressions_in_text_formula() { + public function test_replace_expressions_in_text_formula(): void { $vs = new qtype_calculated_variable_substituter(array('a' => 1, 'b' => 2), '.'); $this->assertEquals('= 3', $vs->replace_expressions_in_text('= {={a} + {b}}')); } - public function test_expression_has_unmapped_placeholder() { + public function test_expression_has_unmapped_placeholder(): void { $this->expectException('moodle_exception'); $this->expectExceptionMessage(get_string('illegalformulasyntax', 'qtype_calculated', '{c}')); $vs = new qtype_calculated_variable_substituter(array('a' => 1, 'b' => 2), '.'); $vs->calculate('{c} - {a} + {b}'); } - public function test_replace_expressions_in_text_negative() { + public function test_replace_expressions_in_text_negative(): void { $vs = new qtype_calculated_variable_substituter(array('a' => -1, 'b' => 2), '.'); $this->assertEquals('temperatures -1 and 2', $vs->replace_expressions_in_text('temperatures {a} and {b}')); } - public function test_replace_expressions_in_text_commas_for_decimals() { + public function test_replace_expressions_in_text_commas_for_decimals(): void { $vs = new qtype_calculated_variable_substituter( array('phi' => 1.61803399, 'pi' => 3.14159265), ','); $this->assertEquals('phi (1,61803399) + pi (3,14159265) = 4,75962664', $vs->replace_expressions_in_text('phi ({phi}) + pi ({pi}) = {={phi} + {pi}}')); } - public function test_format_float_dot() { + public function test_format_float_dot(): void { $vs = new qtype_calculated_variable_substituter(array('a' => -1, 'b' => 2), '.'); $this->assertSame('0.12345', $vs->format_float(0.12345)); @@ -117,7 +117,7 @@ class variablesubstituter_test extends \advanced_testcase { $this->assertSame('0.0012', $vs->format_float(0.0012345, 4, 1)); } - public function test_format_float_comma() { + public function test_format_float_comma(): void { $vs = new qtype_calculated_variable_substituter(array('a' => -1, 'b' => 2), ','); $this->assertSame('0,12345', $vs->format_float(0.12345)); @@ -129,7 +129,7 @@ class variablesubstituter_test extends \advanced_testcase { $this->assertSame('0,0012', $vs->format_float(0.0012345, 4, 1)); } - public function test_format_float_nan_inf() { + public function test_format_float_nan_inf(): void { $vs = new qtype_calculated_variable_substituter([ ], '.'); $this->assertSame('NAN', $vs->format_float(NAN)); diff --git a/question/type/calculated/tests/walkthrough_test.php b/question/type/calculated/tests/walkthrough_test.php index 5ddb1c7592a..804ab6ba09b 100644 --- a/question/type/calculated/tests/walkthrough_test.php +++ b/question/type/calculated/tests/walkthrough_test.php @@ -33,7 +33,7 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php'); * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class walkthrough_test extends \qbehaviour_walkthrough_test_base { - public function test_interactive() { + public function test_interactive(): void { // Create a gapselect question. $q = \test_question_maker::make_question('calculated'); diff --git a/question/type/calculatedmulti/tests/question_test.php b/question/type/calculatedmulti/tests/question_test.php index 0c7a572181a..e5ddd29195a 100644 --- a/question/type/calculatedmulti/tests/question_test.php +++ b/question/type/calculatedmulti/tests/question_test.php @@ -34,7 +34,7 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php'); * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class question_test extends \advanced_testcase { - public function test_is_complete_response() { + public function test_is_complete_response(): void { $question = \test_question_maker::make_question('calculated'); $this->assertFalse($question->is_complete_response(array())); @@ -43,7 +43,7 @@ class question_test extends \advanced_testcase { $this->assertFalse($question->is_complete_response(array('answer' => 'test'))); } - public function test_is_gradable_response() { + public function test_is_gradable_response(): void { $question = \test_question_maker::make_question('calculated'); $this->assertFalse($question->is_gradable_response(array())); @@ -52,7 +52,7 @@ class question_test extends \advanced_testcase { $this->assertTrue($question->is_gradable_response(array('answer' => 'test'))); } - public function test_grading() { + public function test_grading(): void { $question = \test_question_maker::make_question('calculated'); $question->start_attempt(new question_attempt_step(), 1); $values = $question->vs->get_values(); @@ -63,7 +63,7 @@ class question_test extends \advanced_testcase { $question->grade_response(array('answer' => $values['a'] + $values['b']))); } - public function test_get_correct_response() { + public function test_get_correct_response(): void { $question = \test_question_maker::make_question('calculated'); $question->start_attempt(new question_attempt_step(), 1); $values = $question->vs->get_values(); @@ -72,7 +72,7 @@ class question_test extends \advanced_testcase { $question->get_correct_response()); } - public function test_get_question_summary() { + public function test_get_question_summary(): void { $question = \test_question_maker::make_question('calculated'); $question->start_attempt(new question_attempt_step(), 1); $values = $question->vs->get_values(); @@ -81,7 +81,7 @@ class question_test extends \advanced_testcase { $this->assertEquals('What is ' . $values['a'] . ' + ' . $values['b'] . '?', $qsummary); } - public function test_summarise_response() { + public function test_summarise_response(): void { $question = \test_question_maker::make_question('calculated'); $question->start_attempt(new question_attempt_step(), 1); $values = $question->vs->get_values(); @@ -89,7 +89,7 @@ class question_test extends \advanced_testcase { $this->assertEquals('3.1', $question->summarise_response(array('answer' => '3.1'))); } - public function test_classify_response() { + public function test_classify_response(): void { $question = \test_question_maker::make_question('calculated'); $question->start_attempt(new question_attempt_step(), 1); $values = $question->vs->get_values(); diff --git a/question/type/calculatedmulti/tests/upgrade_old_attempt_data_test.php b/question/type/calculatedmulti/tests/upgrade_old_attempt_data_test.php index 7f3fefa487a..4a830c3a316 100644 --- a/question/type/calculatedmulti/tests/upgrade_old_attempt_data_test.php +++ b/question/type/calculatedmulti/tests/upgrade_old_attempt_data_test.php @@ -30,7 +30,7 @@ require_once($CFG->dirroot . '/question/engine/upgrade/tests/helper.php'); * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base { - public function test_calculatedmulti_adaptive_qsession96() { + public function test_calculatedmulti_adaptive_qsession96(): void { $quiz = (object) array( 'id' => '4', 'course' => '2', @@ -250,7 +250,7 @@ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base $this->compare_qas($expectedqa, $qa); } - public function test_calculatedmulti_adaptive_qsession99() { + public function test_calculatedmulti_adaptive_qsession99(): void { $quiz = (object) array( 'id' => '4', 'course' => '2', @@ -490,7 +490,7 @@ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base $this->compare_qas($expectedqa, $qa); } - public function test_calculatedmulti_adaptive_qsession102() { + public function test_calculatedmulti_adaptive_qsession102(): void { $quiz = (object) array( 'id' => '4', 'course' => '2', diff --git a/question/type/calculatedmulti/tests/walkthrough_test.php b/question/type/calculatedmulti/tests/walkthrough_test.php index dc997d40355..cb9c2430f26 100644 --- a/question/type/calculatedmulti/tests/walkthrough_test.php +++ b/question/type/calculatedmulti/tests/walkthrough_test.php @@ -34,7 +34,7 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php'); */ class walkthrough_test extends \qbehaviour_walkthrough_test_base { - public function test_interactive_single_response() { + public function test_interactive_single_response(): void { // Create a gapselect question. $q = \test_question_maker::make_question('calculatedmulti', 'singleresponse'); @@ -98,7 +98,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->get_no_hint_visible_expectation()); } - public function test_interactive_multi_response() { + public function test_interactive_multi_response(): void { // Create a gapselect question. $q = \test_question_maker::make_question('calculatedmulti', 'multiresponse'); diff --git a/question/type/calculatedsimple/tests/question_test.php b/question/type/calculatedsimple/tests/question_test.php index f6f529ad1d8..d3ab48a3744 100644 --- a/question/type/calculatedsimple/tests/question_test.php +++ b/question/type/calculatedsimple/tests/question_test.php @@ -34,7 +34,7 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php'); * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class question_test extends \advanced_testcase { - public function test_is_complete_response() { + public function test_is_complete_response(): void { $question = \test_question_maker::make_question('calculatedsimple'); $this->assertFalse($question->is_complete_response(array())); @@ -43,7 +43,7 @@ class question_test extends \advanced_testcase { $this->assertFalse($question->is_complete_response(array('answer' => 'test'))); } - public function test_is_gradable_response() { + public function test_is_gradable_response(): void { $question = \test_question_maker::make_question('calculatedsimple'); $this->assertFalse($question->is_gradable_response(array())); @@ -52,7 +52,7 @@ class question_test extends \advanced_testcase { $this->assertTrue($question->is_gradable_response(array('answer' => 'test'))); } - public function test_grading() { + public function test_grading(): void { $question = \test_question_maker::make_question('calculatedsimple'); $question->start_attempt(new question_attempt_step(), 1); $values = $question->vs->get_values(); @@ -63,7 +63,7 @@ class question_test extends \advanced_testcase { $question->grade_response(array('answer' => $values['a'] + $values['b']))); } - public function test_get_correct_response() { + public function test_get_correct_response(): void { $question = \test_question_maker::make_question('calculatedsimple'); $question->start_attempt(new question_attempt_step(), 1); $values = $question->vs->get_values(); @@ -72,7 +72,7 @@ class question_test extends \advanced_testcase { $question->get_correct_response()); } - public function test_get_question_summary() { + public function test_get_question_summary(): void { $question = \test_question_maker::make_question('calculatedsimple'); $question->start_attempt(new question_attempt_step(), 1); $values = $question->vs->get_values(); @@ -81,7 +81,7 @@ class question_test extends \advanced_testcase { $this->assertEquals('What is ' . $values['a'] . ' + ' . $values['b'] . '?', $qsummary); } - public function test_summarise_response() { + public function test_summarise_response(): void { $question = \test_question_maker::make_question('calculatedsimple'); $question->start_attempt(new question_attempt_step(), 1); $values = $question->vs->get_values(); @@ -89,7 +89,7 @@ class question_test extends \advanced_testcase { $this->assertEquals('3.1', $question->summarise_response(array('answer' => '3.1'))); } - public function test_classify_response() { + public function test_classify_response(): void { $question = \test_question_maker::make_question('calculatedsimple'); $question->start_attempt(new question_attempt_step(), 1); $values = $question->vs->get_values(); diff --git a/question/type/calculatedsimple/tests/question_type_test.php b/question/type/calculatedsimple/tests/question_type_test.php index aef8180b1fe..3f2db4e008f 100644 --- a/question/type/calculatedsimple/tests/question_type_test.php +++ b/question/type/calculatedsimple/tests/question_type_test.php @@ -55,16 +55,16 @@ class question_type_test extends \advanced_testcase { $this->qtype = null; } - public function test_name() { + public function test_name(): void { $this->assertEquals($this->qtype->name(), 'calculatedsimple'); } - public function test_can_analyse_responses() { + public function test_can_analyse_responses(): void { $this->assertTrue($this->qtype->can_analyse_responses()); } - public function test_question_saving_sumwithvariants() { + public function test_question_saving_sumwithvariants(): void { $this->resetAfterTest(true); $this->setAdminUser(); diff --git a/question/type/calculatedsimple/tests/upgrade_old_attempt_data_test.php b/question/type/calculatedsimple/tests/upgrade_old_attempt_data_test.php index c89293d4047..fec0c738722 100644 --- a/question/type/calculatedsimple/tests/upgrade_old_attempt_data_test.php +++ b/question/type/calculatedsimple/tests/upgrade_old_attempt_data_test.php @@ -30,7 +30,7 @@ require_once($CFG->dirroot . '/question/engine/upgrade/tests/helper.php'); * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base { - public function test_calculatedsimple_adaptive_qsession95() { + public function test_calculatedsimple_adaptive_qsession95(): void { $quiz = (object) array( 'id' => '4', 'course' => '2', @@ -215,7 +215,7 @@ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base $this->compare_qas($expectedqa, $qa); } - public function test_calculatedsimple_adaptive_qsession98() { + public function test_calculatedsimple_adaptive_qsession98(): void { $quiz = (object) array( 'id' => '4', 'course' => '2', @@ -440,7 +440,7 @@ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base $this->compare_qas($expectedqa, $qa); } - public function test_calculatedsimple_adaptive_qsession101() { + public function test_calculatedsimple_adaptive_qsession101(): void { $quiz = (object) array( 'id' => '4', 'course' => '2', diff --git a/question/type/calculatedsimple/tests/walkthrough_test.php b/question/type/calculatedsimple/tests/walkthrough_test.php index 5917bcaa8b6..f430b3fbcf2 100644 --- a/question/type/calculatedsimple/tests/walkthrough_test.php +++ b/question/type/calculatedsimple/tests/walkthrough_test.php @@ -33,7 +33,7 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php'); * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class walkthrough_test extends \qbehaviour_walkthrough_test_base { - public function test_interactive() { + public function test_interactive(): void { // Create a gapselect question. $q = \test_question_maker::make_question('calculatedsimple'); diff --git a/question/type/ddimageortext/tests/form/edit_form_test.php b/question/type/ddimageortext/tests/form/edit_form_test.php index 920ee99012d..3e5b18c2107 100644 --- a/question/type/ddimageortext/tests/form/edit_form_test.php +++ b/question/type/ddimageortext/tests/form/edit_form_test.php @@ -68,7 +68,7 @@ class edit_form_test extends \advanced_testcase { /** * Test the form correctly validates the HTML allowed in items. */ - public function test_item_validation() { + public function test_item_validation(): void { list($form, $category) = $this->get_form(); $submitteddata = [ diff --git a/question/type/ddimageortext/tests/privacy/provider_test.php b/question/type/ddimageortext/tests/privacy/provider_test.php index e19bdfaeb5e..15325d7e195 100644 --- a/question/type/ddimageortext/tests/privacy/provider_test.php +++ b/question/type/ddimageortext/tests/privacy/provider_test.php @@ -44,13 +44,13 @@ require_once($CFG->dirroot . '/question/type/ddimageortext/classes/privacy/provi class provider_test extends \core_privacy\tests\provider_testcase { // Include the privacy helper which has assertions on it. - public function test_get_metadata() { + public function test_get_metadata(): void { $collection = new \core_privacy\local\metadata\collection('qtype_ddimageortext'); $actual = \qtype_ddimageortext\privacy\provider::get_metadata($collection); $this->assertEquals($collection, $actual); } - public function test_export_user_preferences_no_pref() { + public function test_export_user_preferences_no_pref(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); @@ -67,7 +67,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { * @param string $value The value stored in the database * @param string $expected The expected transformed value */ - public function test_export_user_preferences($name, $value, $expected) { + public function test_export_user_preferences($name, $value, $expected): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); set_user_preference("qtype_ddimageortext_$name", $value, $user); diff --git a/question/type/ddimageortext/tests/question_test.php b/question/type/ddimageortext/tests/question_test.php index bf7f521ad07..6dd3cb69147 100644 --- a/question/type/ddimageortext/tests/question_test.php +++ b/question/type/ddimageortext/tests/question_test.php @@ -37,7 +37,7 @@ require_once($CFG->dirroot . '/question/type/ddimageortext/tests/helper.php'); */ class question_test extends \basic_testcase { - public function test_get_question_summary() { + public function test_get_question_summary(): void { $dd = \test_question_maker::make_question('ddimageortext'); $this->assertEquals('The quick brown fox jumped over the lazy dog.; '. '[[Drop zone 1]] -> {1. quick / 2. fox}; '. @@ -47,7 +47,7 @@ class question_test extends \basic_testcase { $dd->get_question_summary()); } - public function test_get_question_summary_maths() { + public function test_get_question_summary_maths(): void { $dd = \test_question_maker::make_question('ddimageortext', 'maths'); $this->assertEquals('Fill in the operators to make this equation work: '. '7 [[1]] 11 [[2]] 13 [[1]] 17 [[2]] 19 = 3; '. @@ -58,7 +58,7 @@ class question_test extends \basic_testcase { $dd->get_question_summary()); } - public function test_summarise_response() { + public function test_summarise_response(): void { $dd = \test_question_maker::make_question('ddimageortext'); $dd->shufflechoices = false; $dd->start_attempt(new question_attempt_step(), 1); @@ -70,7 +70,7 @@ class question_test extends \basic_testcase { $dd->summarise_response(array('p1' => '1', 'p2' => '1', 'p3' => '1', 'p4' => '1'))); } - public function test_summarise_response_maths() { + public function test_summarise_response_maths(): void { $dd = \test_question_maker::make_question('ddimageortext', 'maths'); $dd->shufflechoices = false; $dd->start_attempt(new question_attempt_step(), 1); @@ -82,17 +82,17 @@ class question_test extends \basic_testcase { $dd->summarise_response(array('p1' => '1', 'p2' => '2', 'p3' => '1', 'p4' => '2'))); } - public function test_get_random_guess_score() { + public function test_get_random_guess_score(): void { $dd = \test_question_maker::make_question('ddimageortext'); $this->assertEquals(0.5, $dd->get_random_guess_score()); } - public function test_get_random_guess_score_maths() { + public function test_get_random_guess_score_maths(): void { $dd = \test_question_maker::make_question('ddimageortext', 'maths'); $this->assertEquals(0.5, $dd->get_random_guess_score()); } - public function test_get_random_guess_score_broken_question() { + public function test_get_random_guess_score_broken_question(): void { // Before MDL-76298 was fixed, it was possible to create a question with // no drop zones, and that caused a fatal division by zero error. Because // people might have questions like that in their database, we need to @@ -103,7 +103,7 @@ class question_test extends \basic_testcase { $this->assertNull($dd->get_random_guess_score()); } - public function test_get_right_choice_for() { + public function test_get_right_choice_for(): void { $dd = \test_question_maker::make_question('ddimageortext'); $dd->shufflechoices = false; $dd->start_attempt(new question_attempt_step(), 1); @@ -112,7 +112,7 @@ class question_test extends \basic_testcase { $this->assertEquals(2, $dd->get_right_choice_for(2)); } - public function test_get_right_choice_for_maths() { + public function test_get_right_choice_for_maths(): void { $dd = \test_question_maker::make_question('ddimageortext', 'maths'); $dd->shufflechoices = false; $dd->start_attempt(new question_attempt_step(), 1); @@ -123,7 +123,7 @@ class question_test extends \basic_testcase { $this->assertEquals(2, $dd->get_right_choice_for(4)); } - public function test_clear_wrong_from_response() { + public function test_clear_wrong_from_response(): void { $dd = \test_question_maker::make_question('ddimageortext', 'maths'); $dd->shufflechoices = false; $dd->start_attempt(new question_attempt_step(), 1); @@ -133,7 +133,7 @@ class question_test extends \basic_testcase { $dd->clear_wrong_from_response($initialresponse)); } - public function test_get_num_parts_right() { + public function test_get_num_parts_right(): void { $dd = \test_question_maker::make_question('ddimageortext'); $dd->shufflechoices = false; $dd->start_attempt(new question_attempt_step(), 1); @@ -144,7 +144,7 @@ class question_test extends \basic_testcase { $dd->get_num_parts_right(array('p1' => '1', 'p2' => '2', 'p3' => '1', 'p4' => '2'))); } - public function test_get_num_parts_right_maths() { + public function test_get_num_parts_right_maths(): void { $dd = \test_question_maker::make_question('ddimageortext', 'maths'); $dd->shufflechoices = false; $dd->start_attempt(new question_attempt_step(), 1); @@ -154,7 +154,7 @@ class question_test extends \basic_testcase { 'p1' => '1', 'p2' => '1', 'p3' => '1', 'p4' => '1'))); } - public function test_get_expected_data() { + public function test_get_expected_data(): void { $dd = \test_question_maker::make_question('ddimageortext'); $dd->start_attempt(new question_attempt_step(), 1); @@ -164,7 +164,7 @@ class question_test extends \basic_testcase { ); } - public function test_get_correct_response() { + public function test_get_correct_response(): void { $dd = \test_question_maker::make_question('ddimageortext'); $dd->shufflechoices = false; $dd->start_attempt(new question_attempt_step(), 1); @@ -173,7 +173,7 @@ class question_test extends \basic_testcase { $dd->get_correct_response()); } - public function test_get_correct_response_maths() { + public function test_get_correct_response_maths(): void { $dd = \test_question_maker::make_question('ddimageortext', 'maths'); $dd->shufflechoices = false; $dd->start_attempt(new question_attempt_step(), 1); @@ -182,7 +182,7 @@ class question_test extends \basic_testcase { $dd->get_correct_response()); } - public function test_is_same_response() { + public function test_is_same_response(): void { $dd = \test_question_maker::make_question('ddimageortext'); $dd->start_attempt(new question_attempt_step(), 1); @@ -206,7 +206,7 @@ class question_test extends \basic_testcase { array('p1' => '1', 'p2' => '2', 'p3' => '3', 'p4' => '4'), array('p1' => '1', 'p2' => '2', 'p3' => '2', 'p4' => '4'))); } - public function test_is_complete_response() { + public function test_is_complete_response(): void { $dd = \test_question_maker::make_question('ddimageortext'); $dd->start_attempt(new question_attempt_step(), 1); @@ -218,7 +218,7 @@ class question_test extends \basic_testcase { array('p1' => '1', 'p2' => '1', 'p3' => '1', 'p4' => '1'))); } - public function test_is_gradable_response() { + public function test_is_gradable_response(): void { $dd = \test_question_maker::make_question('ddimageortext'); $dd->start_attempt(new question_attempt_step(), 1); @@ -232,7 +232,7 @@ class question_test extends \basic_testcase { array('p1' => '1', 'p2' => '1', 'p3' => '1'))); } - public function test_grading() { + public function test_grading(): void { $dd = \test_question_maker::make_question('ddimageortext'); $dd->shufflechoices = false; $dd->start_attempt(new question_attempt_step(), 1); @@ -245,7 +245,7 @@ class question_test extends \basic_testcase { $dd->grade_response(array('p1' => '2', 'p2' => '1', 'p3' => '2', 'p4' => '1'))); } - public function test_grading_maths() { + public function test_grading_maths(): void { $dd = \test_question_maker::make_question('ddimageortext', 'maths'); $dd->shufflechoices = false; $dd->start_attempt(new question_attempt_step(), 1); @@ -258,7 +258,7 @@ class question_test extends \basic_testcase { $dd->grade_response(array('p1' => '', 'p2' => '1', 'p3' => '2', 'p4' => '1'))); } - public function test_classify_response() { + public function test_classify_response(): void { $dd = \test_question_maker::make_question('ddimageortext'); $dd->shufflechoices = false; $dd->start_attempt(new question_attempt_step(), 1); @@ -277,7 +277,7 @@ class question_test extends \basic_testcase { ), $dd->classify_response(array('p1' => '', 'p2' => '1', 'p3' => '2', 'p4' => '2'))); } - public function test_summarise_response_choice_deleted() { + public function test_summarise_response_choice_deleted(): void { /** @var qtype_ddtoimage_question_base $dd */ $dd = \test_question_maker::make_question('ddimageortext'); $dd->shufflechoices = false; diff --git a/question/type/ddimageortext/tests/question_type_test.php b/question/type/ddimageortext/tests/question_type_test.php index 8b39c2673ed..116352f01da 100644 --- a/question/type/ddimageortext/tests/question_type_test.php +++ b/question/type/ddimageortext/tests/question_type_test.php @@ -44,11 +44,11 @@ class question_type_test extends \basic_testcase { $this->qtype = null; } - public function test_name() { + public function test_name(): void { $this->assertEquals($this->qtype->name(), 'ddimageortext'); } - public function test_can_analyse_responses() { + public function test_can_analyse_responses(): void { $this->assertTrue($this->qtype->can_analyse_responses()); } } diff --git a/question/type/ddimageortext/tests/walkthrough_test.php b/question/type/ddimageortext/tests/walkthrough_test.php index 79373ed08d2..e3ebfb8d306 100644 --- a/question/type/ddimageortext/tests/walkthrough_test.php +++ b/question/type/ddimageortext/tests/walkthrough_test.php @@ -52,7 +52,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { return new \question_contains_tag_with_attributes('div', $expectedattrs); } - public function test_interactive_behaviour() { + public function test_interactive_behaviour(): void { // Create a drag-and-drop question. $dd = \test_question_maker::make_question('ddimageortext'); @@ -189,7 +189,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->check_current_mark(8); } - public function test_deferred_feedback() { + public function test_deferred_feedback(): void { // Create a drag-and-drop question. $dd = \test_question_maker::make_question('ddimageortext'); @@ -292,7 +292,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->check_current_mark(9); } - public function test_deferred_feedback_unanswered() { + public function test_deferred_feedback_unanswered(): void { // Create a drag-and-drop question. $dd = \test_question_maker::make_question('ddimageortext'); @@ -355,7 +355,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->get_contains_drag_image_home_expectation(4, 2, 2)); } - public function test_deferred_feedback_partial_answer() { + public function test_deferred_feedback_partial_answer(): void { // Create a drag-and-drop question. $dd = \test_question_maker::make_question('ddimageortext'); @@ -417,7 +417,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->get_contains_partcorrect_expectation()); } - public function test_interactive_grading() { + public function test_interactive_grading(): void { // Create a drag-and-drop question. $dd = \test_question_maker::make_question('ddimageortext'); @@ -597,7 +597,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->get_contains_standard_correct_combined_feedback_expectation()); } - public function test_interactive_correct_no_submit() { + public function test_interactive_correct_no_submit(): void { // Create a drag-and-drop question. $dd = \test_question_maker::make_question('ddimageortext'); @@ -657,7 +657,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->check_current_mark(3); } - public function test_interactive_partial_no_submit() { + public function test_interactive_partial_no_submit(): void { // Create a drag-and-drop question. $dd = \test_question_maker::make_question('ddimageortext'); @@ -719,7 +719,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->check_current_mark(1); } - public function test_interactive_no_right_clears() { + public function test_interactive_no_right_clears(): void { // Create a drag-and-drop question. $dd = \test_question_maker::make_question('ddimageortext'); @@ -796,7 +796,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->get_no_hint_visible_expectation()); } - public function test_display_of_right_answer_when_shuffled() { + public function test_display_of_right_answer_when_shuffled(): void { // Create a drag-and-drop question. $dd = \test_question_maker::make_question('ddimageortext'); @@ -853,7 +853,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->check_current_mark(3); } - public function test_mixed_lang_rendering() { + public function test_mixed_lang_rendering(): void { // Create a mixe drag-and-drop question. $dd = \test_question_maker::make_question('ddimageortext', 'mixedlang'); diff --git a/question/type/ddmarker/tests/form/edit_form_test.php b/question/type/ddmarker/tests/form/edit_form_test.php index b71f1fbaad6..0343df6f337 100644 --- a/question/type/ddmarker/tests/form/edit_form_test.php +++ b/question/type/ddmarker/tests/form/edit_form_test.php @@ -68,7 +68,7 @@ class edit_form_test extends \advanced_testcase { /** * Test the form correctly validates the HTML allowed in items. */ - public function test_item_validation() { + public function test_item_validation(): void { list($form, $category) = $this->get_form(); $submitteddata = [ diff --git a/question/type/ddmarker/tests/privacy/provider_test.php b/question/type/ddmarker/tests/privacy/provider_test.php index fcf69c7d15e..32af89f80ca 100644 --- a/question/type/ddmarker/tests/privacy/provider_test.php +++ b/question/type/ddmarker/tests/privacy/provider_test.php @@ -44,13 +44,13 @@ require_once($CFG->dirroot . '/question/type/ddmarker/classes/privacy/provider.p class provider_test extends \core_privacy\tests\provider_testcase { // Include the privacy helper which has assertions on it. - public function test_get_metadata() { + public function test_get_metadata(): void { $collection = new \core_privacy\local\metadata\collection('qtype_ddmarker'); $actual = \qtype_ddmarker\privacy\provider::get_metadata($collection); $this->assertEquals($collection, $actual); } - public function test_export_user_preferences_no_pref() { + public function test_export_user_preferences_no_pref(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); @@ -67,7 +67,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { * @param string $value The value stored in the database * @param string $expected The expected transformed value */ - public function test_export_user_preferences($name, $value, $expected) { + public function test_export_user_preferences($name, $value, $expected): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); set_user_preference("qtype_ddmarker_$name", $value, $user); diff --git a/question/type/ddmarker/tests/question_test.php b/question/type/ddmarker/tests/question_test.php index 2aba2d663de..cba7f05d999 100644 --- a/question/type/ddmarker/tests/question_test.php +++ b/question/type/ddmarker/tests/question_test.php @@ -36,7 +36,7 @@ require_once($CFG->dirroot . '/question/type/ddmarker/tests/helper.php'); */ class question_test extends \basic_testcase { - public function test_get_question_summary() { + public function test_get_question_summary(): void { $dd = \test_question_maker::make_question('ddmarker'); $this->assertEquals('The quick brown fox jumped over the lazy dog.; '. '[[Drop zone 1]] -> {quick / fox / lazy}; '. @@ -45,7 +45,7 @@ class question_test extends \basic_testcase { $dd->get_question_summary()); } - public function test_get_question_summary_maths() { + public function test_get_question_summary_maths(): void { $dd = \test_question_maker::make_question('ddmarker', 'maths'); $this->assertEquals('Fill in the operators to make this equation work:; '. '[[Drop zone 1]] -> {+ / - / * / /}; '. @@ -54,7 +54,7 @@ class question_test extends \basic_testcase { $dd->get_question_summary()); } - public function test_summarise_response() { + public function test_summarise_response(): void { $dd = \test_question_maker::make_question('ddmarker'); $dd->shufflechoices = false; $dd->start_attempt(new question_attempt_step(), 1); @@ -67,7 +67,7 @@ class question_test extends \basic_testcase { 'c3' => '50,150'))); } - public function test_summarise_response_maths() { + public function test_summarise_response_maths(): void { $dd = \test_question_maker::make_question('ddmarker', 'maths'); $dd->shufflechoices = false; $dd->start_attempt(new question_attempt_step(), 1); @@ -80,17 +80,17 @@ class question_test extends \basic_testcase { 'c3' => ''))); } - public function test_get_random_guess_score() { + public function test_get_random_guess_score(): void { $dd = \test_question_maker::make_question('ddmarker'); $this->assertEquals(null, $dd->get_random_guess_score()); } - public function test_get_random_guess_score_maths() { + public function test_get_random_guess_score_maths(): void { $dd = \test_question_maker::make_question('ddmarker', 'maths'); $this->assertEquals(null, $dd->get_random_guess_score()); } - public function test_get_right_choice_for() { + public function test_get_right_choice_for(): void { $dd = \test_question_maker::make_question('ddmarker'); $dd->shufflechoices = false; $dd->start_attempt(new question_attempt_step(), 1); @@ -100,7 +100,7 @@ class question_test extends \basic_testcase { $this->assertEquals(3, $dd->get_right_choice_for(3)); } - public function test_get_right_choice_for_maths() { + public function test_get_right_choice_for_maths(): void { $dd = \test_question_maker::make_question('ddmarker', 'maths'); $dd->shufflechoices = false; $dd->start_attempt(new question_attempt_step(), 1); @@ -110,7 +110,7 @@ class question_test extends \basic_testcase { $this->assertEquals(1, $dd->get_right_choice_for(3)); } - public function test_clear_wrong_from_response() { + public function test_clear_wrong_from_response(): void { $dd = \test_question_maker::make_question('ddmarker', 'maths'); $dd->shufflechoices = false; $dd->start_attempt(new question_attempt_step(), 1); @@ -120,7 +120,7 @@ class question_test extends \basic_testcase { $dd->clear_wrong_from_response($initialresponse)); } - public function test_get_num_parts_right() { + public function test_get_num_parts_right(): void { $dd = \test_question_maker::make_question('ddmarker'); $dd->shufflechoices = false; $dd->start_attempt(new question_attempt_step(), 1); @@ -139,7 +139,7 @@ class question_test extends \basic_testcase { $this->assertEquals(array(1, 3), $dd->get_num_parts_right($response3)); } - public function test_get_num_parts_right_maths() { + public function test_get_num_parts_right_maths(): void { $dd = \test_question_maker::make_question('ddmarker', 'maths'); $dd->shufflechoices = false; $dd->start_attempt(new question_attempt_step(), 1); @@ -149,7 +149,7 @@ class question_test extends \basic_testcase { 'c1' => '50,50;150,50;50,150', 'c2' => '', 'c3' => ''))); } - public function test_get_expected_data() { + public function test_get_expected_data(): void { $dd = \test_question_maker::make_question('ddmarker'); $dd->start_attempt(new question_attempt_step(), 1); @@ -159,7 +159,7 @@ class question_test extends \basic_testcase { ); } - public function test_get_correct_response() { + public function test_get_correct_response(): void { $dd = \test_question_maker::make_question('ddmarker'); $dd->shufflechoices = false; $dd->start_attempt(new question_attempt_step(), 1); @@ -168,7 +168,7 @@ class question_test extends \basic_testcase { $dd->get_correct_response()); } - public function test_get_correct_response_maths() { + public function test_get_correct_response_maths(): void { $dd = \test_question_maker::make_question('ddmarker', 'maths'); $dd->shufflechoices = false; $dd->start_attempt(new question_attempt_step(), 1); @@ -176,7 +176,7 @@ class question_test extends \basic_testcase { $this->assertEquals(array('c1' => '50,50;150,50;50,150'), $dd->get_correct_response()); } - public function test_is_same_response() { + public function test_is_same_response(): void { $dd = \test_question_maker::make_question('ddmarker'); $dd->start_attempt(new question_attempt_step(), 1); @@ -224,7 +224,7 @@ class question_test extends \basic_testcase { array('c1' => '200,200;100,100', 'c2' => '', 'c3' => '300,300;100,100', 'c4' => '400,400'))); } - public function test_is_complete_response() { + public function test_is_complete_response(): void { $dd = \test_question_maker::make_question('ddmarker'); $dd->start_attempt(new question_attempt_step(), 1); @@ -236,7 +236,7 @@ class question_test extends \basic_testcase { array('c1' => '300,300', 'c2' => '300,300', 'c3' => '300,300'))); } - public function test_is_gradable_response() { + public function test_is_gradable_response(): void { $dd = \test_question_maker::make_question('ddmarker'); $dd->start_attempt(new question_attempt_step(), 1); @@ -250,7 +250,7 @@ class question_test extends \basic_testcase { array('c1' => '300,300', 'c2' => '300,300', 'c3' => '300,300'))); } - public function test_grading() { + public function test_grading(): void { $dd = \test_question_maker::make_question('ddmarker'); $dd->shufflechoices = false; $dd->start_attempt(new question_attempt_step(), 1); @@ -263,7 +263,7 @@ class question_test extends \basic_testcase { $dd->grade_response(array('c1' => '150,50', 'c2' => '50,50', 'c3' => '100,50'))); } - public function test_grading_maths() { + public function test_grading_maths(): void { $dd = \test_question_maker::make_question('ddmarker', 'maths'); $dd->shufflechoices = false; $dd->start_attempt(new question_attempt_step(), 1); @@ -281,7 +281,7 @@ class question_test extends \basic_testcase { 'c3' => '100,50'))); } - public function test_classify_response() { + public function test_classify_response(): void { $dd = \test_question_maker::make_question('ddmarker'); $dd->shufflechoices = false; $dd->start_attempt(new question_attempt_step(), 1); diff --git a/question/type/ddmarker/tests/question_type_test.php b/question/type/ddmarker/tests/question_type_test.php index 03acc328f28..eac56135479 100644 --- a/question/type/ddmarker/tests/question_type_test.php +++ b/question/type/ddmarker/tests/question_type_test.php @@ -44,15 +44,15 @@ class question_type_test extends \advanced_testcase { $this->qtype = null; } - public function test_name() { + public function test_name(): void { $this->assertEquals($this->qtype->name(), 'ddmarker'); } - public function test_can_analyse_responses() { + public function test_can_analyse_responses(): void { $this->assertTrue($this->qtype->can_analyse_responses()); } - public function test_save_question() { + public function test_save_question(): void { $this->resetAfterTest(); $this->setAdminUser(); $questiongenerator = $this->getDataGenerator()->get_plugin_generator('core_question'); diff --git a/question/type/ddmarker/tests/shapes_test.php b/question/type/ddmarker/tests/shapes_test.php index 5a43282c8ab..d6988180c5a 100644 --- a/question/type/ddmarker/tests/shapes_test.php +++ b/question/type/ddmarker/tests/shapes_test.php @@ -34,26 +34,26 @@ require_once($CFG->dirroot . '/question/type/ddmarker/shapes.php'); */ class shapes_test extends \basic_testcase { - public function test_polygon_valdiation_test_ok() { + public function test_polygon_valdiation_test_ok(): void { $shape = new qtype_ddmarker_shape_polygon('10, 10; 20, 10; 20, 20; 10, 20'); $this->assertFalse($shape->get_coords_interpreter_error()); // No errors. } - public function test_polygon_valdiation_test_only_two_points() { + public function test_polygon_valdiation_test_only_two_points(): void { $shape = new qtype_ddmarker_shape_polygon('10, 10; 20, 10'); $this->assertEquals(get_string('formerror_polygonmusthaveatleastthreepoints', 'qtype_ddmarker', array('shape' => 'polygon', 'coordsstring' => get_string('shape_polygon_coords', 'qtype_ddmarker'))), $shape->get_coords_interpreter_error()); } - public function test_polygon_valdiation_test_invalid_point() { + public function test_polygon_valdiation_test_invalid_point(): void { $shape = new qtype_ddmarker_shape_polygon('10, 10; 20, ; 20, 20; 10, 20'); $this->assertEquals(get_string('formerror_onlyusewholepositivenumbers', 'qtype_ddmarker', array('shape' => 'polygon', 'coordsstring' => get_string('shape_polygon_coords', 'qtype_ddmarker'))), $shape->get_coords_interpreter_error()); } - public function test_polygon_valdiation_test_repeated_point() { + public function test_polygon_valdiation_test_repeated_point(): void { $shape = new qtype_ddmarker_shape_polygon('70,220;90,200;95,150;120,150;140,200;150,230;'. '150,230;150,240;120,240;110,240;90,240'); $this->assertEquals(get_string('formerror_repeatedpoint', 'qtype_ddmarker', @@ -61,7 +61,7 @@ class shapes_test extends \basic_testcase { $shape->get_coords_interpreter_error()); } - public function test_polygon_hit_test() { + public function test_polygon_hit_test(): void { $shape = new qtype_ddmarker_shape_polygon('10, 10; 20, 10; 20, 20; 10, 20'); $this->assertTrue($shape->is_point_in_shape(array(15, 15))); $this->assertFalse($shape->is_point_in_shape(array(5, 5))); @@ -112,12 +112,12 @@ class shapes_test extends \basic_testcase { $this->assertTrue($shape->is_point_in_shape(array(25, 10))); } - public function test_circle_valdiation_test() { + public function test_circle_valdiation_test(): void { $shape = new qtype_ddmarker_shape_circle('10, 10; 10'); $this->assertFalse($shape->get_coords_interpreter_error()); // No errors. } - public function test_circle_hit_test() { + public function test_circle_hit_test(): void { $shape = new qtype_ddmarker_shape_circle('10, 10; 10'); $this->assertTrue($shape->is_point_in_shape(array(19, 10))); $this->assertTrue($shape->is_point_in_shape(array(20, 10))); @@ -139,12 +139,12 @@ class shapes_test extends \basic_testcase { $this->assertTrue($shape->is_point_in_shape(array(16, 18))); } - public function test_rectangle_valdiation_test() { + public function test_rectangle_valdiation_test(): void { $shape = new qtype_ddmarker_shape_rectangle('1000, 4000; 500, 400'); $this->assertFalse($shape->get_coords_interpreter_error()); // No errors. } - public function test_rectangle_hit_test() { + public function test_rectangle_hit_test(): void { $shape = new qtype_ddmarker_shape_rectangle('1000, 4000; 500, 400'); $this->assertFalse($shape->is_point_in_shape(array(999, 4200))); $this->assertTrue($shape->is_point_in_shape(array(1000, 4200))); diff --git a/question/type/ddmarker/tests/walkthrough_test.php b/question/type/ddmarker/tests/walkthrough_test.php index 652f0f1f636..feb0a5881c0 100644 --- a/question/type/ddmarker/tests/walkthrough_test.php +++ b/question/type/ddmarker/tests/walkthrough_test.php @@ -78,7 +78,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { return new \question_contains_tag_with_attributes('input', $expectedattributes); } - public function test_interactive_behaviour() { + public function test_interactive_behaviour(): void { // Create a drag-and-drop question. $dd = \test_question_maker::make_question('ddmarker'); @@ -187,7 +187,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->check_current_mark(8); } - public function test_deferred_feedback() { + public function test_deferred_feedback(): void { // Create a drag-and-drop question. $dd = \test_question_maker::make_question('ddmarker'); @@ -266,7 +266,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->check_current_mark(8); } - public function test_deferred_feedback_unanswered() { + public function test_deferred_feedback_unanswered(): void { // Create a drag-and-drop question. $dd = \test_question_maker::make_question('ddmarker'); @@ -316,7 +316,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->get_contains_draggable_marker_home_expectation(3, false)); } - public function test_deferred_feedback_partial_answer() { + public function test_deferred_feedback_partial_answer(): void { // Create a drag-and-drop question. $dd = \test_question_maker::make_question('ddmarker'); @@ -364,7 +364,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->get_contains_partcorrect_expectation()); } - public function test_interactive_grading() { + public function test_interactive_grading(): void { // Create a drag-and-drop question. $dd = \test_question_maker::make_question('ddmarker'); @@ -508,7 +508,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->get_contains_standard_correct_combined_feedback_expectation()); } - public function test_interactive_correct_no_submit() { + public function test_interactive_correct_no_submit(): void { // Create a drag-and-drop question. $dd = \test_question_maker::make_question('ddmarker'); @@ -561,7 +561,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->check_current_mark(3); } - public function test_interactive_partial_no_submit() { + public function test_interactive_partial_no_submit(): void { // Create a drag-and-drop question. $dd = \test_question_maker::make_question('ddmarker'); @@ -616,7 +616,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->check_current_mark(2); } - public function test_interactive_no_right_clears() { + public function test_interactive_no_right_clears(): void { // Create a drag-and-drop question. $dd = \test_question_maker::make_question('ddmarker'); @@ -682,7 +682,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->get_no_hint_visible_expectation()); } - public function test_display_of_right_answer_when_shuffled() { + public function test_display_of_right_answer_when_shuffled(): void { // Create a drag-and-drop question. $dd = \test_question_maker::make_question('ddmarker'); @@ -727,7 +727,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->check_current_mark(3); } - public function test_interactive_state_which_incorrect() { + public function test_interactive_state_which_incorrect(): void { // Create a drag-and-drop question. $dd = \test_question_maker::make_question('ddmarker'); diff --git a/question/type/ddwtos/tests/form/edit_form_test.php b/question/type/ddwtos/tests/form/edit_form_test.php index d0ca6bead78..4627790b824 100644 --- a/question/type/ddwtos/tests/form/edit_form_test.php +++ b/question/type/ddwtos/tests/form/edit_form_test.php @@ -68,7 +68,7 @@ class edit_form_test extends \advanced_testcase { /** * Test the form shows the right number of groups of choices. */ - public function test_number_of_choice_groups() { + public function test_number_of_choice_groups(): void { list($form) = $this->get_form('qtype_ddwtos_edit_form'); // Use reflection to get the protected property we need. $property = new \ReflectionProperty('qtype_ddwtos_edit_form', '_form'); @@ -81,7 +81,7 @@ class edit_form_test extends \advanced_testcase { /** * Test the form correctly validates the HTML allowed in choices. */ - public function test_choices_validation() { + public function test_choices_validation(): void { list($form, $category) = $this->get_form('qtype_ddwtos_edit_form'); $submitteddata = [ diff --git a/question/type/ddwtos/tests/privacy/provider_test.php b/question/type/ddwtos/tests/privacy/provider_test.php index 711b7c1744c..16f785d7e7b 100644 --- a/question/type/ddwtos/tests/privacy/provider_test.php +++ b/question/type/ddwtos/tests/privacy/provider_test.php @@ -44,13 +44,13 @@ require_once($CFG->dirroot . '/question/type/ddwtos/classes/privacy/provider.php class provider_test extends \core_privacy\tests\provider_testcase { // Include the privacy helper which has assertions on it. - public function test_get_metadata() { + public function test_get_metadata(): void { $collection = new \core_privacy\local\metadata\collection('qtype_ddwtos'); $actual = \qtype_ddwtos\privacy\provider::get_metadata($collection); $this->assertEquals($collection, $actual); } - public function test_export_user_preferences_no_pref() { + public function test_export_user_preferences_no_pref(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); @@ -67,7 +67,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { * @param string $value The value stored in the database * @param string $expected The expected transformed value */ - public function test_export_user_preferences($name, $value, $expected) { + public function test_export_user_preferences($name, $value, $expected): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); set_user_preference("qtype_ddwtos_$name", $value, $user); diff --git a/question/type/ddwtos/tests/question_test.php b/question/type/ddwtos/tests/question_test.php index 006d864b45e..39c952f5770 100644 --- a/question/type/ddwtos/tests/question_test.php +++ b/question/type/ddwtos/tests/question_test.php @@ -36,21 +36,21 @@ require_once($CFG->dirroot . '/question/type/ddwtos/tests/helper.php'); */ class question_test extends \basic_testcase { - public function test_get_question_summary() { + public function test_get_question_summary(): void { $dd = \test_question_maker::make_question('ddwtos'); $this->assertEquals('The [[1]] brown [[2]] jumped over the [[3]] dog.; ' . '[[1]] -> {quick / slow}; [[2]] -> {fox / dog}; [[3]] -> {lazy / assiduous}', $dd->get_question_summary()); } - public function test_get_question_summary_maths() { + public function test_get_question_summary_maths(): void { $dd = \test_question_maker::make_question('ddwtos', 'maths'); $this->assertEquals('Fill in the operators to make this equation work: ' . '7 [[1]] 11 [[2]] 13 [[1]] 17 [[2]] 19 = 3; [[1]] -> {+ / - / * / /}', $dd->get_question_summary()); } - public function test_summarise_response() { + public function test_summarise_response(): void { $dd = \test_question_maker::make_question('ddwtos'); $dd->shufflechoices = false; $dd->start_attempt(new question_attempt_step(), 1); @@ -59,7 +59,7 @@ class question_test extends \basic_testcase { $dd->summarise_response(array('p1' => '1', 'p2' => '1', 'p3' => '1'))); } - public function test_summarise_response_maths() { + public function test_summarise_response_maths(): void { $dd = \test_question_maker::make_question('ddwtos', 'maths'); $dd->shufflechoices = false; $dd->start_attempt(new question_attempt_step(), 1); @@ -68,17 +68,17 @@ class question_test extends \basic_testcase { $dd->summarise_response(array('p1' => '1', 'p2' => '2', 'p3' => '1', 'p4' => '2'))); } - public function test_get_random_guess_score() { + public function test_get_random_guess_score(): void { $dd = \test_question_maker::make_question('ddwtos'); $this->assertEquals(0.5, $dd->get_random_guess_score()); } - public function test_get_random_guess_score_maths() { + public function test_get_random_guess_score_maths(): void { $dd = \test_question_maker::make_question('ddwtos', 'maths'); $this->assertEquals(0.25, $dd->get_random_guess_score()); } - public function test_get_right_choice_for() { + public function test_get_right_choice_for(): void { $dd = \test_question_maker::make_question('ddwtos'); $dd->shufflechoices = false; $dd->start_attempt(new question_attempt_step(), 1); @@ -87,7 +87,7 @@ class question_test extends \basic_testcase { $this->assertEquals(1, $dd->get_right_choice_for(2)); } - public function test_get_right_choice_for_maths() { + public function test_get_right_choice_for_maths(): void { $dd = \test_question_maker::make_question('ddwtos', 'maths'); $dd->shufflechoices = false; $dd->start_attempt(new question_attempt_step(), 1); @@ -96,7 +96,7 @@ class question_test extends \basic_testcase { $this->assertEquals(2, $dd->get_right_choice_for(2)); } - public function test_clear_wrong_from_response() { + public function test_clear_wrong_from_response(): void { $dd = \test_question_maker::make_question('ddwtos', 'maths'); $dd->shufflechoices = false; $dd->start_attempt(new question_attempt_step(), 1); @@ -106,7 +106,7 @@ class question_test extends \basic_testcase { $dd->clear_wrong_from_response($initialresponse)); } - public function test_get_num_parts_right() { + public function test_get_num_parts_right(): void { $dd = \test_question_maker::make_question('ddwtos'); $dd->shufflechoices = false; $dd->start_attempt(new question_attempt_step(), 1); @@ -117,7 +117,7 @@ class question_test extends \basic_testcase { $dd->get_num_parts_right(array('p1' => '1', 'p2' => '1', 'p3' => '1'))); } - public function test_get_num_parts_right_maths() { + public function test_get_num_parts_right_maths(): void { $dd = \test_question_maker::make_question('ddwtos', 'maths'); $dd->shufflechoices = false; $dd->start_attempt(new question_attempt_step(), 1); @@ -127,7 +127,7 @@ class question_test extends \basic_testcase { 'p1' => '1', 'p2' => '1', 'p3' => '1', 'p4' => '1'))); } - public function test_get_expected_data() { + public function test_get_expected_data(): void { $dd = \test_question_maker::make_question('ddwtos'); $dd->start_attempt(new question_attempt_step(), 1); @@ -135,7 +135,7 @@ class question_test extends \basic_testcase { $dd->get_expected_data()); } - public function test_get_correct_response() { + public function test_get_correct_response(): void { $dd = \test_question_maker::make_question('ddwtos'); $dd->shufflechoices = false; $dd->start_attempt(new question_attempt_step(), 1); @@ -144,7 +144,7 @@ class question_test extends \basic_testcase { $dd->get_correct_response()); } - public function test_get_correct_response_maths() { + public function test_get_correct_response_maths(): void { $dd = \test_question_maker::make_question('ddwtos', 'maths'); $dd->shufflechoices = false; $dd->start_attempt(new question_attempt_step(), 1); @@ -153,7 +153,7 @@ class question_test extends \basic_testcase { $dd->get_correct_response()); } - public function test_is_same_response() { + public function test_is_same_response(): void { $dd = \test_question_maker::make_question('ddwtos'); $dd->start_attempt(new question_attempt_step(), 1); @@ -177,7 +177,7 @@ class question_test extends \basic_testcase { array('p1' => '1', 'p2' => '2', 'p3' => '3'), array('p1' => '1', 'p2' => '2', 'p3' => '2'))); } - public function test_is_complete_response() { + public function test_is_complete_response(): void { $dd = \test_question_maker::make_question('ddwtos'); $dd->start_attempt(new question_attempt_step(), 1); @@ -189,7 +189,7 @@ class question_test extends \basic_testcase { array('p1' => '1', 'p2' => '1', 'p3' => '1'))); } - public function test_is_gradable_response() { + public function test_is_gradable_response(): void { $dd = \test_question_maker::make_question('ddwtos'); $dd->start_attempt(new question_attempt_step(), 1); @@ -203,7 +203,7 @@ class question_test extends \basic_testcase { array('p1' => '1', 'p2' => '1', 'p3' => '1'))); } - public function test_grading() { + public function test_grading(): void { $dd = \test_question_maker::make_question('ddwtos'); $dd->shufflechoices = false; $dd->start_attempt(new question_attempt_step(), 1); @@ -216,7 +216,7 @@ class question_test extends \basic_testcase { $dd->grade_response(array('p1' => '2', 'p2' => '2', 'p3' => '2'))); } - public function test_grading_maths() { + public function test_grading_maths(): void { $dd = \test_question_maker::make_question('ddwtos', 'maths'); $dd->shufflechoices = false; $dd->start_attempt(new question_attempt_step(), 1); @@ -229,7 +229,7 @@ class question_test extends \basic_testcase { $dd->grade_response(array('p1' => '0', 'p2' => '1', 'p3' => '2', 'p4' => '1'))); } - public function test_classify_response() { + public function test_classify_response(): void { $dd = \test_question_maker::make_question('ddwtos'); $dd->shufflechoices = false; $dd->start_attempt(new question_attempt_step(), 1); diff --git a/question/type/ddwtos/tests/question_type_test.php b/question/type/ddwtos/tests/question_type_test.php index 347bc169260..75c6c5e3745 100644 --- a/question/type/ddwtos/tests/question_type_test.php +++ b/question/type/ddwtos/tests/question_type_test.php @@ -105,15 +105,15 @@ class question_type_test extends \question_testcase { return $dd; } - public function test_name() { + public function test_name(): void { $this->assertEquals($this->qtype->name(), 'ddwtos'); } - public function test_can_analyse_responses() { + public function test_can_analyse_responses(): void { $this->assertTrue($this->qtype->can_analyse_responses()); } - public function test_save_question() { + public function test_save_question(): void { $this->resetAfterTest(); $syscontext = \context_system::instance(); @@ -138,7 +138,7 @@ class question_type_test extends \question_testcase { $this->assertEquals([1 => 1, 2 => 2], $q->rightchoices); } - public function test_initialise_question_instance() { + public function test_initialise_question_instance(): void { $qdata = $this->get_test_question_data(); $expected = \test_question_maker::make_question('ddwtos'); @@ -150,12 +150,12 @@ class question_type_test extends \question_testcase { $this->assertEquals($expected, $q); } - public function test_get_random_guess_score() { + public function test_get_random_guess_score(): void { $q = $this->get_test_question_data(); $this->assertEqualsWithDelta(0.5, $this->qtype->get_random_guess_score($q), 0.0000001); } - public function test_get_possible_responses() { + public function test_get_possible_responses(): void { $q = $this->get_test_question_data(); $this->assertEquals(array( @@ -174,7 +174,7 @@ class question_type_test extends \question_testcase { ), $this->qtype->get_possible_responses($q)); } - public function test_xml_import() { + public function test_xml_import(): void { $xml = ' A drag-and-drop question @@ -265,7 +265,7 @@ class question_type_test extends \question_testcase { $this->assertEquals($expectedq->hint, $q->hint); } - public function test_xml_export() { + public function test_xml_export(): void { $qdata = new \stdClass(); $qdata->id = 123; $qdata->contextid = \context_system::instance()->id; diff --git a/question/type/ddwtos/tests/walkthrough_test.php b/question/type/ddwtos/tests/walkthrough_test.php index 2a2bd5f67df..a4274e115dc 100644 --- a/question/type/ddwtos/tests/walkthrough_test.php +++ b/question/type/ddwtos/tests/walkthrough_test.php @@ -51,7 +51,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { return new \question_contains_tag_with_attributes('span', $expectedattrs); } - public function test_interactive_behaviour() { + public function test_interactive_behaviour(): void { // Create a drag-and-drop question. $dd = \test_question_maker::make_question('ddwtos'); @@ -161,7 +161,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->check_current_mark(2); } - public function test_deferred_feedback() { + public function test_deferred_feedback(): void { // Create a drag-and-drop question. $dd = \test_question_maker::make_question('ddwtos'); @@ -244,7 +244,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->check_current_mark(2); } - public function test_deferred_feedback_unanswered() { + public function test_deferred_feedback_unanswered(): void { // Create a drag-and-drop question. $dd = \test_question_maker::make_question('ddwtos'); @@ -300,7 +300,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->get_contains_drop_box_expectation('3', 3, true)); } - public function test_deferred_feedback_partial_answer() { + public function test_deferred_feedback_partial_answer(): void { // Create a drag-and-drop question. $dd = \test_question_maker::make_question('ddwtos'); @@ -355,7 +355,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->get_contains_partcorrect_expectation()); } - public function test_interactive_grading() { + public function test_interactive_grading(): void { // Create a drag-and-drop question. $dd = \test_question_maker::make_question('ddwtos'); @@ -511,7 +511,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->quba->get_field_prefix($this->slot) . 'p3', '1')); } - public function test_interactive_correct_no_submit() { + public function test_interactive_correct_no_submit(): void { // Create a drag-and-drop question. $dd = \test_question_maker::make_question('ddwtos'); @@ -567,7 +567,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->check_current_mark(3); } - public function test_interactive_partial_no_submit() { + public function test_interactive_partial_no_submit(): void { // Create a drag-and-drop question. $dd = \test_question_maker::make_question('ddwtos'); @@ -623,7 +623,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->check_current_mark(1); } - public function test_interactive_no_right_clears() { + public function test_interactive_no_right_clears(): void { // Create a drag-and-drop question. $dd = \test_question_maker::make_question('ddwtos'); @@ -690,7 +690,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->get_no_hint_visible_expectation()); } - public function test_display_of_right_answer_when_shuffled() { + public function test_display_of_right_answer_when_shuffled(): void { // Create a drag-and-drop question. $dd = \test_question_maker::make_question('ddwtos'); diff --git a/question/type/description/tests/question_type_test.php b/question/type/description/tests/question_type_test.php index 2c4f082dac8..b282af10478 100644 --- a/question/type/description/tests/question_type_test.php +++ b/question/type/description/tests/question_type_test.php @@ -46,28 +46,28 @@ class question_type_test extends \advanced_testcase { $this->qtype = null; } - public function test_name() { + public function test_name(): void { $this->assertEquals($this->qtype->name(), 'description'); } - public function test_actual_number_of_questions() { + public function test_actual_number_of_questions(): void { $this->assertEquals(0, $this->qtype->actual_number_of_questions(null)); } - public function test_can_analyse_responses() { + public function test_can_analyse_responses(): void { $this->assertFalse($this->qtype->can_analyse_responses()); } - public function test_get_random_guess_score() { + public function test_get_random_guess_score(): void { $this->assertNull($this->qtype->get_random_guess_score(null)); } - public function test_get_possible_responses() { + public function test_get_possible_responses(): void { $this->assertEquals(array(), $this->qtype->get_possible_responses(null)); } - public function test_question_saving() { + public function test_question_saving(): void { $this->resetAfterTest(true); $this->setAdminUser(); diff --git a/question/type/description/tests/upgrade_old_attempt_data_test.php b/question/type/description/tests/upgrade_old_attempt_data_test.php index 7e2a863cc76..12294f3f1bd 100644 --- a/question/type/description/tests/upgrade_old_attempt_data_test.php +++ b/question/type/description/tests/upgrade_old_attempt_data_test.php @@ -31,7 +31,7 @@ require_once($CFG->dirroot . '/question/engine/upgrade/tests/helper.php'); */ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base { - public function test_description_deferredfeedback_history80() { + public function test_description_deferredfeedback_history80(): void { $quiz = (object) array( 'id' => '278', 'course' => '2950', @@ -176,7 +176,7 @@ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base $this->compare_qas($expectedqa, $qa); } - public function test_description_deferredfeedback_history70() { + public function test_description_deferredfeedback_history70(): void { $quiz = (object) array( 'id' => '442', 'course' => '2591', @@ -321,7 +321,7 @@ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base $this->compare_qas($expectedqa, $qa); } - public function test_description_deferredfeedback_history0() { + public function test_description_deferredfeedback_history0(): void { $quiz = (object) array( 'id' => '466', 'course' => '3464', diff --git a/question/type/description/tests/walkthrough_test.php b/question/type/description/tests/walkthrough_test.php index c5737d2a6a0..a57894da5ae 100644 --- a/question/type/description/tests/walkthrough_test.php +++ b/question/type/description/tests/walkthrough_test.php @@ -31,7 +31,7 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php'); */ class walkthrough_test extends \qbehaviour_walkthrough_test_base { - public function test_informationitem_feedback_description() { + public function test_informationitem_feedback_description(): void { // Create a description question. $description = \test_question_maker::make_question('description'); diff --git a/question/type/essay/tests/privacy/provider_test.php b/question/type/essay/tests/privacy/provider_test.php index ef88678dc3b..705bd39f297 100644 --- a/question/type/essay/tests/privacy/provider_test.php +++ b/question/type/essay/tests/privacy/provider_test.php @@ -44,13 +44,13 @@ require_once($CFG->dirroot . '/question/type/essay/classes/privacy/provider.php' class provider_test extends \core_privacy\tests\provider_testcase { // Include the privacy helper which has assertions on it. - public function test_get_metadata() { + public function test_get_metadata(): void { $collection = new \core_privacy\local\metadata\collection('qtype_essay'); $actual = \qtype_essay\privacy\provider::get_metadata($collection); $this->assertEquals($collection, $actual); } - public function test_export_user_preferences_no_pref() { + public function test_export_user_preferences_no_pref(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); @@ -67,7 +67,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { * @param string $value The value stored in the database * @param string $expected The expected transformed value */ - public function test_export_user_preferences($name, $value, $expected) { + public function test_export_user_preferences($name, $value, $expected): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); set_user_preference("qtype_essay_$name", $value, $user); diff --git a/question/type/essay/tests/question_test.php b/question/type/essay/tests/question_test.php index 1e79abf54f5..24d3b4e7bf1 100644 --- a/question/type/essay/tests/question_test.php +++ b/question/type/essay/tests/question_test.php @@ -33,7 +33,7 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php'); * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class question_test extends \advanced_testcase { - public function test_get_question_summary() { + public function test_get_question_summary(): void { $essay = \test_question_maker::make_an_essay_question(); $essay->questiontext = 'Hello world'; $this->assertEquals('Hello [world]', $essay->get_question_summary()); @@ -100,7 +100,7 @@ class question_test extends \advanced_testcase { ]; } - public function test_is_same_response() { + public function test_is_same_response(): void { $essay = \test_question_maker::make_an_essay_question(); $essay->responsetemplate = ''; @@ -144,7 +144,7 @@ class question_test extends \advanced_testcase { array('answer' => '0'))); } - public function test_is_same_response_with_template() { + public function test_is_same_response_with_template(): void { $essay = \test_question_maker::make_an_essay_question(); $essay->responsetemplate = 'Once upon a time'; @@ -188,7 +188,7 @@ class question_test extends \advanced_testcase { array('answer' => '0'))); } - public function test_is_complete_response() { + public function test_is_complete_response(): void { $this->resetAfterTest(true); // Create sample attachments. @@ -302,7 +302,7 @@ class question_test extends \advanced_testcase { /** * test_get_question_definition_for_external_rendering */ - public function test_get_question_definition_for_external_rendering() { + public function test_get_question_definition_for_external_rendering(): void { $this->resetAfterTest(); $essay = \test_question_maker::make_an_essay_question(); diff --git a/question/type/essay/tests/question_type_test.php b/question/type/essay/tests/question_type_test.php index 410ba2fd779..a6737e6455d 100644 --- a/question/type/essay/tests/question_type_test.php +++ b/question/type/essay/tests/question_type_test.php @@ -49,20 +49,20 @@ class question_type_test extends \advanced_testcase { return $q; } - public function test_name() { + public function test_name(): void { $this->assertEquals($this->qtype->name(), 'essay'); } - public function test_can_analyse_responses() { + public function test_can_analyse_responses(): void { $this->assertFalse($this->qtype->can_analyse_responses()); } - public function test_get_random_guess_score() { + public function test_get_random_guess_score(): void { $q = $this->get_test_question_data(); $this->assertEquals(0, $this->qtype->get_random_guess_score($q)); } - public function test_get_possible_responses() { + public function test_get_possible_responses(): void { $q = $this->get_test_question_data(); $this->assertEquals(array(), $this->qtype->get_possible_responses($q)); diff --git a/question/type/essay/tests/restore_test.php b/question/type/essay/tests/restore_test.php index 5269fe00dc5..9d3d2eda89e 100644 --- a/question/type/essay/tests/restore_test.php +++ b/question/type/essay/tests/restore_test.php @@ -37,7 +37,7 @@ class restore_test extends \restore_date_testcase { * During restore, we add default options for any questions like that. * That is what is tested in this file. */ - public function test_restore_create_missing_qtype_essay_options() { + public function test_restore_create_missing_qtype_essay_options(): void { global $DB; // Create a course with one essay question in its question bank. diff --git a/question/type/essay/tests/upgrade_old_attempt_data_test.php b/question/type/essay/tests/upgrade_old_attempt_data_test.php index 6b4f59c5549..92707e425ea 100644 --- a/question/type/essay/tests/upgrade_old_attempt_data_test.php +++ b/question/type/essay/tests/upgrade_old_attempt_data_test.php @@ -31,7 +31,7 @@ require_once($CFG->dirroot . '/question/engine/upgrade/tests/helper.php'); */ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base { - public function test_essay_deferredfeedback_history98220() { + public function test_essay_deferredfeedback_history98220(): void { $quiz = (object) array( 'id' => '4140', 'course' => '5012', @@ -264,7 +264,7 @@ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base $this->compare_qas($expectedqa, $qa); } - public function test_essay_deferredfeedback_history820() { + public function test_essay_deferredfeedback_history820(): void { $quiz = (object) array( 'id' => '142', 'course' => '187', @@ -443,7 +443,7 @@ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base $this->compare_qas($expectedqa, $qa); } - public function test_essay_deferredfeedback_missing() { + public function test_essay_deferredfeedback_missing(): void { $quiz = (object) array( 'id' => '142', 'course' => '187', diff --git a/question/type/essay/tests/walkthrough_test.php b/question/type/essay/tests/walkthrough_test.php index 2bc993054cf..fd9afb11b54 100644 --- a/question/type/essay/tests/walkthrough_test.php +++ b/question/type/essay/tests/walkthrough_test.php @@ -69,7 +69,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $fs->create_file_from_string($filerecord, $contents); } - public function test_deferred_feedback_html_editor() { + public function test_deferred_feedback_html_editor(): void { global $PAGE; // The current text editor depends on the users profile setting - so it needs a valid user. @@ -127,7 +127,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->get_contains_general_feedback_expectation($q)); } - public function test_deferred_feedback_plain_text() { + public function test_deferred_feedback_plain_text(): void { // Create an essay question. $q = \test_question_maker::make_question('essay', 'plain'); @@ -179,7 +179,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->get_contains_general_feedback_expectation($q)); } - public function test_responsetemplate() { + public function test_responsetemplate(): void { global $PAGE; // The current text editor depends on the users profile setting - so it needs a valid user. @@ -237,7 +237,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->get_contains_general_feedback_expectation($q)); } - public function test_deferred_feedback_html_editor_with_files_attempt_on_last() { + public function test_deferred_feedback_html_editor_with_files_attempt_on_last(): void { global $CFG, $USER, $PAGE; $this->resetAfterTest(true); @@ -361,7 +361,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->check_step_count(1); } - public function test_deferred_feedback_html_editor_with_files_attempt_on_last_no_files_uploaded() { + public function test_deferred_feedback_html_editor_with_files_attempt_on_last_no_files_uploaded(): void { global $CFG, $USER, $PAGE; $this->resetAfterTest(true); @@ -436,7 +436,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->assertMatchesRegularExpression('/I refuse to draw you a picture, so there!/', $this->currentoutput); } - public function test_deferred_feedback_plain_attempt_on_last() { + public function test_deferred_feedback_plain_attempt_on_last(): void { global $CFG, $USER; $this->resetAfterTest(true); @@ -501,7 +501,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->assertStringNotContainsString('d41d8cd98f00b204e9800998ecf8427e', $this->currentoutput); } - public function test_deferred_feedback_html_editor_with_files_attempt_wrong_filetypes() { + public function test_deferred_feedback_html_editor_with_files_attempt_wrong_filetypes(): void { global $CFG, $USER, $PAGE; $this->resetAfterTest(true); @@ -560,7 +560,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->save_quba(); } - public function test_deferred_feedback_html_editor_with_files_attempt_correct_filetypes() { + public function test_deferred_feedback_html_editor_with_files_attempt_correct_filetypes(): void { global $CFG, $USER, $PAGE; $this->resetAfterTest(true); @@ -619,7 +619,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->save_quba(); } - public function test_deferred_feedback_word_limits() { + public function test_deferred_feedback_word_limits(): void { global $PAGE; // The current text editor depends on the users profile setting - so it needs a valid user. diff --git a/question/type/gapselect/tests/form/edit_form_test.php b/question/type/gapselect/tests/form/edit_form_test.php index da69ef1e48e..77f2aaac73d 100644 --- a/question/type/gapselect/tests/form/edit_form_test.php +++ b/question/type/gapselect/tests/form/edit_form_test.php @@ -101,7 +101,7 @@ class edit_form_test extends \advanced_testcase { return [$form, $category]; } - public function test_get_illegal_tag_error() { + public function test_get_illegal_tag_error(): void { list($form) = $this->get_form('\qtype_gapselect\form\qtype_gapselect_edit_form_base_testable'); $this->assertEquals('', $form->get_illegal_tag_error('frog')); @@ -142,7 +142,7 @@ class edit_form_test extends \advanced_testcase { /** * Test the form shows the right number of groups of choices. */ - public function test_number_of_choice_groups() { + public function test_number_of_choice_groups(): void { list($form) = $this->get_form('qtype_gapselect_edit_form'); // Use reflection to get the protected property we need. $property = new \ReflectionProperty('qtype_gapselect_edit_form', '_form'); @@ -155,7 +155,7 @@ class edit_form_test extends \advanced_testcase { /** * Test the form correctly validates the HTML allowed in choices. */ - public function test_choices_validation() { + public function test_choices_validation(): void { list($form, $category) = $this->get_form('qtype_gapselect_edit_form'); $submitteddata = [ diff --git a/question/type/gapselect/tests/privacy/provider_test.php b/question/type/gapselect/tests/privacy/provider_test.php index 85734954527..bec3ff4ac76 100644 --- a/question/type/gapselect/tests/privacy/provider_test.php +++ b/question/type/gapselect/tests/privacy/provider_test.php @@ -44,13 +44,13 @@ require_once($CFG->dirroot . '/question/type/gapselect/classes/privacy/provider. class provider_test extends \core_privacy\tests\provider_testcase { // Include the privacy helper which has assertions on it. - public function test_get_metadata() { + public function test_get_metadata(): void { $collection = new \core_privacy\local\metadata\collection('qtype_gapselect'); $actual = \qtype_gapselect\privacy\provider::get_metadata($collection); $this->assertEquals($collection, $actual); } - public function test_export_user_preferences_no_pref() { + public function test_export_user_preferences_no_pref(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); @@ -67,7 +67,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { * @param string $value The value stored in the database * @param string $expected The expected transformed value */ - public function test_export_user_preferences($name, $value, $expected) { + public function test_export_user_preferences($name, $value, $expected): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); set_user_preference("qtype_gapselect_$name", $value, $user); diff --git a/question/type/gapselect/tests/question_test.php b/question/type/gapselect/tests/question_test.php index 5aef925f250..348fa4b88bb 100644 --- a/question/type/gapselect/tests/question_test.php +++ b/question/type/gapselect/tests/question_test.php @@ -39,21 +39,21 @@ require_once($CFG->dirroot . '/question/type/gapselect/tests/helper.php'); */ class question_test extends \basic_testcase { - public function test_get_question_summary() { + public function test_get_question_summary(): void { $gapselect = \test_question_maker::make_question('gapselect'); $this->assertEquals('The [[1]] brown [[2]] jumped over the [[3]] dog.; ' . '[[1]] -> {quick / slow}; [[2]] -> {fox / dog}; [[3]] -> {lazy / assiduous}', $gapselect->get_question_summary()); } - public function test_get_question_summary_maths() { + public function test_get_question_summary_maths(): void { $gapselect = \test_question_maker::make_question('gapselect', 'maths'); $this->assertEquals('Fill in the operators to make this equation work: ' . '7 [[1]] 11 [[2]] 13 [[1]] 17 [[2]] 19 = 3; [[1]] -> {+ / - / * / /}', $gapselect->get_question_summary()); } - public function test_summarise_response() { + public function test_summarise_response(): void { $gapselect = \test_question_maker::make_question('gapselect'); $gapselect->shufflechoices = false; $gapselect->start_attempt(new question_attempt_step(), 1); @@ -62,7 +62,7 @@ class question_test extends \basic_testcase { $gapselect->summarise_response(array('p1' => '1', 'p2' => '1', 'p3' => '1'))); } - public function test_summarise_response_maths() { + public function test_summarise_response_maths(): void { $gapselect = \test_question_maker::make_question('gapselect', 'maths'); $gapselect->shufflechoices = false; $gapselect->start_attempt(new question_attempt_step(), 1); @@ -71,17 +71,17 @@ class question_test extends \basic_testcase { array('p1' => '1', 'p2' => '2', 'p3' => '1', 'p4' => '2'))); } - public function test_get_random_guess_score() { + public function test_get_random_guess_score(): void { $gapselect = \test_question_maker::make_question('gapselect'); $this->assertEquals(0.5, $gapselect->get_random_guess_score()); } - public function test_get_random_guess_score_maths() { + public function test_get_random_guess_score_maths(): void { $gapselect = \test_question_maker::make_question('gapselect', 'maths'); $this->assertEquals(0.25, $gapselect->get_random_guess_score()); } - public function test_get_right_choice_for() { + public function test_get_right_choice_for(): void { $gapselect = \test_question_maker::make_question('gapselect'); $gapselect->shufflechoices = false; $gapselect->start_attempt(new question_attempt_step(), 1); @@ -90,7 +90,7 @@ class question_test extends \basic_testcase { $this->assertEquals(1, $gapselect->get_right_choice_for(2)); } - public function test_get_right_choice_for_maths() { + public function test_get_right_choice_for_maths(): void { $gapselect = \test_question_maker::make_question('gapselect', 'maths'); $gapselect->shufflechoices = false; $gapselect->start_attempt(new question_attempt_step(), 1); @@ -99,7 +99,7 @@ class question_test extends \basic_testcase { $this->assertEquals(2, $gapselect->get_right_choice_for(2)); } - public function test_clear_wrong_from_response() { + public function test_clear_wrong_from_response(): void { $gapselect = \test_question_maker::make_question('gapselect', 'maths'); $gapselect->shufflechoices = false; $gapselect->start_attempt(new question_attempt_step(), 1); @@ -109,7 +109,7 @@ class question_test extends \basic_testcase { $gapselect->clear_wrong_from_response($initialresponse)); } - public function test_get_num_parts_right() { + public function test_get_num_parts_right(): void { $gapselect = \test_question_maker::make_question('gapselect'); $gapselect->shufflechoices = false; $gapselect->start_attempt(new question_attempt_step(), 1); @@ -120,7 +120,7 @@ class question_test extends \basic_testcase { $gapselect->get_num_parts_right(array('p1' => '1', 'p2' => '1', 'p3' => '1'))); } - public function test_get_num_parts_right_maths() { + public function test_get_num_parts_right_maths(): void { $gapselect = \test_question_maker::make_question('gapselect', 'maths'); $gapselect->shufflechoices = false; $gapselect->start_attempt(new question_attempt_step(), 1); @@ -129,7 +129,7 @@ class question_test extends \basic_testcase { array('p1' => '1', 'p2' => '1', 'p3' => '1', 'p4' => '1'))); } - public function test_get_expected_data() { + public function test_get_expected_data(): void { $gapselect = \test_question_maker::make_question('gapselect'); $gapselect->start_attempt(new question_attempt_step(), 1); @@ -137,7 +137,7 @@ class question_test extends \basic_testcase { $gapselect->get_expected_data()); } - public function test_get_correct_response() { + public function test_get_correct_response(): void { $gapselect = \test_question_maker::make_question('gapselect'); $gapselect->shufflechoices = false; $gapselect->start_attempt(new question_attempt_step(), 1); @@ -146,7 +146,7 @@ class question_test extends \basic_testcase { $gapselect->get_correct_response()); } - public function test_get_correct_response_maths() { + public function test_get_correct_response_maths(): void { $gapselect = \test_question_maker::make_question('gapselect', 'maths'); $gapselect->shufflechoices = false; $gapselect->start_attempt(new question_attempt_step(), 1); @@ -155,7 +155,7 @@ class question_test extends \basic_testcase { $gapselect->get_correct_response()); } - public function test_is_same_response() { + public function test_is_same_response(): void { $gapselect = \test_question_maker::make_question('gapselect'); $gapselect->start_attempt(new question_attempt_step(), 1); @@ -179,7 +179,7 @@ class question_test extends \basic_testcase { array('p1' => '1', 'p2' => '2', 'p3' => '3'), array('p1' => '1', 'p2' => '2', 'p3' => '2'))); } - public function test_is_complete_response() { + public function test_is_complete_response(): void { $gapselect = \test_question_maker::make_question('gapselect'); $gapselect->start_attempt(new question_attempt_step(), 1); @@ -191,7 +191,7 @@ class question_test extends \basic_testcase { array('p1' => '1', 'p2' => '1', 'p3' => '1'))); } - public function test_is_gradable_response() { + public function test_is_gradable_response(): void { $gapselect = \test_question_maker::make_question('gapselect'); $gapselect->start_attempt(new question_attempt_step(), 1); @@ -205,7 +205,7 @@ class question_test extends \basic_testcase { array('p1' => '1', 'p2' => '1', 'p3' => '1'))); } - public function test_grading() { + public function test_grading(): void { $gapselect = \test_question_maker::make_question('gapselect'); $gapselect->shufflechoices = false; $gapselect->start_attempt(new question_attempt_step(), 1); @@ -218,7 +218,7 @@ class question_test extends \basic_testcase { $gapselect->grade_response(array('p1' => '2', 'p2' => '2', 'p3' => '2'))); } - public function test_grading_maths() { + public function test_grading_maths(): void { $gapselect = \test_question_maker::make_question('gapselect', 'maths'); $gapselect->shufflechoices = false; $gapselect->start_attempt(new question_attempt_step(), 1); @@ -231,7 +231,7 @@ class question_test extends \basic_testcase { array('p1' => '0', 'p2' => '1', 'p3' => '2', 'p4' => '1'))); } - public function test_classify_response() { + public function test_classify_response(): void { $gapselect = \test_question_maker::make_question('gapselect'); $gapselect->shufflechoices = false; $gapselect->start_attempt(new question_attempt_step(), 1); @@ -251,7 +251,7 @@ class question_test extends \basic_testcase { /** * test_get_question_definition_for_external_rendering */ - public function test_get_question_definition_for_external_rendering() { + public function test_get_question_definition_for_external_rendering(): void { $question = \test_question_maker::make_question('gapselect', 'maths'); $question->start_attempt(new question_attempt_step(), 1); $qa = \test_question_maker::get_a_qa($question); @@ -261,7 +261,7 @@ class question_test extends \basic_testcase { $this->assertEquals(1, $options['shufflechoices']); } - public function test_validate_can_regrade_with_other_version_ok() { + public function test_validate_can_regrade_with_other_version_ok(): void { $question = \test_question_maker::make_question('gapselect'); $newquestion = clone($question); @@ -269,7 +269,7 @@ class question_test extends \basic_testcase { $this->assertNull($newquestion->validate_can_regrade_with_other_version($question)); } - public function test_validate_can_regrade_with_other_version_bad_groups() { + public function test_validate_can_regrade_with_other_version_bad_groups(): void { $question = \test_question_maker::make_question('gapselect'); $newquestion = clone($question); @@ -279,7 +279,7 @@ class question_test extends \basic_testcase { $newquestion->validate_can_regrade_with_other_version($question)); } - public function test_validate_can_regrade_with_other_version_bad_choices() { + public function test_validate_can_regrade_with_other_version_bad_choices(): void { $question = \test_question_maker::make_question('gapselect'); $newquestion = clone($question); diff --git a/question/type/gapselect/tests/question_type_test.php b/question/type/gapselect/tests/question_type_test.php index 0ad8b3b40af..f05e1aecd9f 100644 --- a/question/type/gapselect/tests/question_type_test.php +++ b/question/type/gapselect/tests/question_type_test.php @@ -46,7 +46,7 @@ class question_type_test extends \question_testcase { $this->qtype = null; } - public function test_save_question() { + public function test_save_question(): void { $this->resetAfterTest(); $syscontext = \context_system::instance(); @@ -80,15 +80,15 @@ class question_type_test extends \question_testcase { return \test_question_maker::get_question_data('gapselect'); } - public function test_name() { + public function test_name(): void { $this->assertEquals($this->qtype->name(), 'gapselect'); } - public function test_can_analyse_responses() { + public function test_can_analyse_responses(): void { $this->assertTrue($this->qtype->can_analyse_responses()); } - public function test_initialise_question_instance() { + public function test_initialise_question_instance(): void { $qdata = $this->get_test_question_data(); $expected = \test_question_maker::make_question('gapselect'); @@ -99,12 +99,12 @@ class question_type_test extends \question_testcase { $this->assertEquals($expected, $q); } - public function test_get_random_guess_score() { + public function test_get_random_guess_score(): void { $q = $this->get_test_question_data(); $this->assertEqualsWithDelta(0.5, $this->qtype->get_random_guess_score($q), 0.0000001); } - public function test_get_possible_responses() { + public function test_get_possible_responses(): void { $q = $this->get_test_question_data(); $this->assertEquals(array( @@ -123,7 +123,7 @@ class question_type_test extends \question_testcase { ), $this->qtype->get_possible_responses($q)); } - public function test_xml_import() { + public function test_xml_import(): void { $xml = ' A select missing words question @@ -212,7 +212,7 @@ class question_type_test extends \question_testcase { $this->assertEquals($expectedq->hint, $q->hint); } - public function test_xml_export() { + public function test_xml_export(): void { $qdata = new \stdClass(); $qdata->id = 123; $qdata->contextid = \context_system::instance()->id; diff --git a/question/type/gapselect/tests/walkthrough_test.php b/question/type/gapselect/tests/walkthrough_test.php index 04473468552..06a808101db 100644 --- a/question/type/gapselect/tests/walkthrough_test.php +++ b/question/type/gapselect/tests/walkthrough_test.php @@ -34,7 +34,7 @@ require_once($CFG->dirroot . '/question/type/gapselect/tests/helper.php'); * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class walkthrough_test extends \qbehaviour_walkthrough_test_base { - public function test_interactive_behaviour() { + public function test_interactive_behaviour(): void { // Create a gapselect question. $q = \test_question_maker::make_question('gapselect'); @@ -148,7 +148,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->check_current_mark(2); } - public function test_multilang_behaviour() { + public function test_multilang_behaviour(): void { // Enable multilang filter to on content and heading. filter_set_global_state('multilang', TEXTFILTER_ON); @@ -171,7 +171,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { ['1' => 'mat', '2' => 'bat'], null, true)); } - public function test_choices_containing_dollars() { + public function test_choices_containing_dollars(): void { // Choices with a currency like entry (e.g. $3) should display. $q = \test_question_maker::make_question('gapselect', 'currency'); diff --git a/question/type/match/tests/backup_test.php b/question/type/match/tests/backup_test.php index 3673cb42ff3..bca4a5a9694 100644 --- a/question/type/match/tests/backup_test.php +++ b/question/type/match/tests/backup_test.php @@ -37,7 +37,7 @@ class backup_test extends \advanced_testcase { /** * Duplicate quiz with a matching question, and check it worked. */ - public function test_duplicate_match_question() { + public function test_duplicate_match_question(): void { global $DB; $this->resetAfterTest(); $this->setAdminUser(); diff --git a/question/type/match/tests/privacy/provider_test.php b/question/type/match/tests/privacy/provider_test.php index 41b0fc5147d..cea8fc9647b 100644 --- a/question/type/match/tests/privacy/provider_test.php +++ b/question/type/match/tests/privacy/provider_test.php @@ -44,13 +44,13 @@ require_once($CFG->dirroot . '/question/type/match/classes/privacy/provider.php' class provider_test extends \core_privacy\tests\provider_testcase { // Include the privacy helper which has assertions on it. - public function test_get_metadata() { + public function test_get_metadata(): void { $collection = new \core_privacy\local\metadata\collection('qtype_match'); $actual = \qtype_match\privacy\provider::get_metadata($collection); $this->assertEquals($collection, $actual); } - public function test_export_user_preferences_no_pref() { + public function test_export_user_preferences_no_pref(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); @@ -67,7 +67,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { * @param string $value The value stored in the database * @param string $expected The expected transformed value */ - public function test_export_user_preferences($name, $value, $expected) { + public function test_export_user_preferences($name, $value, $expected): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); set_user_preference("qtype_match_$name", $value, $user); diff --git a/question/type/match/tests/question_test.php b/question/type/match/tests/question_test.php index 4068c11659f..d5e95a5353d 100644 --- a/question/type/match/tests/question_test.php +++ b/question/type/match/tests/question_test.php @@ -37,7 +37,7 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php'); */ class question_test extends \advanced_testcase { - public function test_get_expected_data() { + public function test_get_expected_data(): void { $question = \test_question_maker::make_question('match'); $question->start_attempt(new question_attempt_step(), 1); @@ -45,7 +45,7 @@ class question_test extends \advanced_testcase { 'sub2' => PARAM_INT, 'sub3' => PARAM_INT), $question->get_expected_data()); } - public function test_is_complete_response() { + public function test_is_complete_response(): void { $question = \test_question_maker::make_question('match'); $question->start_attempt(new question_attempt_step(), 1); @@ -57,7 +57,7 @@ class question_test extends \advanced_testcase { array('sub0' => '1', 'sub1' => '1', 'sub2' => '1', 'sub3' => '1'))); } - public function test_is_gradable_response() { + public function test_is_gradable_response(): void { $question = \test_question_maker::make_question('match'); $question->start_attempt(new question_attempt_step(), 1); @@ -71,7 +71,7 @@ class question_test extends \advanced_testcase { array('sub0' => '1', 'sub1' => '1', 'sub2' => '3', 'sub3' => '1'))); } - public function test_is_same_response() { + public function test_is_same_response(): void { $question = \test_question_maker::make_question('match'); $question->start_attempt(new question_attempt_step(), 1); @@ -96,7 +96,7 @@ class question_test extends \advanced_testcase { array('sub0' => '1', 'sub1' => '2', 'sub2' => '3', 'sub3' => '1'))); } - public function test_grading() { + public function test_grading(): void { $question = \test_question_maker::make_question('match'); $question->start_attempt(new question_attempt_step(), 1); @@ -125,7 +125,7 @@ class question_test extends \advanced_testcase { $this->assertEquals(array(0, question_state::$gradedwrong), $question->grade_response($wrongresponse)); } - public function test_get_correct_response() { + public function test_get_correct_response(): void { $question = \test_question_maker::make_question('match'); $question->start_attempt(new question_attempt_step(), 1); @@ -136,7 +136,7 @@ class question_test extends \advanced_testcase { $this->assertEquals($correct, $question->get_correct_response()); } - public function test_get_question_summary() { + public function test_get_question_summary(): void { $match = \test_question_maker::make_question('match'); $match->start_attempt(new question_attempt_step(), 1); $qsummary = $match->get_question_summary(); @@ -149,7 +149,7 @@ class question_test extends \advanced_testcase { } } - public function test_summarise_response() { + public function test_summarise_response(): void { $match = \test_question_maker::make_question('match'); $match->start_attempt(new question_attempt_step(), 1); @@ -159,7 +159,7 @@ class question_test extends \advanced_testcase { $this->assertMatchesRegularExpression('/Frog -> Mammal/', $summary); } - public function test_classify_response() { + public function test_classify_response(): void { $match = \test_question_maker::make_question('match'); $match->start_attempt(new question_attempt_step(), 1); @@ -181,7 +181,7 @@ class question_test extends \advanced_testcase { ), $match->classify_response($response)); } - public function test_classify_response_choice_deleted_after_attempt() { + public function test_classify_response_choice_deleted_after_attempt(): void { $match = \test_question_maker::make_question('match'); $firststep = new question_attempt_step(); @@ -202,7 +202,7 @@ class question_test extends \advanced_testcase { ), $match->classify_response($response)); } - public function test_classify_response_choice_added_after_attempt() { + public function test_classify_response_choice_added_after_attempt(): void { $match = \test_question_maker::make_question('match'); $firststep = new question_attempt_step(); @@ -225,7 +225,7 @@ class question_test extends \advanced_testcase { ), $match->classify_response($response)); } - public function test_prepare_simulated_post_data() { + public function test_prepare_simulated_post_data(): void { $m = \test_question_maker::make_question('match'); $m->start_attempt(new question_attempt_step(), 1); $postdata = $m->prepare_simulated_post_data(array('Dog' => 'Mammal', 'Frog' => 'Amphibian', @@ -236,7 +236,7 @@ class question_test extends \advanced_testcase { /** * test_get_question_definition_for_external_rendering */ - public function test_get_question_definition_for_external_rendering() { + public function test_get_question_definition_for_external_rendering(): void { $question = \test_question_maker::make_question('match'); $question->start_attempt(new question_attempt_step(), 1); $qa = \test_question_maker::get_a_qa($question); @@ -246,7 +246,7 @@ class question_test extends \advanced_testcase { $this->assertEquals(1, $options['shufflestems']); } - public function test_validate_can_regrade_with_other_version_ok() { + public function test_validate_can_regrade_with_other_version_ok(): void { $m = \test_question_maker::make_question('match'); $newm = clone($m); @@ -254,7 +254,7 @@ class question_test extends \advanced_testcase { $this->assertNull($newm->validate_can_regrade_with_other_version($m)); } - public function test_validate_can_regrade_with_other_version_bad_stems() { + public function test_validate_can_regrade_with_other_version_bad_stems(): void { $m = \test_question_maker::make_question('match'); $newm = clone($m); @@ -264,7 +264,7 @@ class question_test extends \advanced_testcase { $newm->validate_can_regrade_with_other_version($m)); } - public function test_validate_can_regrade_with_other_version_bad_choices() { + public function test_validate_can_regrade_with_other_version_bad_choices(): void { $m = \test_question_maker::make_question('match'); $newm = clone($m); @@ -274,7 +274,7 @@ class question_test extends \advanced_testcase { $newm->validate_can_regrade_with_other_version($m)); } - public function test_update_attempt_state_date_from_old_version_bad() { + public function test_update_attempt_state_date_from_old_version_bad(): void { $m = \test_question_maker::make_question('match'); $newm = clone($m); @@ -290,7 +290,7 @@ class question_test extends \advanced_testcase { $newm->update_attempt_state_data_for_new_version($oldstep, $m); } - public function test_update_attempt_state_date_from_old_version_ok() { + public function test_update_attempt_state_date_from_old_version_ok(): void { $m = \test_question_maker::make_question('match'); $newm = clone($m); diff --git a/question/type/match/tests/question_type_test.php b/question/type/match/tests/question_type_test.php index 792011f21ef..969559b8e8f 100644 --- a/question/type/match/tests/question_type_test.php +++ b/question/type/match/tests/question_type_test.php @@ -105,15 +105,15 @@ class question_type_test extends \advanced_testcase { return $q; } - public function test_name() { + public function test_name(): void { $this->assertEquals($this->qtype->name(), 'match'); } - public function test_can_analyse_responses() { + public function test_can_analyse_responses(): void { $this->assertTrue($this->qtype->can_analyse_responses()); } - public function test_make_question_instance() { + public function test_make_question_instance(): void { $questiondata = \test_question_maker::get_question_data('match', 'trickynums'); $question = question_bank::make_question($questiondata); $this->assertEquals($questiondata->name, $question->name); @@ -133,12 +133,12 @@ class question_type_test extends \advanced_testcase { $this->assertEquals([14 => 14, 15 => 15], $question->right); } - public function test_get_random_guess_score() { + public function test_get_random_guess_score(): void { $q = $this->get_test_question_data(); $this->assertEqualsWithDelta(0.3333333, $this->qtype->get_random_guess_score($q), 0.0000001); } - public function test_get_possible_responses() { + public function test_get_possible_responses(): void { $q = $this->get_test_question_data(); $this->assertEquals(array( @@ -161,7 +161,7 @@ class question_type_test extends \advanced_testcase { } - public function test_question_saving_foursubq() { + public function test_question_saving_foursubq(): void { $this->resetAfterTest(true); $this->setAdminUser(); diff --git a/question/type/match/tests/upgrade_old_attempt_data_test.php b/question/type/match/tests/upgrade_old_attempt_data_test.php index 7c902a0a708..fa17020ec18 100644 --- a/question/type/match/tests/upgrade_old_attempt_data_test.php +++ b/question/type/match/tests/upgrade_old_attempt_data_test.php @@ -31,7 +31,7 @@ require_once($CFG->dirroot . '/question/engine/upgrade/tests/helper.php'); */ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base { - public function test_match_deferredfeedback_history6220() { + public function test_match_deferredfeedback_history6220(): void { $quiz = (object) array( 'id' => '72', 'course' => '1181', @@ -287,7 +287,7 @@ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base $this->compare_qas($expectedqa, $qa); } - public function test_match_deferredfeedback_history60() { + public function test_match_deferredfeedback_history60(): void { $quiz = (object) array( 'id' => '60', 'course' => '2304', @@ -497,7 +497,7 @@ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base $this->compare_qas($expectedqa, $qa); } - public function test_match_deferredfeedback_history622220() { + public function test_match_deferredfeedback_history622220(): void { $quiz = (object) array( 'id' => '719', 'course' => '3541', diff --git a/question/type/match/tests/walkthrough_test.php b/question/type/match/tests/walkthrough_test.php index ce92d2ba837..a35c940e3f6 100644 --- a/question/type/match/tests/walkthrough_test.php +++ b/question/type/match/tests/walkthrough_test.php @@ -34,7 +34,7 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php'); */ class walkthrough_test extends \qbehaviour_walkthrough_test_base { - public function test_deferred_feedback_unanswered() { + public function test_deferred_feedback_unanswered(): void { // Create a matching question. $m = \test_question_maker::make_question('match'); @@ -91,7 +91,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->get_contains_select_expectation('sub3', $choices, null, false)); } - public function test_deferred_feedback_partial_answer() { + public function test_deferred_feedback_partial_answer(): void { // Create a matching question. $m = \test_question_maker::make_question('match'); @@ -148,7 +148,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->get_contains_select_expectation('sub3', $choices, null, false)); } - public function test_interactive_correct_no_submit() { + public function test_interactive_correct_no_submit(): void { // Create a matching question. $m = \test_question_maker::make_question('match'); @@ -221,7 +221,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { get_string('deletedchoice', 'qtype_match'), $this->currentoutput); } - public function test_interactive_partial_no_submit() { + public function test_interactive_partial_no_submit(): void { // Create a matching question. $m = \test_question_maker::make_question('match'); @@ -275,7 +275,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->get_contains_select_expectation('sub3', $choices, null, false)); } - public function test_interactive_with_invalid() { + public function test_interactive_with_invalid(): void { // Create a matching question. $m = \test_question_maker::make_question('match'); @@ -345,7 +345,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->get_contains_select_expectation('sub3', $choices, $orderforchoice[1], false)); } - public function test_match_with_tricky_html_choices() { + public function test_match_with_tricky_html_choices(): void { // Create a matching question. $m = \test_question_maker::make_question('match'); @@ -399,7 +399,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { preg_quote(htmlspecialchars($rightresponsesummary, ENT_COMPAT), '/') . '/')); } - public function test_match_clear_wrong() { + public function test_match_clear_wrong(): void { // Create a matching question. $m = \test_question_maker::make_question('match'); diff --git a/question/type/missingtype/tests/missingtype_test.php b/question/type/missingtype/tests/missingtype_test.php index 44ab9e414c3..f68ddefd1e8 100644 --- a/question/type/missingtype/tests/missingtype_test.php +++ b/question/type/missingtype/tests/missingtype_test.php @@ -72,23 +72,23 @@ class missingtype_test extends \question_testcase { return $questiondata; } - public function test_cannot_grade() { + public function test_cannot_grade(): void { $q = new qtype_missingtype_question(); $this->expectException(\moodle_exception::class); $q->grade_response(array()); } - public function test_load_qtype_strict() { + public function test_load_qtype_strict(): void { $this->expectException(\moodle_exception::class); $qtype = question_bank::get_qtype('strange_unknown'); } - public function test_load_qtype_lax() { + public function test_load_qtype_lax(): void { $qtype = question_bank::get_qtype('strange_unknown', false); $this->assertInstanceOf('qtype_missingtype', $qtype); } - public function test_make_question() { + public function test_make_question(): void { $questiondata = $this->get_unknown_questiondata(); $q = question_bank::make_question($questiondata); $this->assertInstanceOf('qtype_missingtype_question', $q); @@ -98,7 +98,7 @@ class missingtype_test extends \question_testcase { $questiondata->questiontext); } - public function test_render_missing() { + public function test_render_missing(): void { $questiondata = $this->get_unknown_questiondata(); $q = question_bank::make_question($questiondata); $qa = new testable_question_attempt($q, 0); @@ -118,28 +118,28 @@ class missingtype_test extends \question_testcase { 'div', 'class', 'warning missingqtypewarning'), $output); } - public function test_get_question_summary() { + public function test_get_question_summary(): void { $q = new qtype_missingtype_question(); $q->questiontext = 'Test'; $this->assertEquals('TEST', $q->get_question_summary()); } - public function test_summarise_response() { + public function test_summarise_response(): void { $q = new qtype_missingtype_question(); $this->assertNull($q->summarise_response(array('a' => 'irrelevant'))); } - public function test_can_analyse_responses() { + public function test_can_analyse_responses(): void { $qtype = new qtype_missingtype(); $this->assertFalse($qtype->can_analyse_responses()); } - public function test_get_random_guess_score() { + public function test_get_random_guess_score(): void { $qtype = new qtype_missingtype(); $this->assertNull($qtype->get_random_guess_score(null)); } - public function test_get_possible_responses() { + public function test_get_possible_responses(): void { $qtype = new qtype_missingtype(); $this->assertEquals(array(), $qtype->get_possible_responses(null)); } diff --git a/question/type/multianswer/tests/question_test.php b/question/type/multianswer/tests/question_test.php index 5d0beed7a8f..4953aead224 100644 --- a/question/type/multianswer/tests/question_test.php +++ b/question/type/multianswer/tests/question_test.php @@ -36,13 +36,13 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php'); * @covers \qtype_multianswer_question */ class question_test extends \advanced_testcase { - public function test_get_expected_data() { + public function test_get_expected_data(): void { $question = \test_question_maker::make_question('multianswer'); $this->assertEquals(array('sub1_answer' => PARAM_RAW_TRIMMED, 'sub2_answer' => PARAM_RAW), $question->get_expected_data()); } - public function test_is_complete_response() { + public function test_is_complete_response(): void { $question = \test_question_maker::make_question('multianswer'); $this->assertFalse($question->is_complete_response(array())); @@ -53,7 +53,7 @@ class question_test extends \advanced_testcase { $this->assertFalse($question->is_complete_response(array('sub1_answer' => 'Owl'))); } - public function test_is_gradable_response() { + public function test_is_gradable_response(): void { $question = \test_question_maker::make_question('multianswer'); $this->assertFalse($question->is_gradable_response(array())); @@ -64,7 +64,7 @@ class question_test extends \advanced_testcase { $this->assertTrue($question->is_gradable_response(array('sub1_answer' => 'Owl'))); } - public function test_grading() { + public function test_grading(): void { $question = \test_question_maker::make_question('multianswer'); $question->start_attempt(new question_attempt_step(), 1); @@ -80,7 +80,7 @@ class question_test extends \advanced_testcase { array('sub1_answer' => 'Dog'))); } - public function test_get_correct_response() { + public function test_get_correct_response(): void { $question = \test_question_maker::make_question('multianswer'); $question->start_attempt(new question_attempt_step(), 1); @@ -90,7 +90,7 @@ class question_test extends \advanced_testcase { $question->get_correct_response()); } - public function test_get_question_summary() { + public function test_get_question_summary(): void { $question = \test_question_maker::make_question('multianswer'); // Bit of a hack to make testing easier. @@ -103,7 +103,7 @@ class question_test extends \advanced_testcase { '{Bow-wow; Wiggly worm; Pussy-cat} went to sea".', $qsummary); } - public function test_summarise_response() { + public function test_summarise_response(): void { $question = \test_question_maker::make_question('multianswer'); $question->start_attempt(new question_attempt_step(), 1); @@ -116,7 +116,7 @@ class question_test extends \advanced_testcase { array('sub1_answer' => 'Owl', 'sub2_answer' => reset($rightchoice)))); } - public function test_get_num_parts_right() { + public function test_get_num_parts_right(): void { $question = \test_question_maker::make_question('multianswer'); $question->start_attempt(new question_attempt_step(), 1); @@ -144,7 +144,7 @@ class question_test extends \advanced_testcase { $this->assertEquals(1, $numpartsright); } - public function test_get_num_parts_right_fourmc() { + public function test_get_num_parts_right_fourmc(): void { // Create a multianswer question with four mcq. $question = \test_question_maker::make_question('multianswer', 'fourmc'); $question->start_attempt(new question_attempt_step(), 1); @@ -155,7 +155,7 @@ class question_test extends \advanced_testcase { $this->assertEquals(2, $numpartsright); } - public function test_clear_wrong_from_response() { + public function test_clear_wrong_from_response(): void { $question = \test_question_maker::make_question('multianswer'); $question->start_attempt(new question_attempt_step(), 1); @@ -179,7 +179,7 @@ class question_test extends \advanced_testcase { array('sub2_answer' => $right)); } - public function test_compute_final_grade() { + public function test_compute_final_grade(): void { $question = \test_question_maker::make_question('multianswer'); // Set penalty to 0.2 to ease calculations. $question->penalty = 0.2; @@ -243,7 +243,7 @@ class question_test extends \advanced_testcase { /** * test_get_question_definition_for_external_rendering */ - public function test_get_question_definition_for_external_rendering() { + public function test_get_question_definition_for_external_rendering(): void { $this->resetAfterTest(); $question = \test_question_maker::make_question('multianswer'); @@ -298,7 +298,7 @@ class question_test extends \advanced_testcase { return $newquestion; } - public function test_validate_can_regrade_with_other_version_ok() { + public function test_validate_can_regrade_with_other_version_ok(): void { /** @var \qtype_multianswer_question $question */ $question = \test_question_maker::make_question('multianswer', 'multiple'); @@ -307,7 +307,7 @@ class question_test extends \advanced_testcase { $this->assertNull($newquestion->validate_can_regrade_with_other_version($question)); } - public function test_validate_can_regrade_with_other_version_wrong_subquestions() { + public function test_validate_can_regrade_with_other_version_wrong_subquestions(): void { /** @var \qtype_multianswer_question $question */ $question = \test_question_maker::make_question('multianswer', 'multiple'); @@ -319,7 +319,7 @@ class question_test extends \advanced_testcase { $newquestion->validate_can_regrade_with_other_version($question)); } - public function test_validate_can_regrade_with_other_version_one_wrong_subquestion() { + public function test_validate_can_regrade_with_other_version_one_wrong_subquestion(): void { /** @var \qtype_multianswer_question $question */ $question = \test_question_maker::make_question('multianswer', 'multiple'); @@ -331,7 +331,7 @@ class question_test extends \advanced_testcase { $newquestion->validate_can_regrade_with_other_version($question)); } - public function test_update_attempt_state_date_from_old_version_ok() { + public function test_update_attempt_state_date_from_old_version_ok(): void { /** @var \qtype_multianswer_question $question */ $question = \test_question_maker::make_question('multianswer', 'multiple'); @@ -354,7 +354,7 @@ class question_test extends \advanced_testcase { * Test functions work with zero weight. * This is used for testing the MDL-77378 bug. */ - public function test_zeroweight() { + public function test_zeroweight(): void { $this->resetAfterTest(); /** @var \qtype_multianswer_question $question */ $question = \test_question_maker::make_question('multianswer', 'zeroweight'); diff --git a/question/type/multianswer/tests/question_type_test.php b/question/type/multianswer/tests/question_type_test.php index 49a924b4f94..34485048c64 100644 --- a/question/type/multianswer/tests/question_type_test.php +++ b/question/type/multianswer/tests/question_type_test.php @@ -104,20 +104,20 @@ class question_type_test extends \advanced_testcase { return $q; } - public function test_name() { + public function test_name(): void { $this->assertEquals($this->qtype->name(), 'multianswer'); } - public function test_can_analyse_responses() { + public function test_can_analyse_responses(): void { $this->assertFalse($this->qtype->can_analyse_responses()); } - public function test_get_random_guess_score() { + public function test_get_random_guess_score(): void { $q = test_question_maker::get_question_data('multianswer', 'twosubq'); $this->assertEqualsWithDelta(0.1666667, $this->qtype->get_random_guess_score($q), 0.0000001); } - public function test_get_random_guess_score_with_missing_subquestion() { + public function test_get_random_guess_score_with_missing_subquestion(): void { global $DB; $this->resetAfterTest(); @@ -135,7 +135,7 @@ class question_type_test extends \advanced_testcase { $this->assertEqualsWithDelta(0.1666667, $this->qtype->get_random_guess_score($questiondata), 0.0000001); } - public function test_get_random_guess_score_with_all_missing_subquestions() { + public function test_get_random_guess_score_with_all_missing_subquestions(): void { $this->resetAfterTest(); // Create a question where all subquestions are missing. @@ -266,7 +266,7 @@ class question_type_test extends \advanced_testcase { $this->assertEquals($expectedquestions, array_values($gotquestions)); } - public function test_question_saving_twosubq() { + public function test_question_saving_twosubq(): void { $this->resetAfterTest(true); $this->setAdminUser(); @@ -346,7 +346,7 @@ class question_type_test extends \advanced_testcase { * Verify that the multiplechoice variants parameters are correctly interpreted from * the question text */ - public function test_questiontext_extraction_of_multiplechoice_subquestions_variants() { + public function test_questiontext_extraction_of_multiplechoice_subquestions_variants(): void { $questiontext = array(); $questiontext['format'] = FORMAT_HTML; $questiontext['itemid'] = ''; @@ -399,7 +399,7 @@ class question_type_test extends \advanced_testcase { * * @covers \qtype_multianswer::get_question_options */ - public function test_get_question_options() { + public function test_get_question_options(): void { global $DB; $this->resetAfterTest(true); diff --git a/question/type/multianswer/tests/upgrade_old_attempt_data_test.php b/question/type/multianswer/tests/upgrade_old_attempt_data_test.php index 9cde6383693..0b988a1860b 100644 --- a/question/type/multianswer/tests/upgrade_old_attempt_data_test.php +++ b/question/type/multianswer/tests/upgrade_old_attempt_data_test.php @@ -30,7 +30,7 @@ require_once($CFG->dirroot . '/question/engine/upgrade/tests/helper.php'); * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base { - public function test_multianswer_adaptivenopenalty_qsession104() { + public function test_multianswer_adaptivenopenalty_qsession104(): void { $quiz = (object) array( 'id' => '5', 'course' => '2', @@ -233,7 +233,7 @@ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base $this->compare_qas($expectedqa, $qa); } - public function test_multianswer_adaptivenopenalty_qsession106() { + public function test_multianswer_adaptivenopenalty_qsession106(): void { $quiz = (object) array( 'id' => '5', 'course' => '2', @@ -415,7 +415,7 @@ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base $this->compare_qas($expectedqa, $qa); } - public function test_multianswer_adaptivenopenalty_qsession108() { + public function test_multianswer_adaptivenopenalty_qsession108(): void { $quiz = (object) array( 'id' => '5', 'course' => '2', @@ -639,7 +639,7 @@ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base $this->compare_qas($expectedqa, $qa); } - public function test_multianswer_adaptivenopenalty_qsession105() { + public function test_multianswer_adaptivenopenalty_qsession105(): void { $quiz = (object) array( 'id' => '5', 'course' => '2', @@ -1324,7 +1324,7 @@ b) What grade would you give it? _____', $this->compare_qas($expectedqa, $qa); } - public function test_multianswer_adaptivenopenalty_qsession107() { + public function test_multianswer_adaptivenopenalty_qsession107(): void { $quiz = (object) array( 'id' => '5', 'course' => '2', @@ -1981,7 +1981,7 @@ b) What grade would you give it? _____', $this->compare_qas($expectedqa, $qa); } - public function test_multianswer_adaptivenopenalty_qsession109() { + public function test_multianswer_adaptivenopenalty_qsession109(): void { $quiz = (object) array( 'id' => '5', 'course' => '2', diff --git a/question/type/multianswer/tests/walkthrough_test.php b/question/type/multianswer/tests/walkthrough_test.php index 389427a902e..87220b86328 100644 --- a/question/type/multianswer/tests/walkthrough_test.php +++ b/question/type/multianswer/tests/walkthrough_test.php @@ -44,7 +44,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { preg_quote($state->default_string(true), '~') . '~'); } - public function test_deferred_feedback() { + public function test_deferred_feedback(): void { // Create a multianswer question. $q = \test_question_maker::make_question('multianswer', 'fourmc'); @@ -94,7 +94,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->get_does_not_contain_validation_error_expectation()); } - public function test_deferred_feedback_numericalzero_not_answered() { + public function test_deferred_feedback_numericalzero_not_answered(): void { // Tests the situation found in MDL-35370. // Create a multianswer question with one numerical subquestion, right answer zero. @@ -122,7 +122,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->get_does_not_contain_validation_error_expectation()); } - public function test_deferred_feedback_numericalzero_0_answer() { + public function test_deferred_feedback_numericalzero_0_answer(): void { // Tests the situation found in MDL-35370. // Create a multianswer question with one numerical subquestion, right answer zero. @@ -161,7 +161,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->get_does_not_contain_validation_error_expectation()); } - public function test_deferred_feedback_numericalzero_0_wrong() { + public function test_deferred_feedback_numericalzero_0_wrong(): void { // Tests the situation found in MDL-35370. // Create a multianswer question with one numerical subquestion, right answer zero. @@ -200,7 +200,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->get_does_not_contain_validation_error_expectation()); } - public function test_interactive_feedback() { + public function test_interactive_feedback(): void { // Create a multianswer question. $q = \test_question_maker::make_question('multianswer', 'fourmc'); @@ -328,7 +328,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->get_contains_select_expectation('sub4_answer', $choices, '1', true)); } - public function test_interactive_partial_response_does_not_reveal_answer() { + public function test_interactive_partial_response_does_not_reveal_answer(): void { // Create a multianswer question. $q = \test_question_maker::make_question('multianswer', 'fourmc'); @@ -386,7 +386,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->currentoutput); } - public function test_interactivecountback_feedback() { + public function test_interactivecountback_feedback(): void { // Create a multianswer question. $q = \test_question_maker::make_question('multianswer', 'fourmc'); @@ -478,7 +478,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->get_contains_select_expectation('sub4_answer', $choices, '1', false)); } - public function test_deferred_feedback_multiple() { + public function test_deferred_feedback_multiple(): void { // Create a multianswer question. $q = \test_question_maker::make_question('multianswer', 'multiple'); @@ -540,7 +540,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { * * @covers \qtype_multianswer_renderer::subquestion */ - public function test_corrupted_question() { + public function test_corrupted_question(): void { global $DB; $syscontext = \context_system::instance(); diff --git a/question/type/multichoice/tests/privacy/provider_test.php b/question/type/multichoice/tests/privacy/provider_test.php index 0f2dcb07918..b450090aa36 100644 --- a/question/type/multichoice/tests/privacy/provider_test.php +++ b/question/type/multichoice/tests/privacy/provider_test.php @@ -44,13 +44,13 @@ require_once($CFG->dirroot . '/question/type/multichoice/classes/privacy/provide class provider_test extends \core_privacy\tests\provider_testcase { // Include the privacy helper which has assertions on it. - public function test_get_metadata() { + public function test_get_metadata(): void { $collection = new \core_privacy\local\metadata\collection('qtype_multichoice'); $actual = \qtype_multichoice\privacy\provider::get_metadata($collection); $this->assertEquals($collection, $actual); } - public function test_export_user_preferences_no_pref() { + public function test_export_user_preferences_no_pref(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); @@ -67,7 +67,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { * @param string $value The value stored in the database * @param string $expected The expected transformed value */ - public function test_export_user_preferences($name, $value, $expected) { + public function test_export_user_preferences($name, $value, $expected): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); set_user_preference("qtype_multichoice_$name", $value, $user); diff --git a/question/type/multichoice/tests/question_multi_test.php b/question/type/multichoice/tests/question_multi_test.php index 99ff5165d3b..918824ca900 100644 --- a/question/type/multichoice/tests/question_multi_test.php +++ b/question/type/multichoice/tests/question_multi_test.php @@ -36,7 +36,7 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php'); */ class question_multi_test extends \advanced_testcase { - public function test_get_expected_data() { + public function test_get_expected_data(): void { $question = \test_question_maker::make_a_multichoice_multi_question(); $question->start_attempt(new question_attempt_step(), 1); @@ -44,7 +44,7 @@ class question_multi_test extends \advanced_testcase { 'choice2' => PARAM_BOOL, 'choice3' => PARAM_BOOL), $question->get_expected_data()); } - public function test_is_complete_response() { + public function test_is_complete_response(): void { $question = \test_question_maker::make_a_multichoice_multi_question(); $question->start_attempt(new question_attempt_step(), 1); @@ -56,7 +56,7 @@ class question_multi_test extends \advanced_testcase { array('choice0' => '1', 'choice1' => '1', 'choice2' => '1', 'choice3' => '1'))); } - public function test_is_gradable_response() { + public function test_is_gradable_response(): void { $question = \test_question_maker::make_a_multichoice_multi_question(); $question->start_attempt(new question_attempt_step(), 1); @@ -68,7 +68,7 @@ class question_multi_test extends \advanced_testcase { array('choice0' => '1', 'choice1' => '1', 'choice2' => '1', 'choice3' => '1'))); } - public function test_is_same_response() { + public function test_is_same_response(): void { $question = \test_question_maker::make_a_multichoice_multi_question(); $question->start_attempt(new question_attempt_step(), 1); @@ -89,7 +89,7 @@ class question_multi_test extends \advanced_testcase { array('choice0' => '1', 'choice1' => '0', 'choice2' => '1', 'choice3' => '0'))); } - public function test_grading() { + public function test_grading(): void { $question = \test_question_maker::make_a_multichoice_multi_question(); $question->start_attempt(new question_attempt_step(), 1); @@ -103,14 +103,14 @@ class question_multi_test extends \advanced_testcase { $question->grade_response($question->prepare_simulated_post_data(array('B' => 1)))); } - public function test_get_correct_response() { + public function test_get_correct_response(): void { $question = \test_question_maker::make_a_multichoice_multi_question(); $question->start_attempt(new question_attempt_step(), 1); $this->assertEquals($question->prepare_simulated_post_data(array('A' => 1, 'C' => 1)), $question->get_correct_response()); } - public function test_get_question_summary() { + public function test_get_question_summary(): void { $mc = \test_question_maker::make_a_multichoice_single_question(); $mc->start_attempt(new question_attempt_step(), 1); @@ -122,7 +122,7 @@ class question_multi_test extends \advanced_testcase { } } - public function test_summarise_response() { + public function test_summarise_response(): void { $mc = \test_question_maker::make_a_multichoice_multi_question(); $mc->shuffleanswers = false; $mc->start_attempt(new question_attempt_step(), 1); @@ -132,7 +132,7 @@ class question_multi_test extends \advanced_testcase { $this->assertEquals('B; C', $summary); } - public function test_summarise_response_clearchoice() { + public function test_summarise_response_clearchoice(): void { $mc = \test_question_maker::make_a_multichoice_multi_question(); $mc->shuffleanswers = false; $mc->start_attempt(new question_attempt_step(), 1); @@ -142,7 +142,7 @@ class question_multi_test extends \advanced_testcase { $this->assertNull($summary); } - public function test_un_summarise_response() { + public function test_un_summarise_response(): void { $mc = \test_question_maker::make_a_multichoice_multi_question(); $mc->shuffleanswers = false; $mc->start_attempt(new question_attempt_step(), 1); @@ -152,7 +152,7 @@ class question_multi_test extends \advanced_testcase { $this->assertEquals([], $mc->un_summarise_response('')); } - public function test_classify_response() { + public function test_classify_response(): void { $mc = \test_question_maker::make_a_multichoice_multi_question(); $mc->start_attempt(new question_attempt_step(), 1); @@ -164,7 +164,7 @@ class question_multi_test extends \advanced_testcase { $this->assertEquals(array(), $mc->classify_response(array())); } - public function test_prepare_simulated_post_data() { + public function test_prepare_simulated_post_data(): void { $mc = \test_question_maker::make_a_multichoice_multi_question(); $mc->start_attempt(new question_attempt_step(), 1); $correctanswers = array( @@ -186,7 +186,7 @@ class question_multi_test extends \advanced_testcase { /** * test_get_question_definition_for_external_rendering */ - public function test_get_question_definition_for_external_rendering() { + public function test_get_question_definition_for_external_rendering(): void { $question = \test_question_maker::make_a_multichoice_multi_question(); $question->start_attempt(new question_attempt_step(), 1); $qa = \test_question_maker::get_a_qa($question); diff --git a/question/type/multichoice/tests/question_single_test.php b/question/type/multichoice/tests/question_single_test.php index 7a7c370bfdb..12aeaa8b5e9 100644 --- a/question/type/multichoice/tests/question_single_test.php +++ b/question/type/multichoice/tests/question_single_test.php @@ -38,12 +38,12 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php'); */ class question_single_test extends \advanced_testcase { - public function test_get_expected_data() { + public function test_get_expected_data(): void { $question = \test_question_maker::make_a_multichoice_single_question(); $this->assertEquals(array('answer' => PARAM_INT), $question->get_expected_data()); } - public function test_is_complete_response() { + public function test_is_complete_response(): void { $question = \test_question_maker::make_a_multichoice_single_question(); $this->assertFalse($question->is_complete_response(array())); @@ -53,7 +53,7 @@ class question_single_test extends \advanced_testcase { $this->assertFalse($question->is_complete_response(array('answer' => -1))); } - public function test_is_gradable_response() { + public function test_is_gradable_response(): void { $question = \test_question_maker::make_a_multichoice_single_question(); $this->assertFalse($question->is_gradable_response(array())); @@ -62,7 +62,7 @@ class question_single_test extends \advanced_testcase { $this->assertFalse($question->is_gradable_response(array('answer' => '-1'))); } - public function test_is_same_response() { + public function test_is_same_response(): void { $question = \test_question_maker::make_a_multichoice_single_question(); $question->start_attempt(new question_attempt_step(), 1); @@ -103,7 +103,7 @@ class question_single_test extends \advanced_testcase { array('answer' => '-1'))); } - public function test_grading() { + public function test_grading(): void { $question = \test_question_maker::make_a_multichoice_single_question(); $question->start_attempt(new question_attempt_step(), 1); @@ -115,7 +115,7 @@ class question_single_test extends \advanced_testcase { $question->grade_response($question->prepare_simulated_post_data(array('answer' => 'C')))); } - public function test_grading_rounding_three_right() { + public function test_grading_rounding_three_right(): void { question_bank::load_question_definition_classes('multichoice'); $mc = new qtype_multichoice_multi_question(); \test_question_maker::initialise_a_question($mc); @@ -145,14 +145,14 @@ class question_single_test extends \advanced_testcase { $this->assertEquals(question_state::$gradedright, $state); } - public function test_get_correct_response() { + public function test_get_correct_response(): void { $question = \test_question_maker::make_a_multichoice_single_question(); $question->start_attempt(new question_attempt_step(), 1); $this->assertEquals($question->prepare_simulated_post_data(array('answer' => 'A')), $question->get_correct_response()); } - public function test_summarise_response() { + public function test_summarise_response(): void { $mc = \test_question_maker::make_a_multichoice_single_question(); $mc->start_attempt(new question_attempt_step(), 1); @@ -165,7 +165,7 @@ class question_single_test extends \advanced_testcase { $this->assertNull($mc->summarise_response(['answer' => '-1'])); } - public function test_un_summarise_response() { + public function test_un_summarise_response(): void { $mc = \test_question_maker::make_a_multichoice_single_question(); $mc->shuffleanswers = false; $mc->start_attempt(new question_attempt_step(), 1); @@ -175,7 +175,7 @@ class question_single_test extends \advanced_testcase { $this->assertEquals([], $mc->un_summarise_response('')); } - public function test_classify_response() { + public function test_classify_response(): void { $mc = \test_question_maker::make_a_multichoice_single_question(); $mc->start_attempt(new question_attempt_step(), 1); @@ -191,7 +191,7 @@ class question_single_test extends \advanced_testcase { ), $mc->classify_response(array('answer' => '-1'))); } - public function test_make_html_inline() { + public function test_make_html_inline(): void { $mc = \test_question_maker::make_a_multichoice_single_question(); $this->assertEquals('Frog', $mc->make_html_inline('

Frog

')); $this->assertEquals('Frog
Toad', $mc->make_html_inline("

Frog

\n

Toad

")); @@ -205,7 +205,7 @@ class question_single_test extends \advanced_testcase { $this->assertEquals('Frog
†', $mc->make_html_inline('

Frog

')); } - public function test_simulated_post_data() { + public function test_simulated_post_data(): void { $mc = \test_question_maker::make_a_multichoice_single_question(); $mc->shuffleanswers = false; $mc->answers[13]->answer = '

A

'; @@ -222,7 +222,7 @@ class question_single_test extends \advanced_testcase { $this->assertEquals($originalresponse, $reconstucted); } - public function test_validate_can_regrade_with_other_version_bad() { + public function test_validate_can_regrade_with_other_version_bad(): void { $mc = \test_question_maker::make_a_multichoice_single_question(); $newmc = clone($mc); @@ -235,7 +235,7 @@ class question_single_test extends \advanced_testcase { $newmc->validate_can_regrade_with_other_version($mc)); } - public function test_validate_can_regrade_with_other_version_ok() { + public function test_validate_can_regrade_with_other_version_ok(): void { $mc = \test_question_maker::make_a_multichoice_single_question(); $newmc = clone($mc); @@ -248,7 +248,7 @@ class question_single_test extends \advanced_testcase { $this->assertNull($newmc->validate_can_regrade_with_other_version($mc)); } - public function test_update_attempt_state_date_from_old_version_bad() { + public function test_update_attempt_state_date_from_old_version_bad(): void { $mc = \test_question_maker::make_a_multichoice_single_question(); $newmc = clone($mc); @@ -263,7 +263,7 @@ class question_single_test extends \advanced_testcase { $newmc->update_attempt_state_data_for_new_version($oldstep, $mc); } - public function test_update_attempt_state_date_from_old_version_ok() { + public function test_update_attempt_state_date_from_old_version_ok(): void { $mc = \test_question_maker::make_a_multichoice_single_question(); $newmc = clone($mc); diff --git a/question/type/multichoice/tests/question_type_test.php b/question/type/multichoice/tests/question_type_test.php index 2caba525bb0..147f61097f5 100644 --- a/question/type/multichoice/tests/question_type_test.php +++ b/question/type/multichoice/tests/question_type_test.php @@ -47,7 +47,7 @@ class question_type_test extends \advanced_testcase { $this->qtype = null; } - public function test_name() { + public function test_name(): void { $this->assertEquals($this->qtype->name(), 'multichoice'); } @@ -64,28 +64,28 @@ class question_type_test extends \advanced_testcase { return $q; } - public function test_can_analyse_responses() { + public function test_can_analyse_responses(): void { $this->assertTrue($this->qtype->can_analyse_responses()); } - public function test_get_random_guess_score() { + public function test_get_random_guess_score(): void { $q = $this->get_test_question_data(); $this->assertEquals(0.5, $this->qtype->get_random_guess_score($q)); } - public function test_get_random_guess_score_broken_question() { + public function test_get_random_guess_score_broken_question(): void { $q = $this->get_test_question_data(); $q->options->answers = []; $this->assertNull($this->qtype->get_random_guess_score($q)); } - public function test_get_random_guess_score_multi() { + public function test_get_random_guess_score_multi(): void { $q = $this->get_test_question_data(); $q->options->single = false; $this->assertNull($this->qtype->get_random_guess_score($q)); } - public function test_get_possible_responses_single() { + public function test_get_possible_responses_single(): void { $q = $this->get_test_question_data(); $responses = $this->qtype->get_possible_responses($q); @@ -97,7 +97,7 @@ class question_type_test extends \advanced_testcase { )), $this->qtype->get_possible_responses($q)); } - public function test_get_possible_responses_multi() { + public function test_get_possible_responses_multi(): void { $q = $this->get_test_question_data(); $q->options->single = false; @@ -114,7 +114,7 @@ class question_type_test extends \advanced_testcase { /** * @dataProvider get_question_saving_which */ - public function test_question_saving_two_of_four($which) { + public function test_question_saving_two_of_four($which): void { $this->resetAfterTest(true); $this->setAdminUser(); @@ -173,7 +173,7 @@ class question_type_test extends \advanced_testcase { /** * Test to make sure that loading of question options works, including in an error case. */ - public function test_get_question_options() { + public function test_get_question_options(): void { global $DB; $this->resetAfterTest(true); diff --git a/question/type/multichoice/tests/upgrade_old_attempt_data_test.php b/question/type/multichoice/tests/upgrade_old_attempt_data_test.php index c55f3f84f02..38b353d2cbd 100644 --- a/question/type/multichoice/tests/upgrade_old_attempt_data_test.php +++ b/question/type/multichoice/tests/upgrade_old_attempt_data_test.php @@ -31,7 +31,7 @@ require_once($CFG->dirroot . '/question/engine/upgrade/tests/helper.php'); */ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base { - public function test_multichoice_deferredfeedback_history960() { + public function test_multichoice_deferredfeedback_history960(): void { $quiz = (object) array( 'id' => '1', 'course' => '3', @@ -267,7 +267,7 @@ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base $this->compare_qas($expectedqa, $qa); } - public function test_multichoice_deferredfeedback_history0() { + public function test_multichoice_deferredfeedback_history0(): void { $quiz = (object) array( 'id' => '8', 'course' => '1095', @@ -427,7 +427,7 @@ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base $this->compare_qas($expectedqa, $qa); } - public function test_multichoice_deferredfeedback_history60() { + public function test_multichoice_deferredfeedback_history60(): void { $quiz = (object) array( 'id' => '13', 'course' => '1416', @@ -630,7 +630,7 @@ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base $this->compare_qas($expectedqa, $qa); } - public function test_multichoice_deferredfeedback_history6220() { + public function test_multichoice_deferredfeedback_history6220(): void { $quiz = (object) array( 'id' => '95', 'course' => '1181', @@ -869,7 +869,7 @@ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base $this->compare_qas($expectedqa, $qa); } - public function test_multichoice_deferredfeedback_missing() { + public function test_multichoice_deferredfeedback_missing(): void { $quiz = (object) array( 'id' => '8', 'course' => '1095', @@ -1003,7 +1003,7 @@ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base $this->compare_qas($expectedqa, $qa); } -public function test_multichoice_deferredfeedback_qsession140() { +public function test_multichoice_deferredfeedback_qsession140(): void { $quiz = (object) array( 'id' => '58', 'course' => '3420', @@ -1205,7 +1205,7 @@ public function test_multichoice_deferredfeedback_qsession140() { $this->compare_qas($expectedqa, $qa); } - public function test_multichoice_deferredfeedback_qsession2018195() { + public function test_multichoice_deferredfeedback_qsession2018195(): void { $quiz = (object) array( 'id' => '1832', 'course' => '4912', @@ -1451,7 +1451,7 @@ public function test_multichoice_deferredfeedback_qsession140() { $this->compare_qas($expectedqa, $qa); } - public function test_multichoice_deferredfeedback_qsession2653368() { + public function test_multichoice_deferredfeedback_qsession2653368(): void { $quiz = (object) array( 'id' => '3273', 'course' => '5862', @@ -1676,7 +1676,7 @@ public function test_multichoice_deferredfeedback_qsession140() { $this->compare_qas($expectedqa, $qa); } - public function test_multichoice_deferredfeedback_qsession3131() { + public function test_multichoice_deferredfeedback_qsession3131(): void { $quiz = (object) array( 'id' => '10', 'course' => '608', @@ -1921,7 +1921,7 @@ public function test_multichoice_deferredfeedback_qsession140() { $this->compare_qas($expectedqa, $qa); } - public function test_multichoice_deferredfeedback_qsession4307870() { + public function test_multichoice_deferredfeedback_qsession4307870(): void { $quiz = (object) array( 'id' => '4070', 'course' => '5139', @@ -2126,7 +2126,7 @@ public function test_multichoice_deferredfeedback_qsession140() { $this->compare_qas($expectedqa, $qa); } - public function test_multichoice_deferredfeedback_qsession49446() { + public function test_multichoice_deferredfeedback_qsession49446(): void { $quiz = (object) array( 'id' => '203', 'course' => '2359', @@ -2341,7 +2341,7 @@ public function test_multichoice_deferredfeedback_qsession140() { $this->compare_qas($expectedqa, $qa); } - public function test_multichoice_deferredfeedback_qsession591() { + public function test_multichoice_deferredfeedback_qsession591(): void { $quiz = (object) array( 'id' => '22', 'course' => '272', @@ -2550,7 +2550,7 @@ public function test_multichoice_deferredfeedback_qsession140() { $this->compare_qas($expectedqa, $qa); } - public function test_multichoice_deferredfeedback_qsession594() { + public function test_multichoice_deferredfeedback_qsession594(): void { $quiz = (object) array( 'id' => '22', 'course' => '272', diff --git a/question/type/multichoice/tests/walkthrough_test.php b/question/type/multichoice/tests/walkthrough_test.php index 61239422a62..658de33fa10 100644 --- a/question/type/multichoice/tests/walkthrough_test.php +++ b/question/type/multichoice/tests/walkthrough_test.php @@ -39,7 +39,7 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php'); * @covers \qtype_multichoice_single_base */ class walkthrough_test extends \qbehaviour_walkthrough_test_base { - public function test_deferredfeedback_feedback_multichoice_single() { + public function test_deferredfeedback_feedback_multichoice_single(): void { // Create a multichoice, single question. $mc = \test_question_maker::make_a_multichoice_single_question(); @@ -94,7 +94,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { get_string('deletedchoice', 'qtype_multichoice'), $this->currentoutput); } - public function test_deferredfeedback_feedback_multichoice_single_showstandardunstruction_yes() { + public function test_deferredfeedback_feedback_multichoice_single_showstandardunstruction_yes(): void { // Create a multichoice, single question. $mc = \test_question_maker::make_a_multichoice_single_question(); @@ -108,7 +108,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->assertStringContainsString($standardinstruction, $this->currentoutput); } - public function test_deferredfeedback_feedback_multichoice_single_showstandardunstruction_no() { + public function test_deferredfeedback_feedback_multichoice_single_showstandardunstruction_no(): void { // Create a multichoice, single question. $mc = \test_question_maker::make_a_multichoice_single_question(); @@ -122,7 +122,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->assertStringNotContainsString($standardinstruction, $this->currentoutput); } - public function test_deferredfeedback_feedback_multichoice_multi() { + public function test_deferredfeedback_feedback_multichoice_multi(): void { // Create a multichoice, multi question. $mc = \test_question_maker::make_a_multichoice_multi_question(); $mc->shuffleanswers = false; @@ -147,7 +147,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { /** * Test for clear choice option. */ - public function test_deferredfeedback_feedback_multichoice_clearchoice() { + public function test_deferredfeedback_feedback_multichoice_clearchoice(): void { // Create a multichoice, single question. $mc = \test_question_maker::make_a_multichoice_single_question(); @@ -213,7 +213,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { new \question_pattern_expectation('/class="r1"/')); } - public function test_each_attempt_builds_on_last_and_regrade() { + public function test_each_attempt_builds_on_last_and_regrade(): void { // Create a multichoice, single question. $mc = \test_question_maker::make_a_multichoice_single_question(); @@ -278,7 +278,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->assertEquals(3, $newqa->get_mark()); } - public function test_deferredfeedback_feedback_multichoice_multi_showstandardunstruction_yes() { + public function test_deferredfeedback_feedback_multichoice_multi_showstandardunstruction_yes(): void { // Create a multichoice, multi question. $mc = \test_question_maker::make_a_multichoice_multi_question(); @@ -292,7 +292,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->assertStringContainsString($standardinstruction, $this->currentoutput); } - public function test_deferredfeedback_feedback_multichoice_multi_showstandardunstruction_no() { + public function test_deferredfeedback_feedback_multichoice_multi_showstandardunstruction_no(): void { // Create a multichoice, multi question. $mc = \test_question_maker::make_a_multichoice_multi_question(); diff --git a/question/type/numerical/tests/answer_test.php b/question/type/numerical/tests/answer_test.php index 10e2c261006..c3a2774f132 100644 --- a/question/type/numerical/tests/answer_test.php +++ b/question/type/numerical/tests/answer_test.php @@ -33,7 +33,7 @@ require_once($CFG->dirroot . '/question/type/numerical/question.php'); * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class answer_test extends \advanced_testcase { - public function test_within_tolerance_nominal() { + public function test_within_tolerance_nominal(): void { $answer = new qtype_numerical_answer(13, 7.0, 1.0, '', FORMAT_MOODLE, 1.0); $this->assertFalse($answer->within_tolerance(5.99)); @@ -43,7 +43,7 @@ class answer_test extends \advanced_testcase { $this->assertFalse($answer->within_tolerance(8.01)); } - public function test_within_tolerance_nominal_zero() { + public function test_within_tolerance_nominal_zero(): void { // Either an answer or tolerance of 0 requires special care. We still // don't want to end up comparing two floats for absolute equality. @@ -78,14 +78,14 @@ class answer_test extends \advanced_testcase { $this->assertFalse($answer->within_tolerance(1.0002e-20)); } - public function test_within_tolerance_blank() { + public function test_within_tolerance_blank(): void { $answer = new qtype_numerical_answer(13, 1234, 1.0, '', FORMAT_MOODLE, ''); $this->assertTrue($answer->within_tolerance(1234)); $this->assertFalse($answer->within_tolerance(1234.000001)); $this->assertFalse($answer->within_tolerance(0)); } - public function test_within_tolerance_relative() { + public function test_within_tolerance_relative(): void { $answer = new qtype_numerical_answer(13, 7.0, 1.0, '', FORMAT_MOODLE, 0.1); $answer->tolerancetype = 1; @@ -96,7 +96,7 @@ class answer_test extends \advanced_testcase { $this->assertFalse($answer->within_tolerance(7.71)); } - public function test_within_tolerance_geometric() { + public function test_within_tolerance_geometric(): void { $answer = new qtype_numerical_answer(13, 7.0, 1.0, '', FORMAT_MOODLE, 1.0); $answer->tolerancetype = 3; diff --git a/question/type/numerical/tests/privacy/provider_test.php b/question/type/numerical/tests/privacy/provider_test.php index d5fd8fd3059..2c0f920b2cb 100644 --- a/question/type/numerical/tests/privacy/provider_test.php +++ b/question/type/numerical/tests/privacy/provider_test.php @@ -44,13 +44,13 @@ require_once($CFG->dirroot . '/question/type/numerical/questiontype.php'); class provider_test extends \core_privacy\tests\provider_testcase { // Include the privacy helper which has assertions on it. - public function test_get_metadata() { + public function test_get_metadata(): void { $collection = new \core_privacy\local\metadata\collection('qtype_numerical'); $actual = provider::get_metadata($collection); $this->assertEquals($collection, $actual); } - public function test_export_user_preferences_no_pref() { + public function test_export_user_preferences_no_pref(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); @@ -67,7 +67,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { * @param string $value The value stored in the database * @param string $expected The expected transformed value */ - public function test_export_user_preferences($name, $value, $expected) { + public function test_export_user_preferences($name, $value, $expected): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); set_user_preference("qtype_numerical_$name", $value, $user); diff --git a/question/type/numerical/tests/question_test.php b/question/type/numerical/tests/question_test.php index 52b723907df..1a074f4ede4 100644 --- a/question/type/numerical/tests/question_test.php +++ b/question/type/numerical/tests/question_test.php @@ -37,7 +37,7 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php'); * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class question_test extends \advanced_testcase { - public function test_is_complete_response() { + public function test_is_complete_response(): void { $question = \test_question_maker::make_question('numerical'); $this->assertFalse($question->is_complete_response(array())); @@ -46,7 +46,7 @@ class question_test extends \advanced_testcase { $this->assertFalse($question->is_complete_response(array('answer' => 'test'))); } - public function test_is_gradable_response() { + public function test_is_gradable_response(): void { $question = \test_question_maker::make_question('numerical'); $this->assertFalse($question->is_gradable_response(array())); @@ -55,7 +55,7 @@ class question_test extends \advanced_testcase { $this->assertTrue($question->is_gradable_response(array('answer' => 'test'))); } - public function test_grading() { + public function test_grading(): void { $question = \test_question_maker::make_question('numerical'); $this->assertEquals(array(0, question_state::$gradedwrong), @@ -64,7 +64,7 @@ class question_test extends \advanced_testcase { $question->grade_response(array('answer' => '3.14'))); } - public function test_grading_with_units() { + public function test_grading_with_units(): void { $question = \test_question_maker::make_question('numerical'); $question->unitgradingtype = qtype_numerical::UNITOPTIONAL; $question->ap = new qtype_numerical_answer_processor( @@ -82,7 +82,7 @@ class question_test extends \advanced_testcase { $question->grade_response(array('answer' => '314000000x10^-8m'))); } - public function test_grading_with_units_graded() { + public function test_grading_with_units_graded(): void { $question = \test_question_maker::make_question('numerical'); $question->unitgradingtype = qtype_numerical::UNITGRADED; $question->ap = new qtype_numerical_answer_processor( @@ -104,7 +104,7 @@ class question_test extends \advanced_testcase { $question->grade_response(array('answer' => '314 m'))); } - public function test_grading_unit() { + public function test_grading_unit(): void { $question = \test_question_maker::make_question('numerical', 'unit'); $this->assertEquals(array(0, question_state::$gradedwrong), @@ -129,7 +129,7 @@ class question_test extends \advanced_testcase { $question->grade_response(array('answer' => '1.23', 'unit' => ''))); } - public function test_grading_currency() { + public function test_grading_currency(): void { $question = \test_question_maker::make_question('numerical', 'currency'); $this->assertEquals(array(1, question_state::$gradedright), @@ -150,51 +150,51 @@ class question_test extends \advanced_testcase { $question->grade_response(array('answer' => '$1'))); } - public function test_get_correct_response() { + public function test_get_correct_response(): void { $question = \test_question_maker::make_question('numerical'); $this->assertEquals(array('answer' => '3.14'), $question->get_correct_response()); } - public function test_get_correct_response_units() { + public function test_get_correct_response_units(): void { $question = \test_question_maker::make_question('numerical', 'unit'); $this->assertEquals(array('answer' => '1.25', 'unit' => 'm'), $question->get_correct_response()); } - public function test_get_correct_response_currency() { + public function test_get_correct_response_currency(): void { $question = \test_question_maker::make_question('numerical', 'currency'); $this->assertEquals(array('answer' => '$ 1332'), $question->get_correct_response()); } - public function test_get_question_summary() { + public function test_get_question_summary(): void { $num = \test_question_maker::make_question('numerical'); $qsummary = $num->get_question_summary(); $this->assertEquals('What is pi to two d.p.?', $qsummary); } - public function test_summarise_response() { + public function test_summarise_response(): void { $num = \test_question_maker::make_question('numerical'); $this->assertEquals('3.1', $num->summarise_response(array('answer' => '3.1'))); } - public function test_summarise_response_zero() { + public function test_summarise_response_zero(): void { $num = \test_question_maker::make_question('numerical'); $this->assertEquals('0', $num->summarise_response(array('answer' => '0'))); } - public function test_summarise_response_unit() { + public function test_summarise_response_unit(): void { $num = \test_question_maker::make_question('numerical', 'unit'); $this->assertEquals('3.1', $num->summarise_response(array('answer' => '3.1'))); $this->assertEquals('3.1m', $num->summarise_response(array('answer' => '3.1m'))); $this->assertEquals('3.1 cm', $num->summarise_response(array('answer' => '3.1 cm'))); } - public function test_summarise_response_currency() { + public function test_summarise_response_currency(): void { $num = \test_question_maker::make_question('numerical', 'currency'); $this->assertEquals('100', $num->summarise_response(array('answer' => '100'))); $this->assertEquals('$100', $num->summarise_response(array('answer' => '$100'))); @@ -202,7 +202,7 @@ class question_test extends \advanced_testcase { $this->assertEquals('100 frogs', $num->summarise_response(array('answer' => '100 frogs'))); } - public function test_classify_response() { + public function test_classify_response(): void { $num = \test_question_maker::make_question('numerical'); $num->start_attempt(new question_attempt_step(), 1); @@ -221,7 +221,7 @@ class question_test extends \advanced_testcase { $num->classify_response(array('answer' => 'abc'))); } - public function test_classify_response_no_star() { + public function test_classify_response_no_star(): void { $num = \test_question_maker::make_question('numerical'); unset($num->answers[17]); $num->start_attempt(new question_attempt_step(), 1); @@ -238,7 +238,7 @@ class question_test extends \advanced_testcase { $num->classify_response(array('answer' => 'abc'))); } - public function test_classify_response_unit() { + public function test_classify_response_unit(): void { $num = \test_question_maker::make_question('numerical', 'unit'); $num->start_attempt(new question_attempt_step(), 1); @@ -269,7 +269,7 @@ class question_test extends \advanced_testcase { $num->classify_response(array('answer' => 'abc', 'unit' => 'm'))); } - public function test_classify_response_unit_no_star() { + public function test_classify_response_unit_no_star(): void { $num = \test_question_maker::make_question('numerical', 'unit'); unset($num->answers[17]); $num->start_attempt(new question_attempt_step(), 1); @@ -292,7 +292,7 @@ class question_test extends \advanced_testcase { $num->classify_response(array('answer' => 'abc', 'unit' => 'm'))); } - public function test_classify_response_currency() { + public function test_classify_response_currency(): void { $num = \test_question_maker::make_question('numerical', 'currency'); $num->start_attempt(new question_attempt_step(), 1); @@ -311,7 +311,7 @@ class question_test extends \advanced_testcase { /** * test_get_question_definition_for_external_rendering */ - public function test_get_question_definition_for_external_rendering() { + public function test_get_question_definition_for_external_rendering(): void { $this->resetAfterTest(); $question = \test_question_maker::make_question('numerical', 'unit'); diff --git a/question/type/numerical/tests/question_type_test.php b/question/type/numerical/tests/question_type_test.php index 9231ae63ae9..6e64d880efe 100644 --- a/question/type/numerical/tests/question_type_test.php +++ b/question/type/numerical/tests/question_type_test.php @@ -80,20 +80,20 @@ class question_type_test extends \advanced_testcase { return $q; } - public function test_name() { + public function test_name(): void { $this->assertEquals($this->qtype->name(), 'numerical'); } - public function test_can_analyse_responses() { + public function test_can_analyse_responses(): void { $this->assertTrue($this->qtype->can_analyse_responses()); } - public function test_get_random_guess_score() { + public function test_get_random_guess_score(): void { $q = $this->get_test_question_data(); $this->assertEquals(0.1, $this->qtype->get_random_guess_score($q)); } - public function test_get_possible_responses() { + public function test_get_possible_responses(): void { $q = $this->get_test_question_data(); $this->assertEquals(array( @@ -105,7 +105,7 @@ class question_type_test extends \advanced_testcase { ), $this->qtype->get_possible_responses($q)); } - public function test_get_possible_responses_no_star() { + public function test_get_possible_responses_no_star(): void { $q = $this->get_test_question_data(); unset($q->options->answers[14]); @@ -119,7 +119,7 @@ class question_type_test extends \advanced_testcase { ), $this->qtype->get_possible_responses($q)); } - public function test_question_saving_pi() { + public function test_question_saving_pi(): void { $this->resetAfterTest(true); $this->setAdminUser(); @@ -165,7 +165,7 @@ class question_type_test extends \advanced_testcase { } } - public function test_is_valid_number() { + public function test_is_valid_number(): void { $this->assertTrue(qtype_numerical::is_valid_number('1,001')); $this->assertTrue(qtype_numerical::is_valid_number('1.001')); $this->assertTrue(qtype_numerical::is_valid_number('1')); diff --git a/question/type/numerical/tests/upgrade_old_attempt_data_test.php b/question/type/numerical/tests/upgrade_old_attempt_data_test.php index c82c19ecb4a..5c851554961 100644 --- a/question/type/numerical/tests/upgrade_old_attempt_data_test.php +++ b/question/type/numerical/tests/upgrade_old_attempt_data_test.php @@ -31,7 +31,7 @@ require_once($CFG->dirroot . '/question/engine/upgrade/tests/helper.php'); */ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base { - public function test_numerical_deferredfeedback_history620() { + public function test_numerical_deferredfeedback_history620(): void { $quiz = (object) array( 'id' => '221', 'course' => '187', @@ -256,7 +256,7 @@ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base $this->compare_qas($expectedqa, $qa); } - public function test_numerical_deferredfeedback_required_units() { + public function test_numerical_deferredfeedback_required_units(): void { $quiz = (object) array( 'id' => '2', 'course' => '2', diff --git a/question/type/numerical/tests/walkthrough_test.php b/question/type/numerical/tests/walkthrough_test.php index ebc45905ea2..a94bae62929 100644 --- a/question/type/numerical/tests/walkthrough_test.php +++ b/question/type/numerical/tests/walkthrough_test.php @@ -34,7 +34,7 @@ require_once($CFG->dirroot . '/question/type/numerical/tests/helper.php'); * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class walkthrough_test extends \qbehaviour_walkthrough_test_base { - public function test_interactive_currency() { + public function test_interactive_currency(): void { // Create a gapselect question. $q = \test_question_maker::make_question('numerical', 'currency'); @@ -101,7 +101,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->quba->get_response_summary($this->slot)); } - public function test_deferredfeedback_currency() { + public function test_deferredfeedback_currency(): void { // Create a gapselect question. $q = \test_question_maker::make_question('numerical', 'currency'); @@ -175,7 +175,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { // Todo. Test validation if you try to type a unit into a question that does // not expect one. - public function test_deferredfeedback_unit() { + public function test_deferredfeedback_unit(): void { // Create a gapselect question. $q = \test_question_maker::make_question('numerical', 'unit'); diff --git a/question/type/random/tests/question_type_test.php b/question/type/random/tests/question_type_test.php index f2d9e6f687b..c99ba338d53 100644 --- a/question/type/random/tests/question_type_test.php +++ b/question/type/random/tests/question_type_test.php @@ -44,19 +44,19 @@ class question_type_test extends \advanced_testcase { $this->qtype = null; } - public function test_name() { + public function test_name(): void { $this->assertEquals($this->qtype->name(), 'random'); } - public function test_can_analyse_responses() { + public function test_can_analyse_responses(): void { $this->assertFalse($this->qtype->can_analyse_responses()); } - public function test_get_random_guess_score() { + public function test_get_random_guess_score(): void { $this->assertNull($this->qtype->get_random_guess_score(null)); } - public function test_load_question() { + public function test_load_question(): void { $this->resetAfterTest(); $syscontext = \context_system::instance(); @@ -100,11 +100,11 @@ class question_type_test extends \advanced_testcase { $this->assertEquals([], $questiondata->hints); } - public function test_get_possible_responses() { + public function test_get_possible_responses(): void { $this->assertEquals(array(), $this->qtype->get_possible_responses(null)); } - public function test_question_creation() { + public function test_question_creation(): void { $this->resetAfterTest(); question_bank::get_qtype('random')->clear_caches_before_testing(); diff --git a/question/type/random/tests/upgrade_old_attempt_data_test.php b/question/type/random/tests/upgrade_old_attempt_data_test.php index 0cd0c37b3c4..e418c1a0a75 100644 --- a/question/type/random/tests/upgrade_old_attempt_data_test.php +++ b/question/type/random/tests/upgrade_old_attempt_data_test.php @@ -31,7 +31,7 @@ require_once($CFG->dirroot . '/question/engine/upgrade/tests/helper.php'); */ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base { - public function test_random_deferredfeedback_history620() { + public function test_random_deferredfeedback_history620(): void { $quiz = (object) array( 'id' => '2177', 'course' => '5174', @@ -259,7 +259,7 @@ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base $this->compare_qas($expectedqa, $qa); } - public function test_random_deferredfeedback_qsession4225582() { + public function test_random_deferredfeedback_qsession4225582(): void { $quiz = (object) array( 'id' => '4410', 'course' => '5444', @@ -507,7 +507,7 @@ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base $this->compare_qas($expectedqa, $qa); } - public function test_random_deferredfeedback_qsession3481928() { + public function test_random_deferredfeedback_qsession3481928(): void { $quiz = (object) array( 'id' => '2624', 'course' => '5233', @@ -776,7 +776,7 @@ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base $this->compare_qas($expectedqa, $qa); } - public function test_numerical_deferredfeedback_qsession55() { + public function test_numerical_deferredfeedback_qsession55(): void { $quiz = (object) array( 'id' => '2', 'course' => '2', diff --git a/question/type/randomsamatch/tests/question_test.php b/question/type/randomsamatch/tests/question_test.php index 9a6325e3ac5..7baf119df64 100644 --- a/question/type/randomsamatch/tests/question_test.php +++ b/question/type/randomsamatch/tests/question_test.php @@ -34,7 +34,7 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php'); */ class question_test extends \advanced_testcase { - public function test_get_expected_data() { + public function test_get_expected_data(): void { $question = \test_question_maker::make_question('randomsamatch'); $question->start_attempt(new question_attempt_step(), 1); @@ -42,7 +42,7 @@ class question_test extends \advanced_testcase { 'sub2' => PARAM_INT, 'sub3' => PARAM_INT), $question->get_expected_data()); } - public function test_is_complete_response() { + public function test_is_complete_response(): void { $question = \test_question_maker::make_question('randomsamatch'); $question->start_attempt(new question_attempt_step(), 1); @@ -54,7 +54,7 @@ class question_test extends \advanced_testcase { array('sub0' => '1', 'sub1' => '1', 'sub2' => '1', 'sub3' => '1'))); } - public function test_is_gradable_response() { + public function test_is_gradable_response(): void { $question = \test_question_maker::make_question('randomsamatch'); $question->start_attempt(new question_attempt_step(), 1); @@ -68,7 +68,7 @@ class question_test extends \advanced_testcase { array('sub0' => '1', 'sub1' => '1', 'sub2' => '3', 'sub3' => '1'))); } - public function test_is_same_response() { + public function test_is_same_response(): void { $question = \test_question_maker::make_question('randomsamatch'); $question->start_attempt(new question_attempt_step(), 1); @@ -93,7 +93,7 @@ class question_test extends \advanced_testcase { array('sub0' => '1', 'sub1' => '2', 'sub2' => '3', 'sub3' => '1'))); } - public function test_grading() { + public function test_grading(): void { $question = \test_question_maker::make_question('randomsamatch'); $question->start_attempt(new question_attempt_step(), 1); @@ -111,7 +111,7 @@ class question_test extends \advanced_testcase { 'sub3' => $orderforchoice[16]))); } - public function test_get_correct_response() { + public function test_get_correct_response(): void { $question = \test_question_maker::make_question('randomsamatch'); $question->start_attempt(new question_attempt_step(), 1); @@ -123,7 +123,7 @@ class question_test extends \advanced_testcase { $question->get_correct_response()); } - public function test_get_question_summary() { + public function test_get_question_summary(): void { $question = \test_question_maker::make_question('randomsamatch'); $question->start_attempt(new question_attempt_step(), 1); $qsummary = $question->get_question_summary(); @@ -136,7 +136,7 @@ class question_test extends \advanced_testcase { } } - public function test_summarise_response() { + public function test_summarise_response(): void { $question = \test_question_maker::make_question('randomsamatch'); $question->shufflestems = false; $question->start_attempt(new question_attempt_step(), 1); diff --git a/question/type/randomsamatch/tests/upgrade_old_attempt_data_test.php b/question/type/randomsamatch/tests/upgrade_old_attempt_data_test.php index da8844d6962..2b98c9dbfe3 100644 --- a/question/type/randomsamatch/tests/upgrade_old_attempt_data_test.php +++ b/question/type/randomsamatch/tests/upgrade_old_attempt_data_test.php @@ -30,7 +30,7 @@ require_once($CFG->dirroot . '/question/engine/upgrade/tests/helper.php'); * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base { - public function test_randomsamatch_deferredfeedback_qsession1() { + public function test_randomsamatch_deferredfeedback_qsession1(): void { $quiz = (object) array( 'id' => '1', 'course' => '2', diff --git a/question/type/randomsamatch/tests/walkthrough_test.php b/question/type/randomsamatch/tests/walkthrough_test.php index face79665d4..e4182ed0ae4 100644 --- a/question/type/randomsamatch/tests/walkthrough_test.php +++ b/question/type/randomsamatch/tests/walkthrough_test.php @@ -34,7 +34,7 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php'); */ class walkthrough_test extends \qbehaviour_walkthrough_test_base { - public function test_deferred_feedback_unanswered() { + public function test_deferred_feedback_unanswered(): void { // Create a randomsamatch question. $m = \test_question_maker::make_question('randomsamatch'); @@ -90,7 +90,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->get_contains_select_expectation('sub3', $choices, null, false)); } - public function test_deferred_feedback_partial_answer() { + public function test_deferred_feedback_partial_answer(): void { // Create a randomsamatching question. $m = \test_question_maker::make_question('randomsamatch'); @@ -147,7 +147,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->get_contains_select_expectation('sub3', $choices, null, false)); } - public function test_interactive_correct_no_submit() { + public function test_interactive_correct_no_submit(): void { // Create a randomsamatching question. $m = \test_question_maker::make_question('randomsamatch'); @@ -201,7 +201,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->get_contains_select_expectation('sub3', $choices, $orderforchoice[13], false)); } - public function test_interactive_partial_no_submit() { + public function test_interactive_partial_no_submit(): void { // Create a randomsamatching question. $m = \test_question_maker::make_question('randomsamatch'); @@ -255,7 +255,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->get_contains_select_expectation('sub3', $choices, null, false)); } - public function test_interactive_with_invalid() { + public function test_interactive_with_invalid(): void { // Create a randomsamatching question. $m = \test_question_maker::make_question('randomsamatch'); @@ -325,7 +325,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { $this->get_contains_select_expectation('sub3', $choices, $orderforchoice[13], false)); } - public function test_randomsamatch_clear_wrong() { + public function test_randomsamatch_clear_wrong(): void { // Create a randomsamatching question. $m = \test_question_maker::make_question('randomsamatch'); diff --git a/question/type/shortanswer/tests/privacy/provider_test.php b/question/type/shortanswer/tests/privacy/provider_test.php index 4c1aed9fdaa..894e16f90a5 100644 --- a/question/type/shortanswer/tests/privacy/provider_test.php +++ b/question/type/shortanswer/tests/privacy/provider_test.php @@ -44,13 +44,13 @@ require_once($CFG->dirroot . '/question/type/shortanswer/classes/privacy/provide class provider_test extends \core_privacy\tests\provider_testcase { // Include the privacy helper which has assertions on it. - public function test_get_metadata() { + public function test_get_metadata(): void { $collection = new \core_privacy\local\metadata\collection('qtype_shortanswer'); $actual = \qtype_shortanswer\privacy\provider::get_metadata($collection); $this->assertEquals($collection, $actual); } - public function test_export_user_preferences_no_pref() { + public function test_export_user_preferences_no_pref(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); @@ -67,7 +67,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { * @param string $value The value stored in the database * @param string $expected The expected transformed value */ - public function test_export_user_preferences($name, $value, $expected) { + public function test_export_user_preferences($name, $value, $expected): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); set_user_preference("qtype_shortanswer_$name", $value, $user); diff --git a/question/type/shortanswer/tests/question_test.php b/question/type/shortanswer/tests/question_test.php index 4a65108cc9a..6ffe428ef1a 100644 --- a/question/type/shortanswer/tests/question_test.php +++ b/question/type/shortanswer/tests/question_test.php @@ -37,7 +37,7 @@ require_once($CFG->dirroot . '/question/type/shortanswer/question.php'); * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class question_test extends \advanced_testcase { - public function test_compare_string_with_wildcard() { + public function test_compare_string_with_wildcard(): void { // Test case sensitive literal matches. $this->assertTrue((bool)qtype_shortanswer_question::compare_string_with_wildcard( 'Frog', 'Frog', false)); @@ -119,7 +119,7 @@ class question_test extends \advanced_testcase { } } - public function test_compare_0_with_wildcard() { + public function test_compare_0_with_wildcard(): void { // Test the classic PHP problem case with '0'. $this->assertTrue((bool)qtype_shortanswer_question::compare_string_with_wildcard( '0', '0', false)); @@ -131,13 +131,13 @@ class question_test extends \advanced_testcase { '0', '*0*', false)); } - public function test_compare_string_with_wildcard_many_stars() { + public function test_compare_string_with_wildcard_many_stars(): void { // Test the classic PHP problem case with '0'. $this->assertTrue((bool)qtype_shortanswer_question::compare_string_with_wildcard( '', '**********************************************************************', false)); } - public function test_is_complete_response() { + public function test_is_complete_response(): void { $question = \test_question_maker::make_question('shortanswer'); $this->assertFalse($question->is_complete_response(array())); @@ -147,7 +147,7 @@ class question_test extends \advanced_testcase { $this->assertTrue($question->is_complete_response(array('answer' => 'x'))); } - public function test_is_gradable_response() { + public function test_is_gradable_response(): void { $question = \test_question_maker::make_question('shortanswer'); $this->assertFalse($question->is_gradable_response(array())); @@ -157,7 +157,7 @@ class question_test extends \advanced_testcase { $this->assertTrue($question->is_gradable_response(array('answer' => 'x'))); } - public function test_grading() { + public function test_grading(): void { $question = \test_question_maker::make_question('shortanswer'); $this->assertEquals(array(0, question_state::$gradedwrong), @@ -168,32 +168,32 @@ class question_test extends \advanced_testcase { $question->grade_response(array('answer' => 'toad'))); } - public function test_get_correct_response() { + public function test_get_correct_response(): void { $question = \test_question_maker::make_question('shortanswer'); $this->assertEquals(array('answer' => 'frog'), $question->get_correct_response()); } - public function test_get_correct_response_escapedwildcards() { + public function test_get_correct_response_escapedwildcards(): void { $question = \test_question_maker::make_question('shortanswer', 'escapedwildcards'); $this->assertEquals(array('answer' => 'x*y'), $question->get_correct_response()); } - public function test_get_question_summary() { + public function test_get_question_summary(): void { $sa = \test_question_maker::make_question('shortanswer'); $qsummary = $sa->get_question_summary(); $this->assertEquals('Name an amphibian: __________', $qsummary); } - public function test_summarise_response() { + public function test_summarise_response(): void { $sa = \test_question_maker::make_question('shortanswer'); $summary = $sa->summarise_response(array('answer' => 'dog')); $this->assertEquals('dog', $summary); } - public function test_classify_response() { + public function test_classify_response(): void { $sa = \test_question_maker::make_question('shortanswer'); $sa->start_attempt(new question_attempt_step(), 1); @@ -211,7 +211,7 @@ class question_test extends \advanced_testcase { $sa->classify_response(array('answer' => ''))); } - public function test_classify_response_no_star() { + public function test_classify_response_no_star(): void { $sa = \test_question_maker::make_question('shortanswer', 'frogonly'); $sa->start_attempt(new question_attempt_step(), 1); @@ -229,7 +229,7 @@ class question_test extends \advanced_testcase { /** * test_get_question_definition_for_external_rendering */ - public function test_get_question_definition_for_external_rendering() { + public function test_get_question_definition_for_external_rendering(): void { $this->resetAfterTest(); $question = \test_question_maker::make_question('shortanswer'); diff --git a/question/type/shortanswer/tests/question_type_test.php b/question/type/shortanswer/tests/question_type_test.php index a63728fcfb7..08d49389d69 100644 --- a/question/type/shortanswer/tests/question_type_test.php +++ b/question/type/shortanswer/tests/question_type_test.php @@ -53,21 +53,21 @@ class question_type_test extends \advanced_testcase { return \test_question_maker::get_question_data('shortanswer'); } - public function test_name() { + public function test_name(): void { $this->assertEquals($this->qtype->name(), 'shortanswer'); } - public function test_can_analyse_responses() { + public function test_can_analyse_responses(): void { $this->assertTrue($this->qtype->can_analyse_responses()); } - public function test_get_random_guess_score() { + public function test_get_random_guess_score(): void { $q = \test_question_maker::get_question_data('shortanswer'); $q->options->answers[15]->fraction = 0.1; $this->assertEquals(0.1, $this->qtype->get_random_guess_score($q)); } - public function test_get_possible_responses() { + public function test_get_possible_responses(): void { $q = \test_question_maker::get_question_data('shortanswer'); $this->assertEquals(array( @@ -80,7 +80,7 @@ class question_type_test extends \advanced_testcase { ), $this->qtype->get_possible_responses($q)); } - public function test_get_possible_responses_no_star() { + public function test_get_possible_responses_no_star(): void { $q = \test_question_maker::get_question_data('shortanswer', 'frogonly'); $this->assertEquals(array( @@ -92,7 +92,7 @@ class question_type_test extends \advanced_testcase { ), $this->qtype->get_possible_responses($q)); } - public function test_question_saving_frogtoad() { + public function test_question_saving_frogtoad(): void { $this->resetAfterTest(true); $this->setAdminUser(); @@ -140,7 +140,7 @@ class question_type_test extends \advanced_testcase { } } - public function test_question_saving_trims_answers() { + public function test_question_saving_trims_answers(): void { $this->resetAfterTest(true); $this->setAdminUser(); diff --git a/question/type/shortanswer/tests/upgrade_old_attempt_data_test.php b/question/type/shortanswer/tests/upgrade_old_attempt_data_test.php index d002d721b3d..64d4aab21af 100644 --- a/question/type/shortanswer/tests/upgrade_old_attempt_data_test.php +++ b/question/type/shortanswer/tests/upgrade_old_attempt_data_test.php @@ -31,7 +31,7 @@ require_once($CFG->dirroot . '/question/engine/upgrade/tests/helper.php'); */ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base { - public function test_shortanswer_deferredfeedback_history620() { + public function test_shortanswer_deferredfeedback_history620(): void { $quiz = (object) array( 'id' => '221', 'course' => '187', @@ -240,7 +240,7 @@ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base $this->compare_qas($expectedqa, $qa); } - public function test_shortanswer_deferredfeedback_history60() { + public function test_shortanswer_deferredfeedback_history60(): void { $quiz = (object) array( 'id' => '789', 'course' => '3500', @@ -413,7 +413,7 @@ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base $this->compare_qas($expectedqa, $qa); } - public function test_shortanswer_deferredfeedback_history3220() { + public function test_shortanswer_deferredfeedback_history3220(): void { $quiz = (object) array( 'id' => '221', 'course' => '187', diff --git a/question/type/tests/question_definition_test.php b/question/type/tests/question_definition_test.php index aeafe70fa86..4248154d014 100644 --- a/question/type/tests/question_definition_test.php +++ b/question/type/tests/question_definition_test.php @@ -29,7 +29,7 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php'); * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class question_definition_test extends \advanced_testcase { - public function test_make_html_inline() { + public function test_make_html_inline(): void { // Base class is abstract, so we need to pick one qusetion type to test this method. $mc = \test_question_maker::make_a_multichoice_single_question(); $this->assertEquals('Frog', $mc->make_html_inline('

Frog

')); diff --git a/question/type/tests/question_first_matching_answer_grading_strategy_test.php b/question/type/tests/question_first_matching_answer_grading_strategy_test.php index b515c943438..1071f8dd0d7 100644 --- a/question/type/tests/question_first_matching_answer_grading_strategy_test.php +++ b/question/type/tests/question_first_matching_answer_grading_strategy_test.php @@ -68,20 +68,20 @@ class question_first_matching_answer_grading_strategy_test extends \advanced_tes protected function tearDown(): void { } - public function test_no_answers_gives_null() { + public function test_no_answers_gives_null(): void { $question = new test_response_answer_comparer(array()); $strategy = new question_first_matching_answer_grading_strategy($question); $this->assertNull($strategy->grade(array())); } - public function test_matching_answer_returned1() { + public function test_matching_answer_returned1(): void { $answer = new question_answer(0, 'frog', 1, '', FORMAT_HTML); $question = new test_response_answer_comparer(array($answer)); $strategy = new question_first_matching_answer_grading_strategy($question); $this->assertSame($answer, $strategy->grade(array('answer' => 'frog'))); } - public function test_matching_answer_returned2() { + public function test_matching_answer_returned2(): void { $answer = new question_answer(0, 'frog', 1, '', FORMAT_HTML); $answer2 = new question_answer(0, 'frog', 0.5, '', FORMAT_HTML); $question = new test_response_answer_comparer(array($answer, $answer2)); @@ -89,7 +89,7 @@ class question_first_matching_answer_grading_strategy_test extends \advanced_tes $this->assertSame($answer, $strategy->grade(array('answer' => 'frog'))); } - public function test_no_matching_answer_gives_null() { + public function test_no_matching_answer_gives_null(): void { $answer = new question_answer(0, 'frog', 1, '', FORMAT_HTML); $answer2 = new question_answer(0, 'frog', 0.5, '', FORMAT_HTML); $question = new test_response_answer_comparer(array($answer, $answer2)); diff --git a/question/type/tests/question_hint_test.php b/question/type/tests/question_hint_test.php index 7978764e1fe..223cb4e5dcc 100644 --- a/question/type/tests/question_hint_test.php +++ b/question/type/tests/question_hint_test.php @@ -32,7 +32,7 @@ require_once($CFG->dirroot . '/question/type/questiontypebase.php'); * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class question_hint_test extends \advanced_testcase { - public function test_basic() { + public function test_basic(): void { $row = new \stdClass(); $row->id = 123; $row->hint = 'A hint'; @@ -43,7 +43,7 @@ class question_hint_test extends \advanced_testcase { $this->assertEquals($row->hintformat, $hint->hintformat); } - public function test_with_parts() { + public function test_with_parts(): void { $row = new \stdClass(); $row->id = 123; $row->hint = 'A hint'; diff --git a/question/type/tests/question_type_test.php b/question/type/tests/question_type_test.php index 59fe3daa33c..921899c6491 100644 --- a/question/type/tests/question_type_test.php +++ b/question/type/tests/question_type_test.php @@ -34,7 +34,7 @@ require_once($CFG->dirroot . '/question/type/questiontypebase.php'); * @covers \question_type */ class question_type_test extends \advanced_testcase { - public function test_save_question_name() { + public function test_save_question_name(): void { $this->resetAfterTest(); $questiongenerator = $this->getDataGenerator()->get_plugin_generator('core_question'); @@ -47,7 +47,7 @@ class question_type_test extends \advanced_testcase { $this->assertSame('Test question', $actual->name); } - public function test_save_question_zero_name() { + public function test_save_question_zero_name(): void { $this->resetAfterTest(); $questiongenerator = $this->getDataGenerator()->get_plugin_generator('core_question'); diff --git a/question/type/truefalse/tests/question_test.php b/question/type/truefalse/tests/question_test.php index 6060ecfda50..7f0f6525dab 100644 --- a/question/type/truefalse/tests/question_test.php +++ b/question/type/truefalse/tests/question_test.php @@ -35,7 +35,7 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php'); * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class question_test extends \advanced_testcase { - public function test_is_complete_response() { + public function test_is_complete_response(): void { $question = \test_question_maker::make_question('truefalse', 'true'); $this->assertFalse($question->is_complete_response(array())); @@ -43,7 +43,7 @@ class question_test extends \advanced_testcase { $this->assertTrue($question->is_complete_response(array('answer' => 1))); } - public function test_is_gradable_response() { + public function test_is_gradable_response(): void { $question = \test_question_maker::make_question('truefalse', 'true'); $this->assertFalse($question->is_gradable_response(array())); @@ -51,7 +51,7 @@ class question_test extends \advanced_testcase { $this->assertTrue($question->is_gradable_response(array('answer' => 1))); } - public function test_grading() { + public function test_grading(): void { $question = \test_question_maker::make_question('truefalse', 'true'); $this->assertEquals(array(0, question_state::$gradedwrong), @@ -60,7 +60,7 @@ class question_test extends \advanced_testcase { $question->grade_response(array('answer' => 1))); } - public function test_get_correct_response() { + public function test_get_correct_response(): void { $question = \test_question_maker::make_question('truefalse', 'true'); // True. @@ -73,13 +73,13 @@ class question_test extends \advanced_testcase { $question->get_correct_response()); } - public function test_get_question_summary() { + public function test_get_question_summary(): void { $tf = \test_question_maker::make_question('truefalse', 'true'); $qsummary = $tf->get_question_summary(); $this->assertEquals('The answer is true.', $qsummary); } - public function test_summarise_response() { + public function test_summarise_response(): void { $tf = \test_question_maker::make_question('truefalse', 'true'); $this->assertEquals(get_string('false', 'qtype_truefalse'), @@ -89,7 +89,7 @@ class question_test extends \advanced_testcase { $tf->summarise_response(array('answer' => '1'))); } - public function test_classify_response() { + public function test_classify_response(): void { $tf = \test_question_maker::make_question('truefalse', 'true'); $tf->start_attempt(new question_attempt_step(), 1); @@ -109,7 +109,7 @@ class question_test extends \advanced_testcase { /** * test_get_question_definition_for_external_rendering */ - public function test_get_question_definition_for_external_rendering() { + public function test_get_question_definition_for_external_rendering(): void { $this->resetAfterTest(); $question = \test_question_maker::make_question('truefalse', 'true'); diff --git a/question/type/truefalse/tests/question_type_test.php b/question/type/truefalse/tests/question_type_test.php index 239718ff82c..e0ec3fdcb66 100644 --- a/question/type/truefalse/tests/question_type_test.php +++ b/question/type/truefalse/tests/question_type_test.php @@ -47,19 +47,19 @@ class question_type_test extends \advanced_testcase { $this->qtype = null; } - public function test_name() { + public function test_name(): void { $this->assertEquals($this->qtype->name(), 'truefalse'); } - public function test_can_analyse_responses() { + public function test_can_analyse_responses(): void { $this->assertTrue($this->qtype->can_analyse_responses()); } - public function test_get_random_guess_score() { + public function test_get_random_guess_score(): void { $this->assertEquals(0.5, $this->qtype->get_random_guess_score(null)); } - public function test_load_question() { + public function test_load_question(): void { $this->resetAfterTest(); $syscontext = \context_system::instance(); @@ -117,7 +117,7 @@ class question_type_test extends \advanced_testcase { $this->assertEquals([], $questiondata->hints); } - public function test_get_possible_responses() { + public function test_get_possible_responses(): void { $q = new \stdClass(); $q->id = 1; $q->options = new \stdClass(); @@ -134,7 +134,7 @@ class question_type_test extends \advanced_testcase { ), $this->qtype->get_possible_responses($q)); } - public function test_question_saving_true() { + public function test_question_saving_true(): void { $this->resetAfterTest(true); $this->setAdminUser(); diff --git a/question/type/truefalse/tests/upgrade_old_attempt_data_test.php b/question/type/truefalse/tests/upgrade_old_attempt_data_test.php index 17b8002b652..f1f69231e0d 100644 --- a/question/type/truefalse/tests/upgrade_old_attempt_data_test.php +++ b/question/type/truefalse/tests/upgrade_old_attempt_data_test.php @@ -31,7 +31,7 @@ require_once($CFG->dirroot . '/question/engine/upgrade/tests/helper.php'); */ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base { - public function test_truefalse_deferredfeedback_history620() { + public function test_truefalse_deferredfeedback_history620(): void { $quiz = (object) array( 'id' => '203', 'course' => '2359', @@ -220,7 +220,7 @@ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base $this->compare_qas($expectedqa, $qa); } - public function test_truefalse_deferredfeedback_history20() { + public function test_truefalse_deferredfeedback_history20(): void { $quiz = (object) array( 'id' => '551', 'course' => '2828', @@ -398,7 +398,7 @@ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base $this->compare_qas($expectedqa, $qa); } - public function test_truefalse_deferredfeedback_history90() { + public function test_truefalse_deferredfeedback_history90(): void { $quiz = (object) array( 'id' => '3', 'course' => '1095', @@ -574,7 +574,7 @@ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base $this->compare_qas($expectedqa, $qa); } - public function test_truefalse_adaptive_qsession119() { + public function test_truefalse_adaptive_qsession119(): void { $quiz = (object) array( 'id' => '6', 'course' => '3', @@ -764,7 +764,7 @@ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base $this->compare_qas($expectedqa, $qa); } - public function test_truefalse_adaptive_qsession120() { + public function test_truefalse_adaptive_qsession120(): void { $quiz = (object) array( 'id' => '6', 'course' => '3', @@ -953,7 +953,7 @@ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base $this->compare_qas($expectedqa, $qa); } - public function test_truefalse_adaptive_qsession3() { + public function test_truefalse_adaptive_qsession3(): void { $quiz = (object) array( 'id' => '1', 'course' => '2', diff --git a/question/type/truefalse/tests/walkthrough_test.php b/question/type/truefalse/tests/walkthrough_test.php index 94bb1166ccb..bbe1406f626 100644 --- a/question/type/truefalse/tests/walkthrough_test.php +++ b/question/type/truefalse/tests/walkthrough_test.php @@ -33,7 +33,7 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php'); * @covers \qtype_truefalse_question */ class walkthrough_test extends \qbehaviour_walkthrough_test_base { - public function test_false_right_does_not_show_feedback_when_not_answered() { + public function test_false_right_does_not_show_feedback_when_not_answered(): void { // Create a true-false question with correct answer false. $tf = \test_question_maker::make_question('truefalse', 'false'); @@ -68,7 +68,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { } - public function test_each_attempt_builds_on_last_and_regrade() { + public function test_each_attempt_builds_on_last_and_regrade(): void { // Create a true-false question with correct answer false. $tf = \test_question_maker::make_question('truefalse', 'false'); @@ -128,7 +128,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { /** * @covers \qtype_truefalse_renderer::formulation_and_controls */ - public function test_deferredfeedback_feedback_multichoice_single_showstandardinstruction_yes() { + public function test_deferredfeedback_feedback_multichoice_single_showstandardinstruction_yes(): void { // Create a true-false question with correct answer false. $tf = \test_question_maker::make_question('truefalse', 'false'); @@ -145,7 +145,7 @@ class walkthrough_test extends \qbehaviour_walkthrough_test_base { /** * @covers \qtype_truefalse_renderer::formulation_and_controls */ - public function test_deferredfeedback_feedback_multichoice_single_showstandardinstruction_no() { + public function test_deferredfeedback_feedback_multichoice_single_showstandardinstruction_no(): void { // Create a true-false question with correct answer false. $tf = \test_question_maker::make_question('truefalse', 'false'); diff --git a/rating/tests/externallib_test.php b/rating/tests/externallib_test.php index e4890ed1f76..344f831eedf 100644 --- a/rating/tests/externallib_test.php +++ b/rating/tests/externallib_test.php @@ -132,7 +132,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_item_ratings */ - public function test_get_item_ratings() { + public function test_get_item_ratings(): void { global $DB; // Rete the discussion as teacher1. @@ -242,7 +242,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test add_rating */ - public function test_add_rating() { + public function test_add_rating(): void { $this->setUser($this->teacher1); // First rating of 50. diff --git a/rating/tests/privacy/provider_test.php b/rating/tests/privacy/provider_test.php index d605c74f54d..b1c06215eea 100644 --- a/rating/tests/privacy/provider_test.php +++ b/rating/tests/privacy/provider_test.php @@ -70,7 +70,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Ensure that the get_sql_join function returns valid SQL which returns the correct list of rated itemids. */ - public function test_get_sql_join() { + public function test_get_sql_join(): void { global $DB; $this->resetAfterTest(); @@ -158,7 +158,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { * Ensure that the get_sql_join function returns valid SQL which returns the correct list of rated itemids. * This makes use of the optional inner join argument. */ - public function test_get_sql_join_inner() { + public function test_get_sql_join_inner(): void { global $DB; $this->resetAfterTest(); @@ -245,7 +245,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Ensure that export_area_ratings exports all ratings that a user has made, and all ratings for a users own content. */ - public function test_export_area_ratings() { + public function test_export_area_ratings(): void { global $DB; $this->resetAfterTest(); @@ -343,7 +343,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test delete_ratings() method. */ - public function test_delete_ratings() { + public function test_delete_ratings(): void { global $DB; $this->resetAfterTest(); @@ -390,7 +390,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test delete_ratings_select() method. */ - public function test_delete_ratings_select() { + public function test_delete_ratings_select(): void { global $DB; $this->resetAfterTest(); diff --git a/rating/tests/rating_test.php b/rating/tests/rating_test.php index b2fa6a55d15..1b80720aa16 100644 --- a/rating/tests/rating_test.php +++ b/rating/tests/rating_test.php @@ -52,7 +52,7 @@ class rating_test extends \advanced_testcase { /** * Test the current get_ratings method main sql */ - public function test_get_ratings_sql() { + public function test_get_ratings_sql(): void { global $DB; // We load 3 items. Each is rated twice. For simplicity itemid == user id of the item owner. @@ -345,7 +345,7 @@ class rating_test extends \advanced_testcase { * * @dataProvider get_aggregate_string_provider */ - public function test_get_aggregate_string($method, $aggregate, $isnumeric, $scaleitems, $expectation) { + public function test_get_aggregate_string($method, $aggregate, $isnumeric, $scaleitems, $expectation): void { $options = new \stdClass(); $options->aggregate = $aggregate; $options->context = null; diff --git a/report/completion/tests/event/events_test.php b/report/completion/tests/event/events_test.php index c3b58673e61..4626027df60 100644 --- a/report/completion/tests/event/events_test.php +++ b/report/completion/tests/event/events_test.php @@ -49,7 +49,7 @@ class events_test extends \advanced_testcase { * It's not possible to use the moodle API to simulate the viewing of log report, so here we * simply create the event and trigger it. */ - public function test_report_viewed() { + public function test_report_viewed(): void { $course = $this->getDataGenerator()->create_course(); $context = \context_course::instance($course->id); // Trigger event for completion report viewed. @@ -74,7 +74,7 @@ class events_test extends \advanced_testcase { * It's not possible to use the moodle API to simulate the viewing of log report, so here we * simply create the event and trigger it. */ - public function test_user_report_viewed() { + public function test_user_report_viewed(): void { $course = $this->getDataGenerator()->create_course(); $context = \context_course::instance($course->id); // Trigger event for completion report viewed. diff --git a/report/insights/tests/externallib_test.php b/report/insights/tests/externallib_test.php index 0013668b336..3593cc58d94 100644 --- a/report/insights/tests/externallib_test.php +++ b/report/insights/tests/externallib_test.php @@ -41,7 +41,7 @@ class externallib_test extends \advanced_testcase { /** * test_action_executed */ - public function test_action_executed() { + public function test_action_executed(): void { global $DB; $this->setAdminUser(); diff --git a/report/log/tests/event/events_test.php b/report/log/tests/event/events_test.php index c5ff682ba7d..b0abfcf8097 100644 --- a/report/log/tests/event/events_test.php +++ b/report/log/tests/event/events_test.php @@ -49,7 +49,7 @@ class events_test extends \advanced_testcase { * It's not possible to use the moodle API to simulate the viewing of log report, so here we * simply create the event and trigger it. */ - public function test_report_viewed() { + public function test_report_viewed(): void { $course = $this->getDataGenerator()->create_course(); $context = \context_course::instance($course->id); @@ -77,7 +77,7 @@ class events_test extends \advanced_testcase { * It's not possible to use the moodle API to simulate the viewing of user log report, so here we * simply create the event and trigger it. */ - public function test_user_report_viewed() { + public function test_user_report_viewed(): void { $user = $this->getDataGenerator()->create_user(); $course = $this->getDataGenerator()->create_course(); $context = \context_course::instance($course->id); diff --git a/report/log/tests/lib_test.php b/report/log/tests/lib_test.php index c3984cf12c2..0e1985c5dc2 100644 --- a/report/log/tests/lib_test.php +++ b/report/log/tests/lib_test.php @@ -61,7 +61,7 @@ class lib_test extends \advanced_testcase { /** * Test report_log_supports_logstore. */ - public function test_report_log_supports_logstore() { + public function test_report_log_supports_logstore(): void { $logmanager = get_log_manager(); $allstores = \core_component::get_plugin_list_with_class('logstore', 'log\store'); @@ -82,7 +82,7 @@ class lib_test extends \advanced_testcase { /** * Tests the report_log_myprofile_navigation() function as an admin viewing the logs for a user. */ - public function test_report_log_myprofile_navigation() { + public function test_report_log_myprofile_navigation(): void { // Set as the admin. $this->setAdminUser(); $iscurrentuser = false; @@ -98,7 +98,7 @@ class lib_test extends \advanced_testcase { /** * Tests the report_log_myprofile_navigation() function as a user without permission. */ - public function test_report_log_myprofile_navigation_without_permission() { + public function test_report_log_myprofile_navigation_without_permission(): void { // Set to the other user. $this->setUser($this->user); $iscurrentuser = true; diff --git a/report/loglive/tests/event/events_test.php b/report/loglive/tests/event/events_test.php index cb57595a785..5a57cb038ca 100644 --- a/report/loglive/tests/event/events_test.php +++ b/report/loglive/tests/event/events_test.php @@ -49,7 +49,7 @@ class events_test extends \advanced_testcase { * It's not possible to use the moodle API to simulate the viewing of log report, so here we * simply create the event and trigger it. */ - public function test_report_viewed() { + public function test_report_viewed(): void { $course = $this->getDataGenerator()->create_course(); $context = \context_course::instance($course->id); // Trigger event for loglive report viewed. diff --git a/report/loglive/tests/lib_test.php b/report/loglive/tests/lib_test.php index 5698bfc75ac..44e05514716 100644 --- a/report/loglive/tests/lib_test.php +++ b/report/loglive/tests/lib_test.php @@ -37,7 +37,7 @@ class lib_test extends \advanced_testcase { /** * Test report_log_supports_logstore. */ - public function test_report_participation_supports_logstore() { + public function test_report_participation_supports_logstore(): void { $logmanager = get_log_manager(); $allstores = \core_component::get_plugin_list_with_class('logstore', 'log\store'); @@ -59,7 +59,7 @@ class lib_test extends \advanced_testcase { * * @covers ::get_until() */ - public function test_report_get_until() { + public function test_report_get_until(): void { global $DB; $this->resetAfterTest(); $this->preventResetByRollback(); diff --git a/report/outline/tests/lib_test.php b/report/outline/tests/lib_test.php index bffc1fc2dbf..d88ed6d4efe 100644 --- a/report/outline/tests/lib_test.php +++ b/report/outline/tests/lib_test.php @@ -73,7 +73,7 @@ class lib_test extends \advanced_testcase { /** * Test report_log_supports_logstore. */ - public function test_report_participation_supports_logstore() { + public function test_report_participation_supports_logstore(): void { $logmanager = get_log_manager(); $allstores = \core_component::get_plugin_list_with_class('logstore', 'log\store'); @@ -93,7 +93,7 @@ class lib_test extends \advanced_testcase { /** * Tests the report_outline_myprofile_navigation() function as an admin user. */ - public function test_report_outline_myprofile_navigation() { + public function test_report_outline_myprofile_navigation(): void { $this->setAdminUser(); $iscurrentuser = false; @@ -107,7 +107,7 @@ class lib_test extends \advanced_testcase { /** * Tests the report_outline_myprofile_navigation() function as a user without permission. */ - public function test_report_outline_myprofile_navigation_without_permission() { + public function test_report_outline_myprofile_navigation_without_permission(): void { $this->setUser($this->user); $iscurrentuser = true; @@ -121,7 +121,7 @@ class lib_test extends \advanced_testcase { /** * Test that the current user can not access user report without report/outline:viewuserreport permission. */ - public function test_report_outline_can_not_access_user_report_without_viewuserreport_permission() { + public function test_report_outline_can_not_access_user_report_without_viewuserreport_permission(): void { $this->getDataGenerator()->role_assign($this->roleid, $this->user->id, $this->coursecontext->id); $this->setUser($this->user); @@ -131,7 +131,7 @@ class lib_test extends \advanced_testcase { /** * Test that the current user can access user report with report/outline:viewuserreport permission. */ - public function test_report_outline_can_access_user_report_with_viewuserreport_permission() { + public function test_report_outline_can_access_user_report_with_viewuserreport_permission(): void { assign_capability('report/outline:viewuserreport', CAP_ALLOW, $this->roleid, $this->coursecontext->id, true); $this->getDataGenerator()->role_assign($this->roleid, $this->user->id, $this->coursecontext->id); $this->setUser($this->user); diff --git a/report/participation/tests/lib_test.php b/report/participation/tests/lib_test.php index fd4cc371e2d..68ee91e1fb1 100644 --- a/report/participation/tests/lib_test.php +++ b/report/participation/tests/lib_test.php @@ -37,7 +37,7 @@ class lib_test extends \advanced_testcase { /** * Test report_log_supports_logstore. */ - public function test_report_participation_supports_logstore() { + public function test_report_participation_supports_logstore(): void { $logmanager = get_log_manager(); $allstores = \core_component::get_plugin_list_with_class('logstore', 'log\store'); diff --git a/report/questioninstances/tests/event/events_test.php b/report/questioninstances/tests/event/events_test.php index 9704ea31b30..5fe917bc8b5 100644 --- a/report/questioninstances/tests/event/events_test.php +++ b/report/questioninstances/tests/event/events_test.php @@ -44,7 +44,7 @@ class events_test extends \advanced_testcase { /** * Test the report viewed event. */ - public function test_report_viewed() { + public function test_report_viewed(): void { $requestedqtype = 'all'; $event = \report_questioninstances\event\report_viewed::create(array('other' => array('requestedqtype' => $requestedqtype))); diff --git a/report/stats/tests/event/events_test.php b/report/stats/tests/event/events_test.php index c4034d31ffd..4c302777029 100644 --- a/report/stats/tests/event/events_test.php +++ b/report/stats/tests/event/events_test.php @@ -49,7 +49,7 @@ class events_test extends \advanced_testcase { * It's not possible to use the moodle API to simulate the viewing of stats report, so here we * simply create the event and trigger it. */ - public function test_report_viewed() { + public function test_report_viewed(): void { $user = $this->getDataGenerator()->create_user(); $course = $this->getDataGenerator()->create_course(); $context = \context_course::instance($course->id); @@ -75,7 +75,7 @@ class events_test extends \advanced_testcase { * It's not possible to use the moodle API to simulate the viewing of user stats report, so here we * simply create the event and trigger it. */ - public function test_user_report_viewed() { + public function test_user_report_viewed(): void { $user = $this->getDataGenerator()->create_user(); $course = $this->getDataGenerator()->create_course(); $context = \context_course::instance($course->id); diff --git a/report/stats/tests/lib_test.php b/report/stats/tests/lib_test.php index f0d901b3042..2624a37f35e 100644 --- a/report/stats/tests/lib_test.php +++ b/report/stats/tests/lib_test.php @@ -59,7 +59,7 @@ class lib_test extends \advanced_testcase { /** * Test report_log_supports_logstore. */ - public function test_report_participation_supports_logstore() { + public function test_report_participation_supports_logstore(): void { $logmanager = get_log_manager(); $allstores = \core_component::get_plugin_list_with_class('logstore', 'log\store'); @@ -79,7 +79,7 @@ class lib_test extends \advanced_testcase { /** * Tests the report_stats_myprofile_navigation() function. */ - public function test_report_stats_myprofile_navigation() { + public function test_report_stats_myprofile_navigation(): void { $this->setAdminUser(); $iscurrentuser = false; @@ -95,7 +95,7 @@ class lib_test extends \advanced_testcase { /** * Tests the report_stats_myprofile_navigation() function when stats are disabled. */ - public function test_report_stats_myprofile_navigation_stats_disabled() { + public function test_report_stats_myprofile_navigation_stats_disabled(): void { $this->setAdminUser(); $iscurrentuser = false; @@ -111,7 +111,7 @@ class lib_test extends \advanced_testcase { /** * Tests the report_stats_myprofile_navigation() function without permission. */ - public function test_report_stats_myprofile_navigation_without_permission() { + public function test_report_stats_myprofile_navigation_without_permission(): void { // Try to see as a user without permission. $this->setUser($this->user); $iscurrentuser = true; diff --git a/report/stats/tests/privacy/provider_test.php b/report/stats/tests/privacy/provider_test.php index f538eb61e13..8e93d1369c6 100644 --- a/report/stats/tests/privacy/provider_test.php +++ b/report/stats/tests/privacy/provider_test.php @@ -61,7 +61,7 @@ class provider_test extends provider_testcase { /** * Get all of the contexts related to a user and stat tables. */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { $this->resetAfterTest(); $user1 = $this->getDataGenerator()->create_user(); $user2 = $this->getDataGenerator()->create_user(); @@ -93,7 +93,7 @@ class provider_test extends provider_testcase { /** * Test that stat data is exported as required. */ - public function test_export_user_data() { + public function test_export_user_data(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); $course1 = $this->getDataGenerator()->create_course(); @@ -130,7 +130,7 @@ class provider_test extends provider_testcase { /** * Test that stat data is deleted for a whole context. */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; $this->resetAfterTest(); @@ -169,7 +169,7 @@ class provider_test extends provider_testcase { /** * Test that stats are deleted for one user. */ - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; $this->resetAfterTest(); @@ -209,7 +209,7 @@ class provider_test extends provider_testcase { /** * Test that only users within a course context are fetched. */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { $this->resetAfterTest(); $component = 'report_stats'; @@ -257,7 +257,7 @@ class provider_test extends provider_testcase { /** * Test that data for users in approved userlist is deleted. */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { $this->resetAfterTest(); $component = 'report_stats'; diff --git a/report/usersessions/tests/lib_test.php b/report/usersessions/tests/lib_test.php index 7e0962995b2..d9d2f969eae 100644 --- a/report/usersessions/tests/lib_test.php +++ b/report/usersessions/tests/lib_test.php @@ -63,7 +63,7 @@ class lib_test extends \advanced_testcase { /** * Tests the report_userssesions_myprofile_navigation() function as an admin. */ - public function test_report_usersessions_myprofile_navigation_as_admin() { + public function test_report_usersessions_myprofile_navigation_as_admin(): void { $this->setAdminUser(); $iscurrentuser = false; @@ -77,7 +77,7 @@ class lib_test extends \advanced_testcase { /** * Tests the report_userssesions_myprofile_navigation() function as the currently logged in user. */ - public function test_report_usersessions_myprofile_navigation_as_current_user() { + public function test_report_usersessions_myprofile_navigation_as_current_user(): void { $this->setUser($this->user); $iscurrentuser = true; @@ -90,7 +90,7 @@ class lib_test extends \advanced_testcase { /** * Tests the report_userssesions_myprofile_navigation() function as a guest. */ - public function test_report_usersessions_myprofile_navigation_as_guest() { + public function test_report_usersessions_myprofile_navigation_as_guest(): void { $this->setGuestUser(); $iscurrentuser = true; @@ -103,7 +103,7 @@ class lib_test extends \advanced_testcase { /** * Tests the report_userssesions_myprofile_navigation() function as a user without permission. */ - public function test_report_usersessions_myprofile_navigation_without_permission() { + public function test_report_usersessions_myprofile_navigation_without_permission(): void { // Try to see as a user without permission. $user2 = $this->getDataGenerator()->create_user(); $this->setUser($user2); diff --git a/repository/contentbank/tests/browser_test.php b/repository/contentbank/tests/browser_test.php index b7e6cafe0d5..3185e260be5 100644 --- a/repository/contentbank/tests/browser_test.php +++ b/repository/contentbank/tests/browser_test.php @@ -36,7 +36,7 @@ class browser_test extends \advanced_testcase { * within the system context. By default, every authenticated user should be able to access/view the content in * the system context. */ - public function test_get_content_system_context_user_has_capabilities() { + public function test_get_content_system_context_user_has_capabilities(): void { global $DB, $CFG; $this->resetAfterTest(true); @@ -125,7 +125,7 @@ class browser_test extends \advanced_testcase { * content within the system context. By default, every non-authenticated user should not be able to access/view * the content in the system context. */ - public function test_get_content_system_context_user_missing_capabilities() { + public function test_get_content_system_context_user_missing_capabilities(): void { $this->resetAfterTest(true); $systemcontext = \context_system::instance(); @@ -150,7 +150,7 @@ class browser_test extends \advanced_testcase { * bank content within the course category context. By default, every authenticated user that has access to * any category course should be able to access/view the content in the course category context. */ - public function test_get_content_course_category_context_user_has_capabilities() { + public function test_get_content_course_category_context_user_has_capabilities(): void { global $CFG; $this->resetAfterTest(true); @@ -222,7 +222,7 @@ class browser_test extends \advanced_testcase { * that cannot access/view course content from the course category should not be able to access/view the * content in the course category context. */ - public function test_get_content_course_category_context_user_missing_capabilities() { + public function test_get_content_course_category_context_user_missing_capabilities(): void { $this->resetAfterTest(true); // Create a course category 'Category'. @@ -274,7 +274,7 @@ class browser_test extends \advanced_testcase { * bank content within the course context. By default, admin, managers, course creators, editing teachers enrolled * in the course should be able to access/view the content. */ - public function test_get_content_course_context_user_has_capabilities() { + public function test_get_content_course_context_user_has_capabilities(): void { global $CFG; $this->resetAfterTest(true); @@ -323,7 +323,7 @@ class browser_test extends \advanced_testcase { * bank content within the course context. By default, every user which is not an admin, manager, course creator, * editing teacher enrolled in the course should not be able to access/view the content. */ - public function test_get_content_course_context_user_missing_capabilities() { + public function test_get_content_course_context_user_missing_capabilities(): void { $this->resetAfterTest(true); // Create course1. @@ -369,7 +369,7 @@ class browser_test extends \advanced_testcase { /** * Test get_navigation() in the system context. */ - public function test_get_navigation_system_context() { + public function test_get_navigation_system_context(): void { $this->resetAfterTest(true); $systemcontext = \context_system::instance(); @@ -387,7 +387,7 @@ class browser_test extends \advanced_testcase { /** * Test get_navigation() in the course category context. */ - public function test_get_navigation_course_category_context() { + public function test_get_navigation_course_category_context(): void { $this->resetAfterTest(true); $systemcontext = \context_system::instance(); @@ -427,7 +427,7 @@ class browser_test extends \advanced_testcase { /** * Test get_navigation() in the course context. */ - public function test_get_navigation_course_context() { + public function test_get_navigation_course_context(): void { $this->resetAfterTest(true); $systemcontext = \context_system::instance(); diff --git a/repository/contentbank/tests/search/search_test.php b/repository/contentbank/tests/search/search_test.php index 8cba994618e..1ea14b9037f 100644 --- a/repository/contentbank/tests/search/search_test.php +++ b/repository/contentbank/tests/search/search_test.php @@ -139,7 +139,7 @@ class search_test extends \advanced_testcase { * all existing content bank content. By default, admins, managers should be able to view every existing content * that matches the search criteria. */ - public function test_get_search_contents_user_can_access_all_content() { + public function test_get_search_contents_user_can_access_all_content(): void { $this->resetAfterTest(true); // Create a course in default category by default. @@ -183,7 +183,7 @@ class search_test extends \advanced_testcase { * the search criteria AND is in the courses they are enrolled, course categories of the enrolled courses * and system content. Other authenticated users should be able to access only the system content. */ - public function test_get_search_contents_user_can_access_certain_content() { + public function test_get_search_contents_user_can_access_certain_content(): void { global $CFG; $this->resetAfterTest(true); diff --git a/repository/dropbox/tests/api_test.php b/repository/dropbox/tests/api_test.php index 1d2635f7c92..ea436006878 100644 --- a/repository/dropbox/tests/api_test.php +++ b/repository/dropbox/tests/api_test.php @@ -74,7 +74,7 @@ class api_test extends \advanced_testcase { * @param object $result The data to test * @param bool $expected The expected result */ - public function test_has_additional_results($result, $expected) { + public function test_has_additional_results($result, $expected): void { $mock = $this->getMockBuilder(\repository_dropbox\dropbox::class) ->disableOriginalConstructor() ->onlyMethods([]) @@ -150,7 +150,7 @@ class api_test extends \advanced_testcase { * @param string $exception The name of the expected exception * @param string $exceptionmessage The expected message in the exception */ - public function test_check_and_handle_api_errors($info, $data, $exception, $exceptionmessage) { + public function test_check_and_handle_api_errors($info, $data, $exception, $exceptionmessage): void { $mock = $this->getMockBuilder(\repository_dropbox\dropbox::class) ->disableOriginalConstructor() ->onlyMethods([]) @@ -244,7 +244,7 @@ class api_test extends \advanced_testcase { * @param object $entry The entry to test * @param bool $expected Whether this entry supports thumbnail generation */ - public function test_supports_thumbnail($entry, $expected) { + public function test_supports_thumbnail($entry, $expected): void { $mock = $this->getMockBuilder(\repository_dropbox\dropbox::class) ->disableOriginalConstructor() ->onlyMethods([]) @@ -256,7 +256,7 @@ class api_test extends \advanced_testcase { /** * Test that the logout makes a call to the correct revocation endpoint. */ - public function test_logout_revocation() { + public function test_logout_revocation(): void { $mock = $this->getMockBuilder(\repository_dropbox\dropbox::class) ->disableOriginalConstructor() ->onlyMethods(['fetch_dropbox_data']) @@ -272,7 +272,7 @@ class api_test extends \advanced_testcase { /** * Test that the logout function catches authentication_exception exceptions and discards them. */ - public function test_logout_revocation_catch_auth_exception() { + public function test_logout_revocation_catch_auth_exception(): void { $mock = $this->getMockBuilder(\repository_dropbox\dropbox::class) ->disableOriginalConstructor() ->onlyMethods(['fetch_dropbox_data']) @@ -288,7 +288,7 @@ class api_test extends \advanced_testcase { /** * Test that the logout function does not catch any other exception. */ - public function test_logout_revocation_does_not_catch_other_exceptions() { + public function test_logout_revocation_does_not_catch_other_exceptions(): void { $mock = $this->getMockBuilder(\repository_dropbox\dropbox::class) ->disableOriginalConstructor() ->onlyMethods(['fetch_dropbox_data']) @@ -305,7 +305,7 @@ class api_test extends \advanced_testcase { /** * Test basic fetch_dropbox_data function. */ - public function test_fetch_dropbox_data_endpoint() { + public function test_fetch_dropbox_data_endpoint(): void { $mock = $this->getMockBuilder(\repository_dropbox\dropbox::class) ->disableOriginalConstructor() ->onlyMethods([ @@ -392,7 +392,7 @@ class api_test extends \advanced_testcase { /** * When more results are available, these should be fetched until there are no more. */ - public function test_fetch_dropbox_data_recurse_on_additional_records() { + public function test_fetch_dropbox_data_recurse_on_additional_records(): void { $mock = $this->getMockBuilder(\repository_dropbox\dropbox::class) ->disableOriginalConstructor() ->onlyMethods([ @@ -499,7 +499,7 @@ class api_test extends \advanced_testcase { /** * Test that the get_file_share_info function returns an existing link if one is available. */ - public function test_get_file_share_info_existing() { + public function test_get_file_share_info_existing(): void { $mock = $this->getMockBuilder(\repository_dropbox\dropbox::class) ->disableOriginalConstructor() ->onlyMethods([ @@ -532,7 +532,7 @@ class api_test extends \advanced_testcase { /** * Test that the get_file_share_info function creates a new link if one is not available. */ - public function test_get_file_share_info_new() { + public function test_get_file_share_info_new(): void { $mock = $this->getMockBuilder(\repository_dropbox\dropbox::class) ->disableOriginalConstructor() ->onlyMethods([ @@ -573,7 +573,7 @@ class api_test extends \advanced_testcase { /** * Test failure behaviour with get_file_share_info fails to create a new link. */ - public function test_get_file_share_info_new_failure() { + public function test_get_file_share_info_new_failure(): void { $mock = $this->getMockBuilder(\repository_dropbox\dropbox::class) ->disableOriginalConstructor() ->onlyMethods([ diff --git a/repository/flickr/tests/privacy/provider_test.php b/repository/flickr/tests/privacy/provider_test.php index 544cec329cf..ebb4ccbad40 100644 --- a/repository/flickr/tests/privacy/provider_test.php +++ b/repository/flickr/tests/privacy/provider_test.php @@ -47,7 +47,7 @@ class provider_test extends provider_testcase { /** * Test for provider::export_user_preferences(). */ - public function test_export_user_preferences() { + public function test_export_user_preferences(): void { global $DB; // Test setup. diff --git a/repository/googledocs/tests/googledocs_search_content_test.php b/repository/googledocs/tests/googledocs_search_content_test.php index 5dbedae124c..e3d807f452f 100644 --- a/repository/googledocs/tests/googledocs_search_content_test.php +++ b/repository/googledocs/tests/googledocs_search_content_test.php @@ -43,7 +43,7 @@ class googledocs_search_content_test extends \googledocs_content_testcase { * @param array $expected The expected array which contains the generated repository content nodes */ public function test_get_content_nodes(string $query, bool $sortcontent, array $filterextensions, - array $shareddrives, array $searccontents, array $expected) { + array $shareddrives, array $searccontents, array $expected): void { // Mock the service object. $servicemock = $this->createMock(rest::class); diff --git a/repository/googledocs/tests/helper_test.php b/repository/googledocs/tests/helper_test.php index 64c32d8ce06..2cf59fffae2 100644 --- a/repository/googledocs/tests/helper_test.php +++ b/repository/googledocs/tests/helper_test.php @@ -40,7 +40,7 @@ class helper_test extends \repository_googledocs_testcase { * @param string $rootpath The path to append the node on * @param string $expected The expected node path */ - public function test_build_node_path(string $id, string $name, string $rootpath, string $expected) { + public function test_build_node_path(string $id, string $name, string $rootpath, string $expected): void { // Assert that the returned node path is equal to the expected one. $this->assertEquals($expected, helper::build_node_path($id, $name, $rootpath)); } @@ -95,7 +95,7 @@ class helper_test extends \repository_googledocs_testcase { * @param string $node The node string to extract information from * @param array $expected The expected array containing the information about the node */ - public function test_explode_node_path(string $node, array $expected) { + public function test_explode_node_path(string $node, array $expected): void { // Assert that the returned array is equal to the expected one. $this->assertEquals($expected, helper::explode_node_path($node)); } @@ -140,7 +140,7 @@ class helper_test extends \repository_googledocs_testcase { * @param string $nodepath The node path string * @param string $expected The expected browser class */ - public function test_get_browser(string $nodepath, string $expected) { + public function test_get_browser(string $nodepath, string $expected): void { // The service (rest API) object is required by get_browser(), but not being used to determine which browser // object should be returned. Therefore, we can simply mock this object in this test. $servicemock = $this->createMock(rest::class); @@ -192,7 +192,7 @@ class helper_test extends \repository_googledocs_testcase { * @param \stdClass $gdcontent The Google Drive content (file/folder) object * @param string $expected The expected content node class */ - public function test_get_node(\stdClass $gdcontent, string $expected) { + public function test_get_node(\stdClass $gdcontent, string $expected): void { // The path is required by get_content_node(), but not being used to determine which content node // object should be returned. Therefore, we can just generate a dummy path. $path = \repository_googledocs::REPOSITORY_ROOT_ID . '|Google+Drive|' . @@ -232,7 +232,7 @@ class helper_test extends \repository_googledocs_testcase { * @param \Exception $exception The exception thrown by the API call * @param \Exception $expected The expected exception thrown by request() */ - public function test_request_exception(\Exception $exception, \Exception $expected) { + public function test_request_exception(\Exception $exception, \Exception $expected): void { // Mock the service object. $servicemock = $this->createMock(rest::class); diff --git a/repository/googledocs/tests/local/browser/googledocs_drive_content_test.php b/repository/googledocs/tests/local/browser/googledocs_drive_content_test.php index ad5e43e331f..a5aa162009f 100644 --- a/repository/googledocs/tests/local/browser/googledocs_drive_content_test.php +++ b/repository/googledocs/tests/local/browser/googledocs_drive_content_test.php @@ -44,7 +44,7 @@ class googledocs_drive_content_test extends \googledocs_content_testcase { * @param array $expected The expected array which contains the generated repository content nodes */ public function test_get_content_nodes(string $query, string $path, bool $sortcontent, array $filterextensions, - array $shareddrives, array $drivecontents, array $expected) { + array $shareddrives, array $drivecontents, array $expected): void { // Mock the service object. $servicemock = $this->createMock(\repository_googledocs\rest::class); @@ -201,7 +201,7 @@ class googledocs_drive_content_test extends \googledocs_content_testcase { * @param string $nodepath The node path string * @param array $expected The expected array containing the repository navigation nodes */ - public function test_get_navigation(string $nodepath, array $expected) { + public function test_get_navigation(string $nodepath, array $expected): void { // Mock the service object. $servicemock = $this->createMock(\repository_googledocs\rest::class); diff --git a/repository/googledocs/tests/local/browser/googledocs_root_content_test.php b/repository/googledocs/tests/local/browser/googledocs_root_content_test.php index 0ec0b70dff8..5d51190ac71 100644 --- a/repository/googledocs/tests/local/browser/googledocs_root_content_test.php +++ b/repository/googledocs/tests/local/browser/googledocs_root_content_test.php @@ -38,7 +38,7 @@ class googledocs_root_content_test extends \googledocs_content_testcase { * @param array $shareddrives The array containing the existing shared drives * @param array $expected The expected array which contains the generated repository content nodes */ - public function test_get_content_nodes(array $shareddrives, array $expected) { + public function test_get_content_nodes(array $shareddrives, array $expected): void { // Mock the service object. $servicemock = $this->createMock(\repository_googledocs\rest::class); diff --git a/repository/googledocs/tests/local/browser/googledocs_shared_drives_content_test.php b/repository/googledocs/tests/local/browser/googledocs_shared_drives_content_test.php index 93e1fc4288b..94ea029c9dd 100644 --- a/repository/googledocs/tests/local/browser/googledocs_shared_drives_content_test.php +++ b/repository/googledocs/tests/local/browser/googledocs_shared_drives_content_test.php @@ -39,7 +39,7 @@ class googledocs_shared_drives_content_test extends \googledocs_content_testcase * @param bool $sortcontent Whether the contents should be sorted in alphabetical order * @param array $expected The expected array which contains the generated repository content nodes */ - public function test_get_content_nodes(array $shareddrives, bool $sortcontent, array $expected) { + public function test_get_content_nodes(array $shareddrives, bool $sortcontent, array $expected): void { // Mock the service object. $servicemock = $this->createMock(\repository_googledocs\rest::class); diff --git a/repository/googledocs/tests/local/node/file_node_test.php b/repository/googledocs/tests/local/node/file_node_test.php index 188341c15d9..177bedc3268 100644 --- a/repository/googledocs/tests/local/node/file_node_test.php +++ b/repository/googledocs/tests/local/node/file_node_test.php @@ -38,7 +38,7 @@ class file_node_test extends \repository_googledocs_testcase { * @param array $configsettings The googledoc repository config settings that should be set * @param array|null $expected The expected repository file node array */ - public function test_create_node_array(\stdClass $gdfile, array $configsettings, ?array $expected) { + public function test_create_node_array(\stdClass $gdfile, array $configsettings, ?array $expected): void { $this->resetAfterTest(); // Set the required config settings. array_walk($configsettings, function($value, $name) { diff --git a/repository/googledocs/tests/local/node/folder_node_test.php b/repository/googledocs/tests/local/node/folder_node_test.php index 51a2ad7a33e..d041b367797 100644 --- a/repository/googledocs/tests/local/node/folder_node_test.php +++ b/repository/googledocs/tests/local/node/folder_node_test.php @@ -38,7 +38,7 @@ class folder_node_test extends \repository_googledocs_testcase { * @param string $path The current path * @param array $expected The expected repository folder node array */ - public function test_create_node_array(\stdClass $gdfolder, string $path, array $expected) { + public function test_create_node_array(\stdClass $gdfolder, string $path, array $expected): void { $foldernode = new folder_node($gdfolder, $path); $foldernodearray = $foldernode->create_node_array(); // Assert that the returned repository folder node array by create_node_array() is equal to the expected one. diff --git a/repository/nextcloud/tests/access_controlled_link_manager_test.php b/repository/nextcloud/tests/access_controlled_link_manager_test.php index 502329cd55c..79584fe8ecc 100644 --- a/repository/nextcloud/tests/access_controlled_link_manager_test.php +++ b/repository/nextcloud/tests/access_controlled_link_manager_test.php @@ -92,7 +92,7 @@ class access_controlled_link_manager_test extends \advanced_testcase { /** * Function to test the private function create_share_user_sysaccount. */ - public function test_create_share_user_sysaccount_user_shares() { + public function test_create_share_user_sysaccount_user_shares(): void { $params = [ 'path' => "/ambient.txt", 'shareType' => \repository_nextcloud\ocs_client::SHARE_TYPE_USER, @@ -150,7 +150,7 @@ XML; * Test the delete_share_function. In case the request fails, the function throws an exception, however this * can not be tested in phpUnit since it is javascript. */ - public function test_delete_share_dataowner_sysaccount() { + public function test_delete_share_dataowner_sysaccount(): void { $shareid = 5; $deleteshareparams = [ 'share_id' => $shareid @@ -176,7 +176,7 @@ XML; * Function which test that create folder path does return the adequate results (path and success). * Additionally mock checks whether the right params are passed to the corresponding functions. */ - public function test_create_folder_path_folders_are_not_created() { + public function test_create_folder_path_folders_are_not_created(): void { $mocks = $this->set_up_mocks_for_create_folder_path(true, 'somename'); $this->set_private_property($mocks['mockclient'], 'systemwebdavclient', $this->linkmanager); @@ -188,7 +188,7 @@ XML; * Function which test that create folder path does return the adequate results (path and success). * Additionally mock checks whether the right params are passed to the corresponding functions. */ - public function test_create_folder_path_folders_are_created() { + public function test_create_folder_path_folders_are_created(): void { // In Context is okay, number of context counts for number of iterations. $mocks = $this->set_up_mocks_for_create_folder_path(false, 'somename/withslash', true, 201); @@ -200,7 +200,7 @@ XML; /** * Test whether the create_folder_path methode throws exception. */ - public function test_create_folder_path_folder_creation_fails() { + public function test_create_folder_path_folder_creation_fails(): void { $mocks = $this->set_up_mocks_for_create_folder_path(false, 'somename', true, 400); $this->set_private_property($mocks['mockclient'], 'systemwebdavclient', $this->linkmanager); @@ -243,7 +243,7 @@ XML; * Test whether the right methods from the webdavclient are called when the storage_folder is created. * 1. Directory already exist -> no further action needed. */ - public function test_create_storage_folder_success() { + public function test_create_storage_folder_success(): void { $mockwebdavclient = $this->createMock(\webdav_client::class); $url = $this->issuer->get_endpoint_url('webdav'); $parsedwebdavurl = parse_url($url); @@ -259,7 +259,7 @@ XML; * 2. Directory does not exist. It is created with mkcol and returns a success. * */ - public function test_create_storage_folder_success_mkcol() { + public function test_create_storage_folder_success_mkcol(): void { $mockwebdavclient = $this->createMock(\webdav_client::class); $url = $this->issuer->get_endpoint_url('webdav'); $parsedwebdavurl = parse_url($url); @@ -275,7 +275,7 @@ XML; * Test whether the right methods from the webdavclient are called when the storage_folder is created. * 3. Request to create Folder fails. */ - public function test_create_storage_folder_failure() { + public function test_create_storage_folder_failure(): void { $mockwebdavclient = $this->createMock(\webdav_client::class); $url = $this->issuer->get_endpoint_url('webdav'); $parsedwebdavurl = parse_url($url); @@ -290,7 +290,7 @@ XML; /** * Test whether the webdav client gets the right params and whether function differentiates between move and copy. */ - public function test_transfer_file_to_path_copyfile() { + public function test_transfer_file_to_path_copyfile(): void { // Initialize params. $parsedwebdavurl = parse_url($this->issuer->get_endpoint_url('webdav')); $webdavprefix = $parsedwebdavurl['path']; @@ -314,7 +314,7 @@ XML; * * @covers \repository_nextcloud\access_controlled_link_manager::transfer_file_to_path */ - public function test_transfer_file_to_path_overwritefile() { + public function test_transfer_file_to_path_overwritefile(): void { // Initialize params. $parsedwebdavurl = parse_url($this->issuer->get_endpoint_url('webdav')); $webdavprefix = $parsedwebdavurl['path']; @@ -338,7 +338,7 @@ XML; * It tests whether the webdav_client gets the right parameter and whether function distinguishes between move and copy. * */ - public function test_transfer_file_to_path_copyfile_movefile() { + public function test_transfer_file_to_path_copyfile_movefile(): void { // Initialize params. $parsedwebdavurl = parse_url($this->issuer->get_endpoint_url('webdav')); $webdavprefix = $parsedwebdavurl['path']; @@ -363,7 +363,7 @@ XML; * for user1 is extracted then for user2 and last but least whether an error is thrown if the user does not have a share. * @throws moodle_exception */ - public function test_get_shares_from_path() { + public function test_get_shares_from_path(): void { $params = [ 'path' => '/Kernsystem/Kursbereich Miscellaneous/Kurs Example Course/Datei zet/mod_resource/content/0/picture.png', 'reshares' => true @@ -456,7 +456,7 @@ XML; * @throws \repository_nextcloud\configuration_exception * @throws coding_exception */ - public function test_create_system_dav() { + public function test_create_system_dav(): void { // Initialize mock and params. $fakeaccesstoken = new \stdClass(); $fakeaccesstoken->token = "fake access token"; @@ -512,7 +512,7 @@ XML; * @throws \repository_nextcloud\request_exception * @throws coding_exception */ - public function test_get_share_information_from_shareid() { + public function test_get_share_information_from_shareid(): void { $params303 = [ 'share_id' => 303, ]; diff --git a/repository/nextcloud/tests/lib_test.php b/repository/nextcloud/tests/lib_test.php index a0d20e8a315..f6ae5ba85e3 100644 --- a/repository/nextcloud/tests/lib_test.php +++ b/repository/nextcloud/tests/lib_test.php @@ -87,7 +87,7 @@ class lib_test extends \advanced_testcase { /** * Checks the is_visible method in case the repository is set to hidden in the database. */ - public function test_is_visible_parent_false() { + public function test_is_visible_parent_false(): void { global $DB; $id = $this->repo->options['typeid']; @@ -101,7 +101,7 @@ class lib_test extends \advanced_testcase { /** * Test whether the repo is disabled. */ - public function test_repo_creation() { + public function test_repo_creation(): void { $issuerid = $this->repo->get_option('issuerid'); // Config saves the right id. @@ -137,7 +137,7 @@ class lib_test extends \advanced_testcase { /** * Test if repository is disabled when webdav_endpoint is deleted. */ - public function test_issuer_webdav() { + public function test_issuer_webdav(): void { $idwebdav = $this->get_endpoint_id('webdav_endpoint'); if (!empty($idwebdav)) { foreach ($idwebdav as $id) { @@ -149,7 +149,7 @@ class lib_test extends \advanced_testcase { /** * Test if repository is disabled when ocs_endpoint is deleted. */ - public function test_issuer_ocs() { + public function test_issuer_ocs(): void { $idocs = $this->get_endpoint_id('ocs_endpoint'); if (!empty($idocs)) { foreach ($idocs as $id) { @@ -162,7 +162,7 @@ class lib_test extends \advanced_testcase { /** * Test if repository is disabled when userinfo_endpoint is deleted. */ - public function test_issuer_userinfo() { + public function test_issuer_userinfo(): void { $idtoken = $this->get_endpoint_id('userinfo_endpoint'); if (!empty($idtoken)) { foreach ($idtoken as $id) { @@ -175,7 +175,7 @@ class lib_test extends \advanced_testcase { /** * Test if repository is disabled when token_endpoint is deleted. */ - public function test_issuer_token() { + public function test_issuer_token(): void { $idtoken = $this->get_endpoint_id('token_endpoint'); if (!empty($idtoken)) { foreach ($idtoken as $id) { @@ -188,7 +188,7 @@ class lib_test extends \advanced_testcase { /** * Test if repository is disabled when auth_endpoint is deleted. */ - public function test_issuer_authorization() { + public function test_issuer_authorization(): void { $idauth = $this->get_endpoint_id('authorization_endpoint'); if (!empty($idauth)) { foreach ($idauth as $id) { @@ -200,14 +200,14 @@ class lib_test extends \advanced_testcase { /** * Test if repository throws an error when endpoint does not exist. */ - public function test_parse_endpoint_url_error() { + public function test_parse_endpoint_url_error(): void { $this->expectException(\repository_nextcloud\configuration_exception::class); \repository_nextcloud\issuer_management::parse_endpoint_url('notexisting', $this->issuer); } /** * Test get_listing method with an example directory. Tests error cases. */ - public function test_get_listing_error() { + public function test_get_listing_error(): void { $ret = $this->get_initialised_return_array(); $this->setUser(); // WebDAV socket is not opened. @@ -228,7 +228,7 @@ class lib_test extends \advanced_testcase { /** * Test get_listing method with an example directory. Tests the root directory. */ - public function test_get_listing_root() { + public function test_get_listing_root(): void { $this->setUser(); $ret = $this->get_initialised_return_array(); @@ -292,7 +292,7 @@ class lib_test extends \advanced_testcase { * Test get_listing method with an example directory. Tests a different directory than the root * directory. */ - public function test_get_listing_directory() { + public function test_get_listing_directory(): void { $ret = $this->get_initialised_return_array(); $this->setUser(); @@ -361,7 +361,7 @@ class lib_test extends \advanced_testcase { /** * Test the get_link method. */ - public function test_get_link_success() { + public function test_get_link_success(): void { $mock = $this->getMockBuilder(\repository_nextcloud\ocs_client::class)->disableOriginalConstructor()->disableOriginalClone( )->getMock(); $file = '/datei'; @@ -421,7 +421,7 @@ XML; /** * get_link can get OCS failure responses. Test that this is handled appropriately. */ - public function test_get_link_failure() { + public function test_get_link_failure(): void { $mock = $this->getMockBuilder(\repository_nextcloud\ocs_client::class)->disableOriginalConstructor()->disableOriginalClone( )->getMock(); $file = '/datei'; @@ -461,7 +461,7 @@ XML; /** * get_link can get OCS responses that are not actually XML. Test that this is handled appropriately. */ - public function test_get_link_problem() { + public function test_get_link_problem(): void { $mock = $this->getMockBuilder(\repository_nextcloud\ocs_client::class)->disableOriginalConstructor()->disableOriginalClone( )->getMock(); $file = '/datei'; @@ -491,14 +491,14 @@ JSON; /** * Test get_file reference, merely returns the input if no optional_param is set. */ - public function test_get_file_reference_withoutoptionalparam() { + public function test_get_file_reference_withoutoptionalparam(): void { $this->assertEquals('/somefile', $this->repo->get_file_reference('/somefile')); } /** * Test logout. */ - public function test_logout() { + public function test_logout(): void { $mock = $this->createMock(\core\oauth2\client::class); $mock->expects($this->exactly(2))->method('log_out'); @@ -518,7 +518,7 @@ JSON; /** * Test for the get_file method from the repository_nextcloud class. */ - public function test_get_file() { + public function test_get_file(): void { // WebDAV socket is not open. $mock = $this->createMock(\webdav_client::class); $mock->expects($this->once())->method('open')->will($this->returnValue(false)); @@ -540,7 +540,7 @@ JSON; /** * Test callback. */ - public function test_callback() { + public function test_callback(): void { $mock = $this->createMock(\core\oauth2\client::class); // Should call check_login exactly once. $mock->expects($this->once())->method('log_out'); @@ -553,7 +553,7 @@ JSON; /** * Test check_login. */ - public function test_check_login() { + public function test_check_login(): void { $mock = $this->createMock(\core\oauth2\client::class); $mock->expects($this->once())->method('is_logged_in')->will($this->returnValue(true)); $this->set_private_property($mock, 'client'); @@ -563,7 +563,7 @@ JSON; /** * Test print_login. */ - public function test_print_login() { + public function test_print_login(): void { $mock = $this->createMock(\core\oauth2\client::class); $mock->expects($this->exactly(2))->method('get_login_url')->will($this->returnValue(new \moodle_url('url'))); $this->set_private_property($mock, 'client'); @@ -592,7 +592,7 @@ JSON; /** * Test the initiate_webdavclient function. */ - public function test_initiate_webdavclient() { + public function test_initiate_webdavclient(): void { global $CFG; $idwebdav = $this->get_endpoint_id('webdav_endpoint'); @@ -629,7 +629,7 @@ JSON; * FILE_INTERNAL | FILE_REFERENCE when no system account is connected. * FILE_INTERNAL | FILE_CONTROLLED_LINK | FILE_REFERENCE when a system account is connected. */ - public function test_supported_returntypes() { + public function test_supported_returntypes(): void { global $DB; $this->assertEquals(FILE_INTERNAL | FILE_REFERENCE, $this->repo->supported_returntypes()); $dataobject = new \stdClass(); @@ -654,7 +654,7 @@ JSON; * function are tested. * */ - public function test_reference_file_selected_error() { + public function test_reference_file_selected_error(): void { $this->repo->disabled = true; $this->expectException(\repository_exception::class); $this->repo->reference_file_selected('', \context_system::instance(), '', '', ''); @@ -714,7 +714,7 @@ JSON; /** * Test the send_file function for access controlled links. */ - public function test_send_file_errors() { + public function test_send_file_errors(): void { $fs = get_file_storage(); $storedfile = $fs->create_file_from_reference([ 'contextid' => \context_system::instance()->id, diff --git a/repository/nextcloud/tests/ocs_test.php b/repository/nextcloud/tests/ocs_test.php index 8982b8fe419..e787852c6e5 100644 --- a/repository/nextcloud/tests/ocs_test.php +++ b/repository/nextcloud/tests/ocs_test.php @@ -48,7 +48,7 @@ class ocs_test extends \advanced_testcase { /** * Test whether required REST API functions are declared. */ - public function test_api_functions() { + public function test_api_functions(): void { $mock = $this->createMock(\core\oauth2\client::class); $mock->expects($this->once())->method('get_issuer')->willReturn($this->issuer); diff --git a/repository/onedrive/tests/privacy/provider_test.php b/repository/onedrive/tests/privacy/provider_test.php index 6b988f24a93..df11a0f0c8c 100644 --- a/repository/onedrive/tests/privacy/provider_test.php +++ b/repository/onedrive/tests/privacy/provider_test.php @@ -47,7 +47,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::get_contexts_for_userid(). */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { global $DB; // Test setup. @@ -90,7 +90,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::test_get_users_in_context(). */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { global $DB; $component = 'repository_onedrive'; @@ -159,7 +159,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::export_user_data(). */ - public function test_export_user_data() { + public function test_export_user_data(): void { global $DB; // Test setup. @@ -212,7 +212,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::delete_data_for_all_users_in_context(). */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; // Test setup. @@ -260,7 +260,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::delete_data_for_user(). */ - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; // Test setup. @@ -329,7 +329,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::delete_data_for_users(). */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { global $DB; $component = 'repository_onedrive'; diff --git a/repository/recent/tests/lib_test.php b/repository/recent/tests/lib_test.php index 270e1f841aa..291adbdf5fc 100644 --- a/repository/recent/tests/lib_test.php +++ b/repository/recent/tests/lib_test.php @@ -63,7 +63,7 @@ class lib_test extends \advanced_testcase { /** * Test get listing */ - public function test_get_listing_with_duplicate_file() { + public function test_get_listing_with_duplicate_file(): void { global $itemid; $this->resetAfterTest(true); @@ -93,7 +93,7 @@ class lib_test extends \advanced_testcase { /** * Test get listing reference file */ - public function test_get_listing_with_reference_file() { + public function test_get_listing_with_reference_file(): void { $this->resetAfterTest(true); // Create test file 1. $file1 = $this->create_test_file('TestFile1', 'private'); @@ -114,7 +114,7 @@ class lib_test extends \advanced_testcase { /** * Test number limit */ - public function test_get_listing_number_limit() { + public function test_get_listing_number_limit(): void { $this->resetAfterTest(true); $this->create_multiple_test_files('private', 75); $filelist = $this->repo->get_listing()['list']; @@ -131,7 +131,7 @@ class lib_test extends \advanced_testcase { /** * Test time limit */ - public function test_get_listing_time_limit() { + public function test_get_listing_time_limit(): void { $this->resetAfterTest(true); $this->create_multiple_test_files('private', 25); $file1 = $this->create_test_file('TestFileTimeLimit', 'private'); diff --git a/repository/tests/generator_test.php b/repository/tests/generator_test.php index aea74f8cd97..560ae6f7d44 100644 --- a/repository/tests/generator_test.php +++ b/repository/tests/generator_test.php @@ -42,7 +42,7 @@ class generator_test extends \advanced_testcase { * * @return void */ - public function test_create_type() { + public function test_create_type(): void { global $DB; $this->resetAfterTest(true); @@ -83,7 +83,7 @@ class generator_test extends \advanced_testcase { * * @return void */ - public function test_create_type_custom_options() { + public function test_create_type_custom_options(): void { global $DB; $this->resetAfterTest(true); @@ -153,7 +153,7 @@ class generator_test extends \advanced_testcase { * * @return void */ - public function test_create_instance() { + public function test_create_instance(): void { global $DB; $this->resetAfterTest(true); diff --git a/repository/tests/privacy/provider_test.php b/repository/tests/privacy/provider_test.php index d6b4b845663..5b71b4aa236 100644 --- a/repository/tests/privacy/provider_test.php +++ b/repository/tests/privacy/provider_test.php @@ -49,7 +49,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::get_contexts_for_userid(). */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { // Test setup. $user = $this->getDataGenerator()->create_user(); $this->setUser($user); @@ -76,7 +76,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::export_user_data(). */ - public function test_export_user_data() { + public function test_export_user_data(): void { // Test setup. $user = $this->getDataGenerator()->create_user(); $this->setUser($user); @@ -108,7 +108,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::delete_data_for_all_users_in_context(). */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; // Test setup. @@ -138,7 +138,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test for provider::delete_data_for_user(). */ - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; // Test setup. @@ -169,7 +169,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test that only users with a user context are fetched. */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { $this->resetAfterTest(); $component = 'core_repository'; @@ -201,7 +201,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test that data for users in approved userlist is deleted. */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { $this->resetAfterTest(); $component = 'core_repository'; diff --git a/repository/tests/repositorylib_test.php b/repository/tests/repositorylib_test.php index 10416016bcd..e7d8aef6bc5 100644 --- a/repository/tests/repositorylib_test.php +++ b/repository/tests/repositorylib_test.php @@ -40,7 +40,7 @@ class repositorylib_test extends \advanced_testcase { * * @copyright 2012 Dongsheng Cai {@link http://dongsheng.org} */ - public function test_install_repository() { + public function test_install_repository(): void { global $CFG, $DB; $this->resetAfterTest(true); @@ -64,7 +64,7 @@ class repositorylib_test extends \advanced_testcase { $this->assertEquals($repositorypluginname, $info->type); } - public function test_get_unused_filename() { + public function test_get_unused_filename(): void { global $USER; $this->resetAfterTest(true); @@ -118,7 +118,7 @@ class repositorylib_test extends \advanced_testcase { $this->assertEquals('test4 (1).txt', repository::get_unused_filename($draftitemid, '/', 'test4 (1).txt')); } - public function test_draftfile_exists() { + public function test_draftfile_exists(): void { global $USER; $this->resetAfterTest(true); @@ -159,7 +159,7 @@ class repositorylib_test extends \advanced_testcase { } } - public function test_delete_selected_files() { + public function test_delete_selected_files(): void { global $USER; $this->resetAfterTest(true); @@ -213,7 +213,7 @@ class repositorylib_test extends \advanced_testcase { $this->assertEquals(2, count($areafiles)); } - public function test_can_be_edited_by_user() { + public function test_can_be_edited_by_user(): void { $this->resetAfterTest(true); $syscontext = \context_system::instance(); @@ -293,7 +293,7 @@ class repositorylib_test extends \advanced_testcase { } - public function test_check_capability() { + public function test_check_capability(): void { $this->resetAfterTest(true); $syscontext = \context_system::instance(); @@ -518,7 +518,7 @@ class repositorylib_test extends \advanced_testcase { $this->assertTrue($notprivaterepo->check_capability()); } - function test_delete_all_for_context() { + function test_delete_all_for_context(): void { global $DB; $this->resetAfterTest(true); @@ -623,7 +623,7 @@ class repositorylib_test extends \advanced_testcase { $fs->create_file_from_string($filerecord, hash("md5", $filepath . $filename)); } - public function test_listing_and_filter() { + public function test_listing_and_filter(): void { $this->resetAfterTest(true); $this->setUser($this->getDataGenerator()->create_user()); $repoid = $this->getDataGenerator()->create_repository('user')->id; diff --git a/repository/url/tests/lib_test.php b/repository/url/tests/lib_test.php index e26aabf2578..75c69e13a4a 100644 --- a/repository/url/tests/lib_test.php +++ b/repository/url/tests/lib_test.php @@ -40,7 +40,7 @@ class lib_test extends \advanced_testcase { /** * Check that the url escaper performs as expected */ - public function test_escape_url() { + public function test_escape_url(): void { $this->resetAfterTest(); $repoid = $this->getDataGenerator()->create_repository('url')->id; diff --git a/rss/tests/privacy/provider_test.php b/rss/tests/privacy/provider_test.php index c44f4125940..ca8a3612ac9 100644 --- a/rss/tests/privacy/provider_test.php +++ b/rss/tests/privacy/provider_test.php @@ -48,7 +48,7 @@ class provider_test extends provider_testcase { /** * Test getting the context for the user ID related to this plugin. */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { // Create user and RSS user keys. $user = $this->getDataGenerator()->create_user(); $context = \context_user::instance($user->id); @@ -61,7 +61,7 @@ class provider_test extends provider_testcase { /** * Test that data is exported correctly for this plugin. */ - public function test_export_user_data() { + public function test_export_user_data(): void { global $DB; // Create user and RSS user keys. @@ -84,7 +84,7 @@ class provider_test extends provider_testcase { /** * Test for provider::delete_data_for_all_users_in_context(). */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; // Create user and RSS user keys. @@ -108,7 +108,7 @@ class provider_test extends provider_testcase { /** * Test for provider::delete_data_for_user(). */ - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; // Create user and RSS user keys. @@ -134,7 +134,7 @@ class provider_test extends provider_testcase { /** * Test that only users with a user context are fetched. */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { $component = 'core_rss'; // Create a user. $user = $this->getDataGenerator()->create_user(); @@ -164,7 +164,7 @@ class provider_test extends provider_testcase { /** * Test that data for users in approved userlist is deleted. */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { $component = 'core_rss'; // Create a user1. $user1 = $this->getDataGenerator()->create_user(); diff --git a/search/engine/simpledb/tests/engine_test.php b/search/engine/simpledb/tests/engine_test.php index 22fdc0ff59e..7fa21c90105 100644 --- a/search/engine/simpledb/tests/engine_test.php +++ b/search/engine/simpledb/tests/engine_test.php @@ -93,7 +93,7 @@ class engine_test extends \advanced_testcase { * * @return void */ - public function test_index() { + public function test_index(): void { global $DB; $this->add_mock_search_area(); @@ -120,7 +120,7 @@ class engine_test extends \advanced_testcase { * * @return void */ - public function test_search() { + public function test_search(): void { global $USER, $DB; $this->add_mock_search_area(); @@ -207,7 +207,7 @@ class engine_test extends \advanced_testcase { * * @return void */ - public function test_delete() { + public function test_delete(): void { $this->add_mock_search_area(); @@ -232,7 +232,7 @@ class engine_test extends \advanced_testcase { * * @return void */ - public function test_alloweduserid() { + public function test_alloweduserid(): void { $this->add_mock_search_area(); @@ -306,7 +306,7 @@ class engine_test extends \advanced_testcase { $this->assertEquals($originalid, $results[0]->get('id')); } - public function test_delete_by_id() { + public function test_delete_by_id(): void { $this->add_mock_search_area(); @@ -338,7 +338,7 @@ class engine_test extends \advanced_testcase { /** * Tries out deleting data for a context or a course. */ - public function test_deleted_contexts_and_courses() { + public function test_deleted_contexts_and_courses(): void { // Create some courses and activities. $generator = $this->getDataGenerator(); $course1 = $generator->create_course(['fullname' => 'C1', 'summary' => 'xyzzy']); diff --git a/search/engine/simpledb/tests/privacy/provider_test.php b/search/engine/simpledb/tests/privacy/provider_test.php index 9bc628fb36f..b78ff9d96dd 100644 --- a/search/engine/simpledb/tests/privacy/provider_test.php +++ b/search/engine/simpledb/tests/privacy/provider_test.php @@ -146,7 +146,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test fetching contexts for a given user ID. */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { // Ensure both contexts are found for both users. $expected = [$this->c1context->id, $this->c2context->id]; sort($expected); @@ -171,7 +171,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test fetching user IDs for a given context. */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { $component = 'search_simpledb'; // Ensure both users are found for both contexts. @@ -202,7 +202,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { * * @return null */ - public function test_export_user_data() { + public function test_export_user_data(): void { global $DB; $contextlist = new \core_privacy\local\request\approved_contextlist($this->u1, 'search_simpledb', @@ -225,7 +225,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { * * @return null */ - public function test_delete_data_for_all_users() { + public function test_delete_data_for_all_users(): void { global $DB; $this->assertEquals(8, $DB->count_records('search_simpledb_index')); @@ -245,7 +245,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { * * @return null */ - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; $contextlist = new \core_privacy\local\request\approved_contextlist($this->u1, 'search_simpledb', @@ -270,7 +270,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Test deleting data for an approved userlist. */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { global $DB; $component = 'search_simpledb'; $select = 'contextid = :contextid AND (owneruserid = :owneruserid OR userid = :userid)'; diff --git a/search/engine/solr/tests/engine_test.php b/search/engine/solr/tests/engine_test.php index 7b52d2c97c7..fc3369479ae 100644 --- a/search/engine/solr/tests/engine_test.php +++ b/search/engine/solr/tests/engine_test.php @@ -150,14 +150,14 @@ class engine_test extends \advanced_testcase { ); } - public function test_connection() { + public function test_connection(): void { $this->assertTrue($this->engine->is_server_ready()); } /** * Tests that the alternate settings are used when configured. */ - public function test_alternate_settings() { + public function test_alternate_settings(): void { // Index a couple of things. $this->generator->create_record(); $this->generator->create_record(); @@ -196,7 +196,7 @@ class engine_test extends \advanced_testcase { /** * @dataProvider file_indexing_provider */ - public function test_index($fileindexing) { + public function test_index($fileindexing): void { global $DB; $this->engine->test_set_config('fileindexing', $fileindexing); @@ -225,7 +225,7 @@ class engine_test extends \advanced_testcase { * * @return void */ - public function test_search($fileindexing) { + public function test_search($fileindexing): void { global $USER, $DB; $this->engine->test_set_config('fileindexing', $fileindexing); @@ -307,7 +307,7 @@ class engine_test extends \advanced_testcase { /** * @dataProvider file_indexing_provider */ - public function test_delete($fileindexing) { + public function test_delete($fileindexing): void { $this->engine->test_set_config('fileindexing', $fileindexing); $this->generator->create_record(); @@ -327,7 +327,7 @@ class engine_test extends \advanced_testcase { /** * @dataProvider file_indexing_provider */ - public function test_alloweduserid($fileindexing) { + public function test_alloweduserid($fileindexing): void { $this->engine->test_set_config('fileindexing', $fileindexing); $area = new \core_mocksearch\search\mock_search_area(); @@ -402,7 +402,7 @@ class engine_test extends \advanced_testcase { /** * @dataProvider file_indexing_provider */ - public function test_highlight($fileindexing) { + public function test_highlight($fileindexing): void { global $PAGE; $this->engine->test_set_config('fileindexing', $fileindexing); @@ -428,7 +428,7 @@ class engine_test extends \advanced_testcase { $this->assertMatchesRegularExpression($regex, $exported['content']); } - public function test_export_file_for_engine() { + public function test_export_file_for_engine(): void { // Get area to work with. $areaid = \core_search\manager::generate_areaid('core_mocksearch', 'mock_search_area'); $area = \core_search\manager::get_search_area($areaid); @@ -451,7 +451,7 @@ class engine_test extends \advanced_testcase { $this->assertEquals(978310800, \search_solr\document::import_time_from_engine($filearray['modified'])); } - public function test_index_file() { + public function test_index_file(): void { // Very simple test. $file = $this->generator->create_file(); @@ -466,7 +466,7 @@ class engine_test extends \advanced_testcase { $this->assertCount(1, $this->search->search($querydata)); } - public function test_reindexing_files() { + public function test_reindexing_files(): void { // Get area to work with. $areaid = \core_search\manager::generate_areaid('core_mocksearch', 'mock_search_area'); $area = \core_search\manager::get_search_area($areaid); @@ -561,7 +561,7 @@ class engine_test extends \advanced_testcase { /** * Test indexing a file we don't consider indexable. */ - public function test_index_filtered_file() { + public function test_index_filtered_file(): void { // Get area to work with. $areaid = \core_search\manager::generate_areaid('core_mocksearch', 'mock_search_area'); $area = \core_search\manager::get_search_area($areaid); @@ -614,7 +614,7 @@ class engine_test extends \advanced_testcase { $this->assertCount(1, $this->search->search($querydata)); } - public function test_delete_by_id() { + public function test_delete_by_id(): void { // First get files in the index. $file = $this->generator->create_file(); $record = new \stdClass(); @@ -647,7 +647,7 @@ class engine_test extends \advanced_testcase { * * @dataProvider file_indexing_provider */ - public function test_solr_filling($fileindexing) { + public function test_solr_filling($fileindexing): void { $this->engine->test_set_config('fileindexing', $fileindexing); $user1 = self::getDataGenerator()->create_user(); @@ -730,7 +730,7 @@ class engine_test extends \advanced_testcase { * * @dataProvider file_indexing_provider */ - public function test_get_query_total_count($fileindexing) { + public function test_get_query_total_count($fileindexing): void { $this->engine->test_set_config('fileindexing', $fileindexing); $user = self::getDataGenerator()->create_user(); @@ -763,7 +763,7 @@ class engine_test extends \advanced_testcase { * * @dataProvider file_indexing_provider */ - public function test_manager_paged_search($fileindexing) { + public function test_manager_paged_search($fileindexing): void { $this->engine->test_set_config('fileindexing', $fileindexing); $user = self::getDataGenerator()->create_user(); @@ -797,7 +797,7 @@ class engine_test extends \advanced_testcase { /** * Tests searching for results restricted to context id. */ - public function test_context_restriction() { + public function test_context_restriction(): void { // Use real search areas. $this->search->clear_static(); $this->search->add_core_search_areas(); @@ -869,7 +869,7 @@ class engine_test extends \advanced_testcase { * Tests searching for results in groups, either by specified group ids or based on user * access permissions. */ - public function test_groups() { + public function test_groups(): void { global $USER; // Use real search areas. @@ -973,7 +973,7 @@ class engine_test extends \advanced_testcase { /** * Tests searching for results restricted to specific user id(s). */ - public function test_user_restriction() { + public function test_user_restriction(): void { // Use real search areas. $this->search->clear_static(); $this->search->add_core_search_areas(); @@ -1047,7 +1047,7 @@ class engine_test extends \advanced_testcase { /** * Tests searching for results containing words in italic text. (This used to fail.) */ - public function test_italics() { + public function test_italics(): void { global $USER; // Use real search areas. @@ -1126,7 +1126,7 @@ class engine_test extends \advanced_testcase { * Tests the get_supported_orders function for contexts where we can only use relevance * (system, category). */ - public function test_get_supported_orders_relevance_only() { + public function test_get_supported_orders_relevance_only(): void { global $DB; // System or category context: relevance only. @@ -1144,7 +1144,7 @@ class engine_test extends \advanced_testcase { * Tests the get_supported_orders function for contexts where we support location as well * (course, activity, block). */ - public function test_get_supported_orders_relevance_and_location() { + public function test_get_supported_orders_relevance_and_location(): void { global $DB; // Test with course context. @@ -1185,7 +1185,7 @@ class engine_test extends \advanced_testcase { /** * Tests ordering by relevance vs location. */ - public function test_ordering() { + public function test_ordering(): void { // Create 2 courses and 2 activities. $generator = $this->getDataGenerator(); $course1 = $generator->create_course(['fullname' => 'Course 1']); @@ -1234,7 +1234,7 @@ class engine_test extends \advanced_testcase { /** * Tests with bogus content (that can be entered into Moodle) to see if it crashes. */ - public function test_bogus_content() { + public function test_bogus_content(): void { $generator = $this->getDataGenerator(); $course1 = $generator->create_course(['fullname' => 'Course 1']); $course1context = \context_course::instance($course1->id); @@ -1288,7 +1288,7 @@ class engine_test extends \advanced_testcase { /** * Tries out deleting data for a context or a course. */ - public function test_deleted_contexts_and_courses() { + public function test_deleted_contexts_and_courses(): void { // Create some courses and activities. $generator = $this->getDataGenerator(); $course1 = $generator->create_course(['fullname' => 'Course 1']); @@ -1331,7 +1331,7 @@ class engine_test extends \advanced_testcase { /** * Specific test of the add_document_batch function (also used in many other tests). */ - public function test_add_document_batch() { + public function test_add_document_batch(): void { // Get a default document. $area = new \core_mocksearch\search\mock_search_area(); $record = $this->generator->create_record(); @@ -1374,7 +1374,7 @@ class engine_test extends \advanced_testcase { * Tests the batching logic, specifically the limit to 100 documents per * batch, and not batching very large documents. */ - public function test_batching() { + public function test_batching(): void { $area = new \core_mocksearch\search\mock_search_area(); $record = $this->generator->create_record(); $doc = $area->get_document($record); @@ -1431,7 +1431,7 @@ class engine_test extends \advanced_testcase { * documents if they are bigger than 1MB, and the maximum batch count is 100, * so the maximum size batch will be about 100 1MB documents. */ - public function test_add_document_batch_large() { + public function test_add_document_batch_large(): void { // This test is a bit slow and not that important to run every time... if (!PHPUNIT_LONGTEST) { $this->markTestSkipped('PHPUNIT_LONGTEST is not defined'); diff --git a/search/engine/solr/tests/privacy/provider_test.php b/search/engine/solr/tests/privacy/provider_test.php index e6b0f879f0e..7c7f361a478 100644 --- a/search/engine/solr/tests/privacy/provider_test.php +++ b/search/engine/solr/tests/privacy/provider_test.php @@ -36,7 +36,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { /** * Verify that a collection of metadata is returned for this component and that it just links to an external location. */ - public function test_get_metadata() { + public function test_get_metadata(): void { $collection = new \core_privacy\local\metadata\collection('search_solr'); $collection = \search_solr\privacy\provider::get_metadata($collection); $this->assertNotEmpty($collection); diff --git a/search/tests/area_category_test.php b/search/tests/area_category_test.php index 814f3fd3e14..e9f5e5f4465 100644 --- a/search/tests/area_category_test.php +++ b/search/tests/area_category_test.php @@ -66,7 +66,7 @@ class area_category_test extends \advanced_testcase { /** * Test default values. */ - public function test_default_values() { + public function test_default_values(): void { $category = new \core_search\area_category('test_name', 'test_visiblename'); $this->assertEquals('test_name', $category->get_name()); @@ -78,7 +78,7 @@ class area_category_test extends \advanced_testcase { /** * Test that all get functions work as expected. */ - public function test_getters() { + public function test_getters(): void { $category = new \core_search\area_category('test_name', 'test_visiblename', 4, $this->get_areas()); $this->assertEquals('test_name', $category->get_name()); @@ -95,7 +95,7 @@ class area_category_test extends \advanced_testcase { /** * Test that a list of areas could be set correctly. */ - public function test_list_of_areas_could_be_set() { + public function test_list_of_areas_could_be_set(): void { $category = new \core_search\area_category('test_name', 'test_visiblename'); $this->assertEquals([], $category->get_areas()); diff --git a/search/tests/base_activity_test.php b/search/tests/base_activity_test.php index ebd615e48d8..48f501686fd 100644 --- a/search/tests/base_activity_test.php +++ b/search/tests/base_activity_test.php @@ -108,7 +108,7 @@ class base_activity_test extends \advanced_testcase { /** * Test base activity get search fileareas */ - public function test_get_search_fileareas_base() { + public function test_get_search_fileareas_base(): void { $builder = $this->getMockBuilder('\core_search\base_activity'); $builder->disableOriginalConstructor(); @@ -122,7 +122,7 @@ class base_activity_test extends \advanced_testcase { /** * Test base attach files */ - public function test_attach_files_base() { + public function test_attach_files_base(): void { $filearea = 'intro'; $component = 'mod_forum'; $module = 'forum'; @@ -176,7 +176,7 @@ class base_activity_test extends \advanced_testcase { /** * Tests getting the recordset. */ - public function test_get_document_recordset() { + public function test_get_document_recordset(): void { global $USER, $DB; // Get all the forums to index (no restriction). @@ -285,7 +285,7 @@ class base_activity_test extends \advanced_testcase { /** * Tests the get_doc_url function. */ - public function test_get_doc_url() { + public function test_get_doc_url(): void { $area = new \mod_forum\search\activity(); $results = self::recordset_to_indexed_array($area->get_document_recordset()); @@ -299,7 +299,7 @@ class base_activity_test extends \advanced_testcase { /** * Tests the check_access function. */ - public function test_check_access() { + public function test_check_access(): void { global $CFG; require_once($CFG->dirroot . '/course/lib.php'); @@ -333,7 +333,7 @@ class base_activity_test extends \advanced_testcase { * Tests the module version of get_contexts_to_reindex, which is supposed to return all the * activity contexts in order of date added. */ - public function test_get_contexts_to_reindex() { + public function test_get_contexts_to_reindex(): void { global $DB; $this->resetAfterTest(); @@ -371,7 +371,7 @@ class base_activity_test extends \advanced_testcase { /** * Test document icon. */ - public function test_get_doc_icon() { + public function test_get_doc_icon(): void { $baseactivity = $this->getMockBuilder('\core_search\base_activity') ->disableOriginalConstructor() ->onlyMethods(array('get_module_name')) diff --git a/search/tests/base_block_test.php b/search/tests/base_block_test.php index 7ce367c960b..2b30d9b6821 100644 --- a/search/tests/base_block_test.php +++ b/search/tests/base_block_test.php @@ -32,7 +32,7 @@ class base_block_test extends \advanced_testcase { /** * Tests getting the name out of the class name. */ - public function test_get_block_name() { + public function test_get_block_name(): void { $area = new \block_mockblock\search\area(); $this->assertEquals('mockblock', $area->get_block_name()); } @@ -40,7 +40,7 @@ class base_block_test extends \advanced_testcase { /** * Tests getting the recordset. */ - public function test_get_document_recordset() { + public function test_get_document_recordset(): void { global $DB, $USER; $this->resetAfterTest(); @@ -245,7 +245,7 @@ class base_block_test extends \advanced_testcase { /** * Tests the get_doc_url function. */ - public function test_get_doc_url() { + public function test_get_doc_url(): void { global $DB; $this->resetAfterTest(); @@ -327,7 +327,7 @@ class base_block_test extends \advanced_testcase { /** * Tests the check_access function. */ - public function test_check_access() { + public function test_check_access(): void { global $DB; $this->resetAfterTest(); @@ -382,7 +382,7 @@ class base_block_test extends \advanced_testcase { * Tests the block version of get_contexts_to_reindex, which is supposed to return all the * block contexts in order of date added. */ - public function test_get_contexts_to_reindex() { + public function test_get_contexts_to_reindex(): void { global $DB; $this->resetAfterTest(); @@ -442,7 +442,7 @@ class base_block_test extends \advanced_testcase { /** * Test document icon. */ - public function test_get_doc_icon() { + public function test_get_doc_icon(): void { $baseblock = $this->getMockBuilder('\core_search\base_block') ->disableOriginalConstructor() ->getMockForAbstractClass(); diff --git a/search/tests/base_test.php b/search/tests/base_test.php index a9058902560..4b93836ded0 100644 --- a/search/tests/base_test.php +++ b/search/tests/base_test.php @@ -68,7 +68,7 @@ class base_test extends \advanced_testcase { /** * Test base get search fileareas */ - public function test_get_search_fileareas_base() { + public function test_get_search_fileareas_base(): void { $builder = $this->getMockBuilder('\core_search\base'); $builder->disableOriginalConstructor(); @@ -82,7 +82,7 @@ class base_test extends \advanced_testcase { /** * Test base attach files */ - public function test_attach_files_base() { + public function test_attach_files_base(): void { $filearea = 'search'; $component = 'mod_test'; @@ -128,7 +128,7 @@ class base_test extends \advanced_testcase { /** * Tests the base version (stub) of get_contexts_to_reindex. */ - public function test_get_contexts_to_reindex() { + public function test_get_contexts_to_reindex(): void { $area = new \core_mocksearch\search\mock_search_area(); $this->assertEquals([\context_system::instance()], iterator_to_array($area->get_contexts_to_reindex(), false)); @@ -137,7 +137,7 @@ class base_test extends \advanced_testcase { /** * Test default document icon. */ - public function test_get_default_doc_icon() { + public function test_get_default_doc_icon(): void { $basearea = $this->getMockBuilder('\core_search\base') ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -155,7 +155,7 @@ class base_test extends \advanced_testcase { /** * Test base search area category names. */ - public function test_get_category_names() { + public function test_get_category_names(): void { $builder = $this->getMockBuilder('\core_search\base'); $builder->disableOriginalConstructor(); $stub = $builder->getMockForAbstractClass(); @@ -167,7 +167,7 @@ class base_test extends \advanced_testcase { /** * Test getting all required search area setting names. */ - public function test_get_settingnames() { + public function test_get_settingnames(): void { $expected = array('_enabled', '_indexingstart', '_indexingend', '_lastindexrun', '_docsignored', '_docsprocessed', '_recordsprocessed', '_partial'); $this->assertEquals($expected, \core_search\base::get_settingnames()); diff --git a/search/tests/document_icon_test.php b/search/tests/document_icon_test.php index 7fbb837f1b7..b0d8fe33b0a 100644 --- a/search/tests/document_icon_test.php +++ b/search/tests/document_icon_test.php @@ -27,7 +27,7 @@ class document_icon_test extends \advanced_testcase { /** * Test that default component gets returned correctly. */ - public function test_default_component() { + public function test_default_component(): void { $docicon = new \core_search\document_icon('test_name'); $this->assertEquals('test_name', $docicon->get_name()); $this->assertEquals('moodle', $docicon->get_component()); @@ -36,7 +36,7 @@ class document_icon_test extends \advanced_testcase { /** * Test that name and component get returned correctly. */ - public function test_can_get_name_and_component() { + public function test_can_get_name_and_component(): void { $docicon = new \core_search\document_icon('test_name', 'test_component'); $this->assertEquals('test_name', $docicon->get_name()); $this->assertEquals('test_component', $docicon->get_component()); diff --git a/search/tests/document_test.php b/search/tests/document_test.php index d7b83d1d030..b35865adaaf 100644 --- a/search/tests/document_test.php +++ b/search/tests/document_test.php @@ -65,7 +65,7 @@ class document_test extends \advanced_testcase { * @covers ::export_for_template * @return void */ - public function test_search_user_accesses() { + public function test_search_user_accesses(): void { global $PAGE; $area = new mock_search_area(); @@ -114,7 +114,7 @@ class document_test extends \advanced_testcase { * * @covers ::set_doc_icon */ - public function test_get_and_set_doc_icon() { + public function test_get_and_set_doc_icon(): void { $document = $this->getMockBuilder('\core_search\document') ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -151,7 +151,7 @@ class document_test extends \advanced_testcase { array $capexceptions = [], bool $expected = true, bool $owndocument = false - ) { + ): void { global $DB, $PAGE; $area = new mock_search_area(); diff --git a/search/tests/engine_test.php b/search/tests/engine_test.php index 555818a755b..08059b820a9 100644 --- a/search/tests/engine_test.php +++ b/search/tests/engine_test.php @@ -44,7 +44,7 @@ class engine_test extends \advanced_testcase { * * @return void */ - public function test_engine_info() { + public function test_engine_info(): void { $engine = new \mock_search\engine(); $this->assertEquals('mock_search', $engine->get_plugin_name()); @@ -58,7 +58,7 @@ class engine_test extends \advanced_testcase { * * @return void */ - public function test_engine_caches() { + public function test_engine_caches(): void { global $DB; $engine = new \mock_search\engine(); @@ -86,7 +86,7 @@ class engine_test extends \advanced_testcase { /** * Tests the core functions related to schema updates. */ - public function test_engine_schema_modification() { + public function test_engine_schema_modification(): void { // Apply a schema update starting from no version. $engine = new \mock_search\engine(); $engine->check_latest_schema(); @@ -117,7 +117,7 @@ class engine_test extends \advanced_testcase { /** * Tests the get_supported_orders stub function. */ - public function test_get_supported_orders() { + public function test_get_supported_orders(): void { $engine = new \mock_search\engine(); $orders = $engine->get_supported_orders(\context_system::instance()); $this->assertCount(1, $orders); @@ -127,7 +127,7 @@ class engine_test extends \advanced_testcase { /** * Test that search engine sets an icon before render a document. */ - public function test_engine_sets_doc_icon() { + public function test_engine_sets_doc_icon(): void { $generator = self::getDataGenerator()->get_plugin_generator('core_search'); $generator->setup(); diff --git a/search/tests/event/events_test.php b/search/tests/event/events_test.php index 91dfc35dc2b..d66076164ed 100644 --- a/search/tests/event/events_test.php +++ b/search/tests/event/events_test.php @@ -40,7 +40,7 @@ class events_test extends \advanced_testcase { * * @return void */ - public function test_search_results_viewed() { + public function test_search_results_viewed(): void { $this->resetAfterTest(); diff --git a/search/tests/external_test.php b/search/tests/external_test.php index 10ab44c9ec6..b6ca543d78f 100644 --- a/search/tests/external_test.php +++ b/search/tests/external_test.php @@ -40,7 +40,7 @@ class external_test extends \advanced_testcase { /** * Checks the get_relevant_users function used when selecting users in search filter. */ - public function test_get_relevant_users() { + public function test_get_relevant_users(): void { // Set up two users to search for and one to do the searching. $generator = $this->getDataGenerator(); $student1 = $generator->create_user(['firstname' => 'Amelia', 'lastname' => 'Aardvark']); diff --git a/search/tests/manager_test.php b/search/tests/manager_test.php index c1363e687bc..4a9939fd7bb 100644 --- a/search/tests/manager_test.php +++ b/search/tests/manager_test.php @@ -57,7 +57,7 @@ class manager_test extends \advanced_testcase { parent::tearDown(); } - public function test_search_enabled() { + public function test_search_enabled(): void { $this->resetAfterTest(); @@ -80,7 +80,7 @@ class manager_test extends \advanced_testcase { * @param string $expected The expected course search url. * @dataProvider data_course_search_url */ - public function test_course_search_url(?bool $gsenabled, ?bool $allcourses, ?bool $enablearea, string $expected) { + public function test_course_search_url(?bool $gsenabled, ?bool $allcourses, ?bool $enablearea, string $expected): void { $this->resetAfterTest(); if (!is_null($gsenabled)) { @@ -129,7 +129,7 @@ class manager_test extends \advanced_testcase { * @param bool $expected The expected result. * @dataProvider data_can_replace_course_search */ - public function test_can_replace_course_search(?bool $gsenabled, ?bool $allcourses, ?bool $enablearea, bool $expected) { + public function test_can_replace_course_search(?bool $gsenabled, ?bool $allcourses, ?bool $enablearea, bool $expected): void { $this->resetAfterTest(); if (!is_null($gsenabled)) { @@ -169,7 +169,7 @@ class manager_test extends \advanced_testcase { ]; } - public function test_search_areas() { + public function test_search_areas(): void { global $CFG; $this->resetAfterTest(); @@ -205,7 +205,7 @@ class manager_test extends \advanced_testcase { $this->assertArrayHasKey($this->forumpostareaid, \core_search\manager::get_search_areas_list(true)); } - public function test_search_config() { + public function test_search_config(): void { $this->resetAfterTest(); @@ -265,7 +265,7 @@ class manager_test extends \advanced_testcase { /** * Tests the get_last_indexing_duration method in the base area class. */ - public function test_get_last_indexing_duration() { + public function test_get_last_indexing_duration(): void { $this->resetAfterTest(); $search = \testable_core_search::instance(); @@ -289,7 +289,7 @@ class manager_test extends \advanced_testcase { /** * Tests that partial indexing works correctly. */ - public function test_partial_indexing() { + public function test_partial_indexing(): void { global $USER; $this->resetAfterTest(); @@ -389,7 +389,7 @@ class manager_test extends \advanced_testcase { * This tests the different logic about displaying progress for slow/fast and * complete/incomplete processing. */ - public function test_index_progress() { + public function test_index_progress(): void { $this->resetAfterTest(); $generator = $this->getDataGenerator(); @@ -472,7 +472,7 @@ class manager_test extends \advanced_testcase { * a problem by preventing it from indexing other documents modified between now and the future * date). */ - public function test_future_documents() { + public function test_future_documents(): void { $this->resetAfterTest(); // Create a course and a forum. @@ -522,7 +522,7 @@ class manager_test extends \advanced_testcase { /** * Tests that indexing a specified context works correctly. */ - public function test_context_indexing() { + public function test_context_indexing(): void { global $USER; $this->resetAfterTest(); @@ -623,7 +623,7 @@ class manager_test extends \advanced_testcase { * * @return void */ - public function test_search_user_accesses() { + public function test_search_user_accesses(): void { global $DB; $this->resetAfterTest(); @@ -772,7 +772,7 @@ class manager_test extends \advanced_testcase { * * @return void */ - public function test_search_user_accesses_blocks() { + public function test_search_user_accesses_blocks(): void { global $DB; $this->resetAfterTest(); @@ -890,7 +890,7 @@ class manager_test extends \advanced_testcase { /** * Tests retrieval of users search areas when limiting to a course the user is not enrolled in */ - public function test_search_users_accesses_limit_non_enrolled_course() { + public function test_search_users_accesses_limit_non_enrolled_course(): void { global $DB; $this->resetAfterTest(); @@ -929,7 +929,7 @@ class manager_test extends \advanced_testcase { * * @return void */ - public function test_search_user_accesses_allavailable() { + public function test_search_user_accesses_allavailable(): void { global $DB, $CFG; $this->resetAfterTest(); @@ -1010,7 +1010,7 @@ class manager_test extends \advanced_testcase { /** * Tests group-related aspects of the get_areas_user_accesses function. */ - public function test_search_user_accesses_groups() { + public function test_search_user_accesses_groups(): void { global $DB; $this->resetAfterTest(); @@ -1110,7 +1110,7 @@ class manager_test extends \advanced_testcase { * * @return void */ - public function test_is_search_area() { + public function test_is_search_area(): void { $this->assertFalse(\testable_core_search::is_search_area('\asd\asd')); $this->assertFalse(\testable_core_search::is_search_area('\mod_forum\search\posta')); @@ -1125,7 +1125,7 @@ class manager_test extends \advanced_testcase { * adding things to the request list, it doesn't test that they are actually indexed by the * scheduled task. */ - public function test_request_index() { + public function test_request_index(): void { global $DB; $this->resetAfterTest(); @@ -1234,7 +1234,7 @@ class manager_test extends \advanced_testcase { /** * Tests the process_index_requests function. */ - public function test_process_index_requests() { + public function test_process_index_requests(): void { global $DB; $this->resetAfterTest(); @@ -1371,7 +1371,7 @@ class manager_test extends \advanced_testcase { /** * Test search area categories. */ - public function test_get_search_area_categories() { + public function test_get_search_area_categories(): void { $categories = \core_search\manager::get_search_area_categories(); $this->assertTrue(is_array($categories)); @@ -1389,7 +1389,7 @@ class manager_test extends \advanced_testcase { /** * Test that we can find out if search area categories functionality is enabled. */ - public function test_is_search_area_categories_enabled() { + public function test_is_search_area_categories_enabled(): void { $this->resetAfterTest(); $this->assertFalse(\core_search\manager::is_search_area_categories_enabled()); @@ -1402,7 +1402,7 @@ class manager_test extends \advanced_testcase { /** * Test that we can find out if hiding all results category is enabled. */ - public function test_should_hide_all_results_category() { + public function test_should_hide_all_results_category(): void { $this->resetAfterTest(); $this->assertEquals(0, \core_search\manager::should_hide_all_results_category()); @@ -1415,7 +1415,7 @@ class manager_test extends \advanced_testcase { /** * Test that we can get default search category name. */ - public function test_get_default_area_category_name() { + public function test_get_default_area_category_name(): void { $this->resetAfterTest(); $expected = 'core-all'; @@ -1433,7 +1433,7 @@ class manager_test extends \advanced_testcase { /** * Test that we can get correct search area category by its name. */ - public function test_get_search_area_category_by_name() { + public function test_get_search_area_category_by_name(): void { $this->resetAfterTest(); $testcategory = \core_search\manager::get_search_area_category_by_name('test_random_name'); @@ -1450,7 +1450,7 @@ class manager_test extends \advanced_testcase { /** * Test that we can check that "Include all visible courses" feature is enabled. */ - public function test_include_all_courses_enabled() { + public function test_include_all_courses_enabled(): void { $this->resetAfterTest(); $this->assertFalse(\core_search\manager::include_all_courses()); set_config('searchincludeallcourses', 1); @@ -1460,7 +1460,7 @@ class manager_test extends \advanced_testcase { /** * Test that we can correctly build a list of courses for a course filter for the search results. */ - public function test_build_limitcourseids() { + public function test_build_limitcourseids(): void { global $USER; $this->resetAfterTest(); @@ -1518,14 +1518,14 @@ class manager_test extends \advanced_testcase { * @param string $areaid Area id to parse. * @param array $expected Expected result of parsing. */ - public function test_parse_search_area_id($areaid, $expected) { + public function test_parse_search_area_id($areaid, $expected): void { $this->assertEquals($expected, \core_search\manager::parse_areaid($areaid)); } /** * Test that manager class will throw an exception when parsing an invalid area id. */ - public function test_parse_invalid_search_area_id() { + public function test_parse_invalid_search_area_id(): void { $this->expectException('coding_exception'); $this->expectExceptionMessage('Trying to parse invalid search area id invalid_area'); \core_search\manager::parse_areaid('invalid_area'); @@ -1534,7 +1534,7 @@ class manager_test extends \advanced_testcase { /** * Test getting a coding exception when trying to lean up existing search area. */ - public function test_cleaning_up_existing_search_area() { + public function test_cleaning_up_existing_search_area(): void { $expectedmessage = "Area mod_assign-activity exists. Please use appropriate search area class to manipulate the data."; $this->expectException('coding_exception'); @@ -1546,7 +1546,7 @@ class manager_test extends \advanced_testcase { /** * Test clean up of non existing search area. */ - public function test_clean_up_non_existing_search_area() { + public function test_clean_up_non_existing_search_area(): void { global $DB; $this->resetAfterTest(); @@ -1579,7 +1579,7 @@ class manager_test extends \advanced_testcase { /** * Tests the context_deleted, course_deleting_start, and course_deleting_finish methods. */ - public function test_context_deletion() { + public function test_context_deletion(): void { $this->resetAfterTest(); // Create one course with 4 activities, and another with one. diff --git a/search/tests/skip_future_documents_iterator_test.php b/search/tests/skip_future_documents_iterator_test.php index a12ce76ac5b..081630861b6 100644 --- a/search/tests/skip_future_documents_iterator_test.php +++ b/search/tests/skip_future_documents_iterator_test.php @@ -40,7 +40,7 @@ class skip_future_documents_iterator_test extends \basic_testcase { /** * Test normal case with all documents in the past. */ - public function test_iterator_all_in_past() { + public function test_iterator_all_in_past(): void { $past = strtotime('2017-11-01'); $documents = [ self::make_doc($past, 1), @@ -55,7 +55,7 @@ class skip_future_documents_iterator_test extends \basic_testcase { * Confirm that the iterator does not call its parent iterator current() function too many * times. */ - public function test_iterator_performance() { + public function test_iterator_performance(): void { $counter = new test_counting_iterator(); $iterator = new skip_future_documents_iterator($counter); $items = 0; @@ -70,14 +70,14 @@ class skip_future_documents_iterator_test extends \basic_testcase { /** * Test with no documents at all. */ - public function test_iterator_empty() { + public function test_iterator_empty(): void { $this->assertEquals('', self::do_iterator([])); } /** * Test if some documents are in the future. */ - public function test_iterator_some_in_future() { + public function test_iterator_some_in_future(): void { $past = strtotime('2017-11-01'); $future = time() + 1000; $documents = [ @@ -92,7 +92,7 @@ class skip_future_documents_iterator_test extends \basic_testcase { /** * Test if all documents are in the future. */ - public function test_iterator_all_in_future() { + public function test_iterator_all_in_future(): void { $future = time() + 1000; $documents = [ self::make_doc($future, 1), @@ -105,7 +105,7 @@ class skip_future_documents_iterator_test extends \basic_testcase { /** * Test when some documents return error. */ - public function test_iterator_some_false() { + public function test_iterator_some_false(): void { $past = strtotime('2017-11-01'); $documents = [ self::make_doc($past, 1), @@ -119,7 +119,7 @@ class skip_future_documents_iterator_test extends \basic_testcase { /** * Test when all documents return error. */ - public function test_iterator_all_false() { + public function test_iterator_all_false(): void { $documents = [ false, false, @@ -132,7 +132,7 @@ class skip_future_documents_iterator_test extends \basic_testcase { /** * Test iterator with all cases. */ - public function test_iterator_past_false_and_future() { + public function test_iterator_past_false_and_future(): void { $past = strtotime('2017-11-01'); $future = time() + 1000; $documents = [ diff --git a/tag/tests/event/events_test.php b/tag/tests/event/events_test.php index 8cac237e2df..6a7fe02f836 100644 --- a/tag/tests/event/events_test.php +++ b/tag/tests/event/events_test.php @@ -46,7 +46,7 @@ class events_test extends \advanced_testcase { /** * Test the tag updated event. */ - public function test_tag_updated() { + public function test_tag_updated(): void { $this->setAdminUser(); // Save the system context. @@ -95,7 +95,7 @@ class events_test extends \advanced_testcase { /** * Test the tag added event. */ - public function test_tag_added() { + public function test_tag_added(): void { global $DB; // Create a course to tag. @@ -134,7 +134,7 @@ class events_test extends \advanced_testcase { /** * Test the tag removed event. */ - public function test_tag_removed() { + public function test_tag_removed(): void { global $DB; $this->setAdminUser(); @@ -251,7 +251,7 @@ class events_test extends \advanced_testcase { /** * Test the tag flagged event. */ - public function test_tag_flagged() { + public function test_tag_flagged(): void { global $DB; $this->setAdminUser(); @@ -306,7 +306,7 @@ class events_test extends \advanced_testcase { /** * Test the tag unflagged event. */ - public function test_tag_unflagged() { + public function test_tag_unflagged(): void { global $DB; $this->setAdminUser(); @@ -364,7 +364,7 @@ class events_test extends \advanced_testcase { /** * Test the tag deleted event */ - public function test_tag_deleted() { + public function test_tag_deleted(): void { global $DB; $this->setAdminUser(); @@ -452,7 +452,7 @@ class events_test extends \advanced_testcase { /** * Test the tag created event. */ - public function test_tag_created() { + public function test_tag_created(): void { global $DB; // Trigger and capture the event for creating a tag. diff --git a/tag/tests/external/external_test.php b/tag/tests/external/external_test.php index 071f5da7c66..d308df958b7 100644 --- a/tag/tests/external/external_test.php +++ b/tag/tests/external/external_test.php @@ -38,7 +38,7 @@ class external_test extends externallib_advanced_testcase { /** * Test update_categories */ - public function test_update_tags() { + public function test_update_tags(): void { global $DB; $this->resetAfterTest(); $context = \context_system::instance(); @@ -154,7 +154,7 @@ class external_test extends externallib_advanced_testcase { /** * Test update_inplace_editable() */ - public function test_update_inplace_editable() { + public function test_update_inplace_editable(): void { global $CFG, $DB, $PAGE; require_once($CFG->dirroot . '/lib/external/externallib.php'); @@ -189,7 +189,7 @@ class external_test extends externallib_advanced_testcase { /** * Test get_tagindex_per_area. */ - public function test_get_tagindex_per_area() { + public function test_get_tagindex_per_area(): void { global $USER; $this->resetAfterTest(true); @@ -242,7 +242,7 @@ class external_test extends externallib_advanced_testcase { /** * Test get_tag_areas. */ - public function test_get_tag_areas() { + public function test_get_tag_areas(): void { global $DB; $this->resetAfterTest(true); @@ -260,7 +260,7 @@ class external_test extends externallib_advanced_testcase { /** * Test get_tag_collections. */ - public function test_get_tag_collections() { + public function test_get_tag_collections(): void { global $DB; $this->resetAfterTest(true); @@ -283,7 +283,7 @@ class external_test extends externallib_advanced_testcase { /** * Test get_tag_cloud. */ - public function test_get_tag_cloud() { + public function test_get_tag_cloud(): void { global $USER, $DB; $this->resetAfterTest(true); diff --git a/tag/tests/privacy/provider_test.php b/tag/tests/privacy/provider_test.php index 2f41e4e2489..5394d27b940 100644 --- a/tag/tests/privacy/provider_test.php +++ b/tag/tests/privacy/provider_test.php @@ -45,7 +45,7 @@ class provider_test extends provider_testcase { /** * Check the exporting of tags for a user id in a context. */ - public function test_export_tags() { + public function test_export_tags(): void { global $DB; $this->resetAfterTest(true); @@ -93,7 +93,7 @@ class provider_test extends provider_testcase { /** * Test method delete_item_tags(). */ - public function test_delete_item_tags() { + public function test_delete_item_tags(): void { global $DB; $this->resetAfterTest(true); @@ -127,7 +127,7 @@ class provider_test extends provider_testcase { /** * Test method delete_item_tags() with userid. */ - public function test_delete_item_tags_with_userid() { + public function test_delete_item_tags_with_userid(): void { global $DB; $this->resetAfterTest(true); @@ -156,7 +156,7 @@ class provider_test extends provider_testcase { /** * Test method delete_item_tags_select(). */ - public function test_delete_item_tags_select() { + public function test_delete_item_tags_select(): void { global $DB; $this->resetAfterTest(true); @@ -215,14 +215,14 @@ class provider_test extends provider_testcase { return [$user1, $user2]; } - public function test_export_item_tags() { + public function test_export_item_tags(): void { list($user1, $user2) = $this->set_up_tags(); $this->assertEquals([\context_system::instance()->id], provider::get_contexts_for_userid($user1->id)->get_contextids()); $this->assertEmpty(provider::get_contexts_for_userid($user2->id)->get_contextids()); } - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; list($user1, $user2) = $this->set_up_tags(); $context = \context_system::instance(); @@ -236,7 +236,7 @@ class provider_test extends provider_testcase { $this->assertEquals(2, $DB->count_records('tag', ['userid' => 0])); } - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; $course = $this->getDataGenerator()->create_course(); list($user1, $user2) = $this->set_up_tags(); @@ -279,7 +279,7 @@ class provider_test extends provider_testcase { /** * Test that only users within a system context are fetched. */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { $component = 'core_tag'; $user1 = $this->set_up_tags()[0]; @@ -302,7 +302,7 @@ class provider_test extends provider_testcase { /** * Test that data for users in approved userlist is deleted. */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { $component = 'core_tag'; list($user1, $user2) = $this->set_up_tags(); diff --git a/tag/tests/taglib_test.php b/tag/tests/taglib_test.php index 1cc7f127592..7a973515e7c 100644 --- a/tag/tests/taglib_test.php +++ b/tag/tests/taglib_test.php @@ -43,7 +43,7 @@ class taglib_test extends \advanced_testcase { * Test that the tag_set function throws an exception. * This function was deprecated in 3.1 */ - public function test_tag_set_get() { + public function test_tag_set_get(): void { $this->expectException('coding_exception'); $this->expectExceptionMessage('tag_set() can not be used anymore. Please use ' . 'core_tag_tag::set_item_tags().'); @@ -54,7 +54,7 @@ class taglib_test extends \advanced_testcase { * Test that tag_set_add function throws an exception. * This function was deprecated in 3.1 */ - public function test_tag_set_add() { + public function test_tag_set_add(): void { $this->expectException('coding_exception'); $this->expectExceptionMessage('tag_set_add() can not be used anymore. Please use ' . 'core_tag_tag::add_item_tag().'); @@ -65,7 +65,7 @@ class taglib_test extends \advanced_testcase { * Test that tag_set_delete function returns an exception. * This function was deprecated in 3.1 */ - public function test_tag_set_delete() { + public function test_tag_set_delete(): void { $this->expectException('coding_exception'); $this->expectExceptionMessage('tag_set_delete() can not be used anymore. Please use ' . 'core_tag_tag::remove_item_tag().'); @@ -75,7 +75,7 @@ class taglib_test extends \advanced_testcase { /** * Test the core_tag_tag::add_item_tag() and core_tag_tag::remove_item_tag() functions. */ - public function test_add_remove_item_tag() { + public function test_add_remove_item_tag(): void { global $DB; // Create a course to tag. @@ -98,7 +98,7 @@ class taglib_test extends \advanced_testcase { /** * Test add_item_tag function correctly calculates the ordering for a new tag. */ - public function test_add_tag_ordering_calculation() { + public function test_add_tag_ordering_calculation(): void { global $DB; $user1 = $this->getDataGenerator()->create_user(); @@ -146,7 +146,7 @@ class taglib_test extends \advanced_testcase { * Test that tag_assign function throws an exception. * This function was deprecated in 3.1 */ - public function test_tag_assign() { + public function test_tag_assign(): void { $this->expectException(\coding_exception::class); $this->expectExceptionMessage('tag_assign() can not be used anymore. Please use core_tag_tag::set_item_tags() ' . 'or core_tag_tag::add_item_tag() instead.'); @@ -156,7 +156,7 @@ class taglib_test extends \advanced_testcase { /** * Test the tag cleanup function used by the cron. */ - public function test_tag_cleanup() { + public function test_tag_cleanup(): void { global $DB; $task = new \core\task\tag_cron_task(); @@ -249,7 +249,7 @@ class taglib_test extends \advanced_testcase { /** * Test deleting a group of tag instances. */ - public function test_tag_bulk_delete_instances() { + public function test_tag_bulk_delete_instances(): void { global $DB; $task = new \core\task\tag_cron_task(); @@ -427,7 +427,7 @@ class taglib_test extends \advanced_testcase { /** * Test for function cleanup() that is part of tag cron */ - public function test_cleanup() { + public function test_cleanup(): void { global $DB; $task = new \core\task\tag_cron_task(); @@ -490,7 +490,7 @@ class taglib_test extends \advanced_testcase { $this->assertFalse($DB->record_exists('tag_instance', array('tagid' => $sometag->id))); } - public function test_guess_tag() { + public function test_guess_tag(): void { global $DB; $user = $this->getDataGenerator()->create_user(); $this->setUser($user); @@ -502,7 +502,7 @@ class taglib_test extends \advanced_testcase { $this->assertEquals(core_tag_collection::get_default(), core_tag_tag::get_by_name(0, 'Cat')->tagcollid); } - public function test_instances() { + public function test_instances(): void { global $DB; $user = $this->getDataGenerator()->create_user(); $this->setUser($user); @@ -540,7 +540,7 @@ class taglib_test extends \advanced_testcase { $this->assertEquals($initialtagscount + 1, $DB->count_records('tag')); } - public function test_related_tags() { + public function test_related_tags(): void { global $DB; $user = $this->getDataGenerator()->create_user(); $this->setUser($user); @@ -590,7 +590,7 @@ class taglib_test extends \advanced_testcase { /** * Very basic test for create/move/update/delete actions, without any itemtype movements. */ - public function test_tag_coll_basic() { + public function test_tag_coll_basic(): void { global $DB; // Make sure there is one and only one tag coll that is marked as default. @@ -671,7 +671,7 @@ class taglib_test extends \advanced_testcase { return array($collid1, $collid2, $user1, $user2, $blogpost); } - public function test_move_tags_simple() { + public function test_move_tags_simple(): void { global $DB; list($collid1, $collid2, $user1, $user2, $blogpost) = $this->prepare_move_tags(); @@ -693,7 +693,7 @@ class taglib_test extends \advanced_testcase { $this->assertEquals(array('Tag2', 'Tag3'), array_values(core_tag_tag::get_item_tags_array('core', 'user', $user2->id))); } - public function test_move_tags_split_tag() { + public function test_move_tags_split_tag(): void { global $DB; list($collid1, $collid2, $user1, $user2, $blogpost) = $this->prepare_move_tags(); @@ -719,7 +719,7 @@ class taglib_test extends \advanced_testcase { $this->assertEquals(array('Tag1', 'Tag3'), array_values(core_tag_tag::get_item_tags_array('core', 'post', $blogpost->id))); } - public function test_move_tags_merge_tag() { + public function test_move_tags_merge_tag(): void { global $DB; list($collid1, $collid2, $user1, $user2, $blogpost) = $this->prepare_move_tags(); @@ -750,7 +750,7 @@ class taglib_test extends \advanced_testcase { $this->assertEquals(array('TAG1', 'Tag3'), array_values(core_tag_tag::get_item_tags_array('core', 'post', $blogpost->id))); } - public function test_move_tags_with_related() { + public function test_move_tags_with_related(): void { global $DB; list($collid1, $collid2, $user1, $user2, $blogpost) = $this->prepare_move_tags(); @@ -794,7 +794,7 @@ class taglib_test extends \advanced_testcase { $this->assertEquals('Tag2, Tag4', join(', ', $related21)); } - public function test_move_tags_corrupted() { + public function test_move_tags_corrupted(): void { global $DB; list($collid1, $collid2, $user1, $user2, $blogpost) = $this->prepare_move_tags(); $collid3 = core_tag_collection::create(array('name' => 'weirdcoll'))->id; @@ -837,7 +837,7 @@ class taglib_test extends \advanced_testcase { * Tests that tag_normalize function throws an exception. * This function was deprecated in 3.1 */ - public function test_normalize() { + public function test_normalize(): void { $this->expectException(\coding_exception::class); $this->expectExceptionMessage('tag_normalize() can not be used anymore. Please use ' . 'core_tag_tag::normalize().'); @@ -847,7 +847,7 @@ class taglib_test extends \advanced_testcase { /** * Test functions core_tag_tag::create_if_missing() and core_tag_tag::get_by_name_bulk(). */ - public function test_create_get() { + public function test_create_get(): void { $tagset = array('Cat', ' Dog ', '', 'mouse', 'Dog'); $collid = core_tag_collection::get_default(); @@ -872,7 +872,7 @@ class taglib_test extends \advanced_testcase { /** * Testing function core_tag_tag::combine_tags() */ - public function test_combine_tags() { + public function test_combine_tags(): void { $initialtags = array( array('Cat', 'Dog'), array('Dog', 'Cat'), @@ -950,7 +950,7 @@ class taglib_test extends \advanced_testcase { /** * Testing function core_tag_tag::combine_tags() when correlated tags are present. */ - public function test_combine_tags_with_correlated() { + public function test_combine_tags_with_correlated(): void { $task = new \core\task\tag_cron_task(); $tags = $this->prepare_correlated(); @@ -996,7 +996,7 @@ class taglib_test extends \advanced_testcase { * get_tags_by_area_in_contexts should return an empty array if there * are no tag instances for the area in the given context. */ - public function test_get_tags_by_area_in_contexts_empty() { + public function test_get_tags_by_area_in_contexts_empty(): void { $tagnames = ['foo']; $collid = core_tag_collection::get_default(); $tags = core_tag_tag::create_if_missing($collid, $tagnames); @@ -1114,7 +1114,7 @@ class taglib_test extends \advanced_testcase { /** * get_items_tags should return an empty array if the tag area is disabled. */ - public function test_get_items_tags_disabled_component() { + public function test_get_items_tags_disabled_component(): void { global $CFG; $user1 = $this->getDataGenerator()->create_user(); @@ -1135,7 +1135,7 @@ class taglib_test extends \advanced_testcase { * get_items_tags should return an empty array if the tag item ids list * is empty. */ - public function test_get_items_tags_empty_itemids() { + public function test_get_items_tags_empty_itemids(): void { $user1 = $this->getDataGenerator()->create_user(); $context1 = \context_user::instance($user1->id); $component = 'core'; @@ -1151,7 +1151,7 @@ class taglib_test extends \advanced_testcase { * get_items_tags should return an array indexed by the item ids with empty * arrays as the values when the component or itemtype is unknown. */ - public function test_get_items_tags_unknown_component_itemtype() { + public function test_get_items_tags_unknown_component_itemtype(): void { $itemids = [1, 2, 3]; $result = core_tag_tag::get_items_tags('someunknowncomponent', 'user', $itemids); foreach ($itemids as $itemid) { @@ -1273,7 +1273,7 @@ class taglib_test extends \advanced_testcase { * context if the tag area for the items doesn't allow multiple contexts for * the tag instances. */ - public function test_set_item_tags_no_multiple_context_updates_context_of_instances() { + public function test_set_item_tags_no_multiple_context_updates_context_of_instances(): void { $tagnames = ['foo', 'bar']; $collid = core_tag_collection::get_default(); $tags = core_tag_tag::create_if_missing($collid, $tagnames); @@ -1503,7 +1503,7 @@ class taglib_test extends \advanced_testcase { /** * delete_instances_as_record with an empty set of instances should do nothing. */ - public function test_delete_instances_as_record_empty_set() { + public function test_delete_instances_as_record_empty_set(): void { $user = $this->getDataGenerator()->create_user(); $context = \context_user::instance($user->id); $component = 'core'; @@ -1523,7 +1523,7 @@ class taglib_test extends \advanced_testcase { * delete_instances_as_record with an instance that doesn't exist should do * nothing. */ - public function test_delete_instances_as_record_missing_set() { + public function test_delete_instances_as_record_missing_set(): void { $tagnames = ['foo']; $collid = core_tag_collection::get_default(); $tags = core_tag_tag::create_if_missing($collid, $tagnames); @@ -1548,7 +1548,7 @@ class taglib_test extends \advanced_testcase { * delete_instances_as_record with a list of all tag instances should * leave no tags left. */ - public function test_delete_instances_as_record_whole_set() { + public function test_delete_instances_as_record_whole_set(): void { $tagnames = ['foo']; $collid = core_tag_collection::get_default(); $tags = core_tag_tag::create_if_missing($collid, $tagnames); @@ -1571,7 +1571,7 @@ class taglib_test extends \advanced_testcase { * delete_instances_as_record with a list of only some tag instances should * delete only the given tag instances and leave other tag instances. */ - public function test_delete_instances_as_record_partial_set() { + public function test_delete_instances_as_record_partial_set(): void { $tagnames = ['foo', 'bar']; $collid = core_tag_collection::get_default(); $tags = core_tag_tag::create_if_missing($collid, $tagnames); @@ -1596,7 +1596,7 @@ class taglib_test extends \advanced_testcase { /** * delete_instances_by_id with an empty set of ids should do nothing. */ - public function test_delete_instances_by_id_empty_set() { + public function test_delete_instances_by_id_empty_set(): void { $user = $this->getDataGenerator()->create_user(); $context = \context_user::instance($user->id); $component = 'core'; @@ -1616,7 +1616,7 @@ class taglib_test extends \advanced_testcase { * delete_instances_by_id with an id that doesn't exist should do * nothing. */ - public function test_delete_instances_by_id_missing_set() { + public function test_delete_instances_by_id_missing_set(): void { $tagnames = ['foo']; $collid = core_tag_collection::get_default(); $tags = core_tag_tag::create_if_missing($collid, $tagnames); @@ -1640,7 +1640,7 @@ class taglib_test extends \advanced_testcase { * delete_instances_by_id with a list of all tag instance ids should * leave no tags left. */ - public function test_delete_instances_by_id_whole_set() { + public function test_delete_instances_by_id_whole_set(): void { $tagnames = ['foo']; $collid = core_tag_collection::get_default(); $tags = core_tag_tag::create_if_missing($collid, $tagnames); @@ -1663,7 +1663,7 @@ class taglib_test extends \advanced_testcase { * delete_instances_by_id with a list of only some tag instance ids should * delete only the given tag instance ids and leave other tag instances. */ - public function test_delete_instances_by_id_partial_set() { + public function test_delete_instances_by_id_partial_set(): void { $tagnames = ['foo', 'bar']; $collid = core_tag_collection::get_default(); $tags = core_tag_tag::create_if_missing($collid, $tagnames); @@ -1689,7 +1689,7 @@ class taglib_test extends \advanced_testcase { * delete_instances should delete all tag instances for a component if given * only the component as a parameter. */ - public function test_delete_instances_with_component() { + public function test_delete_instances_with_component(): void { global $DB; $tagnames = ['foo', 'bar']; @@ -1719,7 +1719,7 @@ class taglib_test extends \advanced_testcase { * delete_instances should delete all tag instances for a component if given * only the component as a parameter. */ - public function test_delete_instances_with_component_and_itemtype() { + public function test_delete_instances_with_component_and_itemtype(): void { global $DB; $tagnames = ['foo', 'bar']; @@ -1752,7 +1752,7 @@ class taglib_test extends \advanced_testcase { * delete_instances should delete all tag instances for a component in a context * if given both the component and context id as parameters. */ - public function test_delete_instances_with_component_and_context() { + public function test_delete_instances_with_component_and_context(): void { global $DB; $tagnames = ['foo', 'bar', 'baz']; @@ -1833,7 +1833,7 @@ class taglib_test extends \advanced_testcase { * change_instances_context should not change any existing instance contexts * if not given any instance ids. */ - public function test_change_instances_context_empty_set() { + public function test_change_instances_context_empty_set(): void { global $DB; $tagnames = ['foo']; @@ -1861,7 +1861,7 @@ class taglib_test extends \advanced_testcase { /** * change_instances_context should only change the context of the given ids. */ - public function test_change_instances_context_partial_set() { + public function test_change_instances_context_partial_set(): void { global $DB; $tagnames = ['foo', 'bar']; @@ -1892,7 +1892,7 @@ class taglib_test extends \advanced_testcase { /** * change_instances_context should change multiple items from multiple contexts. */ - public function test_change_instances_context_multiple_contexts() { + public function test_change_instances_context_multiple_contexts(): void { global $DB; $tagnames = ['foo', 'bar']; @@ -1933,7 +1933,7 @@ class taglib_test extends \advanced_testcase { * change_instances_context moving an instance from one context into a context * that already has an instance of that tag should throw an exception. */ - public function test_change_instances_context_conflicting_instances() { + public function test_change_instances_context_conflicting_instances(): void { global $DB; $tagnames = ['foo']; diff --git a/theme/boost/tests/boostnavbar_test.php b/theme/boost/tests/boostnavbar_test.php index 6c9c8e0102f..f5d062beaa3 100644 --- a/theme/boost/tests/boostnavbar_test.php +++ b/theme/boost/tests/boostnavbar_test.php @@ -185,7 +185,7 @@ class boostnavbar_test extends \advanced_testcase { * @param array $expected * @throws \ReflectionException */ - public function test_remove_no_link_items(array $setup, bool $removesectionnodes, array $expected) { + public function test_remove_no_link_items(array $setup, bool $removesectionnodes, array $expected): void { global $PAGE; $this->resetAfterTest(); @@ -369,7 +369,7 @@ class boostnavbar_test extends \advanced_testcase { * @param array $navbarnodes The array containing the text and action of the nodes to be added to the navbar * @param array $expected The array containing the text of the expected navbar nodes */ - public function test_remove_duplicate_items(array $navbarnodes, array $expected) { + public function test_remove_duplicate_items(array $navbarnodes, array $expected): void { $this->resetAfterTest(); $page = new \moodle_page(); $page->set_url('/'); @@ -488,7 +488,7 @@ class boostnavbar_test extends \advanced_testcase { * @param array $expected Array containing the text of the expected navbar nodes after the filtering */ public function test_remove_items_that_exist_in_navigation(string $navmenu, array $navmenunodes, array $navbarnodes, - array $expected) { + array $expected): void { global $PAGE; // Unfortunate hack needed because people use global $PAGE around the place. diff --git a/theme/boost/tests/scss_test.php b/theme/boost/tests/scss_test.php index 30d5bb91dc5..8be3e307313 100644 --- a/theme/boost/tests/scss_test.php +++ b/theme/boost/tests/scss_test.php @@ -27,7 +27,7 @@ class scss_test extends \advanced_testcase { /** * Test that boost can be compiled using SassC (the defacto implemention). */ - public function test_scss_compilation_with_sassc() { + public function test_scss_compilation_with_sassc(): void { if (!defined('PHPUNIT_PATH_TO_SASSC')) { $this->markTestSkipped('Path to SassC not provided'); } diff --git a/theme/classic/tests/scss_test.php b/theme/classic/tests/scss_test.php index 1b5d7ff0903..0d57b8f76d7 100644 --- a/theme/classic/tests/scss_test.php +++ b/theme/classic/tests/scss_test.php @@ -28,7 +28,7 @@ class scss_test extends \advanced_testcase { /** * Test that classic can be compiled using SassC (the defacto implemention). */ - public function test_scss_compilation_with_sassc() { + public function test_scss_compilation_with_sassc(): void { if (!defined('PHPUNIT_PATH_TO_SASSC')) { $this->markTestSkipped('Path to SassC not provided'); } diff --git a/user/profile/field/checkbox/tests/privacy/provider_test.php b/user/profile/field/checkbox/tests/privacy/provider_test.php index 37cf9e50621..b8653d2120a 100644 --- a/user/profile/field/checkbox/tests/privacy/provider_test.php +++ b/user/profile/field/checkbox/tests/privacy/provider_test.php @@ -47,7 +47,7 @@ class provider_test extends provider_testcase { /** * Test getting the context for the user ID related to this plugin. */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { global $DB; // Create profile category. $categoryid = $this->add_profile_category(); @@ -68,7 +68,7 @@ class provider_test extends provider_testcase { /** * Test that data is exported correctly for this plugin. */ - public function test_export_user_data() { + public function test_export_user_data(): void { // Create profile category. $categoryid = $this->add_profile_category(); // Create checkbox profile field. @@ -95,7 +95,7 @@ class provider_test extends provider_testcase { /** * Test that user data is deleted using the context. */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; // Create profile category. $categoryid = $this->add_profile_category(); @@ -123,7 +123,7 @@ class provider_test extends provider_testcase { /** * Test that user data is deleted for this user. */ - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; // Create profile category. $categoryid = $this->add_profile_category(); @@ -153,7 +153,7 @@ class provider_test extends provider_testcase { /** * Test that only users with a user context are fetched. */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { $this->resetAfterTest(); $component = 'profilefield_checkbox'; @@ -188,7 +188,7 @@ class provider_test extends provider_testcase { /** * Test that data for users in approved userlist is deleted. */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { $this->resetAfterTest(); $component = 'profilefield_checkbox'; diff --git a/user/profile/field/datetime/tests/privacy/provider_test.php b/user/profile/field/datetime/tests/privacy/provider_test.php index 640a67851ea..28d2209db98 100644 --- a/user/profile/field/datetime/tests/privacy/provider_test.php +++ b/user/profile/field/datetime/tests/privacy/provider_test.php @@ -47,7 +47,7 @@ class provider_test extends provider_testcase { /** * Test getting the context for the user ID related to this plugin. */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { global $DB; // Create profile category. $categoryid = $this->add_profile_category(); @@ -68,7 +68,7 @@ class provider_test extends provider_testcase { /** * Test that data is exported correctly for this plugin. */ - public function test_export_user_data() { + public function test_export_user_data(): void { // Create profile category. $categoryid = $this->add_profile_category(); // Create datetime profile field. @@ -96,7 +96,7 @@ class provider_test extends provider_testcase { /** * Test that user data is deleted using the context. */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; // Create profile category. $categoryid = $this->add_profile_category(); @@ -124,7 +124,7 @@ class provider_test extends provider_testcase { /** * Test that user data is deleted for this user. */ - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; // Create profile category. $categoryid = $this->add_profile_category(); @@ -154,7 +154,7 @@ class provider_test extends provider_testcase { /** * Test that only users with a user context are fetched. */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { $this->resetAfterTest(); $component = 'profilefield_datetime'; @@ -192,7 +192,7 @@ class provider_test extends provider_testcase { /** * Test that data for users in approved userlist is deleted. */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { $this->resetAfterTest(); $component = 'profilefield_datetime'; diff --git a/user/profile/field/menu/tests/privacy/provider_test.php b/user/profile/field/menu/tests/privacy/provider_test.php index dc6f30b9c68..673b2944d2b 100644 --- a/user/profile/field/menu/tests/privacy/provider_test.php +++ b/user/profile/field/menu/tests/privacy/provider_test.php @@ -47,7 +47,7 @@ class provider_test extends provider_testcase { /** * Test getting the context for the user ID related to this plugin. */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { global $DB; // Create profile category. $categoryid = $this->add_profile_category(); @@ -68,7 +68,7 @@ class provider_test extends provider_testcase { /** * Test that data is exported correctly for this plugin. */ - public function test_export_user_data() { + public function test_export_user_data(): void { // Create profile category. $categoryid = $this->add_profile_category(); // Create menu profile field. @@ -95,7 +95,7 @@ class provider_test extends provider_testcase { /** * Test that user data is deleted using the context. */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; // Create profile category. $categoryid = $this->add_profile_category(); @@ -123,7 +123,7 @@ class provider_test extends provider_testcase { /** * Test that user data is deleted for this user. */ - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; // Create profile category. $categoryid = $this->add_profile_category(); @@ -153,7 +153,7 @@ class provider_test extends provider_testcase { /** * Test that only users with a user context are fetched. */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { $this->resetAfterTest(); $component = 'profilefield_menu'; @@ -189,7 +189,7 @@ class provider_test extends provider_testcase { /** * Test that data for users in approved userlist is deleted. */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { $this->resetAfterTest(); $component = 'profilefield_menu'; diff --git a/user/profile/field/social/tests/privacy/provider_test.php b/user/profile/field/social/tests/privacy/provider_test.php index fec6b397ca5..790079af343 100644 --- a/user/profile/field/social/tests/privacy/provider_test.php +++ b/user/profile/field/social/tests/privacy/provider_test.php @@ -47,7 +47,7 @@ class provider_test extends provider_testcase { /** * Test getting the context for the user ID related to this plugin. */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { global $DB; // Create profile category. $categoryid = $this->add_profile_category(); @@ -68,7 +68,7 @@ class provider_test extends provider_testcase { /** * Test that data is exported correctly for this plugin. */ - public function test_export_user_data() { + public function test_export_user_data(): void { // Create profile category. $categoryid = $this->add_profile_category(); // Create social profile field. @@ -95,7 +95,7 @@ class provider_test extends provider_testcase { /** * Test that user data is deleted using the context. */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; // Create profile category. $categoryid = $this->add_profile_category(); @@ -123,7 +123,7 @@ class provider_test extends provider_testcase { /** * Test that user data is deleted for this user. */ - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; // Create profile category. $categoryid = $this->add_profile_category(); @@ -153,7 +153,7 @@ class provider_test extends provider_testcase { /** * Test that only users with a user context are fetched. */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { $this->resetAfterTest(); $component = 'profilefield_social'; @@ -189,7 +189,7 @@ class provider_test extends provider_testcase { /** * Test that data for users in approved userlist is deleted. */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { $this->resetAfterTest(); $component = 'profilefield_social'; diff --git a/user/profile/field/text/tests/privacy/provider_test.php b/user/profile/field/text/tests/privacy/provider_test.php index d32ec1711eb..e7ec984728f 100644 --- a/user/profile/field/text/tests/privacy/provider_test.php +++ b/user/profile/field/text/tests/privacy/provider_test.php @@ -45,7 +45,7 @@ class provider_test extends provider_testcase { /** * Test getting the context for the user ID related to this plugin. */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { global $DB; // Create profile category. $categoryid = $this->add_profile_category(); @@ -66,7 +66,7 @@ class provider_test extends provider_testcase { /** * Test that data is exported correctly for this plugin. */ - public function test_export_user_data() { + public function test_export_user_data(): void { // Create profile category. $categoryid = $this->add_profile_category(); // Create text profile field. @@ -93,7 +93,7 @@ class provider_test extends provider_testcase { /** * Test that user data is deleted using the context. */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; // Create profile category. $categoryid = $this->add_profile_category(); @@ -121,7 +121,7 @@ class provider_test extends provider_testcase { /** * Test that user data is deleted for this user. */ - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; // Create profile category. $categoryid = $this->add_profile_category(); @@ -151,7 +151,7 @@ class provider_test extends provider_testcase { /** * Test that only users with a user context are fetched. */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { $this->resetAfterTest(); $component = 'profilefield_text'; @@ -187,7 +187,7 @@ class provider_test extends provider_testcase { /** * Test that data for users in approved userlist is deleted. */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { $this->resetAfterTest(); $component = 'profilefield_text'; diff --git a/user/profile/field/textarea/tests/privacy/provider_test.php b/user/profile/field/textarea/tests/privacy/provider_test.php index a4c020c6b0a..54e81178ffc 100644 --- a/user/profile/field/textarea/tests/privacy/provider_test.php +++ b/user/profile/field/textarea/tests/privacy/provider_test.php @@ -47,7 +47,7 @@ class provider_test extends provider_testcase { /** * Test getting the context for the user ID related to this plugin. */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { global $DB; // Create profile category. $categoryid = $this->add_profile_category(); @@ -68,7 +68,7 @@ class provider_test extends provider_testcase { /** * Test that data is exported correctly for this plugin. */ - public function test_export_user_data() { + public function test_export_user_data(): void { // Create profile category. $categoryid = $this->add_profile_category(); // Create textarea profile field. @@ -95,7 +95,7 @@ class provider_test extends provider_testcase { /** * Test that user data is deleted using the context. */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; // Create profile category. $categoryid = $this->add_profile_category(); @@ -123,7 +123,7 @@ class provider_test extends provider_testcase { /** * Test that user data is deleted for this user. */ - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; // Create profile category. $categoryid = $this->add_profile_category(); @@ -153,7 +153,7 @@ class provider_test extends provider_testcase { /** * Test that only users with a user context are fetched. */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { $this->resetAfterTest(); $component = 'profilefield_textarea'; @@ -189,7 +189,7 @@ class provider_test extends provider_testcase { /** * Test that data for users in approved userlist is deleted. */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { $this->resetAfterTest(); $component = 'profilefield_textarea'; diff --git a/user/tests/editlib_test.php b/user/tests/editlib_test.php index 37b3a30ee1a..f09d87f42a2 100644 --- a/user/tests/editlib_test.php +++ b/user/tests/editlib_test.php @@ -34,7 +34,7 @@ class editlib_test extends \advanced_testcase { /** * Test that the required fields are returned in the correct order. */ - function test_useredit_get_required_name_fields() { + function test_useredit_get_required_name_fields(): void { global $CFG; // Back up config settings for restore later. $originalcfg = new \stdClass(); @@ -60,7 +60,7 @@ class editlib_test extends \advanced_testcase { /** * Test that the enabled fields are returned in the correct order. */ - function test_useredit_get_enabled_name_fields() { + function test_useredit_get_enabled_name_fields(): void { global $CFG; // Back up config settings for restore later. $originalcfg = new \stdClass(); @@ -86,7 +86,7 @@ class editlib_test extends \advanced_testcase { /** * Test that the disabled fields are returned. */ - function test_useredit_get_disabled_name_fields() { + function test_useredit_get_disabled_name_fields(): void { global $CFG; // Back up config settings for restore later. $originalcfg = new \stdClass(); diff --git a/user/tests/externallib_test.php b/user/tests/externallib_test.php index 0c6c91e99e1..f2ed8b46f80 100644 --- a/user/tests/externallib_test.php +++ b/user/tests/externallib_test.php @@ -50,7 +50,7 @@ final class externallib_test extends externallib_advanced_testcase { /** * Test get_users */ - public function test_get_users() { + public function test_get_users(): void { global $USER, $CFG; $this->resetAfterTest(true); @@ -419,7 +419,7 @@ final class externallib_test extends externallib_advanced_testcase { /** * Test get_course_user_profiles */ - public function test_get_course_user_profiles() { + public function test_get_course_user_profiles(): void { global $USER, $CFG; $this->resetAfterTest(true); @@ -437,7 +437,7 @@ final class externallib_test extends externallib_advanced_testcase { $this->assertEquals(1, count($enrolledusers)); } - public function test_get_user_course_profile_as_admin() { + public function test_get_user_course_profile_as_admin(): void { global $USER, $CFG; global $USER, $CFG; @@ -490,7 +490,7 @@ final class externallib_test extends externallib_advanced_testcase { /** * Test create_users */ - public function test_create_users() { + public function test_create_users(): void { global $DB; $this->resetAfterTest(true); @@ -589,7 +589,7 @@ final class externallib_test extends externallib_advanced_testcase { /** * Test create_users with password and createpassword parameter not set. */ - public function test_create_users_empty_password() { + public function test_create_users_empty_password(): void { $this->resetAfterTest(); $this->setAdminUser(); @@ -632,7 +632,7 @@ final class externallib_test extends externallib_advanced_testcase { * @param int $sameemailallowed The value to set for $CFG->allowaccountssameemail. * @param boolean $differentcase Whether to user a different case for the other user. */ - public function test_create_users_with_same_emails($sameemailallowed, $differentcase) { + public function test_create_users_with_same_emails($sameemailallowed, $differentcase): void { global $DB; $this->resetAfterTest(); @@ -677,7 +677,7 @@ final class externallib_test extends externallib_advanced_testcase { * @param array $data User data to attempt to register. * @param string $expectmessage Expected exception message. */ - public function test_create_users_invalid_parameter(array $data, $expectmessage) { + public function test_create_users_invalid_parameter(array $data, $expectmessage): void { global $USER, $CFG, $DB; $this->resetAfterTest(true); @@ -751,7 +751,7 @@ final class externallib_test extends externallib_advanced_testcase { /** * Test delete_users */ - public function test_delete_users() { + public function test_delete_users(): void { global $USER, $CFG, $DB; $this->resetAfterTest(true); @@ -782,7 +782,7 @@ final class externallib_test extends externallib_advanced_testcase { /** * Test update_users */ - public function test_update_users() { + public function test_update_users(): void { global $USER, $CFG, $DB; $this->resetAfterTest(true); @@ -989,7 +989,7 @@ final class externallib_test extends externallib_advanced_testcase { * @param boolean $successexpected Whether we expect that the target user's email/name will be updated. */ public function test_update_users_emails_with_different_cases($allowsameemail, $currentname, $currentemail, - $newname, $newemail, $withanotheruser, $successexpected) { + $newname, $newemail, $withanotheruser, $successexpected): void { global $DB; $this->resetAfterTest(); @@ -1036,7 +1036,7 @@ final class externallib_test extends externallib_advanced_testcase { /** * Test add_user_private_files */ - public function test_add_user_private_files() { + public function test_add_user_private_files(): void { global $USER, $CFG, $DB; $this->resetAfterTest(true); @@ -1082,7 +1082,7 @@ final class externallib_test extends externallib_advanced_testcase { /** * Test add_user_private_files quota */ - public function test_add_user_private_files_quota() { + public function test_add_user_private_files_quota(): void { global $USER, $CFG, $DB; $this->resetAfterTest(true); @@ -1130,7 +1130,7 @@ final class externallib_test extends externallib_advanced_testcase { /** * Test add user device */ - public function test_add_user_device() { + public function test_add_user_device(): void { global $USER, $CFG, $DB; $this->resetAfterTest(true); @@ -1185,7 +1185,7 @@ final class externallib_test extends externallib_advanced_testcase { /** * Test remove user device */ - public function test_remove_user_device() { + public function test_remove_user_device(): void { global $USER, $CFG, $DB; $this->resetAfterTest(true); @@ -1240,7 +1240,7 @@ final class externallib_test extends externallib_advanced_testcase { /** * Test get_user_preferences */ - public function test_get_user_preferences() { + public function test_get_user_preferences(): void { $this->resetAfterTest(true); $user = self::getDataGenerator()->create_user(); @@ -1303,7 +1303,7 @@ final class externallib_test extends externallib_advanced_testcase { /** * Test update_picture */ - public function test_update_picture() { + public function test_update_picture(): void { global $DB, $USER; $this->resetAfterTest(true); @@ -1356,7 +1356,7 @@ final class externallib_test extends externallib_advanced_testcase { /** * Test update_picture disabled */ - public function test_update_picture_disabled() { + public function test_update_picture_disabled(): void { global $CFG; $this->resetAfterTest(true); $CFG->disableuserimages = true; @@ -1369,7 +1369,7 @@ final class externallib_test extends externallib_advanced_testcase { /** * Test set_user_preferences */ - public function test_set_user_preferences_save() { + public function test_set_user_preferences_save(): void { global $DB; $this->resetAfterTest(true); @@ -1406,7 +1406,7 @@ final class externallib_test extends externallib_advanced_testcase { /** * Test set_user_preferences */ - public function test_set_user_preferences_save_invalid_pref() { + public function test_set_user_preferences_save_invalid_pref(): void { global $DB; $this->resetAfterTest(true); @@ -1435,7 +1435,7 @@ final class externallib_test extends externallib_advanced_testcase { /** * Test set_user_preferences for an invalid user */ - public function test_set_user_preferences_invalid_user() { + public function test_set_user_preferences_invalid_user(): void { $this->resetAfterTest(true); $this->setAdminUser(); @@ -1458,7 +1458,7 @@ final class externallib_test extends externallib_advanced_testcase { /** * Test set_user_preferences using an invalid preference */ - public function test_set_user_preferences_invalid_preference() { + public function test_set_user_preferences_invalid_preference(): void { global $USER, $DB; $this->resetAfterTest(true); @@ -1484,7 +1484,7 @@ final class externallib_test extends externallib_advanced_testcase { /** * Test set_user_preferences for other user not being admin */ - public function test_set_user_preferences_capability() { + public function test_set_user_preferences_capability(): void { $this->resetAfterTest(true); $user1 = self::getDataGenerator()->create_user(); @@ -1510,7 +1510,7 @@ final class externallib_test extends externallib_advanced_testcase { /** * Test update_user_preferences unsetting an existing preference. */ - public function test_update_user_preferences_unset() { + public function test_update_user_preferences_unset(): void { global $DB; $this->resetAfterTest(true); @@ -1544,7 +1544,7 @@ final class externallib_test extends externallib_advanced_testcase { /** * Test agree_site_policy */ - public function test_agree_site_policy() { + public function test_agree_site_policy(): void { global $CFG, $DB, $USER; $this->resetAfterTest(true); @@ -1595,7 +1595,7 @@ final class externallib_test extends externallib_advanced_testcase { /** * Test get_private_files_info */ - public function test_get_private_files_info() { + public function test_get_private_files_info(): void { $this->resetAfterTest(true); $user = self::getDataGenerator()->create_user(); @@ -1635,7 +1635,7 @@ final class externallib_test extends externallib_advanced_testcase { /** * Test get_private_files_info missing permissions. */ - public function test_get_private_files_info_missing_permissions() { + public function test_get_private_files_info_missing_permissions(): void { $this->resetAfterTest(true); $user1 = self::getDataGenerator()->create_user(); @@ -1650,7 +1650,7 @@ final class externallib_test extends externallib_advanced_testcase { /** * Test the functionality of the {@see \core_user\external\search_identity} class. */ - public function test_external_search_identity() { + public function test_external_search_identity(): void { global $CFG; $this->resetAfterTest(true); @@ -1759,7 +1759,7 @@ final class externallib_test extends externallib_advanced_testcase { /** * Test functionality of the {@see \core_user\external\search_identity} class with alternativefullnameformat defined. */ - public function test_external_search_identity_with_alternativefullnameformat() { + public function test_external_search_identity_with_alternativefullnameformat(): void { global $CFG; $this->resetAfterTest(true); @@ -1795,7 +1795,7 @@ final class externallib_test extends externallib_advanced_testcase { /** * Test verifying that update_user_preferences prevents changes to the default homepage for other users. */ - public function test_update_user_preferences_homepage_permission_callback() { + public function test_update_user_preferences_homepage_permission_callback(): void { global $DB; $this->resetAfterTest(); diff --git a/user/tests/fields_test.php b/user/tests/fields_test.php index 2fd0b2e2a0b..59cf7991c64 100644 --- a/user/tests/fields_test.php +++ b/user/tests/fields_test.php @@ -29,7 +29,7 @@ class fields_test extends \advanced_testcase { /** * Tests getting the user picture fields. */ - public function test_get_picture_fields() { + public function test_get_picture_fields(): void { $this->assertEquals(['id', 'picture', 'firstname', 'lastname', 'firstnamephonetic', 'lastnamephonetic', 'middlename', 'alternatename', 'imagealt', 'email'], fields::get_picture_fields()); @@ -38,7 +38,7 @@ class fields_test extends \advanced_testcase { /** * Tests getting the user name fields. */ - public function test_get_name_fields() { + public function test_get_name_fields(): void { $this->assertEquals(['firstnamephonetic', 'lastnamephonetic', 'middlename', 'alternatename', 'firstname', 'lastname'], fields::get_name_fields()); @@ -51,7 +51,7 @@ class fields_test extends \advanced_testcase { /** * Tests getting the identity fields. */ - public function test_get_identity_fields() { + public function test_get_identity_fields(): void { global $DB, $CFG, $COURSE; $this->resetAfterTest(); @@ -182,7 +182,7 @@ class fields_test extends \advanced_testcase { * to test the details of the identity permissions as that was already covered. Just how they * are included/combined. */ - public function test_get_required_fields() { + public function test_get_required_fields(): void { $this->resetAfterTest(); // Set up some profile fields. @@ -232,7 +232,7 @@ class fields_test extends \advanced_testcase { /** * Tests the get_required_fields function when you use the $limitpurposes parameter. */ - public function test_get_required_fields_limitpurposes() { + public function test_get_required_fields_limitpurposes(): void { $this->resetAfterTest(); // Set up some profile fields. @@ -264,7 +264,7 @@ class fields_test extends \advanced_testcase { /** * There should be an exception if you try to 'limit' purposes to one that wasn't even included. */ - public function test_get_required_fields_limitpurposes_not_in_constructor() { + public function test_get_required_fields_limitpurposes_not_in_constructor(): void { $fields = fields::for_identity(null); $this->expectExceptionMessage('$limitpurposes can only include purposes defined in object'); $fields->get_required_fields([fields::PURPOSE_USERPIC]); @@ -296,7 +296,7 @@ class fields_test extends \advanced_testcase { /** * Tests getting SQL (and actually using it). */ - public function test_get_sql_variations() { + public function test_get_sql_variations(): void { global $DB; $this->resetAfterTest(); @@ -446,7 +446,7 @@ class fields_test extends \advanced_testcase { * Tests what happens if you use the SQL multiple times in a query (i.e. that it correctly * creates the different identifiers). */ - public function test_get_sql_multiple() { + public function test_get_sql_multiple(): void { global $DB; $this->resetAfterTest(); @@ -486,7 +486,7 @@ class fields_test extends \advanced_testcase { /** * Tests the get_sql function when there are no fields to retrieve. */ - public function test_get_sql_nothing() { + public function test_get_sql_nothing(): void { $fields = fields::empty(); ['selects' => $selects, 'joins' => $joins, 'params' => $joinparams] = (array)$fields->get_sql(); $this->assertEquals('', $selects); @@ -498,7 +498,7 @@ class fields_test extends \advanced_testcase { * Tests get_sql when there are no custom fields; in this scenario, the joins and joinparams * are always blank. */ - public function test_get_sql_no_custom_fields() { + public function test_get_sql_no_custom_fields(): void { $fields = fields::empty()->including('city', 'country'); ['selects' => $selects, 'joins' => $joins, 'params' => $joinparams, 'mappings' => $mappings] = (array)$fields->get_sql('u'); @@ -512,7 +512,7 @@ class fields_test extends \advanced_testcase { * Tests the format of the $selects string, which is important particularly for backward * compatibility. */ - public function test_get_sql_selects_format() { + public function test_get_sql_selects_format(): void { global $DB; $this->resetAfterTest(); diff --git a/user/tests/group_non_members_selector_test.php b/user/tests/group_non_members_selector_test.php index 04524a72cdc..9235ecd719b 100644 --- a/user/tests/group_non_members_selector_test.php +++ b/user/tests/group_non_members_selector_test.php @@ -36,7 +36,7 @@ class group_non_members_selector_test extends \advanced_testcase { /** * Test find_users that only return group non members */ - public function test_find_users_only_return_group_non_member() { + public function test_find_users_only_return_group_non_member(): void { $this->resetAfterTest(); // Create course. diff --git a/user/tests/myprofile_test.php b/user/tests/myprofile_test.php index b7bd3761a99..c5fece62fcb 100644 --- a/user/tests/myprofile_test.php +++ b/user/tests/myprofile_test.php @@ -32,7 +32,7 @@ class myprofile_test extends \advanced_testcase { /** * Test node::__construct(). */ - public function test_node__construct() { + public function test_node__construct(): void { $node = new \core_user\output\myprofile\node('parentcat', 'nodename', 'nodetitle', 'after', 'www.google.com', 'description', new \pix_icon('i/course', ''), 'class1 class2'); $this->assertSame('parentcat', $node->parentcat); @@ -48,7 +48,7 @@ class myprofile_test extends \advanced_testcase { /** * Test category::node_add(). */ - public function test_add_node() { + public function test_add_node(): void { $tree = new \core_user\output\myprofile\tree(); $category = new \core_user\output\myprofile\category('category', 'categorytitle'); @@ -73,7 +73,7 @@ class myprofile_test extends \advanced_testcase { /** * Test category::__construct(). */ - public function test_category__construct() { + public function test_category__construct(): void { $category = new \core_user\output\myprofile\category('categoryname', 'title', 'after', 'class1 class2'); $this->assertSame('categoryname', $category->name); $this->assertSame('title', $category->title); @@ -81,7 +81,7 @@ class myprofile_test extends \advanced_testcase { $this->assertSame('class1 class2', $category->classes); } - public function test_validate_after_order1() { + public function test_validate_after_order1(): void { $category = new \phpunit_fixture_myprofile_category('category', 'title', null); // Create nodes. @@ -98,7 +98,7 @@ class myprofile_test extends \advanced_testcase { } - public function test_validate_after_order2() { + public function test_validate_after_order2(): void { $category = new \phpunit_fixture_myprofile_category('category', 'title', null); // Create nodes. @@ -118,7 +118,7 @@ class myprofile_test extends \advanced_testcase { /** * Test category::find_nodes_after(). */ - public function test_find_nodes_after() { + public function test_find_nodes_after(): void { $category = new \phpunit_fixture_myprofile_category('category', 'title', null); // Create nodes. @@ -161,7 +161,7 @@ class myprofile_test extends \advanced_testcase { /** * Test category::sort_nodes(). */ - public function test_sort_nodes1() { + public function test_sort_nodes1(): void { $category = new \phpunit_fixture_myprofile_category('category', 'title', null); // Create nodes. @@ -213,7 +213,7 @@ class myprofile_test extends \advanced_testcase { /** * Test category::sort_nodes() with a mix of content and non content nodes. */ - public function test_sort_nodes2() { + public function test_sort_nodes2(): void { $category = new \phpunit_fixture_myprofile_category('category', 'title', null); // Create nodes. @@ -253,7 +253,7 @@ class myprofile_test extends \advanced_testcase { /** * Test tree::add_node(). */ - public function test_tree_add_node() { + public function test_tree_add_node(): void { $tree = new \phpunit_fixture_myprofile_tree(); $node1 = new \core_user\output\myprofile\node('category', 'node1', 'nodetitle'); $tree->add_node($node1); @@ -269,7 +269,7 @@ class myprofile_test extends \advanced_testcase { /** * Test tree::add_category(). */ - public function test_tree_add_category() { + public function test_tree_add_category(): void { $tree = new \phpunit_fixture_myprofile_tree(); $category1 = new \core_user\output\myprofile\category('category', 'title'); $tree->add_category($category1); @@ -285,7 +285,7 @@ class myprofile_test extends \advanced_testcase { /** * Test tree::find_categories_after(). */ - public function test_find_categories_after() { + public function test_find_categories_after(): void { $tree = new \phpunit_fixture_myprofile_tree('category', 'title', null); // Create categories. @@ -328,7 +328,7 @@ class myprofile_test extends \advanced_testcase { /** * Test tree::sort_categories(). */ - public function test_sort_categories() { + public function test_sort_categories(): void { $tree = new \phpunit_fixture_myprofile_tree('category', 'title', null); // Create categories. diff --git a/user/tests/privacy/provider_test.php b/user/tests/privacy/provider_test.php index a908701a4b7..21b5d2564ab 100644 --- a/user/tests/privacy/provider_test.php +++ b/user/tests/privacy/provider_test.php @@ -44,7 +44,7 @@ class provider_test extends provider_testcase { /** * Check that context information is returned correctly. */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); // Create some other users as well. @@ -59,7 +59,7 @@ class provider_test extends provider_testcase { /** * Test that data is exported as expected for a user. */ - public function test_export_user_data() { + public function test_export_user_data(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user([ 'firstaccess' => 1535760000, @@ -141,7 +141,7 @@ class provider_test extends provider_testcase { /** * Test that user data is deleted for one user. */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user([ @@ -210,7 +210,7 @@ class provider_test extends provider_testcase { /** * Test that user data is deleted for one user. */ - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user([ @@ -286,7 +286,7 @@ class provider_test extends provider_testcase { /** * Test that only users with a user context are fetched. */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { $this->resetAfterTest(); $component = 'core_user'; @@ -312,7 +312,7 @@ class provider_test extends provider_testcase { /** * Test that data for users in approved userlist is deleted. */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { global $DB; $this->resetAfterTest(); diff --git a/user/tests/profilelib_test.php b/user/tests/profilelib_test.php index 3daa968211d..6e91acc7967 100644 --- a/user/tests/profilelib_test.php +++ b/user/tests/profilelib_test.php @@ -37,7 +37,7 @@ class profilelib_test extends \advanced_testcase { * Tests profile_get_custom_fields function and checks it is consistent * with profile_user_record. */ - public function test_get_custom_fields() { + public function test_get_custom_fields(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); @@ -84,7 +84,7 @@ class profilelib_test extends \advanced_testcase { /** * Make sure that all profile fields can be initialised without arguments. */ - public function test_default_constructor() { + public function test_default_constructor(): void { global $DB, $CFG; require_once($CFG->dirroot . '/user/profile/definelib.php'); $datatypes = profile_list_datatypes(); @@ -100,7 +100,7 @@ class profilelib_test extends \advanced_testcase { /** * Test profile_view function */ - public function test_profile_view() { + public function test_profile_view(): void { global $USER; $this->resetAfterTest(); @@ -142,7 +142,7 @@ class profilelib_test extends \advanced_testcase { /** * Test that {@link user_not_fully_set_up()} takes required custom fields into account. */ - public function test_profile_has_required_custom_fields_set() { + public function test_profile_has_required_custom_fields_set(): void { global $CFG; require_once($CFG->dirroot.'/mnet/lib.php'); @@ -210,7 +210,7 @@ class profilelib_test extends \advanced_testcase { /** * Test that user generator sets the custom profile fields */ - public function test_profile_fields_in_generator() { + public function test_profile_fields_in_generator(): void { global $CFG; require_once($CFG->dirroot.'/mnet/lib.php'); @@ -240,7 +240,7 @@ class profilelib_test extends \advanced_testcase { /** * Tests the profile_get_custom_field_data_by_shortname function when working normally. */ - public function test_profile_get_custom_field_data_by_shortname_normal() { + public function test_profile_get_custom_field_data_by_shortname_normal(): void { global $DB; $this->resetAfterTest(); @@ -272,7 +272,7 @@ class profilelib_test extends \advanced_testcase { /** * Tests the profile_get_custom_field_data_by_shortname function with a field that doesn't exist. */ - public function test_profile_get_custom_field_data_by_shortname_missing() { + public function test_profile_get_custom_field_data_by_shortname_missing(): void { $this->assertNull(profile_get_custom_field_data_by_shortname('speciality')); } diff --git a/user/tests/search/search_test.php b/user/tests/search/search_test.php index 91ab540bd6b..8bbebdcbfdd 100644 --- a/user/tests/search/search_test.php +++ b/user/tests/search/search_test.php @@ -58,7 +58,7 @@ class search_test extends \advanced_testcase { * * @return void */ - public function test_users_indexing() { + public function test_users_indexing(): void { global $SITE; // Returns the instance as long as the area is supported. @@ -106,7 +106,7 @@ class search_test extends \advanced_testcase { * * @return void */ - public function test_users_document() { + public function test_users_document(): void { // Returns the instance as long as the area is supported. $searcharea = \core_search\manager::get_search_area($this->userareaid); @@ -130,7 +130,7 @@ class search_test extends \advanced_testcase { * * @return void */ - public function test_users_access() { + public function test_users_access(): void { global $CFG; // Returns the instance as long as the area is supported. @@ -221,7 +221,7 @@ class search_test extends \advanced_testcase { /** * Test document icon. */ - public function test_get_doc_icon() { + public function test_get_doc_icon(): void { $searcharea = \core_search\manager::get_search_area($this->userareaid); $user = self::getDataGenerator()->create_user(); $doc = $searcharea->get_document($user); @@ -235,7 +235,7 @@ class search_test extends \advanced_testcase { /** * Test assigned search categories. */ - public function test_get_category_names() { + public function test_get_category_names(): void { $searcharea = \core_search\manager::get_search_area($this->userareaid); $expected = ['core-users']; diff --git a/user/tests/userlib_test.php b/user/tests/userlib_test.php index 7271b2fed40..bdb44dc87d3 100644 --- a/user/tests/userlib_test.php +++ b/user/tests/userlib_test.php @@ -33,7 +33,7 @@ class userlib_test extends \advanced_testcase { /** * Test user_get_user_details_courses */ - public function test_user_get_user_details_courses() { + public function test_user_get_user_details_courses(): void { global $DB; $this->resetAfterTest(); @@ -75,7 +75,7 @@ class userlib_test extends \advanced_testcase { /** * Verify return when course groupmode set to 'no groups'. */ - public function test_user_get_user_details_courses_groupmode_nogroups() { + public function test_user_get_user_details_courses_groupmode_nogroups(): void { $this->resetAfterTest(); // Enrol 2 users into a course with groupmode set to 'no groups'. @@ -95,7 +95,7 @@ class userlib_test extends \advanced_testcase { /** * Verify return when course groupmode set to 'separate groups'. */ - public function test_user_get_user_details_courses_groupmode_separate() { + public function test_user_get_user_details_courses_groupmode_separate(): void { $this->resetAfterTest(); // Enrol 2 users into a course with groupmode set to 'separate groups'. @@ -113,7 +113,7 @@ class userlib_test extends \advanced_testcase { /** * Verify return when course groupmode set to 'visible groups'. */ - public function test_user_get_user_details_courses_groupmode_visible() { + public function test_user_get_user_details_courses_groupmode_visible(): void { $this->resetAfterTest(); // Enrol 2 users into a course with groupmode set to 'visible groups'. @@ -135,7 +135,7 @@ class userlib_test extends \advanced_testcase { * * @covers ::user_get_user_details_courses */ - public function test_user_get_user_details_courses_limit_return() { + public function test_user_get_user_details_courses_limit_return(): void { $this->resetAfterTest(); // Setup some data. @@ -176,7 +176,7 @@ class userlib_test extends \advanced_testcase { /** * Test user_update_user. */ - public function test_user_update_user() { + public function test_user_update_user(): void { global $DB; $this->resetAfterTest(); @@ -250,7 +250,7 @@ class userlib_test extends \advanced_testcase { /** * Test create_users. */ - public function test_create_users() { + public function test_create_users(): void { global $DB; $this->resetAfterTest(); @@ -365,7 +365,7 @@ class userlib_test extends \advanced_testcase { * @param string $username Invalid username * @param string $expectmessage Expected exception message */ - public function test_create_user_invalid_username($username, $expectmessage) { + public function test_create_user_invalid_username($username, $expectmessage): void { global $CFG; $this->resetAfterTest(); @@ -410,7 +410,7 @@ class userlib_test extends \advanced_testcase { /** * Test function user_count_login_failures(). */ - public function test_user_count_login_failures() { + public function test_user_count_login_failures(): void { $this->resetAfterTest(); $user = $this->getDataGenerator()->create_user(); $this->assertEquals(0, get_user_preferences('login_failed_count_since_success', 0, $user)); @@ -434,7 +434,7 @@ class userlib_test extends \advanced_testcase { /** * Test function user_add_password_history(). */ - public function test_user_add_password_history() { + public function test_user_add_password_history(): void { global $DB; $this->resetAfterTest(); @@ -508,7 +508,7 @@ class userlib_test extends \advanced_testcase { /** * Test function user_add_password_history(). */ - public function test_user_is_previously_used_password() { + public function test_user_is_previously_used_password(): void { global $DB; $this->resetAfterTest(); @@ -576,7 +576,7 @@ class userlib_test extends \advanced_testcase { /** * Test that password history is deleted together with user. */ - public function test_delete_of_hashes_on_user_delete() { + public function test_delete_of_hashes_on_user_delete(): void { global $DB; $this->resetAfterTest(); @@ -604,7 +604,7 @@ class userlib_test extends \advanced_testcase { /** * Test user_list_view function */ - public function test_user_list_view() { + public function test_user_list_view(): void { $this->resetAfterTest(); @@ -633,7 +633,7 @@ class userlib_test extends \advanced_testcase { /** * Test setting the user menu avatar size. */ - public function test_user_menu_custom_avatar_size() { + public function test_user_menu_custom_avatar_size(): void { global $PAGE; $this->resetAfterTest(true); @@ -653,7 +653,7 @@ class userlib_test extends \advanced_testcase { /** * Test user_can_view_profile */ - public function test_user_can_view_profile() { + public function test_user_can_view_profile(): void { global $DB, $CFG; $this->resetAfterTest(); @@ -828,7 +828,7 @@ class userlib_test extends \advanced_testcase { /** * Test user_get_user_details */ - public function test_user_get_user_details() { + public function test_user_get_user_details(): void { global $DB; $this->resetAfterTest(); @@ -879,7 +879,7 @@ class userlib_test extends \advanced_testcase { * Ensure the fields "auth, confirmed, idnumber, lang, theme, timezone and mailformat" are present when * calling user_get_user_details() function. */ - public function test_user_get_user_details_missing_fields() { + public function test_user_get_user_details_missing_fields(): void { global $CFG; $this->resetAfterTest(true); @@ -911,7 +911,7 @@ class userlib_test extends \advanced_testcase { * Test user_get_user_details_permissions. * @covers ::user_get_user_details */ - public function test_user_get_user_details_permissions() { + public function test_user_get_user_details_permissions(): void { global $CFG; $this->resetAfterTest(); diff --git a/user/tests/userroleseditable_test.php b/user/tests/userroleseditable_test.php index 04f75e25410..9a8fd072881 100644 --- a/user/tests/userroleseditable_test.php +++ b/user/tests/userroleseditable_test.php @@ -27,7 +27,7 @@ class userroleseditable_test extends \advanced_testcase { /** * Test user roles editable. */ - public function test_update() { + public function test_update(): void { global $DB; $this->resetAfterTest(); diff --git a/user/tests/userselector_test.php b/user/tests/userselector_test.php index 78b8f261955..d18778f5660 100644 --- a/user/tests/userselector_test.php +++ b/user/tests/userselector_test.php @@ -66,7 +66,7 @@ class userselector_test extends \advanced_testcase { /** * No identity fields are not shown to student user (no permission to view identity fields). */ - public function test_hidden_siteidentity_fields_no_access() { + public function test_hidden_siteidentity_fields_no_access(): void { $this->resetAfterTest(); $env = $this->setup_hidden_siteidentity(); $this->setUser($env->student); @@ -85,7 +85,7 @@ class userselector_test extends \advanced_testcase { /** * Teacher can see students' identity fields only within the course. */ - public function test_hidden_siteidentity_fields_course_only_access() { + public function test_hidden_siteidentity_fields_course_only_access(): void { $this->resetAfterTest(); $env = $this->setup_hidden_siteidentity(); $this->setUser($env->teacher); @@ -113,7 +113,7 @@ class userselector_test extends \advanced_testcase { /** * Teacher can be prevented from seeing students' identity fields even within the course. */ - public function test_hidden_siteidentity_fields_course_prevented_access() { + public function test_hidden_siteidentity_fields_course_prevented_access(): void { $this->resetAfterTest(); $env = $this->setup_hidden_siteidentity(); $this->setUser($env->teacher); @@ -134,7 +134,7 @@ class userselector_test extends \advanced_testcase { /** * Manager can see students' identity fields anywhere. */ - public function test_hidden_siteidentity_fields_anywhere_access() { + public function test_hidden_siteidentity_fields_anywhere_access(): void { $this->resetAfterTest(); $env = $this->setup_hidden_siteidentity(); $this->setUser($env->manager); @@ -162,7 +162,7 @@ class userselector_test extends \advanced_testcase { /** * Manager can be prevented from seeing hidden fields outside the course. */ - public function test_hidden_siteidentity_fields_schismatic_access() { + public function test_hidden_siteidentity_fields_schismatic_access(): void { $this->resetAfterTest(); $env = $this->setup_hidden_siteidentity(); $this->setUser($env->manager); @@ -196,7 +196,7 @@ class userselector_test extends \advanced_testcase { /** * Two capabilities must be currently set to prevent manager from seeing hidden fields. */ - public function test_hidden_siteidentity_fields_hard_to_prevent_access() { + public function test_hidden_siteidentity_fields_hard_to_prevent_access(): void { $this->resetAfterTest(); $env = $this->setup_hidden_siteidentity(); $this->setUser($env->manager); @@ -230,7 +230,7 @@ class userselector_test extends \advanced_testcase { * However, this was found as violating the principle of respecting site privacy settings. So the feature has been * dropped in Moodle 3.6. */ - public function test_hidden_siteidentity_fields_explicit_extrafields() { + public function test_hidden_siteidentity_fields_explicit_extrafields(): void { $this->resetAfterTest(); $env = $this->setup_hidden_siteidentity(); $this->setUser($env->manager); diff --git a/webservice/rest/tests/server_test.php b/webservice/rest/tests/server_test.php index c1cb4319cd7..f97812eb990 100644 --- a/webservice/rest/tests/server_test.php +++ b/webservice/rest/tests/server_test.php @@ -205,7 +205,7 @@ class server_test extends \advanced_testcase { * @param mixed $value The value to xmlise. * @param mixed $expected The expected output. */ - public function test_xmlize($description, $value, $expected) { + public function test_xmlize($description, $value, $expected): void { $method = new \ReflectionMethod('webservice_rest_server', 'xmlize_result'); $this->assertEquals($expected, $method->invoke(null, $value, $description)); } diff --git a/webservice/soap/tests/wsdl_test.php b/webservice/soap/tests/wsdl_test.php index 703c0601e6d..07c89c77f93 100644 --- a/webservice/soap/tests/wsdl_test.php +++ b/webservice/soap/tests/wsdl_test.php @@ -41,7 +41,7 @@ class wsdl_test extends \advanced_testcase { /** * Test generated WSDL with no added complex types nor functions. */ - public function test_minimum_wsdl() { + public function test_minimum_wsdl(): void { $this->resetAfterTest(); $serviceclass = 'testserviceclass'; @@ -89,7 +89,7 @@ class wsdl_test extends \advanced_testcase { /** * Test output WSDL with complex type added. */ - public function test_add_complex_type() { + public function test_add_complex_type(): void { $this->resetAfterTest(); $classname = 'testcomplextype'; @@ -162,7 +162,7 @@ class wsdl_test extends \advanced_testcase { /** * Test output WSDL when registering a web service function. */ - public function test_register() { + public function test_register(): void { $this->resetAfterTest(); $serviceclass = 'testserviceclass'; @@ -289,7 +289,7 @@ class wsdl_test extends \advanced_testcase { /** * Test output WSDL when registering a web service function with no input parameters. */ - public function test_register_without_input() { + public function test_register_without_input(): void { $this->resetAfterTest(); $serviceclass = 'testserviceclass'; @@ -331,7 +331,7 @@ class wsdl_test extends \advanced_testcase { /** * Test output WSDL when registering a web service function with no output parameters. */ - public function test_register_without_output() { + public function test_register_without_output(): void { $this->resetAfterTest(); $serviceclass = 'testserviceclass'; diff --git a/webservice/tests/event/events_test.php b/webservice/tests/event/events_test.php index 6ceef550580..899a51d6f7f 100644 --- a/webservice/tests/event/events_test.php +++ b/webservice/tests/event/events_test.php @@ -39,7 +39,7 @@ class events_test extends \advanced_testcase { $this->resetAfterTest(); } - public function test_function_called() { + public function test_function_called(): void { // The Web service API doesn't allow the testing of the events directly by // calling some functions which trigger the events, so what we are going here // is just checking that the event returns the expected information. @@ -63,7 +63,7 @@ class events_test extends \advanced_testcase { $this->assertEventContextNotUsed($event); } - public function test_login_failed() { + public function test_login_failed(): void { // The Web service API doesn't allow the testing of the events directly by // calling some functions which trigger the events, so what we are going here // is just checking that the event returns the expected information. @@ -99,7 +99,7 @@ class events_test extends \advanced_testcase { $this->assertEventContextNotUsed($event); } - public function test_service_created() { + public function test_service_created(): void { global $CFG, $DB; // The Web service API doesn't allow the testing of the events directly by @@ -141,7 +141,7 @@ class events_test extends \advanced_testcase { $this->assertEventContextNotUsed($event); } - public function test_service_updated() { + public function test_service_updated(): void { global $CFG, $DB; // The Web service API doesn't allow the testing of the events directly by @@ -183,7 +183,7 @@ class events_test extends \advanced_testcase { $this->assertEventContextNotUsed($event); } - public function test_service_deleted() { + public function test_service_deleted(): void { global $CFG, $DB; // The Web service API doesn't allow the testing of the events directly by @@ -225,7 +225,7 @@ class events_test extends \advanced_testcase { $this->assertEventContextNotUsed($event); } - public function test_service_user_added() { + public function test_service_user_added(): void { global $CFG; // The Web service API doesn't allow the testing of the events directly by @@ -251,7 +251,7 @@ class events_test extends \advanced_testcase { $this->assertEventContextNotUsed($event); } - public function test_service_user_removed() { + public function test_service_user_removed(): void { global $CFG; // The Web service API doesn't allow the testing of the events directly by @@ -277,7 +277,7 @@ class events_test extends \advanced_testcase { $this->assertEventContextNotUsed($event); } - public function test_token_created() { + public function test_token_created(): void { // The Web service API doesn't allow the testing of the events directly by // calling some functions which trigger the events, so what we are going here // is just checking that the event returns the expected information. @@ -304,7 +304,7 @@ class events_test extends \advanced_testcase { $this->assertEventContextNotUsed($event); } - public function test_token_sent() { + public function test_token_sent(): void { $user = $this->getDataGenerator()->create_user(); $this->setUser($user); diff --git a/webservice/tests/externallib_test.php b/webservice/tests/externallib_test.php index 845851656fb..9dbce930e0b 100644 --- a/webservice/tests/externallib_test.php +++ b/webservice/tests/externallib_test.php @@ -43,7 +43,7 @@ class externallib_test extends externallib_advanced_testcase { set_config('enablewebservices', '1'); } - public function test_get_site_info() { + public function test_get_site_info(): void { global $DB, $USER, $CFG, $PAGE; $this->resetAfterTest(true); @@ -201,7 +201,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_site_info with values > PHP_INT_MAX. We check only userquota since maxbytes require PHP ini changes. */ - public function test_get_site_info_max_int() { + public function test_get_site_info_max_int(): void { $this->resetAfterTest(true); self::setUser(self::getDataGenerator()->create_user()); @@ -218,7 +218,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test get_site_info with missing components. */ - public function test_get_site_missing_components() { + public function test_get_site_missing_components(): void { global $USER, $DB; $this->resetAfterTest(true); diff --git a/webservice/tests/lib_test.php b/webservice/tests/lib_test.php index 059eb5723df..29be23e83cd 100644 --- a/webservice/tests/lib_test.php +++ b/webservice/tests/lib_test.php @@ -59,7 +59,7 @@ class lib_test extends \advanced_testcase { /** * Test init_service_class(). */ - public function test_init_service_class() { + public function test_init_service_class(): void { global $DB, $USER; $this->resetAfterTest(true); @@ -148,7 +148,7 @@ class lib_test extends \advanced_testcase { /** * Tests update_token_lastaccess() function. */ - public function test_update_token_lastaccess() { + public function test_update_token_lastaccess(): void { global $DB, $USER; $this->resetAfterTest(true); @@ -208,7 +208,7 @@ class lib_test extends \advanced_testcase { /** * Tests for the {@see webservice::get_missing_capabilities_by_users()} implementation. */ - public function test_get_missing_capabilities_by_users() { + public function test_get_missing_capabilities_by_users(): void { global $DB; $this->resetAfterTest(true);