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('
');
@@ -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.
download image
no spaceAll 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('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 = <<
';
@@ -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 ";
$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('~^filter_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('
'));
$text = 'xx
xx';
@@ -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('
'));
$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('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?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
\n\ntwo
\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 = "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>?$(*DSFMO#$*)(SDJ)($*)', clean_param('#()*#,9789\'".,<42897>?$(*DSFMO#$*)(SDJ)($*)', PARAM_RAW)); @@ -374,7 +374,7 @@ class moodlelib_test extends \advanced_testcase { * @covers \core\param * @covers \clean_param */ - public function test_clean_param_trim() { + public function test_clean_param_trim(): void { $this->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('|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 = '
';
$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 = ' Frog
')); $this->assertEquals('FrogFrog
\nToad
")); @@ -205,7 +205,7 @@ class question_single_test extends \advanced_testcase { $this->assertEquals('FrogFrog
†
')); } - 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 ', '