MDL-67673 phpunit: Fix the return type of template methods

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...
This commit is contained in:
Eloy Lafuente (stronk7) 2020-08-02 10:59:12 +02:00
parent c611109ed7
commit d81a94807b
421 changed files with 531 additions and 531 deletions

View file

@ -87,7 +87,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase {
/** /**
* Setup test. * Setup test.
*/ */
public function setup() { public function setUp(): void {
global $CFG; global $CFG;
$this->resetAfterTest(); $this->resetAfterTest();

View file

@ -36,7 +36,7 @@ class tool_capability_events_testcase extends advanced_testcase {
/** /**
* Setup testcase. * Setup testcase.
*/ */
public function setUp() { public function setUp(): void {
$this->setAdminUser(); $this->setAdminUser();
$this->resetAfterTest(); $this->resetAfterTest();
} }

View file

@ -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. * Setup function- we will create a course and add an assign instance to it.
*/ */
protected function setUp() { protected function setUp(): void {
$this->resetAfterTest(true); $this->resetAfterTest(true);
// Create some users. // Create some users.

View file

@ -43,7 +43,7 @@ class tool_cohortroles_privacy_testcase extends \core_privacy\tests\provider_tes
/** /**
* Overriding setUp() function to always reset after tests. * Overriding setUp() function to always reset after tests.
*/ */
public function setUp() { public function setUp(): void {
$this->resetAfterTest(true); $this->resetAfterTest(true);
} }

View file

@ -44,7 +44,7 @@ class tool_dataprivacy_expired_data_requests_testcase extends data_privacy_testc
/** /**
* Test tearDown. * Test tearDown.
*/ */
public function tearDown() { public function tearDown(): void {
\core_privacy\local\request\writer::reset(); \core_privacy\local\request\writer::reset();
} }

View file

@ -39,7 +39,7 @@ class tool_dataprivacy_task_testcase extends data_privacy_testcase {
/** /**
* Test tearDown. * Test tearDown.
*/ */
public function tearDown() { public function tearDown(): void {
\core_privacy\local\request\writer::reset(); \core_privacy\local\request\writer::reset();
} }

View file

@ -36,7 +36,7 @@ class tool_langimport_events_testcase extends advanced_testcase {
/** /**
* Setup testcase. * Setup testcase.
*/ */
public function setUp() { public function setUp(): void {
$this->setAdminUser(); $this->setAdminUser();
$this->resetAfterTest(); $this->resetAfterTest();
} }

View file

@ -50,7 +50,7 @@ require_once(__DIR__ . '/fixtures/event.php');
*/ */
class logstore_database_privacy_testcase extends provider_testcase { class logstore_database_privacy_testcase extends provider_testcase {
public function setUp() { public function setUp(): void {
global $CFG; global $CFG;
$this->resetAfterTest(); $this->resetAfterTest();
$this->preventResetByRollback(); // Logging waits till the transaction gets committed. $this->preventResetByRollback(); // Logging waits till the transaction gets committed.

View file

@ -48,7 +48,7 @@ require_once(__DIR__ . '/fixtures/event.php');
*/ */
class logstore_legacy_privacy_testcase extends provider_testcase { class logstore_legacy_privacy_testcase extends provider_testcase {
public function setUp() { public function setUp(): void {
$this->resetAfterTest(); $this->resetAfterTest();
} }

View file

@ -47,7 +47,7 @@ require_once(__DIR__ . '/fixtures/event.php');
*/ */
class logstore_standard_privacy_testcase extends provider_testcase { class logstore_standard_privacy_testcase extends provider_testcase {
public function setUp() { public function setUp(): void {
$this->resetAfterTest(); $this->resetAfterTest();
$this->preventResetByRollback(); // Logging waits till the transaction gets committed. $this->preventResetByRollback(); // Logging waits till the transaction gets committed.
} }

View file

@ -540,7 +540,7 @@ class logstore_standard_store_testcase extends advanced_testcase {
/** /**
* Reset any garbage collector changes to the previous state at the end of the test. * 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) { if ($this->wedisabledgc) {
gc_enable(); gc_enable();
} }

View file

@ -51,7 +51,7 @@ require_once($CFG->dirroot . '/admin/tool/log/store/standard/tests/fixtures/even
*/ */
class tool_log_privacy_testcase extends provider_testcase { class tool_log_privacy_testcase extends provider_testcase {
public function setUp() { public function setUp(): void {
$this->resetAfterTest(); $this->resetAfterTest();
$this->preventResetByRollback(); // Logging waits till the transaction gets committed. $this->preventResetByRollback(); // Logging waits till the transaction gets committed.
} }

View file

@ -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. * Setup function- we will create a course and add an assign instance to it.
*/ */
protected function setUp() { protected function setUp(): void {
global $DB, $CFG; global $DB, $CFG;
$this->resetAfterTest(true); $this->resetAfterTest(true);

View file

@ -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 create 2 courses, and in each 1 CM.
* Then we attach some competencies from the first framework to courses and CM. * Then we attach some competencies from the first framework to courses and CM.
*/ */
public function setUp() { public function setUp(): void {
$this->resetAfterTest(true); $this->resetAfterTest(true);
$dg = $this->getDataGenerator(); $dg = $this->getDataGenerator();
$lpg = $dg->get_plugin_generator('core_competency'); $lpg = $dg->get_plugin_generator('core_competency');

View file

@ -44,7 +44,7 @@ use tool_messageinbound\privacy\provider;
*/ */
class tool_messageinbound_manager_testcase extends provider_testcase { class tool_messageinbound_manager_testcase extends provider_testcase {
public function setUp() { public function setUp(): void {
global $CFG; global $CFG;
$this->resetAfterTest(); $this->resetAfterTest();

View file

@ -46,7 +46,7 @@ use tool_messageinbound\privacy\provider;
*/ */
class tool_messageinbound_privacy_testcase extends provider_testcase { class tool_messageinbound_privacy_testcase extends provider_testcase {
public function setUp() { public function setUp(): void {
global $CFG; global $CFG;
$this->resetAfterTest(); $this->resetAfterTest();

View file

@ -40,7 +40,7 @@ class tool_mobile_privacy_testcase extends \core_privacy\tests\provider_testcase
/** /**
* Basic setup for these tests. * Basic setup for these tests.
*/ */
public function setUp() { public function setUp(): void {
$this->resetAfterTest(true); $this->resetAfterTest(true);
} }

View file

@ -38,7 +38,7 @@ class tool_monitor_eventobservers_testcase extends advanced_testcase {
/** /**
* Set up method. * Set up method.
*/ */
public function setUp() { public function setUp(): void {
// Enable monitor. // Enable monitor.
set_config('enablemonitor', 1, 'tool_monitor'); set_config('enablemonitor', 1, 'tool_monitor');
} }

View file

@ -33,7 +33,7 @@ class tool_monitor_events_testcase extends advanced_testcase {
/** /**
* Tests set up. * Tests set up.
*/ */
public function setUp() { public function setUp(): void {
set_config('enablemonitor', 1, 'tool_monitor'); set_config('enablemonitor', 1, 'tool_monitor');
$this->resetAfterTest(); $this->resetAfterTest();
} }

View file

@ -39,7 +39,7 @@ class tool_monitor_generator_testcase extends advanced_testcase {
/** /**
* Set up method. * Set up method.
*/ */
public function setUp() { public function setUp(): void {
// Enable monitor. // Enable monitor.
set_config('enablemonitor', 1, 'tool_monitor'); set_config('enablemonitor', 1, 'tool_monitor');
} }

View file

@ -43,7 +43,7 @@ class tool_monitor_privacy_testcase extends provider_testcase {
/** /**
* Set up method. * Set up method.
*/ */
public function setUp() { public function setUp(): void {
$this->resetAfterTest(); $this->resetAfterTest();
// Enable monitor. // Enable monitor.
set_config('enablemonitor', 1, 'tool_monitor'); set_config('enablemonitor', 1, 'tool_monitor');

View file

@ -37,7 +37,7 @@ class tool_monitor_rule_manager_testcase extends advanced_testcase {
/** /**
* Set up method. * Set up method.
*/ */
public function setUp() { public function setUp(): void {
// Enable monitor. // Enable monitor.
set_config('enablemonitor', 1, 'tool_monitor'); set_config('enablemonitor', 1, 'tool_monitor');
} }

View file

@ -34,7 +34,7 @@ class tool_monitor_subscription_testcase extends advanced_testcase {
/** /**
* Test set up. * Test set up.
*/ */
public function setUp() { public function setUp(): void {
$this->resetAfterTest(true); $this->resetAfterTest(true);
// Create the mock subscription. // Create the mock subscription.

View file

@ -36,7 +36,7 @@ class tool_monitor_task_check_subscriptions_testcase extends advanced_testcase {
/** /**
* Test set up. * Test set up.
*/ */
public function setUp() { public function setUp(): void {
global $DB; global $DB;
set_config('enablemonitor', 1, 'tool_monitor'); set_config('enablemonitor', 1, 'tool_monitor');
$this->resetAfterTest(true); $this->resetAfterTest(true);

View file

@ -35,7 +35,7 @@ class tool_monitor_task_clean_events_testcase extends advanced_testcase {
/** /**
* Test set up. * Test set up.
*/ */
public function setUp() { public function setUp(): void {
set_config('enablemonitor', 1, 'tool_monitor'); set_config('enablemonitor', 1, 'tool_monitor');
$this->resetAfterTest(true); $this->resetAfterTest(true);
} }

View file

@ -46,7 +46,7 @@ class tool_policy_external_testcase extends externallib_advanced_testcase {
/** /**
* Setup function- we will create some policy docs. * Setup function- we will create some policy docs.
*/ */
public function setUp() { public function setUp(): void {
$this->resetAfterTest(true); $this->resetAfterTest(true);
$this->setAdminUser(); $this->setAdminUser();

View file

@ -51,7 +51,7 @@ class tool_policy_privacy_provider_testcase extends \core_privacy\tests\provider
/** /**
* Setup function. Will create a user. * Setup function. Will create a user.
*/ */
protected function setUp() { protected function setUp(): void {
$this->resetAfterTest(); $this->resetAfterTest();
$generator = $this->getDataGenerator(); $generator = $this->getDataGenerator();

View file

@ -46,7 +46,7 @@ class tool_recyclebin_category_bin_tests extends advanced_testcase {
/** /**
* Setup for each test. * Setup for each test.
*/ */
protected function setUp() { protected function setUp(): void {
$this->resetAfterTest(); $this->resetAfterTest();
$this->setAdminUser(); $this->setAdminUser();

View file

@ -46,7 +46,7 @@ class tool_recyclebin_course_bin_tests extends advanced_testcase {
/** /**
* Setup for each test. * Setup for each test.
*/ */
protected function setUp() { protected function setUp(): void {
$this->resetAfterTest(true); $this->resetAfterTest(true);
$this->setAdminUser(); $this->setAdminUser();

View file

@ -40,7 +40,7 @@ class tool_recyclebin_events_testcase extends advanced_testcase {
* *
* This is executed before running any test in this file. * This is executed before running any test in this file.
*/ */
public function setUp() { public function setUp(): void {
$this->resetAfterTest(); $this->resetAfterTest();
// We want the category and course bin to be enabled. // We want the category and course bin to be enabled.

View file

@ -36,7 +36,7 @@ use tool_usertours\local\filter\accessdate;
*/ */
class tool_usertours_accessdate_filter_test extends advanced_testcase { class tool_usertours_accessdate_filter_test extends advanced_testcase {
public function setUp() { public function setUp(): void {
$this->resetAfterTest(true); $this->resetAfterTest(true);
} }

View file

@ -47,7 +47,7 @@ class tool_usertours_manager_testcase extends advanced_testcase {
/** /**
* Setup to store the DB reference. * Setup to store the DB reference.
*/ */
public function setUp() { public function setUp(): void {
global $DB; global $DB;
$this->db = $DB; $this->db = $DB;
@ -56,7 +56,7 @@ class tool_usertours_manager_testcase extends advanced_testcase {
/** /**
* Tear down to restore the original DB reference. * Tear down to restore the original DB reference.
*/ */
public function tearDown() { public function tearDown(): void {
global $DB; global $DB;
$DB = $this->db; $DB = $this->db;

View file

@ -58,7 +58,7 @@ class tool_usertours_role_filter_testcase extends advanced_testcase {
*/ */
protected $roles; protected $roles;
public function setUp() { public function setUp(): void {
global $DB; global $DB;
$this->resetAfterTest(true); $this->resetAfterTest(true);

View file

@ -44,7 +44,7 @@ class step_testcase extends advanced_testcase {
/** /**
* Setup to store the DB reference. * Setup to store the DB reference.
*/ */
public function setUp() { public function setUp(): void {
global $DB; global $DB;
$this->db = $DB; $this->db = $DB;
@ -53,7 +53,7 @@ class step_testcase extends advanced_testcase {
/** /**
* Tear down to restore the original DB reference. * Tear down to restore the original DB reference.
*/ */
public function tearDown() { public function tearDown(): void {
global $DB; global $DB;
$DB = $this->db; $DB = $this->db;

View file

@ -46,7 +46,7 @@ class tour_testcase extends advanced_testcase {
/** /**
* Setup to store the DB reference. * Setup to store the DB reference.
*/ */
public function setUp() { public function setUp(): void {
global $DB; global $DB;
$this->db = $DB; $this->db = $DB;
@ -55,7 +55,7 @@ class tour_testcase extends advanced_testcase {
/** /**
* Tear down to restore the original DB reference. * Tear down to restore the original DB reference.
*/ */
public function tearDown() { public function tearDown(): void {
global $DB; global $DB;
$DB = $this->db; $DB = $this->db;

View file

@ -33,7 +33,7 @@ defined('MOODLE_INTERNAL') || die();
*/ */
class core_analytics_course_testcase extends advanced_testcase { class core_analytics_course_testcase extends advanced_testcase {
public function setUp() { public function setUp(): void {
global $DB; global $DB;
$this->course = $this->getDataGenerator()->create_course(['startdate' => 0]); $this->course = $this->getDataGenerator()->create_course(['startdate' => 0]);

View file

@ -38,7 +38,7 @@ class dataset_manager_testcase extends advanced_testcase {
* *
* @return null * @return null
*/ */
public function setUp() { public function setUp(): void {
$this->resetAfterTest(true); $this->resetAfterTest(true);
$this->sharedtoprows = array( $this->sharedtoprows = array(

View file

@ -41,7 +41,7 @@ require_once(__DIR__ . '/fixtures/test_analysis.php');
*/ */
class analytics_model_testcase extends advanced_testcase { class analytics_model_testcase extends advanced_testcase {
public function setUp() { public function setUp(): void {
$this->setAdminUser(); $this->setAdminUser();

View file

@ -39,7 +39,7 @@ class analytics_prediction_actions_testcase extends advanced_testcase {
/** /**
* Common startup tasks * Common startup tasks
*/ */
public function setUp() { public function setUp(): void {
global $DB; global $DB;
$this->setAdminUser(); $this->setAdminUser();

View file

@ -62,7 +62,7 @@ class core_analytics_prediction_testcase extends advanced_testcase {
* *
* @return null * @return null
*/ */
public function tearDown() { public function tearDown(): void {
$this->setAdminUser(); $this->setAdminUser();
$models = \core_analytics\manager::get_all_models(); $models = \core_analytics\manager::get_all_models();

View file

@ -44,7 +44,7 @@ require_once(__DIR__ . '/fixtures/test_target_course_users.php');
*/ */
class core_analytics_privacy_model_testcase extends \core_privacy\tests\provider_testcase { class core_analytics_privacy_model_testcase extends \core_privacy\tests\provider_testcase {
public function setUp() { public function setUp(): void {
$this->resetAfterTest(true); $this->resetAfterTest(true);
$this->setAdminUser(); $this->setAdminUser();

View file

@ -39,7 +39,7 @@ class analytics_stats_testcase extends advanced_testcase {
/** /**
* Set up the test environment. * Set up the test environment.
*/ */
public function setUp() { public function setUp(): void {
$this->setAdminUser(); $this->setAdminUser();
} }

View file

@ -43,7 +43,7 @@ class auth_email_external_testcase extends externallib_advanced_testcase {
/** /**
* Set up for every test * Set up for every test
*/ */
public function setUp() { public function setUp(): void {
global $CFG, $DB; global $CFG, $DB;
$this->resetAfterTest(true); $this->resetAfterTest(true);

View file

@ -44,7 +44,7 @@ class auth_manual_testcase extends advanced_testcase {
/** /**
* Setup test data. * Setup test data.
*/ */
protected function setUp() { protected function setUp(): void {
$this->resetAfterTest(true); $this->resetAfterTest(true);
$this->authplugin = new auth_plugin_manual(); $this->authplugin = new auth_plugin_manual();
set_config('expiration', '1', 'auth_manual'); set_config('expiration', '1', 'auth_manual');

View file

@ -45,7 +45,7 @@ class auth_manual_privacy_testcase extends \core_privacy\tests\provider_testcase
/** /**
* Basic setup for these tests. * Basic setup for these tests.
*/ */
public function setUp() { public function setUp(): void {
$this->resetAfterTest(true); $this->resetAfterTest(true);
$this->authplugin = new auth_plugin_manual(); $this->authplugin = new auth_plugin_manual();
} }

View file

@ -43,7 +43,7 @@ class auth_mnet_privacy_testcase extends provider_testcase {
/** /**
* Set up method. * Set up method.
*/ */
public function setUp() { public function setUp(): void {
$this->resetAfterTest(); $this->resetAfterTest();
$this->setAdminUser(); $this->setAdminUser();
} }

View file

@ -42,7 +42,7 @@ class auth_oauth2_privacy_testcase extends provider_testcase {
/** /**
* Set up method. * Set up method.
*/ */
public function setUp() { public function setUp(): void {
$this->resetAfterTest(); $this->resetAfterTest();
$this->setAdminUser(); $this->setAdminUser();
} }

View file

@ -46,7 +46,7 @@ class core_auth_external_testcase extends externallib_advanced_testcase {
/** /**
* Set up for every test * Set up for every test
*/ */
public function setUp() { public function setUp(): void {
global $CFG; global $CFG;
$this->resetAfterTest(true); $this->resetAfterTest(true);
@ -60,7 +60,7 @@ class core_auth_external_testcase extends externallib_advanced_testcase {
/** /**
* Tear down to restore old logging.. * Tear down to restore old logging..
*/ */
protected function tearDown() { protected function tearDown(): void {
ini_set('error_log', $this->oldlog); ini_set('error_log', $this->oldlog);
parent::tearDown(); parent::tearDown();
} }

View file

@ -43,7 +43,7 @@ use core_auth\privacy\provider;
*/ */
class core_auth_privacy_testcase extends provider_testcase { class core_auth_privacy_testcase extends provider_testcase {
public function setUp() { public function setUp(): void {
$this->resetAfterTest(); $this->resetAfterTest();
} }

View file

@ -52,7 +52,7 @@ class availability_completion_condition_testcase extends advanced_testcase {
/** /**
* Load required classes. * Load required classes.
*/ */
public function setUp() { public function setUp(): void {
availability_completion\condition::wipe_static_cache(); availability_completion\condition::wipe_static_cache();
} }

View file

@ -38,7 +38,7 @@ class availability_date_condition_testcase extends advanced_testcase {
/** /**
* Load required classes. * Load required classes.
*/ */
public function setUp() { public function setUp(): void {
// Load the mock info class so that it can be used. // Load the mock info class so that it can be used.
global $CFG; global $CFG;
require_once($CFG->dirroot . '/availability/tests/fixtures/mock_info.php'); require_once($CFG->dirroot . '/availability/tests/fixtures/mock_info.php');

View file

@ -37,7 +37,7 @@ class availability_group_condition_testcase extends advanced_testcase {
/** /**
* Load required classes. * Load required classes.
*/ */
public function setUp() { public function setUp(): void {
// Load the mock info class so that it can be used. // Load the mock info class so that it can be used.
global $CFG; global $CFG;
require_once($CFG->dirroot . '/availability/tests/fixtures/mock_info.php'); require_once($CFG->dirroot . '/availability/tests/fixtures/mock_info.php');

View file

@ -37,7 +37,7 @@ class availability_grouping_condition_testcase extends advanced_testcase {
/** /**
* Load required classes. * Load required classes.
*/ */
public function setUp() { public function setUp(): void {
// Load the mock info class so that it can be used. // Load the mock info class so that it can be used.
global $CFG; global $CFG;
require_once($CFG->dirroot . '/availability/tests/fixtures/mock_info.php'); require_once($CFG->dirroot . '/availability/tests/fixtures/mock_info.php');

View file

@ -45,7 +45,7 @@ class availability_profile_condition_testcase extends advanced_testcase {
/** @var \core_availability\info Current info */ /** @var \core_availability\info Current info */
private $info; private $info;
public function setUp() { public function setUp(): void {
global $DB, $CFG; global $DB, $CFG;
$this->resetAfterTest(); $this->resetAfterTest();

View file

@ -36,7 +36,7 @@ use core_availability\info_section;
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
class info_testcase extends advanced_testcase { class info_testcase extends advanced_testcase {
public function setUp() { public function setUp(): void {
// Load the mock condition so that it can be used. // Load the mock condition so that it can be used.
require_once(__DIR__ . '/fixtures/mock_condition.php'); require_once(__DIR__ . '/fixtures/mock_condition.php');
} }

View file

@ -35,7 +35,7 @@ defined('MOODLE_INTERNAL') || die();
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
class tree_testcase extends \advanced_testcase { class tree_testcase extends \advanced_testcase {
public function setUp() { public function setUp(): void {
// Load the mock classes so they can be used. // Load the mock classes so they can be used.
require_once(__DIR__ . '/fixtures/mock_condition.php'); require_once(__DIR__ . '/fixtures/mock_condition.php');
require_once(__DIR__ . '/fixtures/mock_info.php'); require_once(__DIR__ . '/fixtures/mock_info.php');

View file

@ -38,7 +38,7 @@ class core_backup_controller_testcase extends advanced_testcase {
protected $courseid; // course id used for testing protected $courseid; // course id used for testing
protected $userid; // user used if for testing protected $userid; // user used if for testing
protected function setUp() { protected function setUp(): void {
global $DB, $CFG; global $DB, $CFG;
$this->resetAfterTest(true); $this->resetAfterTest(true);

View file

@ -41,7 +41,7 @@ class core_backup_moodle1_converter_testcase extends advanced_testcase {
/** @var string saved hash of an icon file used during testing */ /** @var string saved hash of an icon file used during testing */
protected $iconhash; protected $iconhash;
protected function setUp() { protected function setUp(): void {
global $CFG; global $CFG;
$this->tempdir = convert_helper::generate_id('unittest'); $this->tempdir = convert_helper::generate_id('unittest');
@ -75,7 +75,7 @@ class core_backup_moodle1_converter_testcase extends advanced_testcase {
); );
} }
protected function tearDown() { protected function tearDown(): void {
global $CFG; global $CFG;
if (empty($CFG->keeptempdirectoriesonbackup)) { if (empty($CFG->keeptempdirectoriesonbackup)) {
fulldelete($this->tempdirpath); fulldelete($this->tempdirpath);

View file

@ -31,7 +31,7 @@ require_once($CFG->dirroot . '/backup/moodle2/backup_custom_fields.php');
class core_backup_encrypted_content_testscase extends advanced_testcase { class core_backup_encrypted_content_testscase extends advanced_testcase {
public function setUp() { public function setUp(): void {
if (!function_exists('openssl_encrypt')) { if (!function_exists('openssl_encrypt')) {
$this->markTestSkipped('OpenSSL extension is not loaded.'); $this->markTestSkipped('OpenSSL extension is not loaded.');

View file

@ -42,7 +42,7 @@ class backup_xml_transformer_testcase extends advanced_testcase {
/** /**
* Initial set up. * Initial set up.
*/ */
public function setUp() { public function setUp(): void {
parent::setUp(); parent::setUp();
$this->resetAfterTest(true); $this->resetAfterTest(true);

View file

@ -46,7 +46,7 @@ class core_backup_automated_backup_testcase extends advanced_testcase {
*/ */
protected $course; protected $course;
protected function setUp() { protected function setUp(): void {
global $DB, $CFG; global $DB, $CFG;
$this->resetAfterTest(true); $this->resetAfterTest(true);

View file

@ -66,7 +66,7 @@ class core_backup_course_copy_testcase extends advanced_testcase {
/** /**
* Set up tasks for all tests. * Set up tasks for all tests.
*/ */
protected function setUp() { protected function setUp(): void {
global $DB, $CFG, $USER; global $DB, $CFG, $USER;
$this->resetAfterTest(true); $this->resetAfterTest(true);

View file

@ -44,7 +44,7 @@ class backup_external_testcase extends externallib_advanced_testcase {
/** /**
* Set up tasks for all tests. * Set up tasks for all tests.
*/ */
protected function setUp() { protected function setUp(): void {
global $CFG; global $CFG;
$this->resetAfterTest(true); $this->resetAfterTest(true);

View file

@ -39,7 +39,7 @@ class backup_check_testcase extends advanced_testcase {
protected $courseid; // course id used for testing protected $courseid; // course id used for testing
protected $userid; // user record id protected $userid; // user record id
protected function setUp() { protected function setUp(): void {
global $DB, $CFG; global $DB, $CFG;
parent::setUp(); parent::setUp();

View file

@ -37,7 +37,7 @@ class backup_dbops_testcase extends advanced_testcase {
protected $courseid; // course id used for testing protected $courseid; // course id used for testing
protected $userid; // user record used for testing protected $userid; // user record used for testing
protected function setUp() { protected function setUp(): void {
global $DB, $CFG; global $DB, $CFG;
parent::setUp(); parent::setUp();

View file

@ -40,7 +40,7 @@ require_once($CFG->dirroot . '/backup/util/factories/backup_factory.class.php');
*/ */
class backup_factories_testcase extends advanced_testcase { class backup_factories_testcase extends advanced_testcase {
function setUp() { public function setUp(): void {
global $CFG; global $CFG;
parent::setUp(); parent::setUp();
@ -57,7 +57,7 @@ class backup_factories_testcase extends advanced_testcase {
/** /**
* test get_logger_chain() method * test get_logger_chain() method
*/ */
function test_backup_factory() { public function test_backup_factory() {
global $CFG; global $CFG;
// Default instantiate, all levels = backup::LOG_NONE // Default instantiate, all levels = backup::LOG_NONE

View file

@ -42,7 +42,7 @@ class restore_structure_parser_processor_test extends advanced_testcase {
/** /**
* Initial set up. * Initial set up.
*/ */
public function setUp() { public function setUp(): void {
parent::setUp(); parent::setUp();
$this->resetAfterTest(true); $this->resetAfterTest(true);

View file

@ -36,7 +36,7 @@ class backup_plan_testcase extends advanced_testcase {
protected $courseid; // course id used for testing protected $courseid; // course id used for testing
protected $userid; // user record used for testing protected $userid; // user record used for testing
protected function setUp() { protected function setUp(): void {
global $DB, $CFG; global $DB, $CFG;
parent::setUp(); parent::setUp();

View file

@ -36,7 +36,7 @@ class backup_step_testcase extends advanced_testcase {
protected $courseid; // course id used for testing protected $courseid; // course id used for testing
protected $userid; // user record used for testing protected $userid; // user record used for testing
protected function setUp() { protected function setUp(): void {
global $DB, $CFG; global $DB, $CFG;
parent::setUp(); parent::setUp();

View file

@ -36,7 +36,7 @@ class backup_task_testcase extends advanced_testcase {
protected $courseid; // course id used for testing protected $courseid; // course id used for testing
protected $userid; // user record used for testing protected $userid; // user record used for testing
protected function setUp() { protected function setUp(): void {
global $DB, $CFG; global $DB, $CFG;
parent::setUp(); parent::setUp();

View file

@ -53,7 +53,7 @@ class backup_structure_testcase extends advanced_testcase {
protected $contextid; protected $contextid;
protected function setUp() { protected function setUp(): void {
parent::setUp(); parent::setUp();
$this->resetAfterTest(true); $this->resetAfterTest(true);

View file

@ -43,7 +43,7 @@ class core_badges_badgeslib_testcase extends advanced_testcase {
/** @var $assertion2 to define json format for Open badge version 2 */ /** @var $assertion2 to define json format for Open badge version 2 */
protected $assertion2; protected $assertion2;
protected function setUp() { protected function setUp(): void {
global $DB, $CFG; global $DB, $CFG;
$this->resetAfterTest(true); $this->resetAfterTest(true);
$CFG->enablecompletion = true; $CFG->enablecompletion = true;

View file

@ -45,7 +45,7 @@ class core_badges_external_testcase extends externallib_advanced_testcase {
/** /**
* Set up for every test * Set up for every test
*/ */
public function setUp() { public function setUp(): void {
global $DB; global $DB;
$this->resetAfterTest(); $this->resetAfterTest();
$this->setAdminUser(); $this->setAdminUser();

View file

@ -48,7 +48,7 @@ require_once($CFG->libdir . '/badgeslib.php');
*/ */
class core_badges_privacy_testcase extends provider_testcase { class core_badges_privacy_testcase extends provider_testcase {
public function setUp() { public function setUp(): void {
$this->resetAfterTest(); $this->resetAfterTest();
} }

View file

@ -43,7 +43,7 @@ class block_comments_events_testcase extends advanced_testcase {
/** /**
* Setup test data. * Setup test data.
*/ */
public function setUp() { public function setUp(): void {
$this->resetAfterTest(); $this->resetAfterTest();
$this->setAdminUser(); $this->setAdminUser();

View file

@ -51,7 +51,7 @@ class block_comments_privacy_provider_testcase extends \core_privacy\tests\provi
/** @var stdClass A test course. */ /** @var stdClass A test course. */
protected $course2; protected $course2;
protected function setUp() { protected function setUp(): void {
global $DB; global $DB;
$this->resetAfterTest(); $this->resetAfterTest();

View file

@ -47,7 +47,7 @@ class block_online_users_testcase extends advanced_testcase {
* Prepare the site with some courses, groups, users and * Prepare the site with some courses, groups, users and
* simulate various recent accesses. * simulate various recent accesses.
*/ */
protected function setUp() { protected function setUp(): void {
// Generate (simulated) recently logged-in users. // Generate (simulated) recently logged-in users.
$generator = $this->getDataGenerator()->get_plugin_generator('block_online_users'); $generator = $this->getDataGenerator()->get_plugin_generator('block_online_users');

View file

@ -42,7 +42,7 @@ class block_recentlyaccesseditems_observer_testcase extends advanced_testcase {
/** /**
* Set up for every test * Set up for every test
*/ */
public function setUp() { public function setUp(): void {
global $DB; global $DB;
$this->resetAfterTest(); $this->resetAfterTest();

View file

@ -38,7 +38,7 @@ class block_rss_client_testcase extends provider_testcase {
/** /**
* Basic setup for these tests. * Basic setup for these tests.
*/ */
public function setUp() { public function setUp(): void {
$this->resetAfterTest(true); $this->resetAfterTest(true);
} }

View file

@ -44,7 +44,7 @@ use core_block\privacy\provider;
*/ */
class core_block_privacy_testcase extends provider_testcase { class core_block_privacy_testcase extends provider_testcase {
public function setUp() { public function setUp(): void {
$this->resetAfterTest(); $this->resetAfterTest();
} }

View file

@ -58,7 +58,7 @@ class core_blog_events_testcase extends advanced_testcase {
/** /**
* Setup the tests. * Setup the tests.
*/ */
protected function setUp() { protected function setUp(): void {
global $DB; global $DB;
parent::setUp(); parent::setUp();

View file

@ -44,7 +44,7 @@ class core_blog_external_testcase extends advanced_testcase {
private $tagid; private $tagid;
private $postid; private $postid;
protected function setUp() { protected function setUp(): void {
global $DB, $CFG; global $DB, $CFG;
parent::setUp(); parent::setUp();

View file

@ -41,7 +41,7 @@ class core_blog_lib_testcase extends advanced_testcase {
private $tagid; private $tagid;
private $postid; private $postid;
protected function setUp() { protected function setUp(): void {
global $DB; global $DB;
parent::setUp(); parent::setUp();

View file

@ -47,7 +47,7 @@ require_once($CFG->dirroot . '/comment/lib.php');
*/ */
class core_blog_privacy_testcase extends provider_testcase { class core_blog_privacy_testcase extends provider_testcase {
public function setUp() { public function setUp(): void {
$this->resetAfterTest(); $this->resetAfterTest();
} }

View file

@ -45,11 +45,11 @@ class cachestore_apcu_test extends cachestore_tests {
return 'cachestore_apcu'; return 'cachestore_apcu';
} }
public function setUp() { public function setUp(): void {
if (!cachestore_apcu::are_requirements_met()) { if (!cachestore_apcu::are_requirements_met()) {
$this->markTestSkipped('Could not test cachestore_apcu. Requirements are not met.'); $this->markTestSkipped('Could not test cachestore_apcu. Requirements are not met.');
} }
return parent::setUp(); parent::setUp();
} }
/** /**

View file

@ -45,7 +45,7 @@ class cachestore_redis_compressor_test extends advanced_testcase {
/** /**
* Test set up * Test set up
*/ */
public function setUp() { public function setUp(): void {
if (!cachestore_redis::are_requirements_met() || !defined('TEST_CACHESTORE_REDIS_TESTSERVERS')) { if (!cachestore_redis::are_requirements_met() || !defined('TEST_CACHESTORE_REDIS_TESTSERVERS')) {
$this->markTestSkipped('Could not test cachestore_redis. Requirements are not met.'); $this->markTestSkipped('Could not test cachestore_redis. Requirements are not met.');
} }

View file

@ -54,13 +54,13 @@ class cachestore_redis_test extends cachestore_tests {
return 'cachestore_redis'; return 'cachestore_redis';
} }
public function setUp() { public function setUp(): void {
if (!cachestore_redis::are_requirements_met() || !defined('TEST_CACHESTORE_REDIS_TESTSERVERS')) { if (!cachestore_redis::are_requirements_met() || !defined('TEST_CACHESTORE_REDIS_TESTSERVERS')) {
$this->markTestSkipped('Could not test cachestore_redis. Requirements are not met.'); $this->markTestSkipped('Could not test cachestore_redis. Requirements are not met.');
} }
parent::setUp(); parent::setUp();
} }
protected function tearDown() { protected function tearDown(): void {
parent::tearDown(); parent::tearDown();
if ($this->store instanceof cachestore_redis) { if ($this->store instanceof cachestore_redis) {

View file

@ -45,7 +45,7 @@ class core_cache_administration_helper_testcase extends advanced_testcase {
/** /**
* Set things back to the default before each test. * Set things back to the default before each test.
*/ */
public function setUp() { public function setUp(): void {
parent::setUp(); parent::setUp();
cache_factory::reset(); cache_factory::reset();
cache_config_testing::create_default_configuration(); cache_config_testing::create_default_configuration();
@ -54,7 +54,7 @@ class core_cache_administration_helper_testcase extends advanced_testcase {
/** /**
* Final task is to reset the cache system * Final task is to reset the cache system
*/ */
public static function tearDownAfterClass() { public static function tearDownAfterClass(): void {
parent::tearDownAfterClass(); parent::tearDownAfterClass();
cache_factory::reset(); cache_factory::reset();
} }

View file

@ -44,7 +44,7 @@ class core_cache_testcase extends advanced_testcase {
/** /**
* Set things back to the default before each test. * Set things back to the default before each test.
*/ */
public function setUp() { public function setUp(): void {
parent::setUp(); parent::setUp();
cache_factory::reset(); cache_factory::reset();
cache_config_testing::create_default_configuration(); cache_config_testing::create_default_configuration();
@ -53,7 +53,7 @@ class core_cache_testcase extends advanced_testcase {
/** /**
* Final task is to reset the cache system * Final task is to reset the cache system
*/ */
public static function tearDownAfterClass() { public static function tearDownAfterClass(): void {
parent::tearDownAfterClass(); parent::tearDownAfterClass();
cache_factory::reset(); cache_factory::reset();
} }

View file

@ -44,7 +44,7 @@ class core_cache_config_writer_testcase extends advanced_testcase {
/** /**
* Set things back to the default before each test. * Set things back to the default before each test.
*/ */
public function setUp() { public function setUp(): void {
parent::setUp(); parent::setUp();
cache_factory::reset(); cache_factory::reset();
cache_config_testing::create_default_configuration(); cache_config_testing::create_default_configuration();
@ -53,7 +53,7 @@ class core_cache_config_writer_testcase extends advanced_testcase {
/** /**
* Final task is to reset the cache system * Final task is to reset the cache system
*/ */
public static function tearDownAfterClass() { public static function tearDownAfterClass(): void {
parent::tearDownAfterClass(); parent::tearDownAfterClass();
cache_factory::reset(); cache_factory::reset();
} }

View file

@ -46,7 +46,7 @@ abstract class cachestore_tests extends advanced_testcase {
* Sets up the fixture, for example, open a network connection. * Sets up the fixture, for example, open a network connection.
* This method is called before a test is executed. * This method is called before a test is executed.
*/ */
public function setUp() { public function setUp(): void {
$class = $this->get_class_name(); $class = $this->get_class_name();
if (!class_exists($class) || !$class::are_requirements_met()) { if (!class_exists($class) || !$class::are_requirements_met()) {
$this->markTestSkipped('Could not test '.$class.'. Requirements are not met.'); $this->markTestSkipped('Could not test '.$class.'. Requirements are not met.');

View file

@ -58,7 +58,7 @@ class core_calendar_type_testcase extends advanced_testcase {
/** /**
* Test set up. * Test set up.
*/ */
protected function setUp() { protected function setUp(): void {
// The user we are going to test this on. // The user we are going to test this on.
$this->user = self::getDataGenerator()->create_user(); $this->user = self::getDataGenerator()->create_user();
self::setUser($this->user); self::setUser($this->user);

View file

@ -47,7 +47,7 @@ class core_calendar_container_testcase extends advanced_testcase {
/** /**
* Test setup. * Test setup.
*/ */
public function setUp() { public function setUp(): void {
$this->resetAfterTest(); $this->resetAfterTest();
$this->setAdminUser(); $this->setAdminUser();
} }

View file

@ -41,7 +41,7 @@ class core_calendar_events_related_objects_cache_testcase extends advanced_testc
/** /**
* Tests set up * Tests set up
*/ */
protected function setUp() { protected function setUp(): void {
$this->resetAfterTest(); $this->resetAfterTest();
} }

View file

@ -48,7 +48,7 @@ class core_calendar_events_testcase extends advanced_testcase {
/** /**
* Test set up. * Test set up.
*/ */
protected function setUp() { protected function setUp(): void {
global $USER; global $USER;
// The user we are going to test this on. // The user we are going to test this on.
$this->setAdminUser(); $this->setAdminUser();

View file

@ -43,7 +43,7 @@ class core_calendar_externallib_testcase extends externallib_advanced_testcase {
/** /**
* Tests set up * Tests set up
*/ */
protected function setUp() { protected function setUp(): void {
global $CFG; global $CFG;
require_once($CFG->dirroot . '/calendar/externallib.php'); require_once($CFG->dirroot . '/calendar/externallib.php');
} }

View file

@ -38,7 +38,7 @@ class core_calendar_lib_testcase extends advanced_testcase {
/** /**
* Tests set up * Tests set up
*/ */
protected function setUp() { protected function setUp(): void {
$this->resetAfterTest(); $this->resetAfterTest();
} }

View file

@ -40,7 +40,7 @@ class core_calendar_local_api_testcase extends advanced_testcase {
/** /**
* Tests set up * Tests set up
*/ */
protected function setUp() { protected function setUp(): void {
$this->resetAfterTest(); $this->resetAfterTest();
} }

View file

@ -47,7 +47,7 @@ class core_calendar_privacy_testcase extends provider_testcase {
/** /**
* Overriding setUp() function to always reset after tests. * Overriding setUp() function to always reset after tests.
*/ */
public function setUp() { public function setUp(): void {
$this->resetAfterTest(true); $this->resetAfterTest(true);
} }

View file

@ -46,7 +46,7 @@ class core_calendar_rrule_manager_testcase extends advanced_testcase {
/** /**
* Set up method. * Set up method.
*/ */
protected function setUp() { protected function setUp(): void {
global $DB; global $DB;
$this->resetAfterTest(); $this->resetAfterTest();

Some files were not shown because too many files have changed in this diff Show more