From 3d51aed3e2133fd808f9f016d29f89c8261cc33c Mon Sep 17 00:00:00 2001
From: Andrew Nicols [
'No PHP code', [], false
diff --git a/admin/tool/dataprivacy/tests/api_test.php b/admin/tool/dataprivacy/tests/api_test.php
index 733d27c9d2b..862c5557b0f 100644
--- a/admin/tool/dataprivacy/tests/api_test.php
+++ b/admin/tool/dataprivacy/tests/api_test.php
@@ -545,7 +545,7 @@ class api_test extends \advanced_testcase {
*
* @return array
*/
- public function data_request_creation_provider() {
+ public static function data_request_creation_provider(): array {
return [
'Export request by user, automatic approval off' => [
false, api::DATAREQUEST_TYPE_EXPORT, 'automaticdataexportapproval', false, 0,
@@ -705,7 +705,7 @@ class api_test extends \advanced_testcase {
*
* @return array
*/
- public function get_data_requests_provider() {
+ public static function get_data_requests_provider(): array {
$completeonly = [api::DATAREQUEST_STATUS_COMPLETE, api::DATAREQUEST_STATUS_DOWNLOAD_READY, api::DATAREQUEST_STATUS_DELETED];
$completeandcancelled = array_merge($completeonly, [api::DATAREQUEST_STATUS_CANCELLED]);
@@ -842,7 +842,7 @@ class api_test extends \advanced_testcase {
/**
* Data provider for test_has_ongoing_request.
*/
- public function status_provider() {
+ public static function status_provider(): array {
return [
[api::DATAREQUEST_STATUS_AWAITING_APPROVAL, true],
[api::DATAREQUEST_STATUS_APPROVED, true],
@@ -932,7 +932,7 @@ class api_test extends \advanced_testcase {
*
* @return array
*/
- public function notify_dpo_provider() {
+ public static function notify_dpo_provider(): array {
return [
[false, api::DATAREQUEST_TYPE_EXPORT, 'requesttypeexport', 'Export my user data'],
[false, api::DATAREQUEST_TYPE_DELETE, 'requesttypedelete', 'Delete my user data'],
@@ -1284,7 +1284,7 @@ class api_test extends \advanced_testcase {
/**
* Data provider for invalid contextlevel fetchers.
*/
- public function invalid_effective_contextlevel_provider() {
+ public static function invalid_effective_contextlevel_provider(): array {
return [
[CONTEXT_COURSECAT],
[CONTEXT_COURSE],
@@ -1844,7 +1844,7 @@ class api_test extends \advanced_testcase {
/**
* Data provider for \tool_dataprivacy_api_testcase::test_set_context_defaults
*/
- public function set_context_defaults_provider() {
+ public static function set_context_defaults_provider(): array {
$contextlevels = [
[CONTEXT_COURSECAT],
[CONTEXT_COURSE],
@@ -2319,7 +2319,7 @@ class api_test extends \advanced_testcase {
*
* @return array
*/
- public function queue_data_request_task_provider() {
+ public static function queue_data_request_task_provider(): array {
return [
'With user ID provided' => [true],
'Without user ID provided' => [false],
@@ -2356,7 +2356,7 @@ class api_test extends \advanced_testcase {
/**
* Data provider for test_is_automatic_request_approval_on().
*/
- public function automatic_request_approval_setting_provider() {
+ public static function automatic_request_approval_setting_provider(): array {
return [
'Data export, not set' => [
'automaticdataexportapproval', api::DATAREQUEST_TYPE_EXPORT, null, false
diff --git a/admin/tool/dataprivacy/tests/data_request_test.php b/admin/tool/dataprivacy/tests/data_request_test.php
index bb9f9310c68..a0f5ebcb177 100644
--- a/admin/tool/dataprivacy/tests/data_request_test.php
+++ b/admin/tool/dataprivacy/tests/data_request_test.php
@@ -35,7 +35,7 @@ class data_request_test extends data_privacy_testcase {
*
* @return array
*/
- public function status_state_provider() : array {
+ public static function status_state_provider(): array {
return [
[
'state' => api::DATAREQUEST_STATUS_PENDING,
@@ -138,9 +138,9 @@ class data_request_test extends data_privacy_testcase {
*
* @return array
*/
- public function non_resettable_provider() : array {
+ public static function non_resettable_provider(): array {
$states = [];
- foreach ($this->status_state_provider() as $thisstatus) {
+ foreach (self::status_state_provider() as $thisstatus) {
if (!$thisstatus['resettable']) {
$states[] = $thisstatus;
}
diff --git a/admin/tool/dataprivacy/tests/expired_contexts_test.php b/admin/tool/dataprivacy/tests/expired_contexts_test.php
index 0b289c85351..91add391e99 100644
--- a/admin/tool/dataprivacy/tests/expired_contexts_test.php
+++ b/admin/tool/dataprivacy/tests/expired_contexts_test.php
@@ -1918,7 +1918,7 @@ class expired_contexts_test extends \advanced_testcase {
*
* @return array
*/
- public function can_process_deletion_provider() : array {
+ public static function can_process_deletion_provider(): array {
return [
'Pending' => [
expired_context::STATUS_EXPIRED,
@@ -1956,7 +1956,7 @@ class expired_contexts_test extends \advanced_testcase {
*
* @return array
*/
- public function is_complete_provider() : array {
+ public static function is_complete_provider(): array {
return [
'Pending' => [
expired_context::STATUS_EXPIRED,
@@ -1991,7 +1991,7 @@ class expired_contexts_test extends \advanced_testcase {
*
* @return array
*/
- public function is_fully_expired_provider() : array {
+ public static function is_fully_expired_provider(): array {
return [
'Fully expired' => [
[
diff --git a/admin/tool/dataprivacy/tests/external/external_test.php b/admin/tool/dataprivacy/tests/external/external_test.php
index 0fc372cc6fa..45a64381f92 100644
--- a/admin/tool/dataprivacy/tests/external/external_test.php
+++ b/admin/tool/dataprivacy/tests/external/external_test.php
@@ -578,7 +578,7 @@ class external_test extends externallib_advanced_testcase {
/**
* Data provider for \tool_dataprivacy_external_testcase::test_XX_options().
*/
- public function get_options_provider() {
+ public static function get_options_provider(): array {
return [
[false, false],
[false, true],
@@ -703,7 +703,7 @@ class external_test extends externallib_advanced_testcase {
/**
* Data provider for \tool_dataprivacy_external_testcase::get_activity_options().
*/
- public function get_activity_options_provider() {
+ public static function get_activity_options_provider(): array {
return [
[false, false, true],
[false, true, true],
diff --git a/admin/tool/dataprivacy/tests/filtered_userlist_test.php b/admin/tool/dataprivacy/tests/filtered_userlist_test.php
index 331ae911fbf..216cbfbaa85 100644
--- a/admin/tool/dataprivacy/tests/filtered_userlist_test.php
+++ b/admin/tool/dataprivacy/tests/filtered_userlist_test.php
@@ -58,7 +58,7 @@ class filtered_userlist_test extends \advanced_testcase {
*
* @return array
*/
- public function apply_expired_contexts_filters_provider() : array {
+ public static function apply_expired_contexts_filters_provider(): array {
return [
// Entire list should be preserved.
'No overrides' => [
diff --git a/admin/tool/httpsreplace/tests/httpsreplace_test.php b/admin/tool/httpsreplace/tests/httpsreplace_test.php
index dcf3c221d2d..c02ca75a635 100644
--- a/admin/tool/httpsreplace/tests/httpsreplace_test.php
+++ b/admin/tool/httpsreplace/tests/httpsreplace_test.php
@@ -38,20 +38,20 @@ class httpsreplace_test extends \advanced_testcase {
/**
* Data provider for test_upgrade_http_links
*/
- public function upgrade_http_links_provider() {
+ public static function upgrade_http_links_provider(): array {
global $CFG;
// Get the http url, since the default test wwwroot is https.
$wwwroothttp = preg_replace('/^https:/', 'http:', $CFG->wwwroot);
return [
"Test image from another site should be replaced" => [
- "content" => '
',
+ "content" => '
',
"outputregex" => '/UPDATE/',
- "expectedcontent" => '
',
+ "expectedcontent" => '
',
],
"Test object from another site should be replaced" => [
- "content" => '
'
',
],
"Broken URL should not be changed" => [
- "content" => '
',
+ "content" => '
',
"outputregex" => '/^$/',
- "expectedcontent" => '
',
+ "expectedcontent" => '
',
],
"Link URL should not be changed" => [
- "content" => '' .
- $this->getExternalTestFileUrl('/test.png', false) . '',
+ "content" => '' .
+ self::getExternalTestFileUrl('/test.png', false) . '',
"outputregex" => '/^$/',
- "expectedcontent" => '' .
- $this->getExternalTestFileUrl('/test.png', false) . '',
+ "expectedcontent" => '' .
+ self::getExternalTestFileUrl('/test.png', false) . '',
],
"Test image from another site should be replaced but link should not" => [
- "content" => '
',
+ "content" => '
',
"outputregex" => '/UPDATE/',
- "expectedcontent" => '
',
+ "expectedcontent" => '
',
],
];
}
@@ -127,8 +127,8 @@ class httpsreplace_test extends \advanced_testcase {
* @param string $path Path to be rewritten
* @return string
*/
- protected function get_converted_http_link($path) {
- return preg_replace('/^http:/', 'https:', $this->getExternalTestFileUrl($path, false));
+ protected static function get_converted_http_link($path) {
+ return preg_replace('/^http:/', 'https:', self::getExternalTestFileUrl($path, false));
}
/**
@@ -160,15 +160,15 @@ class httpsreplace_test extends \advanced_testcase {
/**
* Data provider for test_http_link_stats
*/
- public function http_link_stats_provider() {
+ public static function http_link_stats_provider(): array {
global $CFG;
// Get the http url, since the default test wwwroot is https.
$wwwrootdomain = 'www.example.com';
$wwwroothttp = preg_replace('/^https:/', 'http:', $CFG->wwwroot);
- $testdomain = $this->get_converted_http_link('');
+ $testdomain = self::get_converted_http_link('');
return [
"Test image from an available site so shouldn't be reported" => [
- "content" => '
',
+ "content" => '
',
"domain" => $testdomain,
"expectedcount" => 0,
],
diff --git a/admin/tool/langimport/tests/controller_test.php b/admin/tool/langimport/tests/controller_test.php
index 03b0ebb4700..008dd470dca 100644
--- a/admin/tool/langimport/tests/controller_test.php
+++ b/admin/tool/langimport/tests/controller_test.php
@@ -48,7 +48,7 @@ class controller_test extends \advanced_testcase {
*
* @return array
*/
- public function uninstall_lang_invalid_provider(): array {
+ public static function uninstall_lang_invalid_provider(): array {
return [
'Empty string' => [''],
'Meaningless empty string' => [' '],
diff --git a/admin/tool/log/store/standard/tests/store_test.php b/admin/tool/log/store/standard/tests/store_test.php
index 5358143e59c..dad69f335f4 100644
--- a/admin/tool/log/store/standard/tests/store_test.php
+++ b/admin/tool/log/store/standard/tests/store_test.php
@@ -389,7 +389,7 @@ class store_test extends \advanced_testcase {
*
* @return array Array of parameters
*/
- public function decode_other_provider(): array {
+ public static function decode_other_provider(): array {
return [
[['info' => 'd2819896', 'logurl' => 'discuss.php?d=2819896']],
[null],
diff --git a/admin/tool/moodlenet/tests/lib_test.php b/admin/tool/moodlenet/tests/lib_test.php
index 1ec8e7466e4..5fafc586070 100644
--- a/admin/tool/moodlenet/tests/lib_test.php
+++ b/admin/tool/moodlenet/tests/lib_test.php
@@ -52,7 +52,7 @@ class lib_test extends \advanced_testcase {
*
* @return array
*/
- public function get_endpoints_provider() {
+ public static function get_endpoints_provider(): array {
global $CFG;
return [
[
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..239ec3ebd91 100644
--- a/admin/tool/moodlenet/tests/local/import_handler_info_test.php
+++ b/admin/tool/moodlenet/tests/local/import_handler_info_test.php
@@ -59,7 +59,7 @@ class import_handler_info_test extends \advanced_testcase {
*
* @return array the data for creation of the info object.
*/
- public function handler_info_data_provider() {
+ public static function handler_info_data_provider(): array {
return [
'All data present' => ['label', 'Add a label to the course', false],
'Empty module name' => ['', 'Add a file resource to the course', true],
diff --git a/admin/tool/moodlenet/tests/local/remote_resource_test.php b/admin/tool/moodlenet/tests/local/remote_resource_test.php
index f3195fb7a9c..6d474a4f7b2 100644
--- a/admin/tool/moodlenet/tests/local/remote_resource_test.php
+++ b/admin/tool/moodlenet/tests/local/remote_resource_test.php
@@ -53,10 +53,10 @@ class remote_resource_test extends \advanced_testcase {
*
* @return array
*/
- public function remote_resource_data_provider() {
+ public static function remote_resource_data_provider(): array {
return [
'With filename and extension' => [
- $this->getExternalTestFileUrl('/test.html'),
+ self::getExternalTestFileUrl('/test.html'),
(object) [
'name' => 'Test html file',
'description' => 'Full description of the html file'
@@ -77,9 +77,9 @@ class remote_resource_test extends \advanced_testcase {
/**
* Test confirming the network based operations of a remote_resource.
*/
- public function test_network_features() {
- $url = $this->getExternalTestFileUrl('/test.html');
- $nonexistenturl = $this->getExternalTestFileUrl('/test.htmlzz');
+ public function test_network_features(): void {
+ $url = self::getExternalTestFileUrl('/test.html');
+ $nonexistenturl = self::getExternalTestFileUrl('/test.htmlzz');
$remoteres = new remote_resource(
new \curl(),
diff --git a/admin/tool/moodlenet/tests/local/url_test.php b/admin/tool/moodlenet/tests/local/url_test.php
index f48c0701140..e7137c2f52b 100644
--- a/admin/tool/moodlenet/tests/local/url_test.php
+++ b/admin/tool/moodlenet/tests/local/url_test.php
@@ -55,7 +55,7 @@ class url_test extends \advanced_testcase {
*
* @return array
*/
- public function url_provider() {
+ public static function url_provider(): array {
return [
'No path' => [
'url' => 'https://example.moodle.net',
diff --git a/admin/tool/recyclebin/tests/category_bin_test.php b/admin/tool/recyclebin/tests/category_bin_test.php
index b12aa4de0d3..6e03d76c11a 100644
--- a/admin/tool/recyclebin/tests/category_bin_test.php
+++ b/admin/tool/recyclebin/tests/category_bin_test.php
@@ -175,7 +175,7 @@ class category_bin_test extends \advanced_testcase {
* Used to verify that recycle bin is immune to various settings. Provides plugin, name, value for
* direct usage with set_config()
*/
- public function recycle_bin_settings_provider() {
+ public static function recycle_bin_settings_provider(): array {
return [
'backup/backup_auto_storage moodle' => [[
(object)['plugin' => 'backup', 'name' => 'backup_auto_storage', 'value' => 0],
diff --git a/admin/tool/recyclebin/tests/course_bin_test.php b/admin/tool/recyclebin/tests/course_bin_test.php
index 0a29655de60..34a38690a59 100644
--- a/admin/tool/recyclebin/tests/course_bin_test.php
+++ b/admin/tool/recyclebin/tests/course_bin_test.php
@@ -172,7 +172,7 @@ class course_bin_test extends \advanced_testcase {
* Used to verify that recycle bin is immune to various settings. Provides plugin, name, value for
* direct usage with set_config()
*/
- public function recycle_bin_settings_provider() {
+ public static function recycle_bin_settings_provider(): array {
return [
'backup/backup_auto_storage moodle' => [[
(object)['plugin' => 'backup', 'name' => 'backup_auto_storage', 'value' => 0],
diff --git a/admin/tool/uploadcourse/tests/course_test.php b/admin/tool/uploadcourse/tests/course_test.php
index fbd749de352..ff6991086e1 100644
--- a/admin/tool/uploadcourse/tests/course_test.php
+++ b/admin/tool/uploadcourse/tests/course_test.php
@@ -1182,7 +1182,7 @@ class course_test extends \advanced_testcase {
*
* @return array
*/
- public function enrolment_uploaddata_error_provider(): array {
+ public static function enrolment_uploaddata_error_provider(): array {
return [
['errorcannotcreateorupdateenrolment', [
'shortname' => 'C1',
diff --git a/admin/tool/uploaduser/tests/field_value_validators_test.php b/admin/tool/uploaduser/tests/field_value_validators_test.php
index 8fd5fea8c34..e3650d4bd28 100644
--- a/admin/tool/uploaduser/tests/field_value_validators_test.php
+++ b/admin/tool/uploaduser/tests/field_value_validators_test.php
@@ -30,7 +30,7 @@ class field_value_validators_test extends \advanced_testcase {
/**
* Data provider for \field_value_validators_testcase::test_validate_theme().
*/
- public function themes_provider() {
+ public static function themes_provider(): array {
return [
'User themes disabled' => [
false, 'boost', 'warning', get_string('userthemesnotallowed', 'tool_uploaduser')
diff --git a/admin/tool/usertours/tests/accessdate_filter_test.php b/admin/tool/usertours/tests/accessdate_filter_test.php
index 52b44c3c31b..ae2b2732344 100644
--- a/admin/tool/usertours/tests/accessdate_filter_test.php
+++ b/admin/tool/usertours/tests/accessdate_filter_test.php
@@ -36,7 +36,7 @@ class accessdate_filter_test extends \advanced_testcase {
*
* @return array
*/
- public function filter_matches_provider() {
+ public static function filter_matches_provider(): array {
return [
'No config set; Matches' => [
[],
diff --git a/admin/tool/usertours/tests/cache_test.php b/admin/tool/usertours/tests/cache_test.php
index 27f96008d12..9ba765a1162 100644
--- a/admin/tool/usertours/tests/cache_test.php
+++ b/admin/tool/usertours/tests/cache_test.php
@@ -126,7 +126,7 @@ class cache_test extends \advanced_testcase {
*
* @return array
*/
- public function get_matching_tourdata_provider() {
+ public static function get_matching_tourdata_provider(): array {
$tourconfigs = [
(object) [
'name' => 'my_exact_1',
diff --git a/admin/tool/usertours/tests/helper_test.php b/admin/tool/usertours/tests/helper_test.php
index f6c574b3077..2b356f938cf 100644
--- a/admin/tool/usertours/tests/helper_test.php
+++ b/admin/tool/usertours/tests/helper_test.php
@@ -42,7 +42,7 @@ class helper_test extends advanced_testcase {
*
* @return array
*/
- public function get_string_from_input_provider(): array {
+ public static function get_string_from_input_provider(): array {
return [
'Text' => [
'example',
diff --git a/admin/tool/usertours/tests/manager_test.php b/admin/tool/usertours/tests/manager_test.php
index 17751f0aa74..0310f3169f1 100644
--- a/admin/tool/usertours/tests/manager_test.php
+++ b/admin/tool/usertours/tests/manager_test.php
@@ -74,7 +74,7 @@ class manager_test extends \advanced_testcase {
*
* @return array
*/
- public function sesskey_required_provider() {
+ public static function sesskey_required_provider(): array {
$tourid = rand(1, 100);
$stepid = rand(1, 100);
@@ -121,7 +121,7 @@ class manager_test extends \advanced_testcase {
*
* @return array
*/
- public function move_tour_provider() {
+ public static function move_tour_provider(): array {
$alltours = [
['name' => 'Tour 1'],
['name' => 'Tour 2'],
@@ -198,7 +198,7 @@ class manager_test extends \advanced_testcase {
*
* @return array
*/
- public function get_matching_tours_provider() {
+ public static function get_matching_tours_provider(): array {
global $CFG;
$alltours = [
diff --git a/admin/tool/usertours/tests/step_test.php b/admin/tool/usertours/tests/step_test.php
index 434908e01d5..55ddda887e5 100644
--- a/admin/tool/usertours/tests/step_test.php
+++ b/admin/tool/usertours/tests/step_test.php
@@ -73,7 +73,7 @@ class step_test extends \advanced_testcase {
*
* @return array
*/
- public function dirty_value_provider() {
+ public static function dirty_value_provider(): array {
return [
'tourid' => [
'tourid',
@@ -160,7 +160,7 @@ class step_test extends \advanced_testcase {
*
* @return array
*/
- public function step_sortorder_provider() {
+ public static function step_sortorder_provider(): array {
return [
[0, 5, true, false],
[1, 5, false, false],
@@ -254,7 +254,7 @@ class step_test extends \advanced_testcase {
*
* @return array
*/
- public function get_config_provider() {
+ public static function get_config_provider(): array {
$allvalues = (object) [
'some' => 'value',
'another' => 42,
@@ -410,7 +410,7 @@ class step_test extends \advanced_testcase {
/**
* Data provider for set_config.
*/
- public function set_config_provider() {
+ public static function set_config_provider(): array {
$allvalues = (object) [
'some' => 'value',
'another' => 42,
@@ -764,7 +764,7 @@ class step_test extends \advanced_testcase {
*
* @return array
*/
- public function getter_provider() {
+ public static function getter_provider(): array {
return [
'id' => [
'id',
diff --git a/admin/tool/usertours/tests/theme_filter_test.php b/admin/tool/usertours/tests/theme_filter_test.php
index e3f7b1fae57..cd63ee2d7b2 100644
--- a/admin/tool/usertours/tests/theme_filter_test.php
+++ b/admin/tool/usertours/tests/theme_filter_test.php
@@ -30,7 +30,7 @@ class theme_filter_test extends \advanced_testcase {
*
* @return array
*/
- public function filter_matches_provider() {
+ public static function filter_matches_provider(): array {
return [
'No config set; Matches' => [
null,
diff --git a/admin/tool/usertours/tests/tour_test.php b/admin/tool/usertours/tests/tour_test.php
index f7955dd94e4..e9c75462366 100644
--- a/admin/tool/usertours/tests/tour_test.php
+++ b/admin/tool/usertours/tests/tour_test.php
@@ -73,7 +73,7 @@ class tour_test extends \advanced_testcase {
*
* @return array
*/
- public function dirty_value_provider() {
+ public static function dirty_value_provider(): array {
return [
'name' => [
'name',
@@ -126,7 +126,7 @@ class tour_test extends \advanced_testcase {
*
* @return array
*/
- public function getter_provider() {
+ public static function getter_provider(): array {
return [
'id' => [
'id',
@@ -430,7 +430,7 @@ class tour_test extends \advanced_testcase {
*
* @return array
*/
- public function get_config_provider() {
+ public static function get_config_provider(): array {
$allvalues = (object) [
'some' => 'value',
'another' => 42,
@@ -624,7 +624,7 @@ class tour_test extends \advanced_testcase {
*
* @return array
*/
- public function should_show_for_user_provider() {
+ public static function should_show_for_user_provider(): array {
$time = time();
return [
'Not seen by user at all' => [
@@ -715,7 +715,7 @@ class tour_test extends \advanced_testcase {
*
* @return array
*/
- public function get_tour_key_provider() {
+ public static function get_tour_key_provider(): array {
$id = rand(1, 100);
$time = time();
@@ -723,7 +723,7 @@ class tour_test extends \advanced_testcase {
'No initial values' => [
$id,
[null, $time],
- $this->greaterThanOrEqual($time),
+ self::greaterThanOrEqual($time),
true,
null,
sprintf('tool_usertours_\d_%d_%s', $id, $time),
@@ -879,7 +879,7 @@ class tour_test extends \advanced_testcase {
*
* @return array
*/
- public function sortorder_first_last_provider() {
+ public static function sortorder_first_last_provider(): array {
$topcount = rand(10, 100);
return [
'Only tour => first + last' => [
@@ -987,7 +987,7 @@ class tour_test extends \advanced_testcase {
*
* @return array
*/
- public function get_filter_values_provider() {
+ public static function get_filter_values_provider(): array {
$cheese = ['cheddar', 'boursin', 'mozzarella'];
$horses = ['coolie', 'dakota', 'leo', 'twiggy'];
return [
@@ -1046,7 +1046,7 @@ class tour_test extends \advanced_testcase {
*
* @return array
*/
- public function set_filter_values_provider() {
+ public static function set_filter_values_provider(): array {
$cheese = ['cheddar', 'boursin', 'mozzarella'];
$horses = ['coolie', 'dakota', 'leo', 'twiggy'];
diff --git a/analytics/tests/calculation_info_test.php b/analytics/tests/calculation_info_test.php
index 84051ad3b7c..abbc6079e39 100644
--- a/analytics/tests/calculation_info_test.php
+++ b/analytics/tests/calculation_info_test.php
@@ -23,8 +23,7 @@ namespace core_analytics;
* @copyright 2017 David Monllaó {@link http://www.davidmonllao.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class calculation_info_test extends \advanced_testcase {
-
+final class calculation_info_test extends \advanced_testcase {
/**
* test_calculation_info description
*
@@ -88,7 +87,7 @@ class calculation_info_test extends \advanced_testcase {
*
* @return mixed[]
*/
- public function provider_test_calculation_info_add_pull() {
+ public static function provider_test_calculation_info_add_pull(): array {
return [
'mixed-types' => ['asd', true, [123, 123, 123], (object)['asd' => 'fgfg']],
];
diff --git a/analytics/tests/indicator_test.php b/analytics/tests/indicator_test.php
index 82966cb04c9..82b13c20ca8 100644
--- a/analytics/tests/indicator_test.php
+++ b/analytics/tests/indicator_test.php
@@ -29,8 +29,7 @@ require_once(__DIR__ . '/fixtures/test_indicator_min.php');
* @copyright 2017 David Monllaó {@link http://www.davidmonllao.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class indicator_test extends \advanced_testcase {
-
+final class indicator_test extends \advanced_testcase {
/**
* test_validate_calculated_value
*
@@ -50,7 +49,7 @@ class indicator_test extends \advanced_testcase {
*
* @return array
*/
- public function validate_calculated_value() {
+ public static function validate_calculated_value(): array {
return [
'max' => ['test_indicator_max', [1]],
'min' => ['test_indicator_min', [-1]],
@@ -83,7 +82,7 @@ class indicator_test extends \advanced_testcase {
*
* @return array
*/
- public function validate_calculated_value_exceptions() {
+ public static function validate_calculated_value_exceptions(): array {
return [
'max' => ['test_indicator_max', 2],
'min' => ['test_indicator_min', -2],
diff --git a/analytics/tests/manager_test.php b/analytics/tests/manager_test.php
index eb1bc73e6f3..d159553f30d 100644
--- a/analytics/tests/manager_test.php
+++ b/analytics/tests/manager_test.php
@@ -31,8 +31,7 @@ require_once(__DIR__ . '/fixtures/test_target_course_level_shortname.php');
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @covers \core_analytics\manager
*/
-class manager_test extends \advanced_testcase {
-
+final class manager_test extends \advanced_testcase {
/**
* test_deleted_context
*/
@@ -44,7 +43,7 @@ class manager_test extends \advanced_testcase {
set_config('enabled_stores', 'logstore_standard', 'tool_log');
$target = \core_analytics\manager::get_target('test_target_course_level_shortname');
- $indicators = array('test_indicator_max', 'test_indicator_min', 'test_indicator_fullname');
+ $indicators = ['test_indicator_max', 'test_indicator_min', 'test_indicator_fullname'];
foreach ($indicators as $key => $indicator) {
$indicators[$key] = \core_analytics\manager::get_indicator($indicator);
}
@@ -52,10 +51,10 @@ class manager_test extends \advanced_testcase {
$model = \core_analytics\model::create($target, $indicators);
$modelobj = $model->get_model_obj();
- $coursepredict1 = $this->getDataGenerator()->create_course(array('visible' => 0));
- $coursepredict2 = $this->getDataGenerator()->create_course(array('visible' => 0));
- $coursetrain1 = $this->getDataGenerator()->create_course(array('visible' => 1));
- $coursetrain2 = $this->getDataGenerator()->create_course(array('visible' => 1));
+ $coursepredict1 = $this->getDataGenerator()->create_course(['visible' => 0]);
+ $coursepredict2 = $this->getDataGenerator()->create_course(['visible' => 0]);
+ $coursetrain1 = $this->getDataGenerator()->create_course(['visible' => 1]);
+ $coursetrain2 = $this->getDataGenerator()->create_course(['visible' => 1]);
$model->enable('\core\analytics\time_splitting\no_splitting');
@@ -65,25 +64,33 @@ class manager_test extends \advanced_testcase {
// Generate a prediction action to confirm that it is deleted when there is an important update.
$predictions = $DB->get_records('analytics_predictions');
$prediction = reset($predictions);
- $prediction = new \core_analytics\prediction($prediction, array('whatever' => 'not used'));
+ $prediction = new \core_analytics\prediction($prediction, ['whatever' => 'not used']);
$prediction->action_executed(\core_analytics\prediction::ACTION_USEFUL, $model->get_target());
$predictioncontextid = $prediction->get_prediction_data()->contextid;
- $npredictions = $DB->count_records('analytics_predictions', array('contextid' => $predictioncontextid));
- $npredictionactions = $DB->count_records('analytics_prediction_actions',
- array('predictionid' => $prediction->get_prediction_data()->id));
- $nindicatorcalc = $DB->count_records('analytics_indicator_calc', array('contextid' => $predictioncontextid));
+ $npredictions = $DB->count_records('analytics_predictions', ['contextid' => $predictioncontextid]);
+ $npredictionactions = $DB->count_records(
+ 'analytics_prediction_actions',
+ ['predictionid' => $prediction->get_prediction_data()->id]
+ );
+ $nindicatorcalc = $DB->count_records('analytics_indicator_calc', ['contextid' => $predictioncontextid]);
\core_analytics\manager::cleanup();
// Nothing is incorrectly deleted.
- $this->assertEquals($npredictions, $DB->count_records('analytics_predictions',
- array('contextid' => $predictioncontextid)));
- $this->assertEquals($npredictionactions, $DB->count_records('analytics_prediction_actions',
- array('predictionid' => $prediction->get_prediction_data()->id)));
- $this->assertEquals($nindicatorcalc, $DB->count_records('analytics_indicator_calc',
- array('contextid' => $predictioncontextid)));
+ $this->assertEquals($npredictions, $DB->count_records(
+ 'analytics_predictions',
+ ['contextid' => $predictioncontextid]
+ ));
+ $this->assertEquals($npredictionactions, $DB->count_records(
+ 'analytics_prediction_actions',
+ ['predictionid' => $prediction->get_prediction_data()->id]
+ ));
+ $this->assertEquals($nindicatorcalc, $DB->count_records(
+ 'analytics_indicator_calc',
+ ['contextid' => $predictioncontextid]
+ ));
// Now we delete a context, the course predictions and prediction actions should be deleted.
$deletedcontext = \context::instance_by_id($predictioncontextid);
@@ -91,10 +98,12 @@ class manager_test extends \advanced_testcase {
\core_analytics\manager::cleanup();
- $this->assertEmpty($DB->count_records('analytics_predictions', array('contextid' => $predictioncontextid)));
- $this->assertEmpty($DB->count_records('analytics_prediction_actions',
- array('predictionid' => $prediction->get_prediction_data()->id)));
- $this->assertEmpty($DB->count_records('analytics_indicator_calc', array('contextid' => $predictioncontextid)));
+ $this->assertEmpty($DB->count_records('analytics_predictions', ['contextid' => $predictioncontextid]));
+ $this->assertEmpty($DB->count_records(
+ 'analytics_prediction_actions',
+ ['predictionid' => $prediction->get_prediction_data()->id]
+ ));
+ $this->assertEmpty($DB->count_records('analytics_indicator_calc', ['contextid' => $predictioncontextid]));
set_config('enabled_stores', '', 'tool_log');
get_log_manager(true);
@@ -111,7 +120,7 @@ class manager_test extends \advanced_testcase {
set_config('enabled_stores', 'logstore_standard', 'tool_log');
$target = \core_analytics\manager::get_target('test_target_course_level_shortname');
- $indicators = array('test_indicator_max', 'test_indicator_min', 'test_indicator_fullname');
+ $indicators = ['test_indicator_max', 'test_indicator_min', 'test_indicator_fullname'];
foreach ($indicators as $key => $indicator) {
$indicators[$key] = \core_analytics\manager::get_indicator($indicator);
}
@@ -119,10 +128,10 @@ class manager_test extends \advanced_testcase {
$model = \core_analytics\model::create($target, $indicators);
$modelobj = $model->get_model_obj();
- $coursepredict1 = $this->getDataGenerator()->create_course(array('visible' => 0));
- $coursepredict2 = $this->getDataGenerator()->create_course(array('visible' => 0));
- $coursetrain1 = $this->getDataGenerator()->create_course(array('visible' => 1));
- $coursetrain2 = $this->getDataGenerator()->create_course(array('visible' => 1));
+ $coursepredict1 = $this->getDataGenerator()->create_course(['visible' => 0]);
+ $coursepredict2 = $this->getDataGenerator()->create_course(['visible' => 0]);
+ $coursetrain1 = $this->getDataGenerator()->create_course(['visible' => 1]);
+ $coursetrain2 = $this->getDataGenerator()->create_course(['visible' => 1]);
$model->enable('\core\analytics\time_splitting\no_splitting');
@@ -139,9 +148,9 @@ class manager_test extends \advanced_testcase {
\core_analytics\manager::cleanup();
- $this->assertEmpty($DB->count_records('analytics_predict_samples', array('analysableid' => $coursepredict1->id)));
- $this->assertEmpty($DB->count_records('analytics_train_samples', array('analysableid' => $coursepredict1->id)));
- $this->assertEmpty($DB->count_records('analytics_used_analysables', array('analysableid' => $coursepredict1->id)));
+ $this->assertEmpty($DB->count_records('analytics_predict_samples', ['analysableid' => $coursepredict1->id]));
+ $this->assertEmpty($DB->count_records('analytics_train_samples', ['analysableid' => $coursepredict1->id]));
+ $this->assertEmpty($DB->count_records('analytics_used_analysables', ['analysableid' => $coursepredict1->id]));
set_config('enabled_stores', '', 'tool_log');
get_log_manager(true);
@@ -190,7 +199,7 @@ class manager_test extends \advanced_testcase {
$this->resetAfterTest();
// This is expected to run without an exception.
- $models = $this->load_models_from_fixture_file('no_teaching');
+ $models = self::load_models_from_fixture_file('no_teaching');
\core_analytics\manager::validate_models_declaration($models);
}
@@ -214,34 +223,34 @@ class manager_test extends \advanced_testcase {
*
* @return array of (string)testcase => [(array)models, (string)expected exception message]
*/
- public function validate_models_declaration_exceptions_provider() {
+ public static function validate_models_declaration_exceptions_provider(): array {
return [
'missing_target' => [
- $this->load_models_from_fixture_file('missing_target'),
+ self::load_models_from_fixture_file('missing_target'),
'Missing target declaration',
],
'invalid_target' => [
- $this->load_models_from_fixture_file('invalid_target'),
+ self::load_models_from_fixture_file('invalid_target'),
'Invalid target classname',
],
'missing_indicators' => [
- $this->load_models_from_fixture_file('missing_indicators'),
+ self::load_models_from_fixture_file('missing_indicators'),
'Missing indicators declaration',
],
'invalid_indicators' => [
- $this->load_models_from_fixture_file('invalid_indicators'),
+ self::load_models_from_fixture_file('invalid_indicators'),
'Invalid indicator classname',
],
'invalid_time_splitting' => [
- $this->load_models_from_fixture_file('invalid_time_splitting'),
+ self::load_models_from_fixture_file('invalid_time_splitting'),
'Invalid time splitting classname',
],
'invalid_time_splitting_fq' => [
- $this->load_models_from_fixture_file('invalid_time_splitting_fq'),
+ self::load_models_from_fixture_file('invalid_time_splitting_fq'),
'Expecting fully qualified time splitting classname',
],
'invalid_enabled' => [
- $this->load_models_from_fixture_file('invalid_enabled'),
+ self::load_models_from_fixture_file('invalid_enabled'),
'Cannot enable a model without time splitting method specified',
],
];
@@ -253,12 +262,12 @@ class manager_test extends \advanced_testcase {
* @param string $filename
* @return array
*/
- protected function load_models_from_fixture_file(string $filename) {
+ protected static function load_models_from_fixture_file(string $filename) {
global $CFG;
$models = null;
- require($CFG->dirroot.'/analytics/tests/fixtures/db_analytics_php/'.$filename.'.php');
+ require("{$CFG->dirroot}/analytics/tests/fixtures/db_analytics_php/{$filename}.php");
return $models;
}
@@ -430,9 +439,9 @@ class manager_test extends \advanced_testcase {
*/
public function test_model_declaration_identifier() {
- $noteaching1 = $this->load_models_from_fixture_file('no_teaching');
- $noteaching2 = $this->load_models_from_fixture_file('no_teaching');
- $noteaching3 = $this->load_models_from_fixture_file('no_teaching');
+ $noteaching1 = self::load_models_from_fixture_file('no_teaching');
+ $noteaching2 = self::load_models_from_fixture_file('no_teaching');
+ $noteaching3 = self::load_models_from_fixture_file('no_teaching');
// Same model declaration should always lead to same identifier.
$this->assertEquals(
@@ -474,9 +483,9 @@ class manager_test extends \advanced_testcase {
public function test_get_declared_target_and_indicators_instances() {
$this->resetAfterTest();
- $definition = $this->load_models_from_fixture_file('no_teaching');
+ $definition = self::load_models_from_fixture_file('no_teaching');
- list($target, $indicators) = \core_analytics\manager::get_declared_target_and_indicators_instances($definition[0]);
+ [$target, $indicators] = \core_analytics\manager::get_declared_target_and_indicators_instances($definition[0]);
$this->assertTrue($target instanceof \core_analytics\local\target\base);
$this->assertNotEmpty($indicators);
diff --git a/analytics/tests/prediction_actions_test.php b/analytics/tests/prediction_actions_test.php
index adfd8fe19bb..16e5de0df20 100644
--- a/analytics/tests/prediction_actions_test.php
+++ b/analytics/tests/prediction_actions_test.php
@@ -111,7 +111,7 @@ class prediction_actions_test extends \advanced_testcase {
*
* @return array
*/
- public function execute_actions_provider(): array {
+ public static function execute_actions_provider(): array {
return [
'Empty actions with no filter' => [
[],
diff --git a/analytics/tests/prediction_test.php b/analytics/tests/prediction_test.php
index 08aa1c0f300..63e1b3c463a 100644
--- a/analytics/tests/prediction_test.php
+++ b/analytics/tests/prediction_test.php
@@ -341,14 +341,14 @@ class prediction_test extends \advanced_testcase {
*
* @return array
*/
- public function provider_ml_training_and_prediction() {
+ public static function provider_ml_training_and_prediction(): array {
$cases = array(
'no_splitting' => array('\core\analytics\time_splitting\no_splitting', 0, 1),
'quarters' => array('\core\analytics\time_splitting\quarters', 3, 4)
);
// We need to test all system prediction processors.
- return $this->add_prediction_processors($cases);
+ return static::add_prediction_processors($cases);
}
/**
@@ -417,13 +417,13 @@ class prediction_test extends \advanced_testcase {
*
* @return array
*/
- public function provider_ml_processors() {
+ public static function provider_ml_processors(): array {
$cases = [
'case' => [],
];
// We need to test all system prediction processors.
- return $this->add_prediction_processors($cases);
+ return static::add_prediction_processors($cases);
}
/**
* Test the system classifiers returns.
@@ -507,7 +507,7 @@ class prediction_test extends \advanced_testcase {
*
* @return array
*/
- public function provider_ml_classifiers_return() {
+ public static function provider_ml_classifiers_return(): array {
// Using verbose options as the first argument for readability.
$cases = array(
'1-samples' => array('maybe', 1, [0]),
@@ -517,7 +517,7 @@ class prediction_test extends \advanced_testcase {
);
// We need to test all system prediction processors.
- return $this->add_prediction_processors($cases);
+ return static::add_prediction_processors($cases);
}
/**
@@ -581,13 +581,13 @@ class prediction_test extends \advanced_testcase {
*
* @return array
*/
- public function provider_test_multi_classifier() {
+ public static function provider_test_multi_classifier(): array {
$cases = array(
'notimesplitting' => array('\core\analytics\time_splitting\no_splitting'),
);
// Add all system prediction processors.
- return $this->add_prediction_processors($cases);
+ return static::add_prediction_processors($cases);
}
/**
@@ -777,8 +777,7 @@ class prediction_test extends \advanced_testcase {
*
* @return array
*/
- public function provider_ml_test_evaluation_configuration() {
-
+ public static function provider_ml_test_evaluation_configuration(): array {
$cases = array(
'bad' => array(
'modelquality' => 'random',
@@ -797,7 +796,7 @@ class prediction_test extends \advanced_testcase {
)
)
);
- return $this->add_prediction_processors($cases);
+ return static::add_prediction_processors($cases);
}
/**
@@ -955,8 +954,7 @@ class prediction_test extends \advanced_testcase {
* @param array $cases
* @return array
*/
- protected function add_prediction_processors($cases) {
-
+ protected static function add_prediction_processors($cases): array {
$return = array();
if (defined('TEST_MLBACKEND_PYTHON_HOST') && defined('TEST_MLBACKEND_PYTHON_PORT')
diff --git a/auth/ldap/tests/plugin_test.php b/auth/ldap/tests/plugin_test.php
index fc7ca70fcb3..7635af45852 100644
--- a/auth/ldap/tests/plugin_test.php
+++ b/auth/ldap/tests/plugin_test.php
@@ -45,7 +45,7 @@ class plugin_test extends \advanced_testcase {
*
* @return array[]
*/
- public function auth_ldap_provider() {
+ public static function auth_ldap_provider(): array {
$pagesizes = [1, 3, 5, 1000];
$subcontexts = [0, 1];
$combinations = [];
diff --git a/auth/lti/tests/auth_test.php b/auth/lti/tests/auth_test.php
index 167aed38f9e..bce29ad8bef 100644
--- a/auth/lti/tests/auth_test.php
+++ b/auth/lti/tests/auth_test.php
@@ -27,7 +27,7 @@ namespace auth_lti;
class auth_test extends \advanced_testcase {
/** @var string issuer URL used for test cases. */
- protected $issuer = 'https://lms.example.org';
+ protected static string $issuer = 'https://lms.example.org';
/** @var int const representing cases where no PII is present. */
protected const PII_NONE = 0;
@@ -70,10 +70,13 @@ class auth_test extends \advanced_testcase {
* @param bool $includepicture whether to include a profile picture or not (slows tests, so defaults to false).
* @return array the users list.
*/
- protected function get_mock_users_with_ids(array $ids,
- string $role = 'http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor', bool $includenames = true,
- bool $includeemail = true, bool $includepicture = false): array {
-
+ protected static function get_mock_users_with_ids(
+ array $ids,
+ string $role = 'http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor',
+ bool $includenames = true,
+ bool $includeemail = true,
+ bool $includepicture = false
+ ): array {
$users = [];
foreach ($ids as $id) {
$user = [
@@ -91,7 +94,7 @@ class auth_test extends \advanced_testcase {
unset($user['email']);
}
if ($includepicture) {
- $user['picture'] = $this->getExternalTestFileUrl('/test.jpg');
+ $user['picture'] = self::getExternalTestFileUrl('/test.jpg');
}
$users[] = $user;
}
@@ -137,7 +140,7 @@ class auth_test extends \advanced_testcase {
*/
protected function get_mock_launchdata_for_user(array $mockuser, array $mockmigration = []): array {
$data = [
- 'iss' => $this->issuer, // Must match registration in create_test_environment.
+ 'iss' => self::$issuer, // Must match registration in create_test_environment.
'aud' => '123', // Must match registration in create_test_environment.
'sub' => $mockuser['user_id'], // User id on the platform site.
'exp' => time() + 60,
@@ -318,12 +321,12 @@ class auth_test extends \advanced_testcase {
*
* @return array the test case data.
*/
- public function launch_data_provider(): array {
+ public static function launch_data_provider(): array {
return [
'New (unlinked) platform learner including PII, no legacy user, no migration claim' => [
'legacy_data' => null,
'launch_data' => [
- 'user' => $this->get_mock_users_with_ids(
+ 'user' => self::get_mock_users_with_ids(
['1'],
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner'
)[0],
@@ -336,7 +339,7 @@ class auth_test extends \advanced_testcase {
'New (unlinked) platform learner excluding names, no legacy user, no migration claim' => [
'legacy_data' => null,
'launch_data' => [
- 'user' => $this->get_mock_users_with_ids(
+ 'user' => self::get_mock_users_with_ids(
['1'],
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner',
false
@@ -350,7 +353,7 @@ class auth_test extends \advanced_testcase {
'New (unlinked) platform learner excluding emails, no legacy user, no migration claim' => [
'legacy_data' => null,
'launch_data' => [
- 'user' => $this->get_mock_users_with_ids(
+ 'user' => self::get_mock_users_with_ids(
['1'],
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner',
true,
@@ -365,7 +368,7 @@ class auth_test extends \advanced_testcase {
'New (unlinked) platform learner excluding all PII, no legacy user, no migration claim' => [
'legacy_data' => null,
'launch_data' => [
- 'user' => $this->get_mock_users_with_ids(
+ 'user' => self::get_mock_users_with_ids(
['1'],
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner',
false,
@@ -389,7 +392,7 @@ class auth_test extends \advanced_testcase {
]
],
'launch_data' => [
- 'user' => $this->get_mock_users_with_ids(
+ 'user' => self::get_mock_users_with_ids(
['1'],
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner'
)[0],
@@ -419,7 +422,7 @@ class auth_test extends \advanced_testcase {
]
],
'launch_data' => [
- 'user' => $this->get_mock_users_with_ids(
+ 'user' => self::get_mock_users_with_ids(
['1'],
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner'
)[0],
@@ -442,7 +445,7 @@ class auth_test extends \advanced_testcase {
]
],
'launch_data' => [
- 'user' => $this->get_mock_users_with_ids(
+ 'user' => self::get_mock_users_with_ids(
['1'],
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner'
)[0],
@@ -472,7 +475,7 @@ class auth_test extends \advanced_testcase {
]
],
'launch_data' => [
- 'user' => $this->get_mock_users_with_ids(
+ 'user' => self::get_mock_users_with_ids(
['1'],
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner'
)[0],
@@ -502,7 +505,7 @@ class auth_test extends \advanced_testcase {
]
],
'launch_data' => [
- 'user' => $this->get_mock_users_with_ids(
+ 'user' => self::get_mock_users_with_ids(
['1'],
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner'
)[0],
@@ -532,7 +535,7 @@ class auth_test extends \advanced_testcase {
]
],
'launch_data' => [
- 'user' => $this->get_mock_users_with_ids(
+ 'user' => self::get_mock_users_with_ids(
['1'],
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner'
)[0],
@@ -562,7 +565,7 @@ class auth_test extends \advanced_testcase {
]
],
'launch_data' => [
- 'user' => $this->get_mock_users_with_ids(
+ 'user' => self::get_mock_users_with_ids(
['1'],
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner'
)[0],
@@ -591,7 +594,7 @@ class auth_test extends \advanced_testcase {
]
],
'launch_data' => [
- 'user' => $this->get_mock_users_with_ids(
+ 'user' => self::get_mock_users_with_ids(
['1'],
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner'
)[0],
@@ -621,7 +624,7 @@ class auth_test extends \advanced_testcase {
]
],
'launch_data' => [
- 'user' => $this->get_mock_users_with_ids(
+ 'user' => self::get_mock_users_with_ids(
['1'],
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner',
false,
@@ -644,7 +647,7 @@ class auth_test extends \advanced_testcase {
'New (unlinked) platform instructor including PII, no legacy user, no migration claim' => [
'legacy_data' => null,
'launch_data' => [
- 'user' => $this->get_mock_users_with_ids(
+ 'user' => self::get_mock_users_with_ids(
['1'],
'http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor'
)[0],
@@ -657,7 +660,7 @@ class auth_test extends \advanced_testcase {
'New (unlinked) platform instructor excluding PII, no legacy user, no migration claim' => [
'legacy_data' => null,
'launch_data' => [
- 'user' => $this->get_mock_users_with_ids(
+ 'user' => self::get_mock_users_with_ids(
['1'],
'http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor',
false,
@@ -681,7 +684,7 @@ class auth_test extends \advanced_testcase {
]
],
'launch_data' => [
- 'user' => $this->get_mock_users_with_ids(
+ 'user' => self::get_mock_users_with_ids(
['1'],
'http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor'
)[0],
@@ -703,7 +706,7 @@ class auth_test extends \advanced_testcase {
'legacy_data' => null,
'launch_data' => [
'has_authenticated_before' => true,
- 'user' => $this->get_mock_users_with_ids(
+ 'user' => self::get_mock_users_with_ids(
['1'],
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner'
)[0],
@@ -717,7 +720,7 @@ class auth_test extends \advanced_testcase {
'legacy_data' => null,
'launch_data' => [
'has_authenticated_before' => true,
- 'user' => $this->get_mock_users_with_ids(
+ 'user' => self::get_mock_users_with_ids(
['1'],
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner',
false,
@@ -733,7 +736,7 @@ class auth_test extends \advanced_testcase {
'legacy_data' => null,
'launch_data' => [
'has_authenticated_before' => true,
- 'user' => $this->get_mock_users_with_ids(
+ 'user' => self::get_mock_users_with_ids(
['1'],
'http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor'
)[0],
@@ -747,7 +750,7 @@ class auth_test extends \advanced_testcase {
'legacy_data' => null,
'launch_data' => [
'has_authenticated_before' => true,
- 'user' => $this->get_mock_users_with_ids(
+ 'user' => self::get_mock_users_with_ids(
['1'],
'http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor',
false,
@@ -763,7 +766,7 @@ class auth_test extends \advanced_testcase {
'legacy_data' => null,
'launch_data' => [
'has_authenticated_before' => false,
- 'user' => $this->get_mock_users_with_ids(
+ 'user' => self::get_mock_users_with_ids(
['1'],
'http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor',
false,
@@ -886,17 +889,17 @@ class auth_test extends \advanced_testcase {
*
* @return array the test case data.
*/
- public function membership_data_provider(): array {
+ public static function membership_data_provider(): array {
return [
'New (unlinked) platform learner including PII, no legacy data, no consumer key bound, no legacy id' => [
'legacy_data' => null,
'membership_data' => [
- 'user' => $this->get_mock_users_with_ids(
+ 'user' => self::get_mock_users_with_ids(
['1'],
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner'
)[0],
],
- 'iss' => $this->issuer,
+ 'iss' => self::$issuer,
'legacy_consumer_key' => null,
'expected' => [
'PII' => self::PII_ALL,
@@ -906,14 +909,14 @@ class auth_test extends \advanced_testcase {
'New (unlinked) platform learner excluding PII, no legacy data, no consumer key bound, no legacy id' => [
'legacy_data' => null,
'membership_data' => [
- 'user' => $this->get_mock_users_with_ids(
+ 'user' => self::get_mock_users_with_ids(
['1'],
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner',
false,
false
)[0],
],
- 'iss' => $this->issuer,
+ 'iss' => self::$issuer,
'legacy_consumer_key' => null,
'expected' => [
'PII' => self::PII_NONE,
@@ -923,13 +926,13 @@ class auth_test extends \advanced_testcase {
'New (unlinked) platform learner excluding names, no legacy data, no consumer key bound, no legacy id' => [
'legacy_data' => null,
'membership_data' => [
- 'user' => $this->get_mock_users_with_ids(
+ 'user' => self::get_mock_users_with_ids(
['1'],
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner',
false,
)[0],
],
- 'iss' => $this->issuer,
+ 'iss' => self::$issuer,
'legacy_consumer_key' => null,
'expected' => [
'PII' => self::PII_EMAILS_ONLY,
@@ -939,14 +942,14 @@ class auth_test extends \advanced_testcase {
'New (unlinked) platform learner excluding email, no legacy data, no consumer key bound, no legacy id' => [
'legacy_data' => null,
'membership_data' => [
- 'user' => $this->get_mock_users_with_ids(
+ 'user' => self::get_mock_users_with_ids(
['1'],
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner',
true,
false
)[0],
],
- 'iss' => $this->issuer,
+ 'iss' => self::$issuer,
'legacy_consumer_key' => null,
'expected' => [
'PII' => self::PII_NAMES_ONLY,
@@ -961,13 +964,13 @@ class auth_test extends \advanced_testcase {
'consumer_key' => 'CONSUMER_1',
],
'membership_data' => [
- 'user' => $this->get_mock_users_with_ids(
+ 'user' => self::get_mock_users_with_ids(
['1'],
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner'
)[0],
'legacy_user_id' => '123-abc'
],
- 'iss' => $this->issuer,
+ 'iss' => self::$issuer,
'legacy_consumer_key' => 'CONSUMER_1',
'expected' => [
'PII' => self::PII_ALL,
@@ -982,12 +985,12 @@ class auth_test extends \advanced_testcase {
'consumer_key' => 'CONSUMER_1',
],
'membership_data' => [
- 'user' => $this->get_mock_users_with_ids(
+ 'user' => self::get_mock_users_with_ids(
['1'],
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner'
)[0],
],
- 'iss' => $this->issuer,
+ 'iss' => self::$issuer,
'legacy_consumer_key' => 'CONSUMER_1',
'expected' => [
'PII' => self::PII_ALL,
@@ -1002,12 +1005,12 @@ class auth_test extends \advanced_testcase {
'consumer_key' => 'CONSUMER_1',
],
'membership_data' => [
- 'user' => $this->get_mock_users_with_ids(
+ 'user' => self::get_mock_users_with_ids(
['123-abc'],
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner'
)[0],
],
- 'iss' => $this->issuer,
+ 'iss' => self::$issuer,
'legacy_consumer_key' => 'CONSUMER_1',
'expected' => [
'PII' => self::PII_ALL,
@@ -1022,12 +1025,12 @@ class auth_test extends \advanced_testcase {
'consumer_key' => 'CONSUMER_1',
],
'membership_data' => [
- 'user' => $this->get_mock_users_with_ids(
+ 'user' => self::get_mock_users_with_ids(
['123-abc'],
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner'
)[0],
],
- 'iss' => $this->issuer,
+ 'iss' => self::$issuer,
'legacy_consumer_key' => 'CONSUMER_ABCDEF',
'expected' => [
'PII' => self::PII_ALL,
@@ -1042,13 +1045,13 @@ class auth_test extends \advanced_testcase {
'consumer_key' => 'CONSUMER_1',
],
'membership_data' => [
- 'user' => $this->get_mock_users_with_ids(
+ 'user' => self::get_mock_users_with_ids(
['1'],
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner'
)[0],
'legacy_user_id' => '123-abc'
],
- 'iss' => $this->issuer,
+ 'iss' => self::$issuer,
'legacy_consumer_key' => null,
'expected' => [
'PII' => self::PII_ALL,
@@ -1058,13 +1061,13 @@ class auth_test extends \advanced_testcase {
'New (unlinked) platform learner including PII, no legacy data, consumer key bound, legacy user id sent' => [
'legacy_data' => null,
'membership_data' => [
- 'user' => $this->get_mock_users_with_ids(
+ 'user' => self::get_mock_users_with_ids(
['1'],
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner'
)[0],
'legacy_user_id' => '123-abc'
],
- 'iss' => $this->issuer,
+ 'iss' => self::$issuer,
'legacy_consumer_key' => 'CONSUMER_1',
'expected' => [
'PII' => self::PII_ALL,
@@ -1074,12 +1077,12 @@ class auth_test extends \advanced_testcase {
'New (unlinked) platform instructor including PII, no legacy data, no consumer key bound, no legacy id' => [
'legacy_data' => null,
'membership_data' => [
- 'user' => $this->get_mock_users_with_ids(
+ 'user' => self::get_mock_users_with_ids(
['1'],
'http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor'
)[0],
],
- 'iss' => $this->issuer,
+ 'iss' => self::$issuer,
'legacy_consumer_key' => null,
'expected' => [
'PII' => self::PII_ALL,
@@ -1089,14 +1092,14 @@ class auth_test extends \advanced_testcase {
'New (unlinked) platform instructor excluding PII, no legacy data, no consumer key bound, no legacy id' => [
'legacy_data' => null,
'membership_data' => [
- 'user' => $this->get_mock_users_with_ids(
+ 'user' => self::get_mock_users_with_ids(
['1'],
'http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor',
false,
false
)[0],
],
- 'iss' => $this->issuer,
+ 'iss' => self::$issuer,
'legacy_consumer_key' => null,
'expected' => [
'PII' => self::PII_NONE,
@@ -1107,12 +1110,12 @@ class auth_test extends \advanced_testcase {
'legacy_data' => null,
'launch_data' => [
'has_authenticated_before' => true,
- 'user' => $this->get_mock_users_with_ids(
+ 'user' => self::get_mock_users_with_ids(
['1'],
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner'
)[0],
],
- 'iss' => $this->issuer,
+ 'iss' => self::$issuer,
'legacy_consumer_key' => null,
'expected' => [
'PII' => self::PII_ALL,
@@ -1132,7 +1135,7 @@ class auth_test extends \advanced_testcase {
global $DB;
$auth = get_auth_plugin('lti');
$user = $this->getDataGenerator()->create_user();
- $mockiss = $this->issuer;
+ $mockiss = self::$issuer;
$mocksub = '1';
// Create a binding and verify it exists.
@@ -1144,7 +1147,7 @@ class auth_test extends \advanced_testcase {
$numusersbefore = $DB->count_records('user');
$matcheduser = $auth->find_or_create_user_from_launch(
$this->get_mock_launchdata_for_user(
- $this->get_mock_users_with_ids([$mocksub])[0]
+ self::get_mock_users_with_ids([$mocksub])[0]
)
);
$numusersafter = $DB->count_records('user');
diff --git a/availability/condition/completion/tests/condition_test.php b/availability/condition/completion/tests/condition_test.php
index d76857fdf31..21e1c9d3425 100644
--- a/availability/condition/completion/tests/condition_test.php
+++ b/availability/condition/completion/tests/condition_test.php
@@ -469,7 +469,7 @@ class condition_test extends \advanced_testcase {
$this->assertMatchesRegularExpression($description, $information);
}
- public function previous_activity_data(): array {
+ public static function previous_activity_data(): array {
// Assign grade, condition, activity to complete, activity to test, result, resultnot, description.
return [
'Missing previous activity complete' => [
@@ -634,7 +634,7 @@ class condition_test extends \advanced_testcase {
}
- public function section_previous_activity_data(): array {
+ public static function section_previous_activity_data(): array {
return [
// Condition, Activity completion, section to test, result, resultnot, description.
'Completion complete Section with no previous activity' => [
diff --git a/backup/moodle2/tests/backup_xml_transformer_test.php b/backup/moodle2/tests/backup_xml_transformer_test.php
index 9f061029f25..83c19a44c04 100644
--- a/backup/moodle2/tests/backup_xml_transformer_test.php
+++ b/backup/moodle2/tests/backup_xml_transformer_test.php
@@ -49,7 +49,7 @@ class backup_xml_transformer_test extends \advanced_testcase {
*
* @return array
*/
- public function filephp_links_replace_data_provider() {
+ public static function filephp_links_replace_data_provider(): array {
return array(
array('http://test.test/', 'http://test.test/'),
array('http://test.test/file.php/1', 'http://test.test/file.php/1'),
diff --git a/backup/moodle2/tests/restore_gradebook_structure_step_test.php b/backup/moodle2/tests/restore_gradebook_structure_step_test.php
index 2b47e14c80f..70a8e7ccbdd 100644
--- a/backup/moodle2/tests/restore_gradebook_structure_step_test.php
+++ b/backup/moodle2/tests/restore_gradebook_structure_step_test.php
@@ -37,12 +37,13 @@ class restore_gradebook_structure_step_test extends \advanced_testcase {
*
* @return array
*/
- public function rewrite_step_backup_file_for_legacy_freeze_provider() {
+ public static function rewrite_step_backup_file_for_legacy_freeze_provider(): array {
$fixturesdir = realpath(__DIR__ . '/fixtures/rewrite_step_backup_file_for_legacy_freeze/');
$tests = [];
$iterator = new \RecursiveIteratorIterator(
- new \RecursiveDirectoryIterator($fixturesdir),
- \RecursiveIteratorIterator::LEAVES_ONLY);
+ new \RecursiveDirectoryIterator($fixturesdir),
+ \RecursiveIteratorIterator::LEAVES_ONLY,
+ );
foreach ($iterator as $sourcefile) {
$pattern = '/\.test$/';
diff --git a/backup/util/dbops/tests/restore_dbops_test.php b/backup/util/dbops/tests/restore_dbops_test.php
index 325c01a4adb..6252b5e0a9f 100644
--- a/backup/util/dbops/tests/restore_dbops_test.php
+++ b/backup/util/dbops/tests/restore_dbops_test.php
@@ -124,8 +124,7 @@ class restore_dbops_test extends \advanced_testcase {
/**
* Data provider for {@link test_precheck_user()}
*/
- public function precheck_user_provider() {
-
+ public static function precheck_user_provider(): array {
$emailmultiplier = [
'shortmail' => 'normalusername@example.com',
'longmail' => str_repeat('a', 100) // It's not validated, hence any string is ok.
@@ -135,7 +134,7 @@ class restore_dbops_test extends \advanced_testcase {
foreach ($emailmultiplier as $emailk => $email) {
// Get the related cases.
- $cases = $this->precheck_user_cases($email);
+ $cases = self::precheck_user_cases($email);
// Rename them (keys).
foreach ($cases as $key => $case) {
$providercases[$key . ' - ' . $emailk] = $case;
@@ -150,7 +149,7 @@ class restore_dbops_test extends \advanced_testcase {
*
* @param string $email
*/
- private function precheck_user_cases($email) {
+ private static function precheck_user_cases($email) {
global $CFG;
$baseuserarr = [
diff --git a/backup/util/helper/tests/restore_structure_parser_processor_test.php b/backup/util/helper/tests/restore_structure_parser_processor_test.php
index a5239a10c3e..0edfb84baf1 100644
--- a/backup/util/helper/tests/restore_structure_parser_processor_test.php
+++ b/backup/util/helper/tests/restore_structure_parser_processor_test.php
@@ -53,7 +53,7 @@ class restore_structure_parser_processor_test extends advanced_testcase {
*
* @return array
*/
- public function process_cdata_data_provider() {
+ public static function process_cdata_data_provider(): array {
return array(
array(null, null, true),
array("$@NULL@$", null, true),
diff --git a/badges/tests/badgeslib_test.php b/badges/tests/badgeslib_test.php
index 1fe05f1e5ff..1de13d977a9 100644
--- a/badges/tests/badgeslib_test.php
+++ b/badges/tests/badgeslib_test.php
@@ -470,7 +470,7 @@ class badgeslib_test extends advanced_testcase {
}
- public function data_for_message_from_template() {
+ public static function data_for_message_from_template(): array {
return array(
array(
'This is a message with no variables',
@@ -1173,7 +1173,7 @@ class badgeslib_test extends advanced_testcase {
*
* @return array
*/
- public function save_backpack_credentials_provider(): array {
+ public static function save_backpack_credentials_provider(): array {
return [
'Empty fields' => [
false,
@@ -1241,7 +1241,7 @@ class badgeslib_test extends advanced_testcase {
*
* @return array
*/
- public function badges_save_external_backpack_provider() {
+ public static function badges_save_external_backpack_provider(): array {
$data = [
'apiversion' => 2,
'backpackapiurl' => 'https://api.ca.badgr.io/v2',
@@ -1358,7 +1358,7 @@ class badgeslib_test extends advanced_testcase {
/**
* Provider for test_badges_(create/update)_site_backpack
*/
- public function badges_create_site_backpack_provider() {
+ public static function badges_create_site_backpack_provider(): array {
return [
"Test as admin user - creation test" => [true, true],
"Test as admin user - update test" => [true, false],
@@ -1529,7 +1529,7 @@ class badgeslib_test extends advanced_testcase {
*
* @return array
*/
- public function badges_get_site_primary_backpack_provider() {
+ public static function badges_get_site_primary_backpack_provider(): array {
return [
"Test with auth details" => [true],
"Test without auth details" => [false],
@@ -1584,7 +1584,7 @@ class badgeslib_test extends advanced_testcase {
*
* @return array
*/
- public function badges_change_sortorder_backpacks_provider(): array {
+ public static function badges_change_sortorder_backpacks_provider(): array {
return [
"Test up" => [
'backpacktomove' => 1,
@@ -1638,7 +1638,7 @@ class badgeslib_test extends advanced_testcase {
* Data provider for test_badges_generate_badgr_open_url
* @return array
*/
- public function badgr_open_url_generator() {
+ public static function badgr_open_url_generator(): array {
return [
'Badgr Assertion URL test' => [
OPEN_BADGES_V2_TYPE_ASSERTION, "https://api.ca.badgr.io/public/assertions/123455"
@@ -1685,7 +1685,7 @@ class badgeslib_test extends advanced_testcase {
*
* @return array
*/
- public function badges_external_get_mapping_provider() {
+ public static function badges_external_get_mapping_provider(): array {
return [
"Get the site backpack value" => [
1234, 4321, 'id', 'sitebackpackid'
diff --git a/badges/tests/output/manage_badge_action_bar_test.php b/badges/tests/output/manage_badge_action_bar_test.php
index 0979f5e8c30..e7047eae453 100644
--- a/badges/tests/output/manage_badge_action_bar_test.php
+++ b/badges/tests/output/manage_badge_action_bar_test.php
@@ -36,7 +36,7 @@ class manage_badge_action_bar_test extends \advanced_testcase {
*
* @return array
*/
- public function generate_badge_navigation_provider(): array {
+ public static function generate_badge_navigation_provider(): array {
return [
"Test tertiary nav as an editing teacher" => [
"editingteacher", [
diff --git a/blocks/myoverview/tests/privacy/provider_test.php b/blocks/myoverview/tests/privacy/provider_test.php
index 12ae75763fe..f071cffb405 100644
--- a/blocks/myoverview/tests/privacy/provider_test.php
+++ b/blocks/myoverview/tests/privacy/provider_test.php
@@ -71,7 +71,7 @@ class provider_test extends \core_privacy\tests\provider_testcase {
*
* @return array Array of valid user preferences.
*/
- public function user_preference_provider() {
+ public static function user_preference_provider(): array {
return array(
array('block_myoverview_user_sort_preference', 'lastaccessed', ''),
array('block_myoverview_user_sort_preference', 'title', ''),
diff --git a/blocks/rss_client/tests/cron_test.php b/blocks/rss_client/tests/cron_test.php
index 9bcf0894bba..b90b73fcd7f 100644
--- a/blocks/rss_client/tests/cron_test.php
+++ b/blocks/rss_client/tests/cron_test.php
@@ -67,7 +67,7 @@ class cron_test extends \advanced_testcase {
*
* @return array
*/
- public function skip_time_increase_provider() : array {
+ public static function skip_time_increase_provider(): array {
return [
'Never failed' => [
'skiptime' => 0,
diff --git a/blocks/timeline/tests/privacy/provider_test.php b/blocks/timeline/tests/privacy/provider_test.php
index 4850b9ea82b..6596744fa7b 100644
--- a/blocks/timeline/tests/privacy/provider_test.php
+++ b/blocks/timeline/tests/privacy/provider_test.php
@@ -76,7 +76,7 @@ class provider_test extends \core_privacy\tests\provider_testcase {
*
* @return array Array of valid user preferences.
*/
- public function user_preference_provider() {
+ public static function user_preference_provider(): array {
return array(
array('block_timeline_user_sort_preference', 'sortbydates', ''),
array('block_timeline_user_sort_preference', 'sortbycourses', ''),
diff --git a/blog/tests/reportbuilder/datasource/blogs_test.php b/blog/tests/reportbuilder/datasource/blogs_test.php
index b6b42425901..857c0b1c493 100644
--- a/blog/tests/reportbuilder/datasource/blogs_test.php
+++ b/blog/tests/reportbuilder/datasource/blogs_test.php
@@ -140,7 +140,7 @@ class blogs_test extends core_reportbuilder_testcase {
*
* @return array[]
*/
- public function datasource_filters_provider(): array {
+ public static function datasource_filters_provider(): array {
return [
'Filter title' => ['subject', 'Cool', 'blog:title', [
'blog:title_operator' => text::CONTAINS,
diff --git a/cache/stores/redis/tests/compressor_test.php b/cache/stores/redis/tests/compressor_test.php
index f12377d0e6e..5158554eefd 100644
--- a/cache/stores/redis/tests/compressor_test.php
+++ b/cache/stores/redis/tests/compressor_test.php
@@ -105,7 +105,7 @@ class compressor_test extends \advanced_testcase {
*
* @return array
*/
- public function provider_for_test_it_works_with_different_types() {
+ public static function provider_for_test_it_works_with_different_types(): array {
$object = new \stdClass();
$object->field = 'value';
@@ -147,7 +147,7 @@ class compressor_test extends \advanced_testcase {
public function test_it_works_with_different_types_for_many() {
$store = $this->create_store(cachestore_redis::COMPRESSOR_PHP_GZIP, \Redis::SERIALIZER_PHP);
- $provider = $this->provider_for_test_it_works_with_different_types();
+ $provider = self::provider_for_test_it_works_with_different_types();
$keys = [];
$values = [];
$expected = [];
@@ -166,7 +166,7 @@ class compressor_test extends \advanced_testcase {
*
* @return array
*/
- public function provider_for_tests_setget() {
+ public static function provider_for_tests_setget(): array {
if (!cachestore_redis::are_requirements_met()) {
// Even though we skip all tests in this case, this provider can still show warnings about non-existing class.
return [];
diff --git a/calendar/tests/action_event_test.php b/calendar/tests/action_event_test.php
index 55881793dba..ab77a88edf2 100644
--- a/calendar/tests/action_event_test.php
+++ b/calendar/tests/action_event_test.php
@@ -45,7 +45,7 @@ class action_event_test extends \advanced_testcase {
/**
* Test event class getters.
*
- * @dataProvider getters_testcases()
+ * @dataProvider getters_testcases
* @param array $constructorparams Associative array of constructor parameters.
*/
public function test_getters($constructorparams) {
@@ -64,7 +64,7 @@ class action_event_test extends \advanced_testcase {
/**
* Test cases for getters test.
*/
- public function getters_testcases() {
+ public static function getters_testcases(): array {
return [
'Dataset 1' => [
'constructorparams' => [
diff --git a/calendar/tests/action_test.php b/calendar/tests/action_test.php
index efad0b55721..553db87369d 100644
--- a/calendar/tests/action_test.php
+++ b/calendar/tests/action_test.php
@@ -29,7 +29,7 @@ class action_test extends \advanced_testcase {
/**
* Test action class getters.
*
- * @dataProvider getters_testcases()
+ * @dataProvider getters_testcases
* @param array $constructorparams Associative array of constructor parameters.
*/
public function test_getters($constructorparams) {
@@ -52,7 +52,7 @@ class action_test extends \advanced_testcase {
/**
* Test cases for getters test.
*/
- public function getters_testcases() {
+ public static function getters_testcases(): array {
return [
'Dataset 1' => [
'constructorparams' => [
diff --git a/calendar/tests/calendar_event_exporter_test.php b/calendar/tests/calendar_event_exporter_test.php
index 05530921646..c146a11ed3a 100644
--- a/calendar/tests/calendar_event_exporter_test.php
+++ b/calendar/tests/calendar_event_exporter_test.php
@@ -34,7 +34,7 @@ class calendar_event_exporter_test extends \advanced_testcase {
* Data provider for the timestamp min limit test case to confirm
* that the minimum time limit is set correctly on the boundary cases.
*/
- public function get_timestamp_min_limit_test_cases() {
+ public static function get_timestamp_min_limit_test_cases(): array {
$now = time();
$todaymidnight = usergetmidnight($now);
$tomorrowmidnight = $todaymidnight + DAYSECS;
@@ -70,7 +70,7 @@ class calendar_event_exporter_test extends \advanced_testcase {
}
/**
- * @dataProvider get_timestamp_min_limit_test_cases()
+ * @dataProvider get_timestamp_min_limit_test_cases
*/
public function test_get_timestamp_min_limit($starttime, $min, $expected) {
$class = calendar_event_exporter::class;
@@ -91,7 +91,7 @@ class calendar_event_exporter_test extends \advanced_testcase {
* Data provider for the timestamp max limit test case to confirm
* that the maximum time limit is set correctly on the boundary cases.
*/
- public function get_timestamp_max_limit_test_cases() {
+ public static function get_timestamp_max_limit_test_cases(): array {
$now = time();
$todaymidnight = usergetmidnight($now);
$yesterdaymidnight = $todaymidnight - DAYSECS;
@@ -127,7 +127,7 @@ class calendar_event_exporter_test extends \advanced_testcase {
}
/**
- * @dataProvider get_timestamp_max_limit_test_cases()
+ * @dataProvider get_timestamp_max_limit_test_cases
*/
public function test_get_timestamp_max_limit($starttime, $max, $expected) {
$class = calendar_event_exporter::class;
diff --git a/calendar/tests/container_test.php b/calendar/tests/container_test.php
index b833859538b..b4500815f1b 100644
--- a/calendar/tests/container_test.php
+++ b/calendar/tests/container_test.php
@@ -67,7 +67,7 @@ class container_test extends \advanced_testcase {
/**
* Test that the event factory correctly creates instances of events.
*
- * @dataProvider get_event_factory_testcases()
+ * @dataProvider get_event_factory_testcases
* @param \stdClass $dbrow Row from the "database".
*/
public function test_event_factory_create_instance($dbrow) {
@@ -128,7 +128,7 @@ class container_test extends \advanced_testcase {
/**
* Test that the event factory deals with invisible modules properly as admin.
*
- * @dataProvider get_event_factory_testcases()
+ * @dataProvider get_event_factory_testcases
* @param \stdClass $dbrow Row from the "database".
*/
public function test_event_factory_when_module_visibility_is_toggled_as_admin($dbrow) {
@@ -154,7 +154,7 @@ class container_test extends \advanced_testcase {
/**
* Test that the event factory deals with invisible modules properly as a guest.
*
- * @dataProvider get_event_factory_testcases()
+ * @dataProvider get_event_factory_testcases
* @param \stdClass $dbrow Row from the "database".
*/
public function test_event_factory_when_module_visibility_is_toggled_as_guest($dbrow) {
@@ -183,7 +183,7 @@ class container_test extends \advanced_testcase {
/**
* Test that the event factory deals with invisible courses as an admin.
*
- * @dataProvider get_event_factory_testcases()
+ * @dataProvider get_event_factory_testcases
* @param \stdClass $dbrow Row from the "database".
*/
public function test_event_factory_when_course_visibility_is_toggled_as_admin($dbrow) {
@@ -208,7 +208,7 @@ class container_test extends \advanced_testcase {
/**
* Test that the event factory deals with invisible courses as a student.
*
- * @dataProvider get_event_factory_testcases()
+ * @dataProvider get_event_factory_testcases
* @param \stdClass $dbrow Row from the "database".
*/
public function test_event_factory_when_course_visibility_is_toggled_as_student($dbrow) {
@@ -504,7 +504,7 @@ class container_test extends \advanced_testcase {
/**
* Test cases for the get event factory test.
*/
- public function get_event_factory_testcases() {
+ public static function get_event_factory_testcases(): array {
return [
'Data set 1' => [
'dbrow' => (object)[
diff --git a/calendar/tests/event_description_test.php b/calendar/tests/event_description_test.php
index fd5fdf1179c..b58213a9c37 100644
--- a/calendar/tests/event_description_test.php
+++ b/calendar/tests/event_description_test.php
@@ -29,7 +29,7 @@ class event_description_test extends \advanced_testcase {
/**
* Test event description class getters.
*
- * @dataProvider getters_testcases()
+ * @dataProvider getters_testcases
* @param array $constructorparams Associative array of constructor parameters.
*/
public function test_getters($constructorparams) {
@@ -45,7 +45,7 @@ class event_description_test extends \advanced_testcase {
/**
* Test cases for getters test.
*/
- public function getters_testcases() {
+ public static function getters_testcases(): array {
return [
'Dataset 1' => [
'constructorparams' => [
diff --git a/calendar/tests/event_factory_test.php b/calendar/tests/event_factory_test.php
index 044341ec99a..21ce1522cf6 100644
--- a/calendar/tests/event_factory_test.php
+++ b/calendar/tests/event_factory_test.php
@@ -35,7 +35,7 @@ class event_factory_test extends \advanced_testcase {
/**
* Test event class getters.
*
- * @dataProvider create_instance_testcases()
+ * @dataProvider create_instance_testcases
* @param \stdClass $dbrow Row from the event table.
* @param callable $actioncallbackapplier Action callback applier.
* @param callable $visibilitycallbackapplier Visibility callback applier.
@@ -343,7 +343,7 @@ class event_factory_test extends \advanced_testcase {
*
* @return array Array of testcases.
*/
- public function create_instance_testcases() {
+ public static function create_instance_testcases(): array {
return [
'Sample event record with event exposed' => [
'dbrow' => (object)[
diff --git a/calendar/tests/event_test.php b/calendar/tests/event_test.php
index b6cedc6e70f..a2f31d74834 100644
--- a/calendar/tests/event_test.php
+++ b/calendar/tests/event_test.php
@@ -36,7 +36,7 @@ class event_test extends \advanced_testcase {
/**
* Test event class getters.
*
- * @dataProvider getters_testcases()
+ * @dataProvider getters_testcases
* @param array $constructorparams Associative array of constructor parameters.
*/
public function test_getters($constructorparams) {
@@ -71,7 +71,7 @@ class event_test extends \advanced_testcase {
/**
* Test cases for getters test.
*/
- public function getters_testcases() {
+ public static function getters_testcases(): array {
$lamecallable = function($id) {
return (object)['id' => $id, 'modname' => 'assign'];
};
diff --git a/calendar/tests/event_times_test.php b/calendar/tests/event_times_test.php
index 70fd9e22039..0b3904ccd37 100644
--- a/calendar/tests/event_times_test.php
+++ b/calendar/tests/event_times_test.php
@@ -29,7 +29,7 @@ class event_times_test extends \advanced_testcase {
/**
* Test event times class getters.
*
- * @dataProvider getters_testcases()
+ * @dataProvider getters_testcases
* @param array $constructorparams Associative array of constructor parameters.
*/
public function test_getters($constructorparams) {
@@ -51,7 +51,7 @@ class event_times_test extends \advanced_testcase {
/**
* Test cases for getters test.
*/
- public function getters_testcases() {
+ public static function getters_testcases(): array {
return [
'Dataset 1' => [
'constructorparams' => [
diff --git a/calendar/tests/externallib_test.php b/calendar/tests/externallib_test.php
index bdd2735158a..c5c062b2a72 100644
--- a/calendar/tests/externallib_test.php
+++ b/calendar/tests/externallib_test.php
@@ -2795,7 +2795,7 @@ class externallib_test extends externallib_advanced_testcase {
*
* @return array
*/
- public function get_calendar_event_by_id_prevent_read_other_users_events_data_provider(): array {
+ public static function get_calendar_event_by_id_prevent_read_other_users_events_data_provider(): array {
$syscontext = \context_system::instance();
$managerrole = 'manager';
return [
@@ -2866,7 +2866,7 @@ class externallib_test extends externallib_advanced_testcase {
*
* @return array
*/
- public function edit_or_delete_other_users_events_data_provider(): array {
+ public static function edit_or_delete_other_users_events_data_provider(): array {
$syscontext = \context_system::instance();
$managerrole = 'manager';
return [
diff --git a/calendar/tests/lib_test.php b/calendar/tests/lib_test.php
index f212cdff9e9..68c2f8989ee 100644
--- a/calendar/tests/lib_test.php
+++ b/calendar/tests/lib_test.php
@@ -1050,7 +1050,7 @@ class lib_test extends \advanced_testcase {
*
* @return array[]
*/
- public function calendar_format_event_location_provider(): array {
+ public static function calendar_format_event_location_provider(): array {
return [
'Empty' => ['', ''],
'Text' => ['Barcelona', 'Barcelona'],
diff --git a/calendar/tests/std_proxy_test.php b/calendar/tests/std_proxy_test.php
index 9658a6098fa..5de821581b7 100644
--- a/calendar/tests/std_proxy_test.php
+++ b/calendar/tests/std_proxy_test.php
@@ -115,7 +115,7 @@ class std_proxy_test extends \advanced_testcase {
/**
* Test cases for proxying test.
*/
- public function proxy_testcases() {
+ public static function proxy_testcases(): array {
return [
'Object 1 member 1' => [
1,
@@ -153,7 +153,7 @@ class std_proxy_test extends \advanced_testcase {
/**
* Test cases for getting and setting tests.
*/
- public function get_set_testcases() {
+ public static function get_set_testcases(): array {
return [
'Object 1' => [1],
'Object 2' => [5]
diff --git a/cohort/tests/reportbuilder/datasource/cohorts_test.php b/cohort/tests/reportbuilder/datasource/cohorts_test.php
index ce5765d50aa..cb7f034641f 100644
--- a/cohort/tests/reportbuilder/datasource/cohorts_test.php
+++ b/cohort/tests/reportbuilder/datasource/cohorts_test.php
@@ -80,7 +80,7 @@ class cohorts_test extends core_reportbuilder_testcase {
*
* @return array[]
*/
- public function cohorts_datasource_user_select_provider(): array {
+ public static function datasource_filters_provider(): array {
return [
['user01', 'Cohort01'],
['user02', 'Cohort02'],
@@ -93,7 +93,7 @@ class cohorts_test extends core_reportbuilder_testcase {
* @param string $username
* @param string $expectedcohort
*
- * @dataProvider cohorts_datasource_user_select_provider
+ * @dataProvider datasource_filters_provider
*/
public function test_cohorts_datasource_user_select(string $username, string $expectedcohort): void {
$this->resetAfterTest();
diff --git a/comment/tests/reportbuilder/datasource/comments_test.php b/comment/tests/reportbuilder/datasource/comments_test.php
index 08d4aed9241..7f272b58172 100644
--- a/comment/tests/reportbuilder/datasource/comments_test.php
+++ b/comment/tests/reportbuilder/datasource/comments_test.php
@@ -123,7 +123,7 @@ class comments_test extends core_reportbuilder_testcase {
*
* @return array[]
*/
- public function datasource_filters_provider(): array {
+ public static function datasource_filters_provider(): array {
return [
// Comment.
'Filter content' => ['comment:content', [
diff --git a/completion/tests/activity_custom_completion_test.php b/completion/tests/activity_custom_completion_test.php
index 1a237d96424..9b8bd33b38b 100644
--- a/completion/tests/activity_custom_completion_test.php
+++ b/completion/tests/activity_custom_completion_test.php
@@ -48,7 +48,7 @@ class activity_custom_completion_test extends advanced_testcase {
/**
* Data provider for test_get_overall_completion_state().
*/
- public function overall_completion_state_provider(): array {
+ public static function overall_completion_state_provider(): array {
global $CFG;
require_once($CFG->libdir . '/completionlib.php');
return [
@@ -121,7 +121,7 @@ class activity_custom_completion_test extends advanced_testcase {
*
* @return array[]
*/
- public function validate_rule_provider() {
+ public static function validate_rule_provider(): array {
return [
'Not defined' => [
false, true, coding_exception::class
diff --git a/completion/tests/bulk_update_test.php b/completion/tests/bulk_update_test.php
index 86ef1670d3b..c61db0e6c81 100644
--- a/completion/tests/bulk_update_test.php
+++ b/completion/tests/bulk_update_test.php
@@ -36,7 +36,7 @@ class bulk_update_test extends \advanced_testcase {
* Provider for test_bulk_form_submit_single
* @return array
*/
- public function bulk_form_submit_single_provider() {
+ public static function bulk_form_submit_single_provider(): array {
return [
'assign-1' => ['assign', ['completion' => COMPLETION_TRACKING_AUTOMATIC, 'completionsubmit' => 1]],
'assign-2' => ['assign', ['completion' => COMPLETION_TRACKING_MANUAL]],
@@ -171,7 +171,7 @@ class bulk_update_test extends \advanced_testcase {
* Provider for test_bulk_form_submit_multiple
* @return array
*/
- public function bulk_form_submit_multiple_provider() {
+ public static function bulk_form_submit_multiple_provider(): array {
return [
'Several modules with the same module type (choice)' => [
[
diff --git a/completion/tests/cm_completion_details_test.php b/completion/tests/cm_completion_details_test.php
index 00d660a110d..8417845223c 100644
--- a/completion/tests/cm_completion_details_test.php
+++ b/completion/tests/cm_completion_details_test.php
@@ -104,7 +104,7 @@ class cm_completion_details_test extends advanced_testcase {
*
* @return array[]
*/
- public function has_completion_provider(): array {
+ public static function has_completion_provider(): array {
return [
'Automatic' => [
COMPLETION_TRACKING_AUTOMATIC, true
@@ -136,7 +136,7 @@ class cm_completion_details_test extends advanced_testcase {
*
* @return array[]
*/
- public function is_automatic_provider(): array {
+ public static function is_automatic_provider(): array {
return [
'Automatic' => [
COMPLETION_TRACKING_AUTOMATIC, true
@@ -167,7 +167,7 @@ class cm_completion_details_test extends advanced_testcase {
* Data provider for test_get_overall_completion().
* @return array[]
*/
- public function overall_completion_provider(): array {
+ public static function overall_completion_provider(): array {
return [
'Complete' => [COMPLETION_COMPLETE],
'Incomplete' => [COMPLETION_INCOMPLETE],
@@ -190,7 +190,7 @@ class cm_completion_details_test extends advanced_testcase {
* Data provider for test_get_details().
* @return array[]
*/
- public function get_details_provider() {
+ public static function get_details_provider(): array {
return [
'No completion tracking' => [
COMPLETION_TRACKING_NONE, null, null, null, []
@@ -350,7 +350,7 @@ class cm_completion_details_test extends advanced_testcase {
* Data provider for test_get_details_custom_order().
* @return array[]
*/
- public function get_details_custom_order_provider() {
+ public static function get_details_custom_order_provider(): array {
return [
'Custom and view/grade standard conditions, view first and grade last' => [
true,
diff --git a/contentbank/contenttype/h5p/tests/content_h5p_test.php b/contentbank/contenttype/h5p/tests/content_h5p_test.php
index 4c145c21244..f7cdeb03b2d 100644
--- a/contentbank/contenttype/h5p/tests/content_h5p_test.php
+++ b/contentbank/contenttype/h5p/tests/content_h5p_test.php
@@ -138,7 +138,7 @@ class content_h5p_test extends \advanced_testcase {
*
* @return array
*/
- public function is_view_allowed_provider(): array {
+ public static function is_view_allowed_provider(): array {
return [
'Editing teacher with all libraries enabled' => [
'role' => 'editingteacher',
diff --git a/contentbank/tests/content_test.php b/contentbank/tests/content_test.php
index 9161c1d8729..cee3b9cd813 100644
--- a/contentbank/tests/content_test.php
+++ b/contentbank/tests/content_test.php
@@ -74,7 +74,7 @@ class content_test extends \advanced_testcase {
*
* @return array
*/
- public function set_name_provider() {
+ public static function set_name_provider(): array {
return [
'Standard name' => ['New name', 'New name'],
'Name with digits' => ['Today is 17/04/2017', 'Today is 17/04/2017'],
diff --git a/contentbank/tests/contentbank_test.php b/contentbank/tests/contentbank_test.php
index 88a08ed07a9..c7f369f1d26 100644
--- a/contentbank/tests/contentbank_test.php
+++ b/contentbank/tests/contentbank_test.php
@@ -65,7 +65,7 @@ class contentbank_test extends advanced_testcase {
*
* @return array
*/
- public function get_extension_provider() {
+ public static function get_extension_provider(): array {
return [
'H5P file' => ['something.h5p', '.h5p'],
'PDF file' => ['something.pdf', '.pdf']
@@ -95,7 +95,7 @@ class contentbank_test extends advanced_testcase {
*
* @return array
*/
- public function get_extension_supporters_provider() {
+ public static function get_extension_supporters_provider(): array {
return [
'H5P first' => [['.h5p' => ['h5p', 'testable']], '.h5p', 'h5p'],
'Testable first (but upload not implemented)' => [['.h5p' => ['testable', 'h5p']], '.h5p', 'h5p'],
@@ -259,7 +259,7 @@ class contentbank_test extends advanced_testcase {
*
* @return array
*/
- public function search_contents_provider(): array {
+ public static function search_contents_provider(): array {
return [
'Search all content in all contexts' => [
@@ -519,7 +519,7 @@ class contentbank_test extends advanced_testcase {
*
* @return array
*/
- public function get_contenttypes_with_capability_feature_provider(): array {
+ public static function get_contenttypes_with_capability_feature_provider(): array {
return [
'no-contenttypes_enabled' => [
'contenttypesenabled' => [],
diff --git a/contentbank/tests/contenttype_test.php b/contentbank/tests/contenttype_test.php
index b6a9b82cbd4..d137335e942 100644
--- a/contentbank/tests/contenttype_test.php
+++ b/contentbank/tests/contenttype_test.php
@@ -245,7 +245,7 @@ class contenttype_test extends \advanced_testcase {
*
* @return array
*/
- public function upload_content_provider() {
+ public static function upload_content_provider(): array {
return [
'With record' => [true],
'Without record' => [false],
@@ -454,7 +454,7 @@ class contenttype_test extends \advanced_testcase {
*
* @return array
*/
- public function rename_content_provider() {
+ public static function rename_content_provider(): array {
return [
'Standard name' => ['New name', 'New name', true],
'Name with digits' => ['Today is 17/04/2017', 'Today is 17/04/2017', true],
diff --git a/contentbank/tests/external/rename_content_test.php b/contentbank/tests/external/rename_content_test.php
index 6f7f6ff56a6..822e54fbd15 100644
--- a/contentbank/tests/external/rename_content_test.php
+++ b/contentbank/tests/external/rename_content_test.php
@@ -50,7 +50,7 @@ class rename_content_test extends \externallib_advanced_testcase {
*
* @return array
*/
- public function rename_content_provider() {
+ public static function rename_content_provider(): array {
return [
'Standard name' => ['New name', 'New name', true],
'Name with digits' => ['Today is 17/04/2017', 'Today is 17/04/2017', true],
diff --git a/course/format/tests/base_test.php b/course/format/tests/base_test.php
index a7822a6b1f9..8fa7ef2a9be 100644
--- a/course/format/tests/base_test.php
+++ b/course/format/tests/base_test.php
@@ -263,7 +263,7 @@ class base_test extends advanced_testcase {
*
* @return array the testing scenarios
*/
- public function get_output_classname_provider(): array {
+ public static function get_output_classname_provider(): array {
return [
'overridden class' => [
'find' => 'state\\course',
@@ -498,7 +498,7 @@ class base_test extends advanced_testcase {
*
* @return array the testing scenarios
*/
- public function delete_format_data_provider(): array {
+ public static function delete_format_data_provider(): array {
return [
'direct call' => [
'usehook' => false
diff --git a/course/format/tests/external/get_state_test.php b/course/format/tests/external/get_state_test.php
index bcedd162f7f..3c13dbff7dd 100644
--- a/course/format/tests/external/get_state_test.php
+++ b/course/format/tests/external/get_state_test.php
@@ -167,7 +167,7 @@ class get_state_test extends \externallib_advanced_testcase {
*
* @return array
*/
- public function get_state_provider(): array {
+ public static function get_state_provider(): array {
return [
// ROLES. Testing behaviour depending on the user role calling the method.
'Admin user should work' => [
diff --git a/course/format/tests/external/update_course_test.php b/course/format/tests/external/update_course_test.php
index 56d64f889bd..0691132da30 100644
--- a/course/format/tests/external/update_course_test.php
+++ b/course/format/tests/external/update_course_test.php
@@ -104,7 +104,7 @@ class update_course_test extends \externallib_advanced_testcase {
*
* @return array of testing scenarios
*/
- public function execute_course_state_provider(): array {
+ public static function execute_course_state_provider(): array {
return [
'Execute a core state action (cm_state)' => [
'format' => 'topics',
diff --git a/course/format/tests/output/local/state/cm_test.php b/course/format/tests/output/local/state/cm_test.php
index 2899af7c289..cdbc6bea7cc 100644
--- a/course/format/tests/output/local/state/cm_test.php
+++ b/course/format/tests/output/local/state/cm_test.php
@@ -153,7 +153,7 @@ class cm_test extends \advanced_testcase {
*
* @return array
*/
- public function hasrestrictions_state_provider(): array {
+ public static function hasrestrictions_state_provider(): array {
return [
// Teacher scenarios (topics).
'Teacher, Topics, can edit, has availability and is available' => [
diff --git a/course/format/tests/output/local/state/section_test.php b/course/format/tests/output/local/state/section_test.php
index ef12f894a75..e5afb3fbf24 100644
--- a/course/format/tests/output/local/state/section_test.php
+++ b/course/format/tests/output/local/state/section_test.php
@@ -145,7 +145,7 @@ class section_test extends \advanced_testcase {
*
* @return array
*/
- public function hasrestrictions_state_provider(): array {
+ public static function hasrestrictions_state_provider(): array {
return [
// Teacher scenarios (topics).
'Teacher, Topics, can edit, has availability and is available' => [
diff --git a/course/format/tests/output/local/state/state_test.php b/course/format/tests/output/local/state/state_test.php
index 3c964c98e24..3e508faf1c8 100644
--- a/course/format/tests/output/local/state/state_test.php
+++ b/course/format/tests/output/local/state/state_test.php
@@ -142,7 +142,7 @@ class state_test extends \advanced_testcase {
*
* @return array
*/
- public function state_provider(): array {
+ public static function state_provider(): array {
return [
// COURSEFORMAT. Test behaviour depending on course formats.
'Single activity format' => [
diff --git a/course/format/tests/stateactions_test.php b/course/format/tests/stateactions_test.php
index 429c046150d..d5d9afcc69d 100644
--- a/course/format/tests/stateactions_test.php
+++ b/course/format/tests/stateactions_test.php
@@ -28,8 +28,7 @@ use stdClass;
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @coversDefaultClass \core_courseformat\stateactions
*/
-class stateactions_test extends \advanced_testcase {
-
+final class stateactions_test extends \advanced_testcase {
/**
* Setup to ensure that fixtures are loaded.
*/
@@ -53,7 +52,6 @@ class stateactions_test extends \advanced_testcase {
int $section,
bool $visible = true
): int {
-
$activity = $this->getDataGenerator()->create_module(
$type,
['course' => $courseid],
@@ -188,7 +186,6 @@ class stateactions_test extends \advanced_testcase {
* @param array $params the ids, targetsection and targetcm to use as params
* @param array $expectedresults List of the course module names expected after calling the method.
* @param bool $expectedexception If this call will raise an exception.
-
*/
public function test_get_state(
string $format,
@@ -198,7 +195,6 @@ class stateactions_test extends \advanced_testcase {
array $expectedresults,
bool $expectedexception = false
): void {
-
$this->resetAfterTest();
// Create a course with 3 sections, 1 of them hidden.
@@ -266,29 +262,29 @@ class stateactions_test extends \advanced_testcase {
*
* @return array the testing scenarios
*/
- public function get_state_provider(): array {
+ public static function get_state_provider(): array {
return array_merge(
- $this->course_state_provider('weeks'),
- $this->course_state_provider('topics'),
- $this->course_state_provider('social'),
- $this->section_state_provider('weeks', 'admin'),
- $this->section_state_provider('weeks', 'editingteacher'),
- $this->section_state_provider('weeks', 'student'),
- $this->section_state_provider('topics', 'admin'),
- $this->section_state_provider('topics', 'editingteacher'),
- $this->section_state_provider('topics', 'student'),
- $this->section_state_provider('social', 'admin'),
- $this->section_state_provider('social', 'editingteacher'),
- $this->section_state_provider('social', 'student'),
- $this->cm_state_provider('weeks', 'admin'),
- $this->cm_state_provider('weeks', 'editingteacher'),
- $this->cm_state_provider('weeks', 'student'),
- $this->cm_state_provider('topics', 'admin'),
- $this->cm_state_provider('topics', 'editingteacher'),
- $this->cm_state_provider('topics', 'student'),
- $this->cm_state_provider('social', 'admin'),
- $this->cm_state_provider('social', 'editingteacher'),
- $this->cm_state_provider('social', 'student'),
+ static::course_state_provider('weeks'),
+ static::course_state_provider('topics'),
+ static::course_state_provider('social'),
+ static::section_state_provider('weeks', 'admin'),
+ static::section_state_provider('weeks', 'editingteacher'),
+ static::section_state_provider('weeks', 'student'),
+ static::section_state_provider('topics', 'admin'),
+ static::section_state_provider('topics', 'editingteacher'),
+ static::section_state_provider('topics', 'student'),
+ static::section_state_provider('social', 'admin'),
+ static::section_state_provider('social', 'editingteacher'),
+ static::section_state_provider('social', 'student'),
+ static::cm_state_provider('weeks', 'admin'),
+ static::cm_state_provider('weeks', 'editingteacher'),
+ static::cm_state_provider('weeks', 'student'),
+ static::cm_state_provider('topics', 'admin'),
+ static::cm_state_provider('topics', 'editingteacher'),
+ static::cm_state_provider('topics', 'student'),
+ static::cm_state_provider('social', 'admin'),
+ static::cm_state_provider('social', 'editingteacher'),
+ static::cm_state_provider('social', 'student'),
);
}
@@ -298,7 +294,7 @@ class stateactions_test extends \advanced_testcase {
* @param string $format the course format
* @return array the testing scenarios
*/
- public function course_state_provider(string $format): array {
+ public static function course_state_provider(string $format): array {
$expectedexception = ($format === 'social');
return [
// Tests for course_state.
@@ -354,8 +350,7 @@ class stateactions_test extends \advanced_testcase {
* @param string $role the user role
* @return array the testing scenarios
*/
- public function section_state_provider(string $format, string $role): array {
-
+ public static function section_state_provider(string $format, string $role): array {
// Social format will raise an exception and debug messages because it does not
// use sections and it does not provide a renderer.
$expectedexception = ($format === 'social');
@@ -483,8 +478,7 @@ class stateactions_test extends \advanced_testcase {
* @param string $role the user role
* @return array the testing scenarios
*/
- public function cm_state_provider(string $format, string $role): array {
-
+ public static function cm_state_provider(string $format, string $role): array {
// All sections and cms that the user can access to.
$usersections = ['section0', 'section1', 'section2', 'section3'];
$usercms = ['cm0', 'cm1', 'cm2', 'cm3'];
@@ -850,7 +844,7 @@ class stateactions_test extends \advanced_testcase {
*
* @return array the testing scenarios
*/
- public function basic_role_provider() {
+ public static function basic_role_provider(): array {
return [
'editingteacher' => [
'role' => 'editingteacher',
diff --git a/course/format/tests/stateupdates_test.php b/course/format/tests/stateupdates_test.php
index 714d123fadb..183d8114611 100644
--- a/course/format/tests/stateupdates_test.php
+++ b/course/format/tests/stateupdates_test.php
@@ -81,7 +81,7 @@ class stateupdates_test extends \advanced_testcase {
*
* @return array testing scenarios
*/
- public function add_course_put_provider() {
+ public static function add_course_put_provider(): array {
return [
'Admin role' => [
'admin',
@@ -199,11 +199,11 @@ class stateupdates_test extends \advanced_testcase {
*
* @return array testing scenarios
*/
- public function add_section_provider(): array {
+ public static function add_section_provider(): array {
return array_merge(
- $this->add_section_provider_helper('put'),
- $this->add_section_provider_helper('create'),
- $this->add_section_provider_helper('remove'),
+ self::add_section_provider_helper('put'),
+ self::add_section_provider_helper('create'),
+ self::add_section_provider_helper('remove'),
);
}
@@ -213,7 +213,7 @@ class stateupdates_test extends \advanced_testcase {
* @param string $action the action to perform
* @return array testing scenarios
*/
- private function add_section_provider_helper(string $action): array {
+ private static function add_section_provider_helper(string $action): array {
// Delete does not depends on user permissions.
if ($action == 'remove') {
$studentsections = [0, 1, 2];
@@ -343,11 +343,11 @@ class stateupdates_test extends \advanced_testcase {
*
* @return array testing scenarios
*/
- public function add_cm_provider(): array {
+ public static function add_cm_provider(): array {
return array_merge(
- $this->add_cm_provider_helper('put'),
- $this->add_cm_provider_helper('create'),
- $this->add_cm_provider_helper('remove'),
+ self::add_cm_provider_helper('put'),
+ self::add_cm_provider_helper('create'),
+ self::add_cm_provider_helper('remove'),
);
}
@@ -357,7 +357,7 @@ class stateupdates_test extends \advanced_testcase {
* @param string $action the action to perform
* @return array testing scenarios
*/
- private function add_cm_provider_helper(string $action): array {
+ private static function add_cm_provider_helper(string $action): array {
// Delete does not depends on user permissions.
if ($action == 'remove') {
$studentcms = [0, 1, 2, 3];
diff --git a/course/tests/category_test.php b/course/tests/category_test.php
index 288cdc1318a..bc51b31295a 100644
--- a/course/tests/category_test.php
+++ b/course/tests/category_test.php
@@ -1256,7 +1256,7 @@ class category_test extends \advanced_testcase {
*
* @return array
*/
- public function get_nearest_editable_subcategory_provider(): array {
+ public static function get_nearest_editable_subcategory_provider(): array {
return [
'Hidden main category for manager. Checking create and manage' => [
0,
diff --git a/course/tests/courselib_test.php b/course/tests/courselib_test.php
index 860c814ce2e..01b0d1fde9e 100644
--- a/course/tests/courselib_test.php
+++ b/course/tests/courselib_test.php
@@ -636,7 +636,7 @@ class courselib_test extends advanced_testcase {
*
* @return array An array of arrays contain test data
*/
- public function provider_course_delete_module() {
+ public static function provider_course_delete_module(): array {
$data = array();
$data['assign'] = array('assign', array('duedate' => time()));
@@ -801,7 +801,7 @@ class courselib_test extends advanced_testcase {
/**
* Relative dates mode settings provider for course creation.
*/
- public function create_course_relative_dates_provider() {
+ public static function create_course_relative_dates_provider(): array {
return [
[0, 0, 0],
[0, 1, 0],
@@ -3590,7 +3590,7 @@ class courselib_test extends advanced_testcase {
*
* @return array
*/
- public function course_enddate_provider() {
+ public static function course_enddate_provider(): array {
// Each provided example contains startdate, enddate and the expected exception error code if there is any.
return [
[
@@ -3672,7 +3672,7 @@ class courselib_test extends advanced_testcase {
*
* @return array
*/
- public function course_dates_reset_provider() {
+ public static function course_dates_reset_provider(): array {
// Each example contains the following:
// - course startdate
@@ -4573,7 +4573,7 @@ class courselib_test extends advanced_testcase {
/**
* Test cases for the course_classify_courses_for_timeline test.
*/
- public function get_course_classify_courses_for_timeline_test_cases() {
+ public static function get_course_classify_courses_for_timeline_test_cases(): array {
$now = time();
$day = 86400;
@@ -4684,7 +4684,7 @@ class courselib_test extends advanced_testcase {
/**
* Test the course_classify_courses_for_timeline function.
*
- * @dataProvider get_course_classify_courses_for_timeline_test_cases()
+ * @dataProvider get_course_classify_courses_for_timeline_test_cases
* @param array $coursesdata Courses to create
* @param array $expected Expected test results.
*/
@@ -4726,7 +4726,7 @@ class courselib_test extends advanced_testcase {
/**
* Test cases for the course_get_enrolled_courses_for_logged_in_user tests.
*/
- public function get_course_get_enrolled_courses_for_logged_in_user_test_cases() {
+ public static function get_course_get_enrolled_courses_for_logged_in_user_test_cases(): array {
$buildexpectedresult = function($limit, $offset) {
$result = [];
for ($i = $offset; $i < $offset + $limit; $i++) {
@@ -4814,7 +4814,7 @@ class courselib_test extends advanced_testcase {
/**
* Test the course_get_enrolled_courses_for_logged_in_user function.
*
- * @dataProvider get_course_get_enrolled_courses_for_logged_in_user_test_cases()
+ * @dataProvider get_course_get_enrolled_courses_for_logged_in_user_test_cases
* @param int $dbquerylimit Number of records to load per DB request
* @param int $totalcourses Number of courses to create
* @param int $limit Maximum number of results to get.
@@ -4862,7 +4862,7 @@ class courselib_test extends advanced_testcase {
/**
* Test cases for the course_filter_courses_by_timeline_classification tests.
*/
- public function get_course_filter_courses_by_timeline_classification_test_cases() {
+ public static function get_course_filter_courses_by_timeline_classification_test_cases(): array {
$now = time();
$day = 86400;
@@ -5112,7 +5112,7 @@ class courselib_test extends advanced_testcase {
/**
* Test the course_filter_courses_by_timeline_classification function.
*
- * @dataProvider get_course_filter_courses_by_timeline_classification_test_cases()
+ * @dataProvider get_course_filter_courses_by_timeline_classification_test_cases
* @param array $coursedata Course test data to create.
* @param string $classification Timeline classification.
* @param int $limit Maximum number of results to return.
@@ -5161,7 +5161,7 @@ class courselib_test extends advanced_testcase {
/**
* Test cases for the course_filter_courses_by_timeline_classification tests.
*/
- public function get_course_filter_courses_by_customfield_test_cases() {
+ public static function get_course_filter_courses_by_customfield_test_cases(): array {
global $CFG;
require_once($CFG->dirroot.'/blocks/myoverview/lib.php');
$coursedata = [
@@ -5331,7 +5331,7 @@ class courselib_test extends advanced_testcase {
/**
* Test the course_filter_courses_by_customfield function.
*
- * @dataProvider get_course_filter_courses_by_customfield_test_cases()
+ * @dataProvider get_course_filter_courses_by_customfield_test_cases
* @param array $coursedata Course test data to create.
* @param string $customfield Shortname of the customfield.
* @param string $customfieldvalue the value to filter by.
@@ -5417,7 +5417,7 @@ class courselib_test extends advanced_testcase {
/**
* Test cases for the course_filter_courses_by_timeline_classification w/ hidden courses tests.
*/
- public function get_course_filter_courses_by_timeline_classification_hidden_courses_test_cases() {
+ public static function get_course_filter_courses_by_timeline_classification_hidden_courses_test_cases(): array {
$now = time();
$day = 86400;
@@ -5576,7 +5576,7 @@ class courselib_test extends advanced_testcase {
/**
* Test the course_filter_courses_by_timeline_classification function hidden courses.
*
- * @dataProvider get_course_filter_courses_by_timeline_classification_hidden_courses_test_cases()
+ * @dataProvider get_course_filter_courses_by_timeline_classification_hidden_courses_test_cases
* @param array $coursedata Course test data to create.
* @param string $classification Timeline classification.
* @param int $limit Maximum number of results to return.
@@ -5786,7 +5786,7 @@ class courselib_test extends advanced_testcase {
*
* @return array
*/
- function course_get_recent_courses_sort_validation_provider() {
+ public static function course_get_recent_courses_sort_validation_provider(): array {
return [
'Invalid sort format (SQL injection attempt)' =>
[
@@ -5860,7 +5860,7 @@ class courselib_test extends advanced_testcase {
/**
* Test cases for the course_get_course_dates_for_user_ids tests.
*/
- public function get_course_get_course_dates_for_user_ids_test_cases() {
+ public static function get_course_get_course_dates_for_user_ids_test_cases(): array {
$now = time();
$pastcoursestart = $now - 100;
$futurecoursestart = $now + 100;
@@ -7074,7 +7074,7 @@ class courselib_test extends advanced_testcase {
/**
* Test the course_get_course_dates_for_user_ids function.
*
- * @dataProvider get_course_get_course_dates_for_user_ids_test_cases()
+ * @dataProvider get_course_get_course_dates_for_user_ids_test_cases
* @param bool $relativedatemode Set the course to relative dates mode
* @param int $coursestart Course start date
* @param int $usercount Number of users to create
@@ -7167,7 +7167,7 @@ class courselib_test extends advanced_testcase {
*
* @return array An array of arrays contain test data
*/
- public function provider_course_modules_pending_deletion() {
+ public static function provider_course_modules_pending_deletion(): array {
return [
'Non-gradable activity, check all' => [['forum'], 0, false, true],
'Gradable activity, check all' => [['assign'], 0, false, true],
diff --git a/course/tests/externallib_test.php b/course/tests/externallib_test.php
index b909276550d..47fbc00ff2c 100644
--- a/course/tests/externallib_test.php
+++ b/course/tests/externallib_test.php
@@ -3494,7 +3494,7 @@ final class externallib_test extends externallib_advanced_testcase {
/**
* Test the get_enrolled_courses_by_timeline_classification function.
*
- * @dataProvider get_get_enrolled_courses_by_timeline_classification_test_cases()
+ * @dataProvider get_get_enrolled_courses_by_timeline_classification_test_cases
* @param array $coursedata Courses to create
* @param string $classification Timeline classification
* @param int $limit Maximum number of results
diff --git a/course/tests/reportbuilder/datasource/courses_test.php b/course/tests/reportbuilder/datasource/courses_test.php
index 60eb9271743..07adbcbd22a 100644
--- a/course/tests/reportbuilder/datasource/courses_test.php
+++ b/course/tests/reportbuilder/datasource/courses_test.php
@@ -198,7 +198,7 @@ class courses_test extends core_reportbuilder_testcase {
*
* @return array[]
*/
- public function datasource_filters_provider(): array {
+ public static function datasource_filters_provider(): array {
return [
// Category.
'Filter category' => ['course_category:name', [
diff --git a/course/tests/targets_test.php b/course/tests/targets_test.php
index 9e2e72b9823..d9ced154164 100644
--- a/course/tests/targets_test.php
+++ b/course/tests/targets_test.php
@@ -40,7 +40,7 @@ class targets_test extends \advanced_testcase {
*
* @return array
*/
- public function analysable_provider() {
+ public static function analysable_provider(): array {
$now = new \DateTime("now", \core_date::get_server_timezone_object());
$year = $now->format('Y');
@@ -153,7 +153,7 @@ class targets_test extends \advanced_testcase {
*
* @return array
*/
- public function sample_provider() {
+ public static function sample_provider(): array {
$now = time();
return [
'enrolmentendbeforecourse' => [
@@ -204,7 +204,7 @@ class targets_test extends \advanced_testcase {
*
* @return array
*/
- public function active_during_analysis_time_provider() {
+ public static function active_during_analysis_time_provider(): array {
$now = time();
return [
diff --git a/customfield/field/date/tests/plugin_test.php b/customfield/field/date/tests/plugin_test.php
index a2cd087c78c..002b6b4d395 100644
--- a/customfield/field/date/tests/plugin_test.php
+++ b/customfield/field/date/tests/plugin_test.php
@@ -169,7 +169,7 @@ class plugin_test extends \advanced_testcase {
*
* @return array
*/
- public function parse_value_provider() : array {
+ public static function parse_value_provider(): array {
return [
// Valid times.
['2019-10-01', strtotime('2019-10-01')],
diff --git a/enrol/ldap/tests/ldap_test.php b/enrol/ldap/tests/ldap_test.php
index 13bea0effdb..f83a2651eaf 100644
--- a/enrol/ldap/tests/ldap_test.php
+++ b/enrol/ldap/tests/ldap_test.php
@@ -45,7 +45,7 @@ class ldap_test extends \advanced_testcase {
*
* @return array[]
*/
- public function enrol_ldap_provider() {
+ public static function enrol_ldap_provider(): array {
$pagesizes = [1, 3, 5, 1000];
$subcontexts = [0, 1];
$combinations = [];
@@ -525,7 +525,7 @@ class ldap_test extends \advanced_testcase {
*
* @return array of testcases.
*/
- public function objectclass_fetch_provider() {
+ public static function objectclass_fetch_provider(): array {
return array(
// This is the list of values from ldap_getdefaults() normalised.
'edir' => array(
diff --git a/enrol/lti/tests/helper_test.php b/enrol/lti/tests/helper_test.php
index 0a41fbb90bd..5675593dc38 100644
--- a/enrol/lti/tests/helper_test.php
+++ b/enrol/lti/tests/helper_test.php
@@ -404,7 +404,7 @@ class helper_test extends \advanced_testcase {
/**
* Data provider for the set_xpath test.
*/
- public function set_xpath_provider() {
+ public static function set_xpath_provider(): array {
return [
"Correct structure" => [
"parameters" => [
diff --git a/enrol/lti/tests/local/ltiadvantage/entity/ags_info_test.php b/enrol/lti/tests/local/ltiadvantage/entity/ags_info_test.php
index 87d0bba422c..e0d20fc4f22 100644
--- a/enrol/lti/tests/local/ltiadvantage/entity/ags_info_test.php
+++ b/enrol/lti/tests/local/ltiadvantage/entity/ags_info_test.php
@@ -58,7 +58,7 @@ class ags_info_test extends \advanced_testcase {
* Data provider for testing object instantiation.
* @return array the data for testing.
*/
- public function instantiation_data_provider(): array {
+ public static function instantiation_data_provider(): array {
return [
'Both lineitems and lineitem URL provided with full list of valid scopes' => [
'args' => [
diff --git a/enrol/lti/tests/local/ltiadvantage/entity/application_registration_test.php b/enrol/lti/tests/local/ltiadvantage/entity/application_registration_test.php
index 5937136af6e..692093eadba 100644
--- a/enrol/lti/tests/local/ltiadvantage/entity/application_registration_test.php
+++ b/enrol/lti/tests/local/ltiadvantage/entity/application_registration_test.php
@@ -59,7 +59,7 @@ class application_registration_test extends \advanced_testcase {
*
* @return array the data for testing.
*/
- public function creation_data_provider(): array {
+ public static function creation_data_provider(): array {
return [
'Valid, only required args provided' => [
'args' => [
@@ -203,7 +203,7 @@ class application_registration_test extends \advanced_testcase {
*
* @return array the test case data.
*/
- public function create_draft_data_provider(): array {
+ public static function create_draft_data_provider(): array {
return [
'Valid, new draft' => [
'args' => [
@@ -268,7 +268,7 @@ class application_registration_test extends \advanced_testcase {
*
* @return array the array of test data.
*/
- public function add_tool_deployment_data_provider(): array {
+ public static function add_tool_deployment_data_provider(): array {
return [
'Valid, contains id on registration and valid deployment data provided' => [
'args' => [
diff --git a/enrol/lti/tests/local/ltiadvantage/entity/context_test.php b/enrol/lti/tests/local/ltiadvantage/entity/context_test.php
index b9f5d4d631b..2d9195d67a8 100644
--- a/enrol/lti/tests/local/ltiadvantage/entity/context_test.php
+++ b/enrol/lti/tests/local/ltiadvantage/entity/context_test.php
@@ -52,7 +52,7 @@ class context_test extends \advanced_testcase {
* Data provider for testing object instantiation.
* @return array[] the data for testing.
*/
- public function instantiation_data_provider(): array {
+ public static function instantiation_data_provider(): array {
return [
'Creation of a course section context' => [
'args' => [
diff --git a/enrol/lti/tests/local/ltiadvantage/entity/deployment_test.php b/enrol/lti/tests/local/ltiadvantage/entity/deployment_test.php
index 81f252161c5..f422ba694c2 100644
--- a/enrol/lti/tests/local/ltiadvantage/entity/deployment_test.php
+++ b/enrol/lti/tests/local/ltiadvantage/entity/deployment_test.php
@@ -53,7 +53,7 @@ class deployment_test extends \advanced_testcase {
* Data provider for testing object instantiation.
* @return array the data for testing.
*/
- public function instantiation_data_provider(): array {
+ public static function instantiation_data_provider(): array {
return [
'Valid deployment creation, no id or legacy consumer key' => [
'args' => [
diff --git a/enrol/lti/tests/local/ltiadvantage/entity/migration_claim_test.php b/enrol/lti/tests/local/ltiadvantage/entity/migration_claim_test.php
index 6900408a513..5332207d9b4 100644
--- a/enrol/lti/tests/local/ltiadvantage/entity/migration_claim_test.php
+++ b/enrol/lti/tests/local/ltiadvantage/entity/migration_claim_test.php
@@ -54,27 +54,55 @@ class migration_claim_test extends \advanced_testcase {
* @param string $clientid string id of the client.
* @param string $exp expiry time.
* @param string $nonce nonce.
- * @param legacy_consumer_repository $legacyconsumerrepo legacy consumer repo instance.
+ * @param bool $stublegacyconsumerrepo Whether the legacy consumer repo is a stub
* @param array $expected array containing expectation data.
* @covers ::__construct
*/
- public function test_migration_claim(array $migrationclaimdata, string $deploymentid, string $platform,
- string $clientid, string $exp, string $nonce, legacy_consumer_repository $legacyconsumerrepo,
- array $expected) {
+ public function test_migration_claim(
+ array $migrationclaimdata,
+ string $deploymentid,
+ string $platform,
+ string $clientid,
+ string $exp,
+ string $nonce,
+ bool $stublegacyconsumerrepo,
+ array $expected
+ ): void {
+ if ($stublegacyconsumerrepo) {
+ $legacyconsumerrepo = $this->get_stub_legacy_consumer_repo();
+ } else {
+ $legacyconsumerrepo = new legacy_consumer_repository();
+ }
if (!empty($expected['exception'])) {
$this->expectException($expected['exception']);
$this->expectExceptionMessage($expected['exceptionmessage']);
- new migration_claim($migrationclaimdata, $deploymentid, $platform, $clientid, $exp, $nonce,
- $legacyconsumerrepo);
+ new migration_claim(
+ $migrationclaimdata,
+ $deploymentid,
+ $platform,
+ $clientid,
+ $exp,
+ $nonce,
+ $legacyconsumerrepo,
+ );
} else {
- $migrationclaim = new migration_claim($migrationclaimdata, $deploymentid, $platform, $clientid, $exp,
- $nonce, $legacyconsumerrepo);
+ $migrationclaim = new migration_claim(
+ $migrationclaimdata,
+ $deploymentid,
+ $platform,
+ $clientid,
+ $exp,
+ $nonce,
+ $legacyconsumerrepo,
+ );
$this->assertInstanceOf(migration_claim::class, $migrationclaim);
$this->assertEquals($expected['user_id'], $migrationclaim->get_user_id());
$this->assertEquals($expected['context_id'], $migrationclaim->get_context_id());
- $this->assertEquals($expected['tool_consumer_instance_guid'],
- $migrationclaim->get_tool_consumer_instance_guid());
+ $this->assertEquals(
+ $expected['tool_consumer_instance_guid'],
+ $migrationclaim->get_tool_consumer_instance_guid(),
+ );
$this->assertEquals($expected['resource_link_id'], $migrationclaim->get_resource_link_id());
}
}
@@ -84,7 +112,7 @@ class migration_claim_test extends \advanced_testcase {
*
* @return array[] the test case data.
*/
- public function migration_claim_provider(): array {
+ public static function migration_claim_provider(): array {
// Note: See https://www.imsglobal.org/spec/lti/v1p3/migr#lti-1-1-migration-claim for details regarding the
// correct generation of oauth_consumer_key_sign signature.
return [
@@ -98,7 +126,7 @@ class migration_claim_test extends \advanced_testcase {
'clientid' => 'a1b2c3d4',
'exp' => '1622612930',
'nonce' => 'j45j2j5nnjn24544',
- new legacy_consumer_repository(),
+ 'stublegacyconsumerrepo' => false,
'expected' => [
'exception' => \coding_exception::class,
'exceptionmessage' => "Missing 'oauth_consumer_key' property in lti1p1 migration claim."
@@ -114,7 +142,7 @@ class migration_claim_test extends \advanced_testcase {
'clientid' => 'a1b2c3d4',
'exp' => '1622612930',
'nonce' => 'j45j2j5nnjn24544',
- new legacy_consumer_repository(),
+ 'stublegacyconsumerrepo' => false,
'expected' => [
'exception' => \coding_exception::class,
'exceptionmessage' => "Missing 'oauth_consumer_key_sign' property in lti1p1 migration claim."
@@ -130,7 +158,7 @@ class migration_claim_test extends \advanced_testcase {
'clientid' => 'a1b2c3d4',
'exp' => '1622612930',
'nonce' => 'j45j2j5nnjn24544',
- new legacy_consumer_repository(),
+ 'stublegacyconsumerrepo' => false,
'expected' => [
'exception' => \coding_exception::class,
'exceptionmessage' => "Invalid 'oauth_consumer_key_sign' signature in lti1p1 claim."
@@ -152,7 +180,7 @@ class migration_claim_test extends \advanced_testcase {
'clientid' => 'a1b2c3d4',
'exp' => '1622612930',
'nonce' => 'j45j2j5nnjn24544',
- $this->get_stub_legacy_consumer_repo(),
+ 'stublegacyconsumerrepo' => true,
'expected' => [
'user_id' => null,
'context_id' => null,
@@ -180,7 +208,7 @@ class migration_claim_test extends \advanced_testcase {
'clientid' => 'a1b2c3d4',
'exp' => '1622612930',
'nonce' => 'j45j2j5nnjn24544',
- $this->get_stub_legacy_consumer_repo(),
+ 'stublegacyconsumerrepo' => true,
'expected' => [
'user_id' => '24',
'context_id' => 'd345b',
diff --git a/enrol/lti/tests/local/ltiadvantage/entity/nrps_info_test.php b/enrol/lti/tests/local/ltiadvantage/entity/nrps_info_test.php
index 7e23fe90b90..642633b0a0d 100644
--- a/enrol/lti/tests/local/ltiadvantage/entity/nrps_info_test.php
+++ b/enrol/lti/tests/local/ltiadvantage/entity/nrps_info_test.php
@@ -52,7 +52,7 @@ class nrps_info_test extends \advanced_testcase {
* Data provider for testing object instantiation.
* @return array the data for testing.
*/
- public function instantiation_data_provider(): array {
+ public static function instantiation_data_provider(): array {
return [
'Valid creation' => [
'args' => [
diff --git a/enrol/lti/tests/local/ltiadvantage/entity/resource_link_test.php b/enrol/lti/tests/local/ltiadvantage/entity/resource_link_test.php
index 04f35d0b01c..8a36880864c 100644
--- a/enrol/lti/tests/local/ltiadvantage/entity/resource_link_test.php
+++ b/enrol/lti/tests/local/ltiadvantage/entity/resource_link_test.php
@@ -54,7 +54,7 @@ class resource_link_test extends \advanced_testcase {
* Data provider for testing object instantiation.
* @return array the data for testing.
*/
- public function instantiation_data_provider(): array {
+ public static function instantiation_data_provider(): array {
return [
'Valid creation, no context or id provided' => [
'args' => [
@@ -140,7 +140,7 @@ class resource_link_test extends \advanced_testcase {
*
* @return array the array of test case data.
*/
- public function add_grade_service_provider(): array {
+ public static function add_grade_service_provider(): array {
return [
'Valid, both URLs, some scopes' => [
'args' => [
diff --git a/enrol/lti/tests/local/ltiadvantage/lib/http_client_test.php b/enrol/lti/tests/local/ltiadvantage/lib/http_client_test.php
index 578e11a14f7..4a1d70f0928 100644
--- a/enrol/lti/tests/local/ltiadvantage/lib/http_client_test.php
+++ b/enrol/lti/tests/local/ltiadvantage/lib/http_client_test.php
@@ -109,7 +109,7 @@ class http_client_test extends \advanced_testcase {
*
* @return array the test case data.
*/
- public function unsupported_methods_provider() {
+ public static function unsupported_methods_provider(): array {
return [
'head' => ['HEAD'],
'put' => ['PUT'],
diff --git a/enrol/lti/tests/local/ltiadvantage/lib/http_exception_test.php b/enrol/lti/tests/local/ltiadvantage/lib/http_exception_test.php
index ae3684f5764..b6ac68b4277 100644
--- a/enrol/lti/tests/local/ltiadvantage/lib/http_exception_test.php
+++ b/enrol/lti/tests/local/ltiadvantage/lib/http_exception_test.php
@@ -55,7 +55,7 @@ class http_exception_test extends \basic_testcase {
*
* @return array the test case data.
*/
- public function exception_data_provider() {
+ public static function exception_data_provider(): array {
return [
'With only the response object' => [
'args' => [
diff --git a/enrol/lti/tests/local/ltiadvantage/lib/http_response_test.php b/enrol/lti/tests/local/ltiadvantage/lib/http_response_test.php
index 05ec320b92e..a0a9e32887b 100644
--- a/enrol/lti/tests/local/ltiadvantage/lib/http_response_test.php
+++ b/enrol/lti/tests/local/ltiadvantage/lib/http_response_test.php
@@ -46,7 +46,7 @@ class http_response_test extends \basic_testcase {
*
* @return array the test case data.
*/
- public function response_data_provider() {
+ public static function response_data_provider(): array {
return [
'valid headers and body' => [
'payload' => [
diff --git a/enrol/lti/tests/local/ltiadvantage/lti_advantage_testcase.php b/enrol/lti/tests/local/ltiadvantage/lti_advantage_testcase.php
index ca844c26a85..ce8cd7fbb65 100644
--- a/enrol/lti/tests/local/ltiadvantage/lti_advantage_testcase.php
+++ b/enrol/lti/tests/local/ltiadvantage/lti_advantage_testcase.php
@@ -100,9 +100,11 @@ abstract class lti_advantage_testcase extends \advanced_testcase {
* @param string $role the LTI role to include in the user data.
* @return array the users list.
*/
- protected function get_mock_launch_users_with_ids(array $ids, bool $includepicture = false,
- string $role = 'http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor'): array {
-
+ protected static function get_mock_launch_users_with_ids(
+ array $ids,
+ bool $includepicture = false,
+ string $role = 'http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor'
+ ): array {
$users = [];
foreach ($ids as $id) {
$user = [
diff --git a/enrol/lti/tests/local/ltiadvantage/repository/application_registration_repository_test.php b/enrol/lti/tests/local/ltiadvantage/repository/application_registration_repository_test.php
index cef5b0bbbdf..efac42c6f9c 100644
--- a/enrol/lti/tests/local/ltiadvantage/repository/application_registration_repository_test.php
+++ b/enrol/lti/tests/local/ltiadvantage/repository/application_registration_repository_test.php
@@ -135,7 +135,7 @@ class application_registration_repository_test extends \advanced_testcase {
*
* @return array the array of test data.
*/
- public function save_data_provider(): array {
+ public static function save_data_provider(): array {
return [
'minimal draft' => [
'registrationdata' => [
diff --git a/enrol/lti/tests/local/ltiadvantage/service/tool_launch_service_test.php b/enrol/lti/tests/local/ltiadvantage/service/tool_launch_service_test.php
index 6558e44ec43..83c30460ef4 100644
--- a/enrol/lti/tests/local/ltiadvantage/service/tool_launch_service_test.php
+++ b/enrol/lti/tests/local/ltiadvantage/service/tool_launch_service_test.php
@@ -123,12 +123,12 @@ class tool_launch_service_test extends \lti_advantage_testcase {
*
* @return array the test case data.
*/
- public function user_launch_provider(): array {
+ public static function user_launch_provider(): array {
return [
'New tool: no legacy data, no migration claim sent' => [
'legacy_data' => null,
'launch_data' => [
- 'user' => $this->get_mock_launch_users_with_ids(['1p3_1'])[0],
+ 'user' => self::get_mock_launch_users_with_ids(['1p3_1'])[0],
'launch_migration_claim' => null,
],
'expected' => [
@@ -144,7 +144,7 @@ class tool_launch_service_test extends \lti_advantage_testcase {
]
],
'launch_data' => [
- 'user' => $this->get_mock_launch_users_with_ids(['1'])[0],
+ 'user' => self::get_mock_launch_users_with_ids(['1'])[0],
'launch_migration_claim' => [
'consumer_key' => 'CONSUMER_1',
'signing_secret' => 'toolsecret1',
@@ -167,7 +167,7 @@ class tool_launch_service_test extends \lti_advantage_testcase {
]
],
'launch_data' => [
- 'user' => $this->get_mock_launch_users_with_ids(['1p3_1'])[0],
+ 'user' => self::get_mock_launch_users_with_ids(['1p3_1'])[0],
'launch_migration_claim' => [
'consumer_key' => 'CONSUMER_1',
'signing_secret' => 'toolsecret2',
@@ -189,7 +189,7 @@ class tool_launch_service_test extends \lti_advantage_testcase {
]
],
'launch_data' => [
- 'user' => $this->get_mock_launch_users_with_ids(['1p3_1'])[0],
+ 'user' => self::get_mock_launch_users_with_ids(['1p3_1'])[0],
'launch_migration_claim' => null,
],
'expected' => [
@@ -205,7 +205,7 @@ class tool_launch_service_test extends \lti_advantage_testcase {
]
],
'launch_data' => [
- 'user' => $this->get_mock_launch_users_with_ids(['1p3_1'])[0],
+ 'user' => self::get_mock_launch_users_with_ids(['1p3_1'])[0],
'launch_migration_claim' => [
'consumer_key' => 'CONSUMER_1',
'signing_secret' => 'secret-not-mapped-to-consumer',
@@ -229,7 +229,7 @@ class tool_launch_service_test extends \lti_advantage_testcase {
]
],
'launch_data' => [
- 'user' => $this->get_mock_launch_users_with_ids(['1p3_1'])[0],
+ 'user' => self::get_mock_launch_users_with_ids(['1p3_1'])[0],
'launch_migration_claim' => [
'consumer_key' => 'CONSUMER_1',
'user_id' => 'user-id-123',
@@ -252,7 +252,7 @@ class tool_launch_service_test extends \lti_advantage_testcase {
]
],
'launch_data' => [
- 'user' => $this->get_mock_launch_users_with_ids(['1p3_1'])[0],
+ 'user' => self::get_mock_launch_users_with_ids(['1p3_1'])[0],
'launch_migration_claim' => [
'user_id' => 'user-id-123',
'context_id' => 'd345b',
@@ -277,7 +277,7 @@ class tool_launch_service_test extends \lti_advantage_testcase {
[$course, $modresource] = $this->create_test_environment();
$instructoruser = $this->getDataGenerator()->create_user();
$launchservice = $this->get_tool_launch_service();
- $mockuser = $this->get_mock_launch_users_with_ids(['1p3_1'])[0];
+ $mockuser = self::get_mock_launch_users_with_ids(['1p3_1'])[0];
$mocklaunch = $this->get_mock_launch($modresource, $mockuser, null, null, false, null, []);
$this->expectException(\moodle_exception::class);
@@ -295,7 +295,7 @@ class tool_launch_service_test extends \lti_advantage_testcase {
[$course, $modresource] = $this->create_test_environment();
$instructoruser = $this->getDataGenerator()->create_user();
$launchservice = $this->get_tool_launch_service();
- $mockuser = $this->get_mock_launch_users_with_ids(['1p3_1'])[0];
+ $mockuser = self::get_mock_launch_users_with_ids(['1p3_1'])[0];
$mocklaunch = $this->get_mock_launch($modresource, $mockuser, null, null, false, null, ['id' => 999999]);
$this->expectException(\moodle_exception::class);
@@ -327,7 +327,7 @@ class tool_launch_service_test extends \lti_advantage_testcase {
// Call the service.
$launchservice = $this->get_tool_launch_service();
- $mockuser = $this->get_mock_launch_users_with_ids(['1p3_1'])[0];
+ $mockuser = self::get_mock_launch_users_with_ids(['1p3_1'])[0];
$mocklaunch = $this->get_mock_launch($modresource, $mockuser);
$this->expectException(\moodle_exception::class);
@@ -360,7 +360,7 @@ class tool_launch_service_test extends \lti_advantage_testcase {
// Call the service.
$launchservice = $this->get_tool_launch_service();
- $mockuser = $this->get_mock_launch_users_with_ids(['1p3_1'])[0];
+ $mockuser = self::get_mock_launch_users_with_ids(['1p3_1'])[0];
$mocklaunch = $this->get_mock_launch($modresource, $mockuser);
$this->expectException(\moodle_exception::class);
@@ -382,18 +382,18 @@ class tool_launch_service_test extends \lti_advantage_testcase {
$instructor2user = $this->getDataGenerator()->create_user();
$adminuser = $this->getDataGenerator()->create_user();
$learneruser = $this->getDataGenerator()->create_user();
- $mockinstructoruser = $this->get_mock_launch_users_with_ids(['1'])[0];
- $mockadminuser = $this->get_mock_launch_users_with_ids(
+ $mockinstructoruser = self::get_mock_launch_users_with_ids(['1'])[0];
+ $mockadminuser = self::get_mock_launch_users_with_ids(
['2'],
false,
'http://purl.imsglobal.org/vocab/lis/v2/system/person#Administrator'
)[0];
- $mocklearneruser = $this->get_mock_launch_users_with_ids(
+ $mocklearneruser = self::get_mock_launch_users_with_ids(
['3'],
false,
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner'
)[0];
- $mockinstructor2user = $this->get_mock_launch_users_with_ids(
+ $mockinstructor2user = self::get_mock_launch_users_with_ids(
['3'],
false,
'Instructor' // Using the legacy (deprecated in 1.3) simple name.
@@ -433,7 +433,7 @@ class tool_launch_service_test extends \lti_advantage_testcase {
$this->resetAfterTest();
[$course, $modresource] = $this->create_test_environment();
$user = $this->getDataGenerator()->create_user();
- $mockinstructoruser = $this->get_mock_launch_users_with_ids(['1'])[0];
+ $mockinstructoruser = self::get_mock_launch_users_with_ids(['1'])[0];
$launchservice = $this->get_tool_launch_service();
$userrepo = new user_repository();
@@ -481,7 +481,7 @@ class tool_launch_service_test extends \lti_advantage_testcase {
[$course, $modresource] = $this->create_test_environment(true, true, false,
\enrol_lti\helper::MEMBER_SYNC_ENROL_NEW, false, false, time() + DAYSECS);
$instructoruser = $this->getDataGenerator()->create_user();
- $mockinstructoruser = $this->get_mock_launch_users_with_ids(['1'])[0];
+ $mockinstructoruser = self::get_mock_launch_users_with_ids(['1'])[0];
$mockinstructorlaunch = $this->get_mock_launch($modresource, $mockinstructoruser);
$launchservice = $this->get_tool_launch_service();
@@ -499,8 +499,8 @@ class tool_launch_service_test extends \lti_advantage_testcase {
[$course, $modresource] = $this->create_test_environment();
$instructoruser = $this->getDataGenerator()->create_user();
$learneruser = $this->getDataGenerator()->create_user();
- $mockinstructoruser = $this->get_mock_launch_users_with_ids(['1'])[0];
- $mocklearneruser = $this->get_mock_launch_users_with_ids(['1'], false, '')[0];
+ $mockinstructoruser = self::get_mock_launch_users_with_ids(['1'])[0];
+ $mocklearneruser = self::get_mock_launch_users_with_ids(['1'], false, '')[0];
$mockinstructorlaunch = $this->get_mock_launch($modresource, $mockinstructoruser, null, null, false, null, [
'id' => $modresource->uuid,
'forcedembed' => true
@@ -533,7 +533,7 @@ class tool_launch_service_test extends \lti_advantage_testcase {
$this->resetAfterTest();
[$course, $modresource] = $this->create_test_environment();
$instructoruser = $this->getDataGenerator()->create_user();
- $mockinstructoruser = $this->get_mock_launch_users_with_ids(['1'])[0];
+ $mockinstructoruser = self::get_mock_launch_users_with_ids(['1'])[0];
$mockinstructorlaunch = $this->get_mock_launch($modresource, $mockinstructoruser, null, null, false, null, [
'id' => $modresource->uuid,
], $aud);
@@ -554,7 +554,7 @@ class tool_launch_service_test extends \lti_advantage_testcase {
*
* @return array the test case data
*/
- public function aud_data_provider(): array {
+ public static function aud_data_provider(): array {
return [
'valid, array having multiple entries with the first one being clientid' => [
'aud' => ['123', 'something else', 'blah'],
@@ -622,7 +622,7 @@ class tool_launch_service_test extends \lti_advantage_testcase {
$this->resetAfterTest();
[$course, $modresource] = $this->create_test_environment();
$instructoruser = $this->getDataGenerator()->create_user();
- $mockinstructoruser = $this->get_mock_launch_users_with_ids(['1'])[0];
+ $mockinstructoruser = self::get_mock_launch_users_with_ids(['1'])[0];
$userrepo = new user_repository();
$resourcelinkrepo = new resource_link_repository();
$launchservice = $this->get_tool_launch_service();
@@ -662,7 +662,7 @@ class tool_launch_service_test extends \lti_advantage_testcase {
*
* @return array the array of test case data.
*/
- public function ags_claim_provider(): array {
+ public static function ags_claim_provider(): array {
return [
'Coupled line item with score post only, no change to scopes on subsequent launch' => [
'agsclaim1' => [
diff --git a/enrol/lti/tests/local/ltiadvantage/task/sync_members_test.php b/enrol/lti/tests/local/ltiadvantage/task/sync_members_test.php
index ec265de1b91..6f190201685 100644
--- a/enrol/lti/tests/local/ltiadvantage/task/sync_members_test.php
+++ b/enrol/lti/tests/local/ltiadvantage/task/sync_members_test.php
@@ -73,8 +73,15 @@ class sync_members_test extends \lti_advantage_testcase {
* @return array the array of users.
* @throws \Exception if the legacyuserids array doesn't contain the correct number of ids.
*/
- protected function get_mock_members_with_ids(array $userids, ?array $legacyuserids = null, $names = true,
- $emails = true, bool $linklevel = true, bool $picture = false, array $roles = []): array {
+ protected static function get_mock_members_with_ids(
+ array $userids,
+ ?array $legacyuserids = null,
+ $names = true,
+ $emails = true,
+ bool $linklevel = true,
+ bool $picture = false,
+ array $roles = []
+ ): array {
if (!is_null($legacyuserids) && count($legacyuserids) != count($userids)) {
throw new \Exception('legacyuserids must contain the same number of ids as $userids.');
@@ -88,7 +95,7 @@ class sync_members_test extends \lti_advantage_testcase {
foreach ($userids as $userid) {
$user = ['user_id' => (string) $userid, 'roles' => $roles];
if ($picture) {
- $user['picture'] = $this->getExternalTestFileUrl('/test.jpg', false);
+ $user['picture'] = static::getExternalTestFileUrl('/test.jpg', false);
}
if ($names) {
$user['given_name'] = 'Firstname' . $userid;
@@ -137,7 +144,7 @@ class sync_members_test extends \lti_advantage_testcase {
}
}
} else {
- return $this->get_mock_members_with_ids(range(1, 2));
+ return self::get_mock_members_with_ids(range(1, 2));
}
}));
return $mocktask;
@@ -161,7 +168,7 @@ class sync_members_test extends \lti_advantage_testcase {
$mocktask->expects($this->any())
->method('get_context_level_members')
->will($this->returnCallback(function() {
- return $this->get_mock_members_with_ids(range(1, 3), null, true, true, false);
+ return self::get_mock_members_with_ids(range(1, 3), null, true, true, false);
}));;
return $mocktask;
}
@@ -229,7 +236,7 @@ class sync_members_test extends \lti_advantage_testcase {
[$course, $resource] = $this->create_test_environment();
// Launch the tool for a user.
- $mocklaunch = $this->get_mock_launch($resource, $this->get_mock_launch_users_with_ids(['1'])[0]);
+ $mocklaunch = $this->get_mock_launch($resource, self::get_mock_launch_users_with_ids(['1'])[0]);
$instructoruser = $this->lti_advantage_user_authenticates('1');
$launchservice = $this->get_tool_launch_service();
$launchservice->user_launches_tool($instructoruser, $mocklaunch);
@@ -261,15 +268,15 @@ class sync_members_test extends \lti_advantage_testcase {
// Launch twice - once from each resource link in the platform.
$launchservice = $this->get_tool_launch_service();
$instructoruser = $this->lti_advantage_user_authenticates('1');
- $mocklaunch = $this->get_mock_launch($resource, $this->get_mock_launch_users_with_ids(['1'])[0], '123');
+ $mocklaunch = $this->get_mock_launch($resource, self::get_mock_launch_users_with_ids(['1'])[0], '123');
$launchservice->user_launches_tool($instructoruser, $mocklaunch);
- $mocklaunch = $this->get_mock_launch($resource, $this->get_mock_launch_users_with_ids(['1'])[0], '456');
+ $mocklaunch = $this->get_mock_launch($resource, self::get_mock_launch_users_with_ids(['1'])[0], '456');
$launchservice->user_launches_tool($instructoruser, $mocklaunch);
// Now, grab the resource links.
$rlrepo = new resource_link_repository();
$reslinks = $rlrepo->find_by_resource($resource->id);
- $mockmembers = $this->get_mock_members_with_ids(range(1, 10));
+ $mockmembers = self::get_mock_members_with_ids(range(1, 10));
$mockusers1 = array_slice($mockmembers, 0, 6);
$mockusers2 = array_slice($mockmembers, 6);
$resourcelinks = [
@@ -305,13 +312,13 @@ class sync_members_test extends \lti_advantage_testcase {
[$course, $resource] = $this->create_test_environment();
// Launch the tool for a user.
- $mocklaunch = $this->get_mock_launch($resource, $this->get_mock_launch_users_with_ids(['1'])[0]);
+ $mocklaunch = $this->get_mock_launch($resource, self::get_mock_launch_users_with_ids(['1'])[0]);
$launchservice = $this->get_tool_launch_service();
$instructoruser = $this->lti_advantage_user_authenticates('1');
$launchservice->user_launches_tool($instructoruser, $mocklaunch);
// Sync members.
- $task = $this->get_mock_task_with_users($this->get_mock_members_with_ids(['1'], null, true, true, true, true));
+ $task = $this->get_mock_task_with_users(self::get_mock_members_with_ids(['1'], null, true, true, true, true));
ob_start();
$task->execute();
ob_end_clean();
@@ -336,7 +343,7 @@ class sync_members_test extends \lti_advantage_testcase {
[$course, $resource] = $this->create_test_environment();
// Launch the tool for a user.
- $mocklaunch = $this->get_mock_launch($resource, $this->get_mock_launch_users_with_ids(['1'])[0]);
+ $mocklaunch = $this->get_mock_launch($resource, self::get_mock_launch_users_with_ids(['1'])[0]);
$launchservice = $this->get_tool_launch_service();
$instructoruser = $this->lti_advantage_user_authenticates('1');
$launchservice->user_launches_tool($instructoruser, $mocklaunch);
@@ -365,13 +372,13 @@ class sync_members_test extends \lti_advantage_testcase {
$userrepo = new user_repository();
// Launch the tool for a user.
- $mocklaunch = $this->get_mock_launch($resource, $this->get_mock_launch_users_with_ids(['1'])[0]);
+ $mocklaunch = $this->get_mock_launch($resource, self::get_mock_launch_users_with_ids(['1'])[0]);
$launchservice = $this->get_tool_launch_service();
$instructoruser = $this->lti_advantage_user_authenticates('1');
$launchservice->user_launches_tool($instructoruser, $mocklaunch);
// Sync members.
- $task = $this->get_mock_task_with_users($this->get_mock_members_with_ids(range(1, 5), null, false, false));
+ $task = $this->get_mock_task_with_users(self::get_mock_members_with_ids(range(1, 5), null, false, false));
ob_start();
$task->execute();
@@ -398,7 +405,7 @@ class sync_members_test extends \lti_advantage_testcase {
}
// Sync again, this time with user data included.
- $mockmembers = $this->get_mock_members_with_ids(range(1, 5));
+ $mockmembers = self::get_mock_members_with_ids(range(1, 5));
$task = $this->get_mock_task_with_users($mockmembers);
ob_start();
@@ -429,14 +436,14 @@ class sync_members_test extends \lti_advantage_testcase {
[$course, $resource] = $this->create_test_environment(true, true, false);
// Launch the tool for a user.
- $mockuser = $this->get_mock_launch_users_with_ids(['1'])[0];
+ $mockuser = self::get_mock_launch_users_with_ids(['1'])[0];
$mocklaunch = $this->get_mock_launch($resource, $mockuser);
$launchservice = $this->get_tool_launch_service();
$instructoruser = $this->lti_advantage_user_authenticates('1');
$launchservice->user_launches_tool($instructoruser, $mocklaunch);
// Sync members.
- $task = $this->get_mock_task_with_users($this->get_mock_launch_users_with_ids(range(1, 4)));
+ $task = $this->get_mock_task_with_users(self::get_mock_launch_users_with_ids(range(1, 4)));
ob_start();
$task->execute();
ob_end_clean();
@@ -461,14 +468,14 @@ class sync_members_test extends \lti_advantage_testcase {
$userrepo = new user_repository();
// Launch the tool for a user.
- $mockuser = $this->get_mock_launch_users_with_ids(['1'])[0];
+ $mockuser = self::get_mock_launch_users_with_ids(['1'])[0];
$mocklaunch = $this->get_mock_launch($resource, $mockuser);
$launchservice = $this->get_tool_launch_service();
$instructoruser = $this->lti_advantage_user_authenticates('1');
$launchservice->user_launches_tool($instructoruser, $mocklaunch);
// Sync members.
- $task = $this->get_mock_task_with_users($this->get_mock_members_with_ids(range(1, 3)));
+ $task = $this->get_mock_task_with_users(self::get_mock_members_with_ids(range(1, 3)));
ob_start();
$task->execute();
@@ -481,7 +488,7 @@ class sync_members_test extends \lti_advantage_testcase {
// Now, simulate a subsequent sync in which 1 existing user maintains access,
// 2 existing users are unenrolled and 3 new users are enrolled.
- $task2 = $this->get_mock_task_with_users($this->get_mock_members_with_ids(['1', '4', '5', '6']));
+ $task2 = $this->get_mock_task_with_users(self::get_mock_members_with_ids(['1', '4', '5', '6']));
ob_start();
$task2->execute();
ob_end_clean();
@@ -509,14 +516,14 @@ class sync_members_test extends \lti_advantage_testcase {
$userrepo = new user_repository();
// Launch the tool for a user.
- $mocklaunch = $this->get_mock_launch($resource, $this->get_mock_launch_users_with_ids([1])[0]);
+ $mocklaunch = $this->get_mock_launch($resource, self::get_mock_launch_users_with_ids([1])[0]);
$launchservice = $this->get_tool_launch_service();
$instructoruser = $this->lti_advantage_user_authenticates('1');
$launchservice->user_launches_tool($instructoruser, $mocklaunch);
$this->assertCount(1, $userrepo->find_by_resource($resource->id));
// Sync members using a payload which doesn't include the original launch user (User id = 1).
- $task = $this->get_mock_task_with_users($this->get_mock_members_with_ids(range(2, 3)));
+ $task = $this->get_mock_task_with_users(self::get_mock_members_with_ids(range(2, 3)));
ob_start();
$task->execute();
@@ -538,14 +545,14 @@ class sync_members_test extends \lti_advantage_testcase {
$userrepo = new user_repository();
// Launch the tool for a user.
- $mocklaunch = $this->get_mock_launch($resource, $this->get_mock_launch_users_with_ids([1])[0]);
+ $mocklaunch = $this->get_mock_launch($resource, self::get_mock_launch_users_with_ids([1])[0]);
$launchservice = $this->get_tool_launch_service();
$instructoruser = $this->lti_advantage_user_authenticates('1');
$launchservice->user_launches_tool($instructoruser, $mocklaunch);
$this->assertCount(1, $userrepo->find_by_resource($resource->id));
// Sync members using a payload which includes two new members only (i.e. not the original launching user).
- $task = $this->get_mock_task_with_users($this->get_mock_members_with_ids(range(2, 3)));
+ $task = $this->get_mock_task_with_users(self::get_mock_members_with_ids(range(2, 3)));
ob_start();
$task->execute();
@@ -568,14 +575,14 @@ class sync_members_test extends \lti_advantage_testcase {
$userrepo = new user_repository();
// Launch the tool for a user.
- $mocklaunch = $this->get_mock_launch($resource, $this->get_mock_launch_users_with_ids([1])[0]);
+ $mocklaunch = $this->get_mock_launch($resource, self::get_mock_launch_users_with_ids([1])[0]);
$launchservice = $this->get_tool_launch_service();
$instructoruser = $this->lti_advantage_user_authenticates('1');
$launchservice->user_launches_tool($instructoruser, $mocklaunch);
$this->assertCount(1, $userrepo->find_by_resource($resource->id));
// If the task were to run, this would trigger 1 unenrolment (the launching user) and 3 enrolments.
- $task = $this->get_mock_task_with_users($this->get_mock_members_with_ids(range(2, 2)));
+ $task = $this->get_mock_task_with_users(self::get_mock_members_with_ids(range(2, 2)));
$task->execute();
// Verify that the sync didn't take place.
@@ -594,14 +601,14 @@ class sync_members_test extends \lti_advantage_testcase {
$userrepo = new user_repository();
// Launch the tool for a user.
- $mocklaunch = $this->get_mock_launch($resource, $this->get_mock_launch_users_with_ids([1])[0]);
+ $mocklaunch = $this->get_mock_launch($resource, self::get_mock_launch_users_with_ids([1])[0]);
$launchservice = $this->get_tool_launch_service();
$instructoruser = $this->lti_advantage_user_authenticates('1');
$launchservice->user_launches_tool($instructoruser, $mocklaunch);
$this->assertCount(1, $userrepo->find_by_resource($resource->id));
// If the task were to run, this would trigger 1 unenrolment of the launching user and enrolment of 3 users.
- $task = $this->get_mock_task_with_users($this->get_mock_members_with_ids(range(2, 2)));
+ $task = $this->get_mock_task_with_users(self::get_mock_members_with_ids(range(2, 2)));
$task->execute();
// Verify that the sync didn't take place.
@@ -630,7 +637,7 @@ class sync_members_test extends \lti_advantage_testcase {
course_delete_module($modcontext->instanceid);
// Only the enabled resource 3 should sync members.
- $task = $this->get_mock_task_with_users($this->get_mock_members_with_ids(range(1, 1)));
+ $task = $this->get_mock_task_with_users(self::get_mock_members_with_ids(range(1, 1)));
$task->execute();
$this->expectOutputRegex(
@@ -652,7 +659,7 @@ class sync_members_test extends \lti_advantage_testcase {
$userrepo = new user_repository();
// Launch the tool for a user.
- $mockinstructor = $this->get_mock_launch_users_with_ids([1])[0];
+ $mockinstructor = self::get_mock_launch_users_with_ids([1])[0];
$mocklaunch = $this->get_mock_launch($resource, $mockinstructor, null, null, false);
$launchservice = $this->get_tool_launch_service();
$instructoruser = $this->lti_advantage_user_authenticates('1');
@@ -660,7 +667,7 @@ class sync_members_test extends \lti_advantage_testcase {
$this->assertCount(1, $userrepo->find_by_resource($resource->id));
// The task would sync an additional 2 users if the link had NRPS service support.
- $task = $this->get_mock_task_with_users($this->get_mock_members_with_ids(range(2, 2)));
+ $task = $this->get_mock_task_with_users(self::get_mock_members_with_ids(range(2, 2)));
// We expect the task to report that it is skipping the resource due to a lack of NRPS support.
$task->execute();
@@ -693,12 +700,12 @@ class sync_members_test extends \lti_advantage_testcase {
$authenticateduser = \core_user::get_user($authenticateduser->id);
// Mock the launch for the specified user.
- $mocklaunchuser = $this->get_mock_launch_users_with_ids([$authenticateduser->id])[0];
+ $mocklaunchuser = self::get_mock_launch_users_with_ids([$authenticateduser->id])[0];
$mocklaunch = $this->get_mock_launch($resource, $mocklaunchuser);
$this->get_tool_launch_service()->user_launches_tool($authenticateduser, $mocklaunch);
// Prepare the sync task, with a stubbed list of members.
- $task = $this->get_mock_task_with_users($this->get_mock_members_with_ids(['123'], null, true, true, true, true));
+ $task = $this->get_mock_task_with_users(self::get_mock_members_with_ids(['123'], null, true, true, true, true));
// Run the member sync.
$this->expectOutputRegex(
@@ -788,7 +795,7 @@ class sync_members_test extends \lti_advantage_testcase {
*
* @return array[] the array of test data.
*/
- public function member_sync_data_provider(): array {
+ public static function member_sync_data_provider(): array {
global $CFG;
require_once($CFG->dirroot . '/auth/lti/auth.php');
return [
@@ -806,7 +813,7 @@ class sync_members_test extends \lti_advantage_testcase {
],
'resource_config' => null,
'launch_data' => [
- 'user' => $this->get_mock_launch_users_with_ids(['1p3_1'])[0],
+ 'user' => self::get_mock_launch_users_with_ids(['1p3_1'])[0],
'launch_migration_claim' => [
'consumer_key' => 'CONSUMER_1',
'signing_secret' => 'toolsecret1',
@@ -817,10 +824,10 @@ class sync_members_test extends \lti_advantage_testcase {
],
],
'sync_members_data' => [
- $this->get_mock_members_with_ids(['1p3_1'], ['1'])[0],
- $this->get_mock_members_with_ids(['1p3_2'], ['2'])[0],
- $this->get_mock_members_with_ids(['1p3_3'], ['3'])[0],
- $this->get_mock_members_with_ids(['1p3_4'], ['4'])[0],
+ self::get_mock_members_with_ids(['1p3_1'], ['1'])[0],
+ self::get_mock_members_with_ids(['1p3_2'], ['2'])[0],
+ self::get_mock_members_with_ids(['1p3_3'], ['3'])[0],
+ self::get_mock_members_with_ids(['1p3_4'], ['4'])[0],
],
'expected' => [
'enrolments' => [
@@ -857,7 +864,7 @@ class sync_members_test extends \lti_advantage_testcase {
],
'resource_config' => null,
'launch_data' => [
- 'user' => $this->get_mock_launch_users_with_ids(['1'])[0],
+ 'user' => self::get_mock_launch_users_with_ids(['1'])[0],
'launch_migration_claim' => [
'consumer_key' => 'CONSUMER_1',
'signing_secret' => 'toolsecret1',
@@ -867,10 +874,10 @@ class sync_members_test extends \lti_advantage_testcase {
],
],
'sync_members_data' => [
- $this->get_mock_members_with_ids(['1'], null)[0],
- $this->get_mock_members_with_ids(['2'], null)[0],
- $this->get_mock_members_with_ids(['3'], null)[0],
- $this->get_mock_members_with_ids(['4'], null)[0],
+ self::get_mock_members_with_ids(['1'], null)[0],
+ self::get_mock_members_with_ids(['2'], null)[0],
+ self::get_mock_members_with_ids(['3'], null)[0],
+ self::get_mock_members_with_ids(['4'], null)[0],
],
'expected' => [
'enrolments' => [
@@ -907,14 +914,14 @@ class sync_members_test extends \lti_advantage_testcase {
],
'resource_config' => null,
'launch_data' => [
- 'user' => $this->get_mock_launch_users_with_ids(['1p3_1'])[0],
+ 'user' => self::get_mock_launch_users_with_ids(['1p3_1'])[0],
'launch_migration_claim' => null,
],
'sync_members_data' => [
- $this->get_mock_members_with_ids(['1p3_1'], null)[0],
- $this->get_mock_members_with_ids(['1p3_2'], null)[0],
- $this->get_mock_members_with_ids(['1p3_3'], null)[0],
- $this->get_mock_members_with_ids(['1p3_4'], null)[0],
+ self::get_mock_members_with_ids(['1p3_1'], null)[0],
+ self::get_mock_members_with_ids(['1p3_2'], null)[0],
+ self::get_mock_members_with_ids(['1p3_3'], null)[0],
+ self::get_mock_members_with_ids(['1p3_4'], null)[0],
],
'expected' => [
'enrolments' => [
@@ -951,14 +958,14 @@ class sync_members_test extends \lti_advantage_testcase {
],
'resource_config' => null,
'launch_data' => [
- 'user' => $this->get_mock_launch_users_with_ids(['1'])[0],
+ 'user' => self::get_mock_launch_users_with_ids(['1'])[0],
'launch_migration_claim' => null,
],
'sync_members_data' => [
- $this->get_mock_members_with_ids(['1'], null)[0],
- $this->get_mock_members_with_ids(['2'], null)[0],
- $this->get_mock_members_with_ids(['3'], null)[0],
- $this->get_mock_members_with_ids(['4'], null)[0],
+ self::get_mock_members_with_ids(['1'], null)[0],
+ self::get_mock_members_with_ids(['2'], null)[0],
+ self::get_mock_members_with_ids(['3'], null)[0],
+ self::get_mock_members_with_ids(['4'], null)[0],
],
'expected' => [
'enrolments' => [
@@ -995,14 +1002,14 @@ class sync_members_test extends \lti_advantage_testcase {
],
'resource_config' => null,
'launch_data' => [
- 'user' => $this->get_mock_launch_users_with_ids(['1p3_1'])[0],
+ 'user' => self::get_mock_launch_users_with_ids(['1p3_1'])[0],
'launch_migration_claim' => null,
],
'sync_members_data' => [
- $this->get_mock_members_with_ids(['1p3_1'], ['1'])[0],
- $this->get_mock_members_with_ids(['1p3_2'], ['2'])[0],
- $this->get_mock_members_with_ids(['1p3_3'], ['3'])[0],
- $this->get_mock_members_with_ids(['1p3_4'], ['4'])[0],
+ self::get_mock_members_with_ids(['1p3_1'], ['1'])[0],
+ self::get_mock_members_with_ids(['1p3_2'], ['2'])[0],
+ self::get_mock_members_with_ids(['1p3_3'], ['3'])[0],
+ self::get_mock_members_with_ids(['1p3_4'], ['4'])[0],
],
'expected' => [
'enrolments' => [
@@ -1032,24 +1039,24 @@ class sync_members_test extends \lti_advantage_testcase {
'provisioningmodeinstructor' => \auth_plugin_lti::PROVISIONING_MODE_PROMPT_NEW_EXISTING
],
'launch_data' => [
- 'user' => $this->get_mock_launch_users_with_ids(['1p3_1'])[0],
+ 'user' => self::get_mock_launch_users_with_ids(['1p3_1'])[0],
'launch_migration_claim' => null,
],
'sync_members_data' => [
// This user is just an instructor but is also the user who is already linked, via the launch above.
- $this->get_mock_members_with_ids(['1p3_1'], null, true, true, true, false, [
+ self::get_mock_members_with_ids(['1p3_1'], null, true, true, true, false, [
'http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor',
])[0],
// This user is just a learner.
- $this->get_mock_members_with_ids(['1p3_2'], null, true, true, true, false, [
+ self::get_mock_members_with_ids(['1p3_2'], null, true, true, true, false, [
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner'
])[0],
// This user is also a learner.
- $this->get_mock_members_with_ids(['1p3_3'], null, true, true, true, false, [
+ self::get_mock_members_with_ids(['1p3_3'], null, true, true, true, false, [
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner'
])[0],
// This user is both an instructor and a learner.
- $this->get_mock_members_with_ids(['1p3_4'], null, true, true, true, false, [
+ self::get_mock_members_with_ids(['1p3_4'], null, true, true, true, false, [
'http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor',
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner'
])[0],
@@ -1082,24 +1089,24 @@ class sync_members_test extends \lti_advantage_testcase {
'provisioningmodeinstructor' => \auth_plugin_lti::PROVISIONING_MODE_AUTO_ONLY
],
'launch_data' => [
- 'user' => $this->get_mock_launch_users_with_ids(['1p3_1'])[0],
+ 'user' => self::get_mock_launch_users_with_ids(['1p3_1'])[0],
'launch_migration_claim' => null,
],
'sync_members_data' => [
// This user is just an instructor but is also the user who is already linked, via the launch above.
- $this->get_mock_members_with_ids(['1p3_1'], null, true, true, true, false, [
+ self::get_mock_members_with_ids(['1p3_1'], null, true, true, true, false, [
'http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor',
])[0],
// This user is just a learner.
- $this->get_mock_members_with_ids(['1p3_2'], null, true, true, true, false, [
+ self::get_mock_members_with_ids(['1p3_2'], null, true, true, true, false, [
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner'
])[0],
// This user is also a learner.
- $this->get_mock_members_with_ids(['1p3_3'], null, true, true, true, false, [
+ self::get_mock_members_with_ids(['1p3_3'], null, true, true, true, false, [
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner'
])[0],
// This user is both an instructor and a learner.
- $this->get_mock_members_with_ids(['1p3_4'], null, true, true, true, false, [
+ self::get_mock_members_with_ids(['1p3_4'], null, true, true, true, false, [
'http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor',
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner'
])[0],
@@ -1132,24 +1139,24 @@ class sync_members_test extends \lti_advantage_testcase {
'provisioningmodeinstructor' => \auth_plugin_lti::PROVISIONING_MODE_PROMPT_NEW_EXISTING
],
'launch_data' => [
- 'user' => $this->get_mock_launch_users_with_ids(['1p3_1'])[0],
+ 'user' => self::get_mock_launch_users_with_ids(['1p3_1'])[0],
'launch_migration_claim' => null,
],
'sync_members_data' => [
// This user is just an instructor but is also the user who is already linked, via the launch above.
- $this->get_mock_members_with_ids(['1p3_1'], null, true, true, true, false, [
+ self::get_mock_members_with_ids(['1p3_1'], null, true, true, true, false, [
'http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor',
])[0],
// This user is just a learner.
- $this->get_mock_members_with_ids(['1p3_2'], null, true, true, true, false, [
+ self::get_mock_members_with_ids(['1p3_2'], null, true, true, true, false, [
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner'
])[0],
// This user is also a learner.
- $this->get_mock_members_with_ids(['1p3_3'], null, true, true, true, false, [
+ self::get_mock_members_with_ids(['1p3_3'], null, true, true, true, false, [
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner'
])[0],
// This user is both an instructor and a learner.
- $this->get_mock_members_with_ids(['1p3_4'], null, true, true, true, false, [
+ self::get_mock_members_with_ids(['1p3_4'], null, true, true, true, false, [
'http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor',
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner'
])[0],
@@ -1194,7 +1201,7 @@ class sync_members_test extends \lti_advantage_testcase {
'provisioningmodeinstructor' => \auth_plugin_lti::PROVISIONING_MODE_AUTO_ONLY
],
'launch_data' => [
- 'user' => $this->get_mock_launch_users_with_ids(['1p3_1'])[0],
+ 'user' => self::get_mock_launch_users_with_ids(['1p3_1'])[0],
'launch_migration_claim' => [
'consumer_key' => 'CONSUMER_1',
'signing_secret' => 'toolsecret1',
@@ -1205,24 +1212,24 @@ class sync_members_test extends \lti_advantage_testcase {
],
'sync_members_data' => [
// This user is just an instructor but is also the user who is already linked, via the launch above.
- $this->get_mock_members_with_ids(['1p3_1'], null, true, true, true, false, [
+ self::get_mock_members_with_ids(['1p3_1'], null, true, true, true, false, [
'http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor',
])[0],
// This user is just a learner.
- $this->get_mock_members_with_ids(['1p3_2'], ['2'], true, true, true, false, [
+ self::get_mock_members_with_ids(['1p3_2'], ['2'], true, true, true, false, [
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner'
])[0],
// This user is also a learner.
- $this->get_mock_members_with_ids(['1p3_3'], ['3'], true, true, true, false, [
+ self::get_mock_members_with_ids(['1p3_3'], ['3'], true, true, true, false, [
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner'
])[0],
// This user is both an instructor and a learner.
- $this->get_mock_members_with_ids(['1p3_4'], ['4'], true, true, true, false, [
+ self::get_mock_members_with_ids(['1p3_4'], ['4'], true, true, true, false, [
'http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor',
'http://purl.imsglobal.org/vocab/lis/v2/membership#Learner'
])[0],
// This user is just an instructor who hasn't launched before (unlike the first user here).
- $this->get_mock_members_with_ids(['1p3_5'], ['5'], true, true, true, false, [
+ self::get_mock_members_with_ids(['1p3_5'], ['5'], true, true, true, false, [
'http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor',
])[0],
],
diff --git a/enrol/lti/tests/local/ltiadvantage/utility/message_helper_test.php b/enrol/lti/tests/local/ltiadvantage/utility/message_helper_test.php
index ccaf1d9047a..14c0c33ff0c 100644
--- a/enrol/lti/tests/local/ltiadvantage/utility/message_helper_test.php
+++ b/enrol/lti/tests/local/ltiadvantage/utility/message_helper_test.php
@@ -43,7 +43,7 @@ class message_helper_test extends \base_testcase {
*
* @return array the array of test JWT data.
*/
- public function message_roles_provider(): array {
+ public static function message_roles_provider(): array {
return [
'Roles claim present, includes learner role only' => [
'jwtdata' => [
diff --git a/enrol/manual/tests/lib_test.php b/enrol/manual/tests/lib_test.php
index 0f4b09bdc10..6ecb5aab20c 100644
--- a/enrol/manual/tests/lib_test.php
+++ b/enrol/manual/tests/lib_test.php
@@ -586,7 +586,7 @@ class lib_test extends \advanced_testcase {
*
* @return array
*/
- public function default_enrolment_instance_data_provider(): array {
+ public static function default_enrolment_instance_data_provider(): array {
$studentroles = get_archetype_roles('student');
$studentrole = array_shift($studentroles);
@@ -700,7 +700,7 @@ class lib_test extends \advanced_testcase {
*
* @return array
*/
- public function update_enrolment_instance_data_provider(): array {
+ public static function update_enrolment_instance_data_provider(): array {
$studentroles = get_archetype_roles('student');
$studentrole = array_shift($studentroles);
diff --git a/enrol/tests/course_enrolment_manager_test.php b/enrol/tests/course_enrolment_manager_test.php
index 9e39e18a583..f7e3ab28c5b 100644
--- a/enrol/tests/course_enrolment_manager_test.php
+++ b/enrol/tests/course_enrolment_manager_test.php
@@ -503,7 +503,7 @@ class course_enrolment_manager_test extends \advanced_testcase {
*
* @return array Dataset
*/
- public function search_users_provider() {
+ public static function search_users_provider(): array {
return [
[2, false, 2, 3, true],
[5, false, 3, 3, false],
diff --git a/enrol/tests/enrollib_test.php b/enrol/tests/enrollib_test.php
index 92c1255bf38..e1f1b2cb4db 100644
--- a/enrol/tests/enrollib_test.php
+++ b/enrol/tests/enrollib_test.php
@@ -379,7 +379,7 @@ class enrollib_test extends advanced_testcase {
*
* @return array
*/
- public function enrol_course_delete_with_userid_provider() {
+ public static function enrol_course_delete_with_userid_provider(): array {
return [
'The teacher can un-enrol users in a course' =>
[
@@ -1041,7 +1041,7 @@ class enrollib_test extends advanced_testcase {
*
* @return array
*/
- public function enrol_get_my_courses_by_time_provider(): array {
+ public static function enrol_get_my_courses_by_time_provider(): array {
return [
'No start or end time' =>
[null, null, true],
@@ -1203,7 +1203,7 @@ class enrollib_test extends advanced_testcase {
/**
* Test cases for the test_enrol_get_my_courses_sort_by_last_access test.
*/
- public function get_enrol_get_my_courses_sort_by_last_access_test_cases() {
+ public static function get_enrol_get_my_courses_sort_by_last_access_test_cases(): array {
$now = time();
$enrolledcoursesdata = [
@@ -1306,7 +1306,7 @@ class enrollib_test extends advanced_testcase {
/**
* Test the get_enrolled_courses_by_timeline_classification function.
*
- * @dataProvider get_enrol_get_my_courses_sort_by_last_access_test_cases()
+ * @dataProvider get_enrol_get_my_courses_sort_by_last_access_test_cases
* @param array $enrolledcoursesdata Courses to create and enrol the user in
* @param array $unenrolledcoursesdata Courses to create nut not enrol the user in
* @param string $sort Sort string for the enrol function
@@ -1456,7 +1456,7 @@ class enrollib_test extends advanced_testcase {
/**
* Test get_enrolled_with_capabilities_join cannotmatchanyrows attribute.
*
- * @dataProvider get_enrolled_with_capabilities_join_cannotmatchanyrows_data()
+ * @dataProvider get_enrolled_with_capabilities_join_cannotmatchanyrows_data
* @param string $capability the tested capability
* @param bool $useprohibit if the capability must be assigned to prohibit
* @param int $expectedmatch expected cannotmatchanyrows value
@@ -1503,7 +1503,7 @@ class enrollib_test extends advanced_testcase {
*
* @return @array of testing scenarios
*/
- public function get_enrolled_with_capabilities_join_cannotmatchanyrows_data() {
+ public static function get_enrolled_with_capabilities_join_cannotmatchanyrows_data(): array {
return [
'no prohibits, no capability' => [
'capability' => '',
@@ -1543,7 +1543,7 @@ class enrollib_test extends advanced_testcase {
* Data provided for test_enrol_check_plugins_with_empty_config_value test.
* @return array
*/
- public function empty_config_data_provider(): array {
+ public static function empty_config_data_provider(): array {
return [
[0],
["0"],
diff --git a/files/converter/unoconv/tests/converter_test.php b/files/converter/unoconv/tests/converter_test.php
index 90df8298b55..ecc0e7b1257 100644
--- a/files/converter/unoconv/tests/converter_test.php
+++ b/files/converter/unoconv/tests/converter_test.php
@@ -114,7 +114,7 @@ class converter_test extends \advanced_testcase {
*
* @return array
*/
- public function provider_test_unoconv_path() {
+ public static function provider_test_unoconv_path(): array {
return [
'Empty path' => [
'path' => null,
diff --git a/filter/displayh5p/tests/filter_test.php b/filter/displayh5p/tests/filter_test.php
index 9609c68c3e0..49a3ddf9275 100644
--- a/filter/displayh5p/tests/filter_test.php
+++ b/filter/displayh5p/tests/filter_test.php
@@ -72,7 +72,7 @@ class filter_test extends \advanced_testcase {
*
* @return array
*/
- public function texts_provider() {
+ public static function texts_provider(): array {
global $CFG;
return [
diff --git a/filter/emoticon/tests/filter_test.php b/filter/emoticon/tests/filter_test.php
index 7046390c478..3d35ddb9a41 100644
--- a/filter/emoticon/tests/filter_test.php
+++ b/filter/emoticon/tests/filter_test.php
@@ -97,7 +97,7 @@ class filter_test extends \advanced_testcase {
*
* @return array
*/
- public function filter_emoticon_provider() {
+ public static function filter_emoticon_provider(): array {
$grr = '(grr)';
return [
'FORMAT_MOODLE is not filtered' => [
diff --git a/filter/mathjaxloader/tests/filter_test.php b/filter/mathjaxloader/tests/filter_test.php
index e445e06c20f..d97b23ee368 100644
--- a/filter/mathjaxloader/tests/filter_test.php
+++ b/filter/mathjaxloader/tests/filter_test.php
@@ -52,7 +52,7 @@ class filter_test extends \advanced_testcase {
*
* @return array of [moodlelangcode, mathjaxcode] tuples
*/
- public function map_language_code_expected_mappings() {
+ public static function map_language_code_expected_mappings(): array {
return [
['cz', 'cs'], // Explicit mapping.
diff --git a/filter/mathjaxloader/tests/filtermath_test.php b/filter/mathjaxloader/tests/filtermath_test.php
index be65eb45aa6..ae508a90acf 100644
--- a/filter/mathjaxloader/tests/filtermath_test.php
+++ b/filter/mathjaxloader/tests/filtermath_test.php
@@ -50,7 +50,7 @@ class filtermath_test extends \advanced_testcase {
*
* @return array of [inputtext, expectedoutput] tuples.
*/
- public function math_filtering_inputs() {
+ public static function math_filtering_inputs(): array {
return [
// One inline formula.
['Some inline math \\( y = x^2 \\).',
diff --git a/filter/tex/tests/lib_test.php b/filter/tex/tests/lib_test.php
index d581ee94bc9..23ada285752 100644
--- a/filter/tex/tests/lib_test.php
+++ b/filter/tex/tests/lib_test.php
@@ -44,7 +44,7 @@ class lib_test extends advanced_testcase {
*
* @return array
*/
- public function filter_tex_sanitize_formula_provider() : array {
+ public static function filter_tex_sanitize_formula_provider(): array {
return [
['x\ =\ \frac{\sqrt{144}}{2}\ \times\ (y\ +\ 12)', 'x\ =\ \frac{\sqrt{144}}{2}\ \times\ (y\ +\ 12)'],
['\usepackage[latin1]{inputenc}', '\usepackage[latin1]{inputenc}'],
diff --git a/grade/import/csv/tests/load_data_test.php b/grade/import/csv/tests/load_data_test.php
index 4b20f4fb543..b4aa3543259 100644
--- a/grade/import/csv/tests/load_data_test.php
+++ b/grade/import/csv/tests/load_data_test.php
@@ -241,7 +241,7 @@ Bobby,Bunce,,"Moodle HQ","Rock on!",student5@example.com,75.00,,75.00,{exportdat
*
* @return array
*/
- public function check_user_exists_provider() {
+ public static function check_user_exists_provider(): array {
return [
'Fetch by email' => [
'email', 's1@example.com', true
diff --git a/grade/tests/component_gradeitems_test.php b/grade/tests/component_gradeitems_test.php
index a37c22d01c2..764be060802 100644
--- a/grade/tests/component_gradeitems_test.php
+++ b/grade/tests/component_gradeitems_test.php
@@ -76,7 +76,7 @@ namespace core_grades {
*
* @return array
*/
- public function is_valid_itemname_provider(): array {
+ public static function is_valid_itemname_provider(): array {
return [
'valid' => [
'someother',
@@ -173,7 +173,7 @@ namespace core_grades {
*
* @return array
*/
- public function is_advancedgrading_itemname_provider(): array {
+ public static function is_advancedgrading_itemname_provider(): array {
return [
'valid' => [
'someother',
@@ -209,7 +209,7 @@ namespace core_grades {
*
* @return array
*/
- public function get_field_name_for_itemnumber_provider(): array {
+ public static function get_field_name_for_itemnumber_provider(): array {
return [
'Valid itemnumber 0 case 1' => [
0,
@@ -291,7 +291,7 @@ namespace core_grades {
*
* @return array
*/
- public function get_field_name_for_itemname_provider(): array {
+ public static function get_field_name_for_itemname_provider(): array {
return [
'Empty itemname empty case 1' => [
'',
@@ -393,7 +393,7 @@ namespace core_grades {
*
* @return array
*/
- public function get_itemname_from_itemnumber_provider(): array {
+ public static function get_itemname_from_itemnumber_provider(): array {
return [
'Valid itemnumber 0' => [
0,
@@ -471,7 +471,7 @@ namespace core_grades {
*
* @return array
*/
- public function get_itemnumber_from_itemname_provider(): array {
+ public static function get_itemnumber_from_itemname_provider(): array {
return [
'Empty itemname empty' => [
'',
diff --git a/grade/tests/export_test.php b/grade/tests/export_test.php
index f52c606ea8d..ea58a8538ab 100644
--- a/grade/tests/export_test.php
+++ b/grade/tests/export_test.php
@@ -127,7 +127,7 @@ class export_test extends \advanced_testcase {
*
* @return array
*/
- public function format_feedback_provider() : array {
+ public static function format_feedback_provider(): array {
return [
'Basic string (PLAIN)' => [
'This is an example string',
diff --git a/grade/tests/external/get_gradable_users_test.php b/grade/tests/external/get_gradable_users_test.php
index 456a1db2192..41841b3db5f 100644
--- a/grade/tests/external/get_gradable_users_test.php
+++ b/grade/tests/external/get_gradable_users_test.php
@@ -100,7 +100,7 @@ class get_gradable_users_test extends \externallib_advanced_testcase {
*
* @return array
*/
- public function execute_data(): array {
+ public static function execute_data(): array {
return [
'All users' => [
false,
diff --git a/grade/tests/grades/grader/gradingpanel/point/external/store_test.php b/grade/tests/grades/grader/gradingpanel/point/external/store_test.php
index 183d2ea8c96..09e2fd5e66e 100644
--- a/grade/tests/grades/grader/gradingpanel/point/external/store_test.php
+++ b/grade/tests/grades/grader/gradingpanel/point/external/store_test.php
@@ -298,7 +298,7 @@ class store_test extends advanced_testcase {
*
* @return array
*/
- public function execute_out_of_range_provider(): array {
+ public static function execute_out_of_range_provider(): array {
return [
'above' => [
'max' => 100,
diff --git a/grade/tests/grades/grader/gradingpanel/scale/external/store_test.php b/grade/tests/grades/grader/gradingpanel/scale/external/store_test.php
index 96a0d8fc558..95ef0f18dec 100644
--- a/grade/tests/grades/grader/gradingpanel/scale/external/store_test.php
+++ b/grade/tests/grades/grader/gradingpanel/scale/external/store_test.php
@@ -403,7 +403,7 @@ class store_test extends advanced_testcase {
*
* @return array
*/
- public function execute_out_of_range_provider(): array {
+ public static function execute_out_of_range_provider(): array {
return [
'above' => [
'supplied' => 500,
diff --git a/grade/tests/lib_test.php b/grade/tests/lib_test.php
index 5f03f6dd50e..6e647c33f20 100644
--- a/grade/tests/lib_test.php
+++ b/grade/tests/lib_test.php
@@ -527,7 +527,7 @@ class lib_test extends \advanced_testcase {
/**
* Tests for calculate_average.
- * @dataProvider calculate_average_data()
+ * @dataProvider calculate_average_data
* @param int $meanselection Whether to inlcude all grades or non-empty grades in aggregation.
* @param array $expectedmeancount expected meancount value
* @param array $expectedaverage expceted average value
@@ -619,7 +619,7 @@ class lib_test extends \advanced_testcase {
*
* @return array of testing scenarios
*/
- public function calculate_average_data() : array {
+ public static function calculate_average_data(): array {
return [
'Non-empty grades' => [
'meanselection' => 1,
diff --git a/grade/tests/output/general_action_bar_test.php b/grade/tests/output/general_action_bar_test.php
index 49b09c061c8..bfdabc4fd5e 100644
--- a/grade/tests/output/general_action_bar_test.php
+++ b/grade/tests/output/general_action_bar_test.php
@@ -155,7 +155,7 @@ class general_action_bar_test extends advanced_testcase {
*
* @return array
*/
- public function export_for_template_provider(): array {
+ public static function export_for_template_provider(): array {
$graderpluginname = get_string('pluginname', 'gradereport_grader');
$historypluginname = get_string('pluginname', 'gradereport_history');
$outcomespluginname = get_string('pluginname', 'gradereport_outcomes');
diff --git a/group/tests/reportbuilder/datasource/groups_test.php b/group/tests/reportbuilder/datasource/groups_test.php
index 8f32bd1924f..963ed25803f 100644
--- a/group/tests/reportbuilder/datasource/groups_test.php
+++ b/group/tests/reportbuilder/datasource/groups_test.php
@@ -194,7 +194,7 @@ class groups_test extends core_reportbuilder_testcase {
*
* @return array[]
*/
- public function datasource_filters_provider(): array {
+ public static function datasource_filters_provider(): array {
return [
// Course (just to test join).
'Filter course name' => ['course:fullname', [
diff --git a/h5p/tests/api_test.php b/h5p/tests/api_test.php
index b3fe6c3322d..5e67daf844b 100644
--- a/h5p/tests/api_test.php
+++ b/h5p/tests/api_test.php
@@ -98,7 +98,7 @@ class api_test extends \advanced_testcase {
*
* @return array
*/
- public function delete_library_provider(): array {
+ public static function delete_library_provider(): array {
return [
'Delete MainLibrary' => [
'MainLibrary',
@@ -192,7 +192,7 @@ class api_test extends \advanced_testcase {
*
* @return array
*/
- public function get_dependent_libraries_provider(): array {
+ public static function get_dependent_libraries_provider(): array {
return [
'Main library of a content' => [
'MainLibrary',
@@ -256,7 +256,7 @@ class api_test extends \advanced_testcase {
*
* @return array
*/
- public function get_library_provider(): array {
+ public static function get_library_provider(): array {
return [
'Main library of a content' => [
'MainLibrary',
@@ -529,7 +529,7 @@ class api_test extends \advanced_testcase {
*
* @return array
*/
- public function can_edit_content_provider(): array {
+ public static function can_edit_content_provider(): array {
return [
// Component = user.
'user: Admin user is author' => [
@@ -963,7 +963,7 @@ class api_test extends \advanced_testcase {
*
* @return array
*/
- public function set_library_enabled_provider(): array {
+ public static function set_library_enabled_provider(): array {
return [
'Disable existing library' => [
'libraryname' => 'MainLibrary',
@@ -1068,7 +1068,7 @@ class api_test extends \advanced_testcase {
*
* @return array
*/
- public function is_library_enabled_provider(): array {
+ public static function is_library_enabled_provider(): array {
return [
'Library with 2 versions, one of them disabled' => [
'libraryname' => 'H5P.Lib1',
@@ -1194,7 +1194,7 @@ class api_test extends \advanced_testcase {
*
* @return array
*/
- public function is_valid_package_provider(): array {
+ public static function is_valid_package_provider(): array {
return [
'Valid H5P file (as admin)' => [
'filename' => '/fixtures/greeting-card.h5p',
diff --git a/h5p/tests/editor_ajax_test.php b/h5p/tests/editor_ajax_test.php
index f09de5145a8..318f2478b42 100644
--- a/h5p/tests/editor_ajax_test.php
+++ b/h5p/tests/editor_ajax_test.php
@@ -161,7 +161,7 @@ class editor_ajax_test extends \advanced_testcase {
*
* @return array
*/
- public function get_translations_provider(): array {
+ public static function get_translations_provider(): array {
return [
'No library' => [
[],
diff --git a/h5p/tests/editor_framework_test.php b/h5p/tests/editor_framework_test.php
index 1c93f87beb5..db142e1fc4c 100644
--- a/h5p/tests/editor_framework_test.php
+++ b/h5p/tests/editor_framework_test.php
@@ -125,7 +125,7 @@ class editor_framework_test extends \advanced_testcase {
*
* @return array
*/
- public function get_language_provider(): array {
+ public static function get_language_provider(): array {
return [
'No library' => [
[],
@@ -289,7 +289,7 @@ class editor_framework_test extends \advanced_testcase {
*
* @return array
*/
- public function get_available_languages_provider(): array {
+ public static function get_available_languages_provider(): array {
return [
'No library' => [
[],
diff --git a/h5p/tests/file_storage_test.php b/h5p/tests/file_storage_test.php
index fa61ed79b3e..40c16134ff3 100644
--- a/h5p/tests/file_storage_test.php
+++ b/h5p/tests/file_storage_test.php
@@ -598,7 +598,7 @@ class file_storage_test extends \advanced_testcase {
*
* @return array
*/
- public function get_icon_url_provider(): array {
+ public static function get_icon_url_provider(): array {
return [
'Icon included' => [
'filltheblanks.h5p',
diff --git a/h5p/tests/framework_test.php b/h5p/tests/framework_test.php
index 5045c077d25..9f0c04a5662 100644
--- a/h5p/tests/framework_test.php
+++ b/h5p/tests/framework_test.php
@@ -655,7 +655,7 @@ class framework_test extends \advanced_testcase {
*
* @return array
*/
- public function isPatchedLibrary_provider(): array {
+ public static function isPatchedLibrary_provider(): array {
return [
'Unpatched library. No different versioning' => [
[
@@ -1483,7 +1483,7 @@ class framework_test extends \advanced_testcase {
*
* @return array
*/
- public function loadLibrarySemantics_provider(): array {
+ public static function loadLibrarySemantics_provider(): array {
$semantics = json_encode(
[
@@ -2274,7 +2274,7 @@ class framework_test extends \advanced_testcase {
*
* @return array
*/
- public function libraryHasUpgrade_provider(): array {
+ public static function libraryHasUpgrade_provider(): array {
return [
'Lower major version; Identical lower version' => [
[
diff --git a/h5p/tests/generator_test.php b/h5p/tests/generator_test.php
index 910bc518793..911cb812b87 100644
--- a/h5p/tests/generator_test.php
+++ b/h5p/tests/generator_test.php
@@ -194,7 +194,7 @@ class generator_test extends \advanced_testcase {
*
* @return array
*/
- public function generate_h5p_data_files_creation_provider(): array {
+ public static function generate_h5p_data_files_creation_provider(): array {
return [
'Do not create library related files on the filesystem' => [
false,
@@ -276,7 +276,7 @@ class generator_test extends \advanced_testcase {
*
* @return array
*/
- public function create_h5p_record_provider(): array {
+ public static function create_h5p_record_provider(): array {
$createdjsoncontent = json_encode(
array(
'text' => 'Created dummy text<\/p>\n',
@@ -397,7 +397,7 @@ class generator_test extends \advanced_testcase {
*
* @return array
*/
- public function create_contents_libraries_record_provider(): array {
+ public static function create_contents_libraries_record_provider(): array {
return [
'Create h5p content library with set dependency type' => [
[
@@ -457,7 +457,7 @@ class generator_test extends \advanced_testcase {
*
* @return array
*/
- public function create_library_dependency_record_provider(): array {
+ public static function create_library_dependency_record_provider(): array {
return [
'Create h5p library dependency with set dependency type' => [
[
@@ -523,7 +523,7 @@ class generator_test extends \advanced_testcase {
*
* @return array
**/
- public function create_content_file_provider(): array {
+ public static function create_content_file_provider(): array {
return [
'Create file in content with id 4' => [
[
diff --git a/h5p/tests/helper_test.php b/h5p/tests/helper_test.php
index 5857f3bab14..b20c462ceac 100644
--- a/h5p/tests/helper_test.php
+++ b/h5p/tests/helper_test.php
@@ -77,7 +77,7 @@ class helper_test extends \advanced_testcase {
*
* @return array
*/
- public function display_options_provider(): array {
+ public static function display_options_provider(): array {
return [
'All display options disabled' => [
false,
@@ -449,7 +449,7 @@ class helper_test extends \advanced_testcase {
*
* @return array
*/
- public function parse_js_array_provider(): array {
+ public static function parse_js_array_provider(): array {
$lines = [
"{",
" missingTranslation: '[Missing translation :key]',",
diff --git a/h5p/tests/local/library/handler_test.php b/h5p/tests/local/library/handler_test.php
index 6e366d4ae2c..3298b1185d6 100644
--- a/h5p/tests/local/library/handler_test.php
+++ b/h5p/tests/local/library/handler_test.php
@@ -54,7 +54,7 @@ class handler_test extends advanced_testcase {
*
* @return array
*/
- public function get_h5p_string_provider(): array {
+ public static function get_h5p_string_provider(): array {
return [
'Existing string in h5plib plugin' => [
'editor:add',
diff --git a/iplookup/tests/geoip_test.php b/iplookup/tests/geoip_test.php
index b547c186ff1..f623f26dc0c 100644
--- a/iplookup/tests/geoip_test.php
+++ b/iplookup/tests/geoip_test.php
@@ -16,14 +16,6 @@
namespace core;
-defined('MOODLE_INTERNAL') || die();
-
-global $CFG;
-
-require_once("{$CFG->libdir}/filelib.php");
-require_once("{$CFG->dirroot}/iplookup/lib.php");
-
-
/**
* GeoIp data file parsing test.
*
@@ -32,15 +24,21 @@ require_once("{$CFG->dirroot}/iplookup/lib.php");
* @copyright 2012 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class geoip_test extends \advanced_testcase {
- public function setUp(): void {
- $this->resetAfterTest();
+final class geoip_test extends \advanced_testcase {
+ #[\Override]
+ public static function setUpBeforeClass(): void {
+ global $CFG;
+
+ parent::setUpBeforeClass();
+
+ require_once("{$CFG->libdir}/filelib.php");
+ require_once("{$CFG->dirroot}/iplookup/lib.php");
}
/**
* Setup the GeoIP2File system.
*/
- public function setup_geoip2file() {
+ public function setup_geoip2file(): void {
global $CFG;
$CFG->geoip2file = "$CFG->dirroot/iplookup/tests/fixtures/GeoIP2-City-Test.mmdb";
}
@@ -51,7 +49,9 @@ 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->resetAfterTest();
+
$this->setup_geoip2file();
// Note: The results we get from the iplookup tests are beyond our control.
@@ -76,7 +76,7 @@ class geoip_test extends \advanced_testcase {
*
* @return array
*/
- public function ip_provider() {
+ public static function ip_provider(): array {
return [
'IPv4: IPV4 test' => ['81.2.69.142'],
'IPv6: IPV6 test' => ['2001:252:1::1:1:1'],
diff --git a/lib/ddl/tests/ddl_test.php b/lib/ddl/tests/ddl_test.php
index 3dd3d07f22a..7e552f6edd2 100644
--- a/lib/ddl/tests/ddl_test.php
+++ b/lib/ddl/tests/ddl_test.php
@@ -2266,7 +2266,7 @@ class ddl_test extends \database_driver_testcase {
*
* @return array The type-value pair fixture.
*/
- public function get_enc_quoted_provider() {
+ public static function get_enc_quoted_provider(): array {
return array(
// Reserved: some examples from SQL-92.
[true, 'from'],
@@ -2315,7 +2315,7 @@ class ddl_test extends \database_driver_testcase {
*
* @return array The type-old-new tuple fixture.
*/
- public function sql_generator_get_rename_field_sql_provider() {
+ public static function sql_generator_get_rename_field_sql_provider(): array {
return array(
// Reserved: an example from SQL-92.
// Both names should be reserved.
diff --git a/lib/dml/tests/dml_read_slave_test.php b/lib/dml/tests/dml_read_slave_test.php
index 88e294e26a6..5f53b537f20 100644
--- a/lib/dml/tests/dml_read_slave_test.php
+++ b/lib/dml/tests/dml_read_slave_test.php
@@ -94,7 +94,7 @@ class dml_read_slave_test extends \base_testcase {
* @return array
* @dataProvider table_names_provider
*/
- public function table_names_provider() : array {
+ public static function table_names_provider(): array {
return [
[
"SELECT *
diff --git a/lib/dml/tests/dml_table_test.php b/lib/dml/tests/dml_table_test.php
index 49da717dddf..2fe8a45de2c 100644
--- a/lib/dml/tests/dml_table_test.php
+++ b/lib/dml/tests/dml_table_test.php
@@ -35,7 +35,7 @@ class dml_table_test extends \database_driver_testcase {
*
* @return array
*/
- public function get_field_select_provider() : array {
+ public static function get_field_select_provider(): array {
return [
'single field' => [
'tablename' => 'test_table_single',
@@ -102,7 +102,7 @@ class dml_table_test extends \database_driver_testcase {
*
* @return array
*/
- public function extract_from_result_provider() : array {
+ public static function extract_from_result_provider(): array {
return [
'single table' => [
'fieldlist' => [
diff --git a/lib/dml/tests/dml_test.php b/lib/dml/tests/dml_test.php
index ae58fadccbf..41816f671e6 100644
--- a/lib/dml/tests/dml_test.php
+++ b/lib/dml/tests/dml_test.php
@@ -4431,7 +4431,7 @@ EOD;
}
- public function sql_concat_join_provider() {
+ public static function sql_concat_join_provider(): array {
return array(
// All strings.
array(
diff --git a/lib/dml/tests/sqlsrv_native_moodle_database_test.php b/lib/dml/tests/sqlsrv_native_moodle_database_test.php
index 9e0f34b9f7e..79b93ab6389 100644
--- a/lib/dml/tests/sqlsrv_native_moodle_database_test.php
+++ b/lib/dml/tests/sqlsrv_native_moodle_database_test.php
@@ -40,8 +40,7 @@ require_once($CFG->dirroot.'/lib/dml/sqlsrv_native_moodle_database.php');
* @copyright 2017 John Okely
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class sqlsrv_native_moodle_database_test extends \advanced_testcase {
-
+final class sqlsrv_native_moodle_database_test extends \advanced_testcase {
public function setUp(): void {
parent::setUp();
$this->resetAfterTest();
@@ -51,7 +50,7 @@ class sqlsrv_native_moodle_database_test extends \advanced_testcase {
* Dataprovider for test_add_no_lock_to_temp_tables
* @return array Data for test_add_no_lock_to_temp_tables
*/
- public function add_no_lock_to_temp_tables_provider() {
+ public static function add_no_lock_to_temp_tables_provider(): array {
return [
"Basic temp table, nothing following" => [
'input' => 'SELECT * FROM {table_temp}',
@@ -144,7 +143,7 @@ class sqlsrv_native_moodle_database_test extends \advanced_testcase {
*
* @return array data for test_has_query_order_by
*/
- public function has_query_order_by_provider() {
+ public static function has_query_order_by_provider(): array {
// Fixtures taken from https://docs.moodle.org/en/ad-hoc_contributed_reports.
return [
diff --git a/lib/filestorage/tests/file_storage_test.php b/lib/filestorage/tests/file_storage_test.php
index 257a1a83ae6..e868b49ad31 100644
--- a/lib/filestorage/tests/file_storage_test.php
+++ b/lib/filestorage/tests/file_storage_test.php
@@ -2129,7 +2129,7 @@ class file_storage_test extends \advanced_testcase {
*
* @return array[]
*/
- public function filepath_mimetype_provider(): array {
+ public static function filepath_mimetype_provider(): array {
return [
[__DIR__ . '/fixtures/testimage.jpg', 'image/jpeg'],
[__DIR__ . '/fixtures/testimage.svg', 'image/svg+xml'],
diff --git a/lib/filestorage/tests/file_system_filedir_test.php b/lib/filestorage/tests/file_system_filedir_test.php
index e75fdc9fdef..1155726321b 100644
--- a/lib/filestorage/tests/file_system_filedir_test.php
+++ b/lib/filestorage/tests/file_system_filedir_test.php
@@ -1107,7 +1107,7 @@ class file_system_filedir_test extends \advanced_testcase {
*
* @return array
*/
- public function contenthash_dataprovider() {
+ public static function contenthash_dataprovider(): array {
return array(
array(
'contenthash' => 'eee4943847a35a4b6942c6f96daafde06bcfdfab',
diff --git a/lib/filestorage/tests/file_system_test.php b/lib/filestorage/tests/file_system_test.php
index 94433665e04..bb873d976da 100644
--- a/lib/filestorage/tests/file_system_test.php
+++ b/lib/filestorage/tests/file_system_test.php
@@ -1219,7 +1219,7 @@ class file_system_test extends \advanced_testcase {
*
* @return array
*/
- public function is_image_from_storedfile_provider() {
+ public static function is_image_from_storedfile_provider(): array {
return array(
'Standard image' => array('image/png', true),
'Made up document/image' => array('document/image', false),
@@ -1231,7 +1231,7 @@ class file_system_test extends \advanced_testcase {
*
* @return array
*/
- public function get_local_path_from_storedfile_provider() {
+ public static function get_local_path_from_storedfile_provider(): array {
return [
'default args (nofetch)' => [
'args' => [],
diff --git a/lib/filestorage/tests/mbz_packer_test.php b/lib/filestorage/tests/mbz_packer_test.php
index affed9f5f48..9b50f1793c4 100644
--- a/lib/filestorage/tests/mbz_packer_test.php
+++ b/lib/filestorage/tests/mbz_packer_test.php
@@ -89,7 +89,7 @@ class mbz_packer_test extends \advanced_testcase {
$this->assertEquals('frog', $out->get_content());
}
- public function usezipbackups_provider() {
+ public static function usezipbackups_provider(): array {
return [
'Use zips' => [true],
'Use tgz' => [false],
diff --git a/lib/form/tests/duration_test.php b/lib/form/tests/duration_test.php
index a19ce851e20..34901d4bf67 100644
--- a/lib/form/tests/duration_test.php
+++ b/lib/form/tests/duration_test.php
@@ -106,7 +106,7 @@ class duration_test extends \basic_testcase {
*
* @return array test cases.
*/
- public function seconds_to_unit_cases(): array {
+ public static function seconds_to_unit_cases(): array {
return [
[[0, MINSECS], 0], // Zero minutes, for a nice default unit.
[[1, 1], 1],
@@ -147,7 +147,7 @@ class duration_test extends \basic_testcase {
*
* @return array test cases.
*/
- public function export_value_cases(): array {
+ public static function export_value_cases(): array {
return [
[10, '10', 1],
[9, '9.3', 1],
diff --git a/lib/form/tests/filetypes_util_test.php b/lib/form/tests/filetypes_util_test.php
index 26dcc80193d..0daaa5a930b 100644
--- a/lib/form/tests/filetypes_util_test.php
+++ b/lib/form/tests/filetypes_util_test.php
@@ -14,36 +14,21 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see
Paragraph
Bold', 'Paragraph
Bold', true diff --git a/mod/assign/submission/file/tests/locallib_test.php b/mod/assign/submission/file/tests/locallib_test.php index f593336d6ac..fa08288209a 100644 --- a/mod/assign/submission/file/tests/locallib_test.php +++ b/mod/assign/submission/file/tests/locallib_test.php @@ -169,7 +169,7 @@ class locallib_test extends \advanced_testcase { * * @return array of testcases */ - public function submission_is_empty_testcases() { + public static function submission_is_empty_testcases(): array { return [ 'With file' => [ [ diff --git a/mod/assign/submission/onlinetext/tests/locallib_test.php b/mod/assign/submission/onlinetext/tests/locallib_test.php index 0d6f33c122f..32c91b29394 100644 --- a/mod/assign/submission/onlinetext/tests/locallib_test.php +++ b/mod/assign/submission/onlinetext/tests/locallib_test.php @@ -100,7 +100,7 @@ class locallib_test extends \advanced_testcase { * * @return array of testcases */ - public function submission_is_empty_testcases() { + public static function submission_is_empty_testcases(): array { return [ 'Empty submission string' => ['', true], 'Empty submission null' => [null, true], diff --git a/mod/assign/tests/custom_completion_test.php b/mod/assign/tests/custom_completion_test.php index 91c7220eb84..81362931719 100644 --- a/mod/assign/tests/custom_completion_test.php +++ b/mod/assign/tests/custom_completion_test.php @@ -54,7 +54,7 @@ class custom_completion_test extends advanced_testcase { * * @return array[] */ - public function get_state_provider(): array { + public static function get_state_provider(): array { return [ 'Undefined rule' => [ 'somenonexistentrule', COMPLETION_DISABLED, false, null, coding_exception::class @@ -200,7 +200,7 @@ class custom_completion_test extends advanced_testcase { * * @return array[] */ - public function get_available_custom_rules_provider(): array { + public static function get_available_custom_rules_provider(): array { return [ 'Completion submit available' => [ COMPLETION_ENABLED, ['completionsubmit'] diff --git a/mod/assign/tests/dates_test.php b/mod/assign/tests/dates_test.php index 57fbaa05cd3..31b840c62b1 100644 --- a/mod/assign/tests/dates_test.php +++ b/mod/assign/tests/dates_test.php @@ -43,7 +43,7 @@ class dates_test extends advanced_testcase { * Data provider for get_dates_for_module(). * @return array[] */ - public function get_dates_for_module_provider(): array { + public static function get_dates_for_module_provider(): array { $now = time(); $before = $now - DAYSECS; $earlier = $before - DAYSECS; diff --git a/mod/assign/tests/downloader_test.php b/mod/assign/tests/downloader_test.php index da077a3a9ba..0340701d4c2 100644 --- a/mod/assign/tests/downloader_test.php +++ b/mod/assign/tests/downloader_test.php @@ -179,9 +179,9 @@ class downloader_test extends \advanced_testcase { * * @return array of scenarios */ - public function load_filelist_provider(): array { - $downloadasfoldertests = $this->load_filelist_downloadasfolder_scenarios(); - $downloadasfilestests = $this->load_filelist_downloadasfiles_scenarios(); + public static function load_filelist_provider(): array { + $downloadasfoldertests = static::load_filelist_downloadasfolder_scenarios(); + $downloadasfilestests = static::load_filelist_downloadasfiles_scenarios(); return array_merge( $downloadasfoldertests, $downloadasfilestests, @@ -196,8 +196,8 @@ class downloader_test extends \advanced_testcase { * * @return array of scenarios */ - private function load_filelist_downloadasfiles_scenarios(): array { - $result = $this->load_filelist_downloadasfolder_scenarios("Download as files:"); + private static function load_filelist_downloadasfiles_scenarios(): array { + $result = static::load_filelist_downloadasfolder_scenarios("Download as files:"); // Transform paths from files. foreach ($result as $scenario => $info) { $info['downloadasfolder'] = false; @@ -215,7 +215,9 @@ class downloader_test extends \advanced_testcase { * @param string $prefix the scenarios prefix * @return array of scenarios */ - private function load_filelist_downloadasfolder_scenarios(string $prefix = "Download as folders:"): array { + private static function load_filelist_downloadasfolder_scenarios( + string $prefix = "Download as folders:" + ): array { return [ // Test without team submissions. $prefix . ' All users without groups' => [ diff --git a/mod/assign/tests/externallib_test.php b/mod/assign/tests/externallib_test.php index 75095906e79..bda52f2b5b9 100644 --- a/mod/assign/tests/externallib_test.php +++ b/mod/assign/tests/externallib_test.php @@ -2747,7 +2747,7 @@ class externallib_test extends \mod_assign\externallib_advanced_testcase { /** * The test_get_participant_relative_dates data provider. */ - public function get_participant_relative_dates_provider() { + public static function get_participant_relative_dates_provider(): array { $timenow = time(); return [ diff --git a/mod/assign/tests/locallib_test.php b/mod/assign/tests/locallib_test.php index b91f2f444ea..a777a0453ef 100644 --- a/mod/assign/tests/locallib_test.php +++ b/mod/assign/tests/locallib_test.php @@ -145,7 +145,7 @@ class locallib_test extends \advanced_testcase { * * @return array Provider data */ - public function get_assign_perpage_provider() { + public static function get_assign_perpage_provider(): array { return array( array( 'maxperpage' => -1, @@ -914,7 +914,7 @@ class locallib_test extends \advanced_testcase { * * @return array of testcases */ - public function new_submission_empty_testcases() { + public static function new_submission_empty_testcases(): array { return [ 'With file and onlinetext' => [ [ @@ -3062,7 +3062,7 @@ class locallib_test extends \advanced_testcase { $this->assertEquals($isenabled, (bool) $plugin->is_enabled('enabled')); } - public function submission_plugin_settings_provider() { + public static function submission_plugin_settings_provider(): array { return [ 'CFG->usecomments true, empty config => Enabled by default' => [ true, @@ -3197,7 +3197,7 @@ Anchor link 2:Link text $this->assertEquals($isenabled, (bool) $plugin->is_enabled('enabled')); } - public function feedback_plugin_settings_provider() { + public static function feedback_plugin_settings_provider(): array { return [ 'No configuration => disabled' => [ [], @@ -3935,7 +3935,7 @@ Anchor link 2:Link text * Data provider for test_fix_null_grades * @return array[] Test data for test_fix_null_grades. Each element should contain grade, expectedcount and gradebookvalue */ - public function fix_null_grades_provider() { + public static function fix_null_grades_provider(): array { return [ 'Negative less than one is errant' => [ 'grade' => -0.64, @@ -4122,7 +4122,7 @@ Anchor link 2:Link text /** * The test_assign_get_instance data provider. */ - public function assign_get_instance_provider() { + public static function assign_get_instance_provider(): array { $timenow = time(); // The get_default_instance() method shouldn't calculate any properties per-user. It should just return the record data. @@ -4203,7 +4203,7 @@ Anchor link 2:Link text /** * The test_assign_get_default_instance data provider. */ - public function assign_get_default_instance_provider() { + public static function assign_get_default_instance_provider(): array { $timenow = time(); // The get_default_instance() method shouldn't calculate any properties per-user. It should just return the record data. diff --git a/mod/assign/tests/upgradelib_test.php b/mod/assign/tests/upgradelib_test.php index 5c270c25b12..39162eb7416 100644 --- a/mod/assign/tests/upgradelib_test.php +++ b/mod/assign/tests/upgradelib_test.php @@ -38,7 +38,7 @@ class upgradelib_test extends \advanced_testcase { * * @return array */ - public function assignment_upgrade_provider() { + public static function assignment_upgrade_provider(): array { return [ 'upload' => [ 'type' => 'upload', diff --git a/mod/bigbluebuttonbn/tests/backup_restore_test.php b/mod/bigbluebuttonbn/tests/backup_restore_test.php index f173ea1802e..84bbf28ce28 100644 --- a/mod/bigbluebuttonbn/tests/backup_restore_test.php +++ b/mod/bigbluebuttonbn/tests/backup_restore_test.php @@ -223,7 +223,7 @@ class backup_restore_test extends restore_date_testcase { * Return an array of BigBlueButton types * @return array[] */ - public function bbb_type_provider() { + public static function bbb_type_provider(): array { return [ 'All' => [instance::TYPE_ALL], 'Recording Only' => [instance::TYPE_RECORDING_ONLY], diff --git a/mod/bigbluebuttonbn/tests/completion/completion_test.php b/mod/bigbluebuttonbn/tests/completion/completion_test.php index 4870447881e..c39061400ef 100644 --- a/mod/bigbluebuttonbn/tests/completion/completion_test.php +++ b/mod/bigbluebuttonbn/tests/completion/completion_test.php @@ -281,7 +281,7 @@ class completion_test extends \advanced_testcase { * * @return array[] */ - public function custom_completion_data_provider() { + public static function custom_completion_data_provider(): array { return [ 'simple' => [ 'customcompletionrules' => [ diff --git a/mod/bigbluebuttonbn/tests/external/get_recordings_test.php b/mod/bigbluebuttonbn/tests/external/get_recordings_test.php index b1040873e3c..4d7ab3391c4 100644 --- a/mod/bigbluebuttonbn/tests/external/get_recordings_test.php +++ b/mod/bigbluebuttonbn/tests/external/get_recordings_test.php @@ -420,7 +420,7 @@ class get_recordings_test extends \externallib_advanced_testcase { * * @return array[] */ - public function recording_group_test_data() { + public static function recording_group_test_data(): array { return [ 'visiblegroups' => [ 'type' => instance::TYPE_ALL, diff --git a/mod/bigbluebuttonbn/tests/instance_test.php b/mod/bigbluebuttonbn/tests/instance_test.php index 8fe81cb2277..4af1cfd49f5 100644 --- a/mod/bigbluebuttonbn/tests/instance_test.php +++ b/mod/bigbluebuttonbn/tests/instance_test.php @@ -65,7 +65,7 @@ class instance_test extends advanced_testcase { * * @return string[][] */ - public function get_from_location_provider(): array { + public static function get_from_location_provider(): array { return [ ['get_from_instanceid', 'id'], ['get_from_cmid', 'cmid'], @@ -174,7 +174,7 @@ class instance_test extends advanced_testcase { * * @return \string[][] */ - public function invalid_meetingid_provider(): array { + public static function invalid_meetingid_provider(): array { // Meeting IDs are in the formats: // -Simple textual content
',
diff --git a/mod/lesson/tests/dates_test.php b/mod/lesson/tests/dates_test.php
index 4d4345cb665..0d2b676ff40 100644
--- a/mod/lesson/tests/dates_test.php
+++ b/mod/lesson/tests/dates_test.php
@@ -43,7 +43,7 @@ class dates_test extends advanced_testcase {
* Data provider for get_dates_for_module().
* @return array[]
*/
- public function get_dates_for_module_provider(): array {
+ public static function get_dates_for_module_provider(): array {
$now = time();
$before = $now - DAYSECS;
$earlier = $before - DAYSECS;
diff --git a/mod/lesson/tests/locallib_test.php b/mod/lesson/tests/locallib_test.php
index 91e8ce64b4b..7571ed7a1f4 100644
--- a/mod/lesson/tests/locallib_test.php
+++ b/mod/lesson/tests/locallib_test.php
@@ -260,7 +260,7 @@ class locallib_test extends \advanced_testcase {
*
* @return array
*/
- public function get_last_attempt_dataprovider() {
+ public static function get_last_attempt_dataprovider(): array {
return [
[0, [(object)['id' => 1], (object)['id' => 2], (object)['id' => 3]], (object)['id' => 3]],
[1, [(object)['id' => 1], (object)['id' => 2], (object)['id' => 3]], (object)['id' => 1]],
diff --git a/mod/lesson/tests/numeric_helper_test.php b/mod/lesson/tests/numeric_helper_test.php
index a0ea02a24b9..f72e32ded46 100644
--- a/mod/lesson/tests/numeric_helper_test.php
+++ b/mod/lesson/tests/numeric_helper_test.php
@@ -62,7 +62,7 @@ class numeric_helper_test extends \advanced_testcase {
*
* @return array
*/
- public function lesson_unformat_dataprovider() {
+ public static function lesson_unformat_dataprovider(): array {
return [
"Using a decimal as a separator" => [
"decsep" => ".",
@@ -100,7 +100,7 @@ class numeric_helper_test extends \advanced_testcase {
*
* @return array
*/
- public function lesson_format_dataprovider() {
+ public static function lesson_format_dataprovider(): array {
return [
"Using a decimal as a separator" => [
"decsep" => ".",
diff --git a/mod/lti/tests/local/ltiopenid/jwks_helper_test.php b/mod/lti/tests/local/ltiopenid/jwks_helper_test.php
index 0fe71e29fb9..8fcac76df8c 100644
--- a/mod/lti/tests/local/ltiopenid/jwks_helper_test.php
+++ b/mod/lti/tests/local/ltiopenid/jwks_helper_test.php
@@ -66,7 +66,7 @@ class jwks_helper_test extends \basic_testcase {
* Provider for test_fix_jwks_alg.
* @return array test data.
*/
- public function jwks_alg_provider(): array {
+ public static function jwks_alg_provider(): array {
return [
// Algs already present, so no changes to input key array.
'All JWKS keys have algs set' => [
diff --git a/mod/lti/tests/locallib_test.php b/mod/lti/tests/locallib_test.php
index 3a04c21f6eb..a3f0d35e9fe 100644
--- a/mod/lti/tests/locallib_test.php
+++ b/mod/lti/tests/locallib_test.php
@@ -517,7 +517,7 @@ class locallib_test extends mod_lti_testcase {
*
* @return array of [urlToTest, expectedTool, allTools]
*/
- public function lti_get_best_tool_by_url_provider() {
+ public static function lti_get_best_tool_by_url_provider(): array {
$tools = [
(object) [
'name' => 'Here',
@@ -605,7 +605,7 @@ class locallib_test extends mod_lti_testcase {
// Construct the final array as required by the provider API. Each row
// of the array contains the URL to test, the expected tool, and
// the complete list of tools.
- return array_map(function($data) use ($tools) {
+ return array_map(function($data) use ($tools): array {
return [$data['url'], $data['expected'], $tools];
}, $data);
}
@@ -1915,7 +1915,7 @@ MwIDAQAB
*
* @return array[] the test case data.
*/
- public function lti_get_ims_role_provider() {
+ public static function lti_get_ims_role_provider(): array {
return [
'Student, LTI 1.1, no role switch' => [
'islti2' => false,
diff --git a/mod/lti/tests/servicelib_test.php b/mod/lti/tests/servicelib_test.php
index a20fbc8184e..1fd5c321a1a 100644
--- a/mod/lti/tests/servicelib_test.php
+++ b/mod/lti/tests/servicelib_test.php
@@ -47,7 +47,7 @@ class servicelib_test extends \basic_testcase {
*
* @return array
*/
- public function message_id_provider() {
+ public static function message_id_provider(): array {
$valid = <<