Skip to content

Commit

Permalink
MDL-81522 phpunit: Add missing void return type to all tests
Browse files Browse the repository at this point in the history
While this change is not 100% required now, it's good habit
and we are checking for it since Moodle 4.4.

All the changes in this commit have been applied automatically
using the moodle.PHPUnit.TestReturnType sniff and are, exclusively
adding the ": void" return types when missing.
  • Loading branch information
stronk7 committed Jun 11, 2024
1 parent d3ae139 commit 01148a0
Show file tree
Hide file tree
Showing 1,360 changed files with 9,928 additions and 9,928 deletions.
12 changes: 6 additions & 6 deletions admin/presets/tests/privacy/privacy_provider_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -49,7 +49,7 @@ public function test_get_metadata() {
* 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();
Expand All @@ -67,7 +67,7 @@ public function test_get_contexts_for_userid() {
* 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();
Expand All @@ -88,7 +88,7 @@ public function test_get_users_in_context() {
* 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();
Expand Down Expand Up @@ -121,7 +121,7 @@ public function test_export_user_data() {
* 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();
Expand All @@ -146,7 +146,7 @@ public function test_delete_data_for_all_users_in_context() {
* 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();
Expand Down
4 changes: 2 additions & 2 deletions admin/roles/tests/preset_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @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');
Expand Down Expand Up @@ -81,7 +81,7 @@ public function test_xml() {
* 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');
Expand Down
18 changes: 9 additions & 9 deletions admin/roles/tests/privacy/provider_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -64,7 +64,7 @@ public function test_export_user_preferences() {
/**
* 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();
Expand Down Expand Up @@ -114,7 +114,7 @@ public function test_get_contexts_for_userid() {
/**
* Test that user data is exported correctly.
*/
public function test_export_user_data() {
public function test_export_user_data(): void {
global $DB;

$this->resetAfterTest();
Expand Down Expand Up @@ -243,7 +243,7 @@ public function test_export_user_data() {
/**
* 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();
Expand Down Expand Up @@ -329,7 +329,7 @@ public function test_delete_data_for_all_users_in_context() {
/**
* 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();
Expand Down Expand Up @@ -387,7 +387,7 @@ public function test_delete_data_for_user() {
/**
* 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();
Expand Down Expand Up @@ -443,7 +443,7 @@ public function test_export_user_role_to_cohort() {
/**
* 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();
Expand Down Expand Up @@ -478,7 +478,7 @@ public function test_delete_user_role_to_cohort() {
/**
* 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();
Expand Down Expand Up @@ -599,7 +599,7 @@ public function test_get_users_in_context() {
/**
* 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions admin/tool/analytics/tests/external/external_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -71,7 +71,7 @@ public function test_potential_contexts() {
/**
* 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();
Expand Down
4 changes: 2 additions & 2 deletions admin/tool/behat/tests/behat_form_text_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function provider_test_set_get_value() {
* @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);
Expand Down Expand Up @@ -115,7 +115,7 @@ public function provider_test_matches() {
* @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.
Expand Down
8 changes: 4 additions & 4 deletions admin/tool/brickfield/tests/accessibility_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -57,7 +57,7 @@ public function test_get_title() {
*
* @throws \dml_exception
*/
public function test_check_ids() {
public function test_check_ids(): void {
$this->resetAfterTest();
$object = new accessibility();

Expand All @@ -74,7 +74,7 @@ public function test_check_ids() {
*
* @throws \dml_exception
*/
public function test_get_translations() {
public function test_get_translations(): void {
$this->resetAfterTest();
$object = new accessibility();

Expand All @@ -90,7 +90,7 @@ public function test_get_translations() {
*
* @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();
Expand Down
8 changes: 4 additions & 4 deletions admin/tool/brickfield/tests/area_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -87,7 +87,7 @@ public function test_assign() {
/**
* 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');
Expand Down Expand Up @@ -147,7 +147,7 @@ public function test_questiontext() {
/**
* test for the area questionanswers
*/
public function test_questionanswers() {
public function test_questionanswers(): void {
global $DB;

$this->resetAfterTest();
Expand Down Expand Up @@ -191,7 +191,7 @@ public function test_questionanswers() {
/**
* 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();
Expand Down
12 changes: 6 additions & 6 deletions admin/tool/brickfield/tests/filters_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @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.
Expand Down Expand Up @@ -56,7 +56,7 @@ public function test_constructor() {
$this->assertEquals($object->url, $url);
}

public function test_get_course_sql() {
public function test_get_course_sql(): void {
$this->resetAfterTest();
$object = new filter();

Expand All @@ -73,7 +73,7 @@ public function test_get_course_sql() {

}

public function test_validate_filters() {
public function test_validate_filters(): void {
$this->resetAfterTest();
// Variables.
$courseid = 0;
Expand Down Expand Up @@ -102,7 +102,7 @@ public function test_validate_filters() {
$this->assertFalse($output);
}

public function test_has_course_filters() {
public function test_has_course_filters(): void {
$this->resetAfterTest();

$object = new filter();
Expand All @@ -114,7 +114,7 @@ public function test_has_course_filters() {
$this->assertTrue($output);
}

public function test_has_capability_in_context() {
public function test_has_capability_in_context(): void {
global $DB;

$this->resetAfterTest();
Expand Down Expand Up @@ -151,7 +151,7 @@ public function test_has_capability_in_context() {
$this->assertTrue($output);
}

public function test_get_errormessage() {
public function test_get_errormessage(): void {
$this->resetAfterTest();
// Variables.
$courseid = 0;
Expand Down
Loading

0 comments on commit 01148a0

Please sign in to comment.