Skip to content

Commit

Permalink
MDL-67673 phpunit: Fix the return type of template methods
Browse files Browse the repository at this point in the history
All the setup/teardown/pre/post/conditions template methods
now are required to return void. This was warned with phpunit 7
and now is enforced.

At the same time, fix a few wrong function names,
provider data and param types, return statements...
  • Loading branch information
stronk7 committed Oct 21, 2020
1 parent bdc3ad0 commit f6711bb
Show file tree
Hide file tree
Showing 421 changed files with 531 additions and 531 deletions.
2 changes: 1 addition & 1 deletion admin/tool/behat/tests/manager_util_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase {
/**
* Setup test.
*/
public function setup() {
public function setUp(): void {
global $CFG;

$this->resetAfterTest();
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/capability/tests/events_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class tool_capability_events_testcase extends advanced_testcase {
/**
* Setup testcase.
*/
public function setUp() {
public function setUp(): void {
$this->setAdminUser();
$this->resetAfterTest();
}
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/cohortroles/tests/api_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class tool_cohortroles_api_testcase extends advanced_testcase {
/**
* Setup function- we will create a course and add an assign instance to it.
*/
protected function setUp() {
protected function setUp(): void {
$this->resetAfterTest(true);

// Create some users.
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/cohortroles/tests/privacy_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class tool_cohortroles_privacy_testcase extends \core_privacy\tests\provider_tes
/**
* Overriding setUp() function to always reset after tests.
*/
public function setUp() {
public function setUp(): void {
$this->resetAfterTest(true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class tool_dataprivacy_expired_data_requests_testcase extends data_privacy_testc
/**
* Test tearDown.
*/
public function tearDown() {
public function tearDown(): void {
\core_privacy\local\request\writer::reset();
}

Expand Down
2 changes: 1 addition & 1 deletion admin/tool/dataprivacy/tests/task_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class tool_dataprivacy_task_testcase extends data_privacy_testcase {
/**
* Test tearDown.
*/
public function tearDown() {
public function tearDown(): void {
\core_privacy\local\request\writer::reset();
}

Expand Down
2 changes: 1 addition & 1 deletion admin/tool/langimport/tests/events_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class tool_langimport_events_testcase extends advanced_testcase {
/**
* Setup testcase.
*/
public function setUp() {
public function setUp(): void {
$this->setAdminUser();
$this->resetAfterTest();
}
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/log/store/database/tests/privacy_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
*/
class logstore_database_privacy_testcase extends provider_testcase {

public function setUp() {
public function setUp(): void {
global $CFG;
$this->resetAfterTest();
$this->preventResetByRollback(); // Logging waits till the transaction gets committed.
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/log/store/legacy/tests/privacy_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
*/
class logstore_legacy_privacy_testcase extends provider_testcase {

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

Expand Down
2 changes: 1 addition & 1 deletion admin/tool/log/store/standard/tests/privacy_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
*/
class logstore_standard_privacy_testcase extends provider_testcase {

public function setUp() {
public function setUp(): void {
$this->resetAfterTest();
$this->preventResetByRollback(); // Logging waits till the transaction gets committed.
}
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/log/store/standard/tests/store_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ private function disable_gc() {
/**
* Reset any garbage collector changes to the previous state at the end of the test.
*/
public function tearDown() {
public function tearDown(): void {
if ($this->wedisabledgc) {
gc_enable();
}
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/log/tests/privacy_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
*/
class tool_log_privacy_testcase extends provider_testcase {

public function setUp() {
public function setUp(): void {
$this->resetAfterTest();
$this->preventResetByRollback(); // Logging waits till the transaction gets committed.
}
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/tests/externallib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
/**
* Setup function- we will create a course and add an assign instance to it.
*/
protected function setUp() {
protected function setUp(): void {
global $DB, $CFG;

$this->resetAfterTest(true);
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lpmigrate/tests/processor_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
* Then we create 2 courses, and in each 1 CM.
* Then we attach some competencies from the first framework to courses and CM.
*/
public function setUp() {
public function setUp(): void {
$this->resetAfterTest(true);
$dg = $this->getDataGenerator();
$lpg = $dg->get_plugin_generator('core_competency');
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/messageinbound/tests/manager_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
*/
class tool_messageinbound_manager_testcase extends provider_testcase {

public function setUp() {
public function setUp(): void {
global $CFG;
$this->resetAfterTest();

Expand Down
2 changes: 1 addition & 1 deletion admin/tool/messageinbound/tests/privacy_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
*/
class tool_messageinbound_privacy_testcase extends provider_testcase {

public function setUp() {
public function setUp(): void {
global $CFG;
$this->resetAfterTest();

Expand Down
2 changes: 1 addition & 1 deletion admin/tool/mobile/tests/privacy_provider_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class tool_mobile_privacy_testcase extends \core_privacy\tests\provider_testcase
/**
* Basic setup for these tests.
*/
public function setUp() {
public function setUp(): void {
$this->resetAfterTest(true);
}

Expand Down
2 changes: 1 addition & 1 deletion admin/tool/monitor/tests/eventobservers_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class tool_monitor_eventobservers_testcase extends advanced_testcase {
/**
* Set up method.
*/
public function setUp() {
public function setUp(): void {
// Enable monitor.
set_config('enablemonitor', 1, 'tool_monitor');
}
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/monitor/tests/events_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class tool_monitor_events_testcase extends advanced_testcase {
/**
* Tests set up.
*/
public function setUp() {
public function setUp(): void {
set_config('enablemonitor', 1, 'tool_monitor');
$this->resetAfterTest();
}
Expand Down
4 changes: 2 additions & 2 deletions admin/tool/monitor/tests/generator_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class tool_monitor_generator_testcase extends advanced_testcase {
/**
* Set up method.
*/
public function setUp() {
public function setUp(): void {
// Enable monitor.
set_config('enablemonitor', 1, 'tool_monitor');
}
Expand Down Expand Up @@ -138,4 +138,4 @@ public function test_create_history() {
$this->assertEquals(1, $historydata->userid);
$this->assertEquals(1, $historydata->sid);
}
}
}
2 changes: 1 addition & 1 deletion admin/tool/monitor/tests/privacy_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class tool_monitor_privacy_testcase extends provider_testcase {
/**
* Set up method.
*/
public function setUp() {
public function setUp(): void {
$this->resetAfterTest();
// Enable monitor.
set_config('enablemonitor', 1, 'tool_monitor');
Expand Down
4 changes: 2 additions & 2 deletions admin/tool/monitor/tests/rule_manager_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class tool_monitor_rule_manager_testcase extends advanced_testcase {
/**
* Set up method.
*/
public function setUp() {
public function setUp(): void {
// Enable monitor.
set_config('enablemonitor', 1, 'tool_monitor');
}
Expand Down Expand Up @@ -192,4 +192,4 @@ public function test_get_rules_by_event() {
$this->assertEmpty(array_diff(array_keys($ruledata), $ruleids));
$this->assertCount(10, $ruledata);
}
}
}
2 changes: 1 addition & 1 deletion admin/tool/monitor/tests/subscription_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class tool_monitor_subscription_testcase extends advanced_testcase {
/**
* Test set up.
*/
public function setUp() {
public function setUp(): void {
$this->resetAfterTest(true);

// Create the mock subscription.
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/monitor/tests/task_check_subscriptions_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class tool_monitor_task_check_subscriptions_testcase extends advanced_testcase {
/**
* Test set up.
*/
public function setUp() {
public function setUp(): void {
global $DB;
set_config('enablemonitor', 1, 'tool_monitor');
$this->resetAfterTest(true);
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/monitor/tests/task_clean_events_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class tool_monitor_task_clean_events_testcase extends advanced_testcase {
/**
* Test set up.
*/
public function setUp() {
public function setUp(): void {
set_config('enablemonitor', 1, 'tool_monitor');
$this->resetAfterTest(true);
}
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/policy/tests/externallib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class tool_policy_external_testcase extends externallib_advanced_testcase {
/**
* Setup function- we will create some policy docs.
*/
public function setUp() {
public function setUp(): void {
$this->resetAfterTest(true);
$this->setAdminUser();

Expand Down
2 changes: 1 addition & 1 deletion admin/tool/policy/tests/privacy_provider_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class tool_policy_privacy_provider_testcase extends \core_privacy\tests\provider
/**
* Setup function. Will create a user.
*/
protected function setUp() {
protected function setUp(): void {
$this->resetAfterTest();

$generator = $this->getDataGenerator();
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/recyclebin/tests/category_bin_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class tool_recyclebin_category_bin_tests extends advanced_testcase {
/**
* Setup for each test.
*/
protected function setUp() {
protected function setUp(): void {
$this->resetAfterTest();
$this->setAdminUser();

Expand Down
2 changes: 1 addition & 1 deletion admin/tool/recyclebin/tests/course_bin_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class tool_recyclebin_course_bin_tests extends advanced_testcase {
/**
* Setup for each test.
*/
protected function setUp() {
protected function setUp(): void {
$this->resetAfterTest(true);
$this->setAdminUser();

Expand Down
2 changes: 1 addition & 1 deletion admin/tool/recyclebin/tests/events_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class tool_recyclebin_events_testcase extends advanced_testcase {
*
* This is executed before running any test in this file.
*/
public function setUp() {
public function setUp(): void {
$this->resetAfterTest();

// We want the category and course bin to be enabled.
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/usertours/tests/accessdate_filter_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
*/
class tool_usertours_accessdate_filter_test extends advanced_testcase {

public function setUp() {
public function setUp(): void {
$this->resetAfterTest(true);
}

Expand Down
4 changes: 2 additions & 2 deletions admin/tool/usertours/tests/manager_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class tool_usertours_manager_testcase extends advanced_testcase {
/**
* Setup to store the DB reference.
*/
public function setUp() {
public function setUp(): void {
global $DB;

$this->db = $DB;
Expand All @@ -56,7 +56,7 @@ public function setUp() {
/**
* Tear down to restore the original DB reference.
*/
public function tearDown() {
public function tearDown(): void {
global $DB;

$DB = $this->db;
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/usertours/tests/role_filter_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class tool_usertours_role_filter_testcase extends advanced_testcase {
*/
protected $roles;

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

$this->resetAfterTest(true);
Expand Down
4 changes: 2 additions & 2 deletions admin/tool/usertours/tests/step_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class step_testcase extends advanced_testcase {
/**
* Setup to store the DB reference.
*/
public function setUp() {
public function setUp(): void {
global $DB;

$this->db = $DB;
Expand All @@ -53,7 +53,7 @@ public function setUp() {
/**
* Tear down to restore the original DB reference.
*/
public function tearDown() {
public function tearDown(): void {
global $DB;

$DB = $this->db;
Expand Down
4 changes: 2 additions & 2 deletions admin/tool/usertours/tests/tour_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class tour_testcase extends advanced_testcase {
/**
* Setup to store the DB reference.
*/
public function setUp() {
public function setUp(): void {
global $DB;

$this->db = $DB;
Expand All @@ -55,7 +55,7 @@ public function setUp() {
/**
* Tear down to restore the original DB reference.
*/
public function tearDown() {
public function tearDown(): void {
global $DB;

$DB = $this->db;
Expand Down
2 changes: 1 addition & 1 deletion analytics/tests/course_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*/
class core_analytics_course_testcase extends advanced_testcase {

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

$this->course = $this->getDataGenerator()->create_course(['startdate' => 0]);
Expand Down
2 changes: 1 addition & 1 deletion analytics/tests/dataset_manager_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class dataset_manager_testcase extends advanced_testcase {
*
* @return null
*/
public function setUp() {
public function setUp(): void {
$this->resetAfterTest(true);

$this->sharedtoprows = array(
Expand Down
2 changes: 1 addition & 1 deletion analytics/tests/model_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
*/
class analytics_model_testcase extends advanced_testcase {

public function setUp() {
public function setUp(): void {

$this->setAdminUser();

Expand Down
2 changes: 1 addition & 1 deletion analytics/tests/prediction_actions_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class analytics_prediction_actions_testcase extends advanced_testcase {
/**
* Common startup tasks
*/
public function setUp() {
public function setUp(): void {
global $DB;

$this->setAdminUser();
Expand Down
Loading

0 comments on commit f6711bb

Please sign in to comment.