diff --git a/admin/presets/tests/generator_test.php b/admin/presets/tests/generator_test.php index 52ef904e996..a8bef76ceed 100644 --- a/admin/presets/tests/generator_test.php +++ b/admin/presets/tests/generator_test.php @@ -180,7 +180,7 @@ class generator_test extends \advanced_testcase { * * @return array */ - public function create_preset_provider(): array { + public static function create_preset_provider(): array { return [ 'Default values' => [ ], diff --git a/admin/presets/tests/helper_test.php b/admin/presets/tests/helper_test.php index 0a4c6ed0595..eea7ddc2595 100644 --- a/admin/presets/tests/helper_test.php +++ b/admin/presets/tests/helper_test.php @@ -84,7 +84,7 @@ class helper_test extends \advanced_testcase { * * @return array */ - public function create_preset_provider(): array { + public static function create_preset_provider(): array { return [ 'Default values' => [ ], @@ -177,7 +177,7 @@ class helper_test extends \advanced_testcase { * * @return array */ - public function add_item_provider(): array { + public static function add_item_provider(): array { return [ 'Setting without plugin' => [ 'name' => 'settingname', @@ -239,7 +239,7 @@ class helper_test extends \advanced_testcase { * * @return array */ - public function add_plugin_provider(): array { + public static function add_plugin_provider(): array { return [ 'Plugin: enabled (using int)' => [ 'type' => 'plugintype', @@ -321,7 +321,7 @@ class helper_test extends \advanced_testcase { * * @return array */ - public function change_default_preset_provider(): array { + public static function change_default_preset_provider(): array { return [ 'Starter preset' => [ 'preset' => 'starter', diff --git a/admin/presets/tests/local/setting/adminpresets_admin_setting_bloglevel_test.php b/admin/presets/tests/local/setting/adminpresets_admin_setting_bloglevel_test.php index d59108abbc5..4f6a59a5a65 100644 --- a/admin/presets/tests/local/setting/adminpresets_admin_setting_bloglevel_test.php +++ b/admin/presets/tests/local/setting/adminpresets_admin_setting_bloglevel_test.php @@ -72,7 +72,7 @@ class adminpresets_admin_setting_bloglevel_test extends \advanced_testcase { * * @return array */ - public function save_value_provider(): array { + public static function save_value_provider(): array { return [ 'Save the bloglevel and set blog_menu block visibility to true' => [ 'setttingvalue' => BLOG_USER_LEVEL, diff --git a/admin/presets/tests/local/setting/adminpresets_admin_setting_sitesettext_test.php b/admin/presets/tests/local/setting/adminpresets_admin_setting_sitesettext_test.php index 3ae332154fa..de2f2159800 100644 --- a/admin/presets/tests/local/setting/adminpresets_admin_setting_sitesettext_test.php +++ b/admin/presets/tests/local/setting/adminpresets_admin_setting_sitesettext_test.php @@ -66,7 +66,7 @@ class adminpresets_admin_setting_sitesettext_test extends \advanced_testcase { * * @return array */ - public function save_value_provider(): array { + public static function save_value_provider(): array { return [ 'Fullname: different value' => [ 'settingname' => 'fullname', diff --git a/admin/presets/tests/local/setting/adminpresets_setting_test.php b/admin/presets/tests/local/setting/adminpresets_setting_test.php index 3cd81ed5d54..e57dbb9ed0e 100644 --- a/admin/presets/tests/local/setting/adminpresets_setting_test.php +++ b/admin/presets/tests/local/setting/adminpresets_setting_test.php @@ -77,7 +77,7 @@ class adminpresets_setting_test extends \advanced_testcase { * * @return array */ - public function save_value_provider(): array { + public static function save_value_provider(): array { return [ 'Core setting with the same value is not saved' => [ 'category' => 'optionalsubsystems', @@ -167,7 +167,7 @@ class adminpresets_setting_test extends \advanced_testcase { * * @return array */ - public function save_attributes_values_provider(): array { + public static function save_attributes_values_provider(): array { return [ 'Plugin setting with the same value is not saved' => [ 'category' => 'modsettinglesson', diff --git a/admin/presets/tests/manager_test.php b/admin/presets/tests/manager_test.php index a87da91f4fb..193997b3153 100644 --- a/admin/presets/tests/manager_test.php +++ b/admin/presets/tests/manager_test.php @@ -358,7 +358,7 @@ class manager_test extends \advanced_testcase { * * @return array */ - public function export_preset_provider(): array { + public static function export_preset_provider(): array { return [ 'Export settings and plugins, excluding sensible' => [ 'includesensible' => false, @@ -521,7 +521,7 @@ class manager_test extends \advanced_testcase { * * @return array */ - public function import_preset_provider(): array { + public static function import_preset_provider(): array { return [ 'Import settings from an empty file' => [ 'filecontents' => '', diff --git a/admin/tests/reportbuilder/datasource/task_logs_test.php b/admin/tests/reportbuilder/datasource/task_logs_test.php index ca0f81e2470..b1ea340e797 100644 --- a/admin/tests/reportbuilder/datasource/task_logs_test.php +++ b/admin/tests/reportbuilder/datasource/task_logs_test.php @@ -103,7 +103,7 @@ class task_logs_test extends core_reportbuilder_testcase { * * @return array[] */ - public function datasource_filters_provider(): array { + public static function datasource_filters_provider(): array { return [ 'Filter name' => ['task_log:name', [ 'task_log:name_values' => [send_schedules::class], diff --git a/admin/tool/admin_presets/tests/local/action/base_test.php b/admin/tool/admin_presets/tests/local/action/base_test.php index 2cf069cc361..de2b8354057 100644 --- a/admin/tool/admin_presets/tests/local/action/base_test.php +++ b/admin/tool/admin_presets/tests/local/action/base_test.php @@ -70,7 +70,7 @@ class base_test extends \advanced_testcase { * * @return array */ - public function log_provider(): array { + public static function log_provider(): array { return [ // Action = base. 'action=base and mode = show' => [ diff --git a/admin/tool/admin_presets/tests/local/action/export_test.php b/admin/tool/admin_presets/tests/local/action/export_test.php index 4e858f400b9..0a7660b7939 100644 --- a/admin/tool/admin_presets/tests/local/action/export_test.php +++ b/admin/tool/admin_presets/tests/local/action/export_test.php @@ -156,7 +156,7 @@ class export_test extends \advanced_testcase { * * @return array */ - public function export_execute_provider(): array { + public static function export_execute_provider(): array { return [ 'Export settings and plugins, excluding sensible' => [ 'includesensible' => false, diff --git a/admin/tool/admin_presets/tests/local/action/import_test.php b/admin/tool/admin_presets/tests/local/action/import_test.php index db31668f2c9..9369100a93b 100644 --- a/admin/tool/admin_presets/tests/local/action/import_test.php +++ b/admin/tool/admin_presets/tests/local/action/import_test.php @@ -190,7 +190,7 @@ class import_test extends \advanced_testcase { * * @return array */ - public function import_execute_provider(): array { + public static function import_execute_provider(): array { $fixturesfolder = __DIR__ . '/../../../../../presets/tests/fixtures/'; return [ diff --git a/admin/tool/behat/tests/behat_form_text_test.php b/admin/tool/behat/tests/behat_form_text_test.php index 0823cbac758..2ec6720aa38 100644 --- a/admin/tool/behat/tests/behat_form_text_test.php +++ b/admin/tool/behat/tests/behat_form_text_test.php @@ -53,7 +53,7 @@ class behat_form_text_test extends \basic_testcase { * * @return array of value and expectation pairs to be tested. */ - public function provider_test_set_get_value() { + public static function provider_test_set_get_value(): array { return [ 'null' => [null, null], 'int' => [3, 3], @@ -68,7 +68,7 @@ class behat_form_text_test extends \basic_testcase { * * @param mixed $value value to be set. * @param mixed $expectation value to be checked. - * @dataProvider provider_test_set_get_value() + * @dataProvider provider_test_set_get_value */ public function test_set_get_value($value, $expectation) { $session = $this->createMock(Session::class); @@ -85,7 +85,7 @@ class behat_form_text_test extends \basic_testcase { * * @return array of decsep, value, match and result pairs to be tested. */ - public function provider_test_matches() { + public static function provider_test_matches(): array { return [ 'lazy true' => ['.', 'hello', 'hello', true], 'lazy false' => ['.', 'hello', 'bye', false], @@ -113,7 +113,7 @@ class behat_form_text_test extends \basic_testcase { * @param mixed $value value to be set. * @param mixed $match value to be matched. * @param bool $result expected return status of the function. - * @dataProvider provider_test_matches() + * @dataProvider provider_test_matches */ public function test_matches($decsep, $value, $match, $result) { global $CFG; diff --git a/admin/tool/brickfield/tests/tool_test.php b/admin/tool/brickfield/tests/tool_test.php index 1b23a062e70..1144e766837 100644 --- a/admin/tool/brickfield/tests/tool_test.php +++ b/admin/tool/brickfield/tests/tool_test.php @@ -30,7 +30,7 @@ use tool_brickfield\local\tool\tool; class tool_test extends \advanced_testcase { /** @var string base 64 image */ - protected $base64img = <<'; return [ 'Image tag alone (base64)' => [ - $this->base64img, + self::$base64img, true, ], 'Image tag alone (link)' => [ @@ -130,7 +130,7 @@ EOF; false, ], 'Image tag in string (base64)' => [ - "This is my image {$this->base64img}.", + "This is my image " . self::$base64img, true, ], 'Image tag in string (link)' => [ @@ -162,7 +162,7 @@ EOF; } public function test_truncate_base64() { - $truncated = tool::truncate_base64($this->base64img); + $truncated = tool::truncate_base64(self::$base64img); $this->assertStringContainsString(' [ '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" => '', + "content" => '', "outputregex" => '/UPDATE/', - "expectedcontent" => '', + "expectedcontent" => '', ], "Test image from a site with international name should be replaced" => [ "content" => '', @@ -79,9 +79,9 @@ class httpsreplace_test extends \advanced_testcase { "expectedcontent" => '', ], "Search for params should be case insensitive" => [ - "content" => '', + "content" => '', "outputregex" => '/UPDATE/', - "expectedcontent" => '', + "expectedcontent" => '', ], "URL should be case insensitive" => [ "content" => '', @@ -89,30 +89,30 @@ class httpsreplace_test extends \advanced_testcase { "expectedcontent" => '', ], "More params should not interfere" => [ - "content" => 'A picture 'A picture

', "outputregex" => '/UPDATE/', - "expectedcontent" => 'A picture 'A picture

', ], "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 . -/** - * Provides the {@link core_form\filetypes_util_testcase} class. - * - * @package core_form - * @category test - * @copyright 2017 David Mudrák - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - namespace core_form; -use advanced_testcase; - -defined('MOODLE_INTERNAL') || die(); - -global $CFG; - /** * Test cases for the {@link core_form\filetypes_util} class. * + * @package core_form * @copyright 2017 David Mudrak * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @covers \core_form\filetypes_util */ -class filetypes_util_test extends advanced_testcase { - +final class filetypes_util_test extends \advanced_testcase { /** * Test normalizing list of extensions. */ - public function test_normalize_file_types() { - + public function test_normalize_file_types(): void { $this->resetAfterTest(true); $util = new filetypes_util(); @@ -74,8 +59,7 @@ class filetypes_util_test extends advanced_testcase { /** * Test MIME type formal recognition. */ - public function test_looks_like_mimetype() { - + public function test_looks_like_mimetype(): void { $this->resetAfterTest(true); $util = new filetypes_util(); @@ -93,8 +77,7 @@ class filetypes_util_test extends advanced_testcase { /** * Test getting/checking group. */ - public function test_is_filetype_group() { - + public function test_is_filetype_group(): void { $this->resetAfterTest(true); $util = new filetypes_util(); @@ -111,8 +94,7 @@ class filetypes_util_test extends advanced_testcase { /** * Test describing list of extensions. */ - public function test_describe_file_types() { - + public function test_describe_file_types(): void { $this->resetAfterTest(true); $util = new filetypes_util(); @@ -169,8 +151,7 @@ class filetypes_util_test extends advanced_testcase { /** * Test expanding mime types into extensions. */ - public function test_expand() { - + public function test_expand(): void { $this->resetAfterTest(true); $util = new filetypes_util(); @@ -207,8 +188,7 @@ class filetypes_util_test extends advanced_testcase { /** * Test checking that a type is among others. */ - public function test_is_listed() { - + public function test_is_listed(): void { $this->resetAfterTest(true); $util = new filetypes_util(); @@ -250,8 +230,7 @@ class filetypes_util_test extends advanced_testcase { /** * Test getting types not present in a list. */ - public function test_get_not_listed() { - + public function test_get_not_listed(): void { $this->resetAfterTest(true); $util = new filetypes_util(); @@ -273,8 +252,7 @@ class filetypes_util_test extends advanced_testcase { /** * Test populating the tree for the browser. */ - public function test_data_for_browser() { - + public function test_data_for_browser(): void { $this->resetAfterTest(true); $util = new filetypes_util(); @@ -359,7 +337,7 @@ class filetypes_util_test extends advanced_testcase { * * @return array */ - public function is_allowed_file_type_provider() { + public static function is_allowed_file_type_provider(): array { return [ 'Filetype not in extension list' => [ 'filename' => 'test.xml', @@ -421,7 +399,7 @@ class filetypes_util_test extends advanced_testcase { * * @return array */ - public function get_unknown_file_types_provider() { + public static function get_unknown_file_types_provider(): array { return [ 'Empty list' => [ 'filetypes' => '', diff --git a/lib/form/tests/privacy/provider_test.php b/lib/form/tests/privacy/provider_test.php index dc42e39b204..d28d26cbe74 100644 --- a/lib/form/tests/privacy/provider_test.php +++ b/lib/form/tests/privacy/provider_test.php @@ -27,16 +27,13 @@ namespace core_form\privacy; use core_form\privacy\provider; use core_privacy\local\request\writer; -defined('MOODLE_INTERNAL') || die(); - /** * Unit tests for the privacy API implementation. * * @copyright 2018 David Mudrák * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class provider_test extends \core_privacy\tests\provider_testcase { - +final class provider_test extends \core_privacy\tests\provider_testcase { /** * When no preference exists, there should be no export. */ @@ -85,7 +82,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { * * @return array */ - public function data_filemanager_recentviewmode() { + public static function data_filemanager_recentviewmode(): array { return [ 'icons' => [ 'val' => '1', diff --git a/lib/mlbackend/python/tests/processor_test.php b/lib/mlbackend/python/tests/processor_test.php index d14dd088ccc..58ec84d1afc 100644 --- a/lib/mlbackend/python/tests/processor_test.php +++ b/lib/mlbackend/python/tests/processor_test.php @@ -23,9 +23,9 @@ namespace mlbackend_python; * @category test * @copyright 2019 David Mudrák * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @covers \mlbackend_python\processor */ -class processor_test extends \advanced_testcase { - +final class processor_test extends \advanced_testcase { /** * Test implementation of the {@link \mlbackend_python\processor::check_pip_package_version()} method. * @@ -41,11 +41,12 @@ class processor_test extends \advanced_testcase { /** * Check that the {@link \mlbackend_python\processor::check_pip_package_version()} can be called with single argument. */ - public function test_check_pip_package_version_default() { - + public function test_check_pip_package_version_default(): void { $this->assertSame(-1, \mlbackend_python\processor::check_pip_package_version('0.0.1')); - $this->assertSame(0, \mlbackend_python\processor::check_pip_package_version( - \mlbackend_python\processor::REQUIRED_PIP_PACKAGE_VERSION)); + $this->assertSame( + 0, + \mlbackend_python\processor::check_pip_package_version(\mlbackend_python\processor::REQUIRED_PIP_PACKAGE_VERSION), + ); } /** @@ -53,7 +54,7 @@ class processor_test extends \advanced_testcase { * * @return array */ - public function check_pip_package_versions() { + public static function check_pip_package_versions(): array { return [ // Exact match. [ diff --git a/lib/phpunit/classes/advanced_testcase.php b/lib/phpunit/classes/advanced_testcase.php index 6c1669e426a..23fb2633366 100644 --- a/lib/phpunit/classes/advanced_testcase.php +++ b/lib/phpunit/classes/advanced_testcase.php @@ -228,7 +228,7 @@ abstract class advanced_testcase extends base_testcase { * @param array $files full paths to CSV or XML files to load. * @return phpunit_dataset */ - protected function dataset_from_files(array $files) { + protected static function dataset_from_files(array $files) { // We ignore $delimiter, $enclosure and $escape, use the default ones in your fixtures. $dataset = new phpunit_dataset(); $dataset->from_files($files); @@ -245,7 +245,7 @@ abstract class advanced_testcase extends base_testcase { * @param string $table name of the table which the file belongs to (only for CSV files). * @return phpunit_dataset */ - protected function dataset_from_string(string $content, string $type, ?string $table = null) { + protected static function dataset_from_string(string $content, string $type, ?string $table = null) { $dataset = new phpunit_dataset(); $dataset->from_string($content, $type, $table); return $dataset; @@ -259,7 +259,7 @@ abstract class advanced_testcase extends base_testcase { * @param array $data array of tables, see {@see phpunit_dataset::from_array()} for supported formats. * @return phpunit_dataset */ - protected function dataset_from_array(array $data) { + protected static function dataset_from_array(array $data) { $dataset = new phpunit_dataset(); $dataset->from_array($data); return $dataset; @@ -622,28 +622,31 @@ abstract class advanced_testcase extends base_testcase { * @param bool $https true if https required * @return string url */ - public function getExternalTestFileUrl($path, $https = false) { + public static function getExternalTestFileUrl( + string $path, + bool $https = false + ): string { $path = ltrim($path, '/'); if ($path) { - $path = '/'.$path; + $path = "/{$path}"; } if ($https) { if (defined('TEST_EXTERNAL_FILES_HTTPS_URL')) { if (!TEST_EXTERNAL_FILES_HTTPS_URL) { - $this->markTestSkipped('Tests using external https test files are disabled'); + self::markTestSkipped('Tests using external https test files are disabled'); } return TEST_EXTERNAL_FILES_HTTPS_URL.$path; } - return 'https://download.moodle.org/unittest'.$path; + return "https://download.moodle.org/unittest/{$path}"; } if (defined('TEST_EXTERNAL_FILES_HTTP_URL')) { if (!TEST_EXTERNAL_FILES_HTTP_URL) { - $this->markTestSkipped('Tests using external http test files are disabled'); + self::markTestSkipped('Tests using external http test files are disabled'); } return TEST_EXTERNAL_FILES_HTTP_URL.$path; } - return 'http://download.moodle.org/unittest'.$path; + return "http://download.moodle.org/unittest/{$path}"; } /** @@ -747,6 +750,24 @@ abstract class advanced_testcase extends base_testcase { $tasks->close(); } + /** + * Convenience method to get the path to a fixture. + * + * @param string $component + * @param string $path + * @throws coding_exception + */ + protected static function get_fixture_path( + string $component, + string $path + ): string { + return sprintf( + "%s/tests/fixtures/%s", + \core_component::get_component_directory($component), + $path, + ); + } + /** * Convenience method to load a fixture from a component's fixture directory. * @@ -758,15 +779,6 @@ abstract class advanced_testcase extends base_testcase { string $component, string $path ): void { - $fullpath = sprintf( - "%s/tests/fixtures/%s", - \core_component::get_component_directory($component), - $path, - ); - if (!file_exists($fullpath)) { - throw new \coding_exception("Fixture file not found: $fullpath"); - } - global $ADMIN; global $CFG; global $DB; @@ -778,6 +790,12 @@ abstract class advanced_testcase extends base_testcase { global $COURSE; global $SITE; + $fullpath = static::get_fixture_path($component, $path); + + if (!file_exists($fullpath)) { + throw new \coding_exception("Fixture file not found: $fullpath"); + } + require_once($fullpath); } } diff --git a/lib/phpunit/tests/phpunit_dataset_test.php b/lib/phpunit/tests/phpunit_dataset_test.php index 4e0aa982f74..4eb07e4acf1 100644 --- a/lib/phpunit/tests/phpunit_dataset_test.php +++ b/lib/phpunit/tests/phpunit_dataset_test.php @@ -83,7 +83,7 @@ class phpunit_dataset_test extends advanced_testcase { /** * test_from_file() data provider. */ - public function from_file_provider() { + public static function from_file_provider(): array { // Create an unreadable file with vfsStream. $vfsfile = vfsStream::newFile('unreadable', 0222); vfsStream::setup('root')->addChild($vfsfile); @@ -183,7 +183,7 @@ class phpunit_dataset_test extends advanced_testcase { /** * test_from_string() data provider. */ - public function from_string_provider() { + public static function from_string_provider(): array { return [ 'wrong type' => [ @@ -276,7 +276,7 @@ class phpunit_dataset_test extends advanced_testcase { /** * test_from_array() data provider. */ - public function from_array_provider() { + public static function from_array_provider(): array { return [ 'repeated array table many structures' => [ 'structure' => [ @@ -425,7 +425,7 @@ class phpunit_dataset_test extends advanced_testcase { /** * test_load_csv() data provider. */ - public function load_csv_provider() { + public static function load_csv_provider(): array { return [ 'repeated csv table many files' => [ @@ -516,7 +516,7 @@ class phpunit_dataset_test extends advanced_testcase { /** * test_load_xml() data provider. */ - public function load_xml_provider() { + public static function load_xml_provider(): array { return [ 'repeated xml table multiple files' => [ @@ -687,7 +687,7 @@ class phpunit_dataset_test extends advanced_testcase { /** * test_to_database() data provider. */ - public function to_database_provider() { + public static function to_database_provider(): array { return [ 'wrong table requested' => [ @@ -842,7 +842,7 @@ class phpunit_dataset_test extends advanced_testcase { /** * test_get_rows() data provider. */ - public function get_rows_provider() { + public static function get_rows_provider(): array { return [ 'wrong table requested' => [ diff --git a/lib/phpunit/tests/util_test.php b/lib/phpunit/tests/util_test.php index 4676e4177a3..54c54462523 100644 --- a/lib/phpunit/tests/util_test.php +++ b/lib/phpunit/tests/util_test.php @@ -36,7 +36,7 @@ class util_test extends \advanced_testcase { } } - public function set_table_modified_by_sql_provider() { + public static function set_table_modified_by_sql_provider(): array { global $DB; $prefix = $DB->get_prefix(); diff --git a/lib/table/tests/local/filter/filter_test.php b/lib/table/tests/local/filter/filter_test.php index 1b37f312894..0f93aada468 100644 --- a/lib/table/tests/local/filter/filter_test.php +++ b/lib/table/tests/local/filter/filter_test.php @@ -57,7 +57,7 @@ class filter_test extends advanced_testcase { * * @return array */ - public function constructor_provider(): array { + public static function constructor_provider(): array { return [ 'Name without values' => [['keyword'], filter::JOINTYPE_DEFAULT, []], 'Name with valid join type ANY' => [[ @@ -147,7 +147,7 @@ class filter_test extends advanced_testcase { * * @return array */ - public function constructor_invalid_join_provider(): array { + public static function constructor_invalid_join_provider(): array { return [ 'Too low' => [-1], 'Too high' => [4], @@ -255,7 +255,7 @@ class filter_test extends advanced_testcase { * * @return array */ - public function filter_value_provider(): array { + public static function filter_value_provider(): array { return [ 'Empty' => [[], 0], 'Single value' => [[10], 1], diff --git a/lib/table/tests/local/filter/integer_filter_test.php b/lib/table/tests/local/filter/integer_filter_test.php index caf0027155b..a42f873a725 100644 --- a/lib/table/tests/local/filter/integer_filter_test.php +++ b/lib/table/tests/local/filter/integer_filter_test.php @@ -91,7 +91,7 @@ class integer_filter_test extends advanced_testcase { * * @return array */ - public function add_filter_value_invalid_types_provider(): array { + public static function add_filter_value_invalid_types_provider(): array { return [ 'Null' => [null, 'NULL'], 'Empty string' => ['', 'string'], diff --git a/lib/table/tests/local/filter/numeric_comparison_filter_test.php b/lib/table/tests/local/filter/numeric_comparison_filter_test.php index af8ac564056..876bb5746ec 100644 --- a/lib/table/tests/local/filter/numeric_comparison_filter_test.php +++ b/lib/table/tests/local/filter/numeric_comparison_filter_test.php @@ -117,7 +117,7 @@ class numeric_comparison_filter_test extends advanced_testcase { * * @return array */ - public function add_filter_value_invalid_types_provider(): array { + public static function add_filter_value_invalid_types_provider(): array { return [ 'Null' => [ [null], diff --git a/lib/table/tests/local/filter/string_filter_test.php b/lib/table/tests/local/filter/string_filter_test.php index 7a092bb80e0..ecc3e587084 100644 --- a/lib/table/tests/local/filter/string_filter_test.php +++ b/lib/table/tests/local/filter/string_filter_test.php @@ -91,7 +91,7 @@ class string_filter_test extends advanced_testcase { * * @return array */ - public function add_filter_value_invalid_types_provider(): array { + public static function add_filter_value_invalid_types_provider(): array { return [ 'Null' => [null, 'NULL'], '1' => [1, 'integer'], diff --git a/lib/tests/accesslib_has_capability_test.php b/lib/tests/accesslib_has_capability_test.php index fda323e038a..92829f4733a 100644 --- a/lib/tests/accesslib_has_capability_test.php +++ b/lib/tests/accesslib_has_capability_test.php @@ -364,7 +364,7 @@ class accesslib_has_capability_test extends \advanced_testcase { * * @return array */ - public function locked_context_provider() { + public static function locked_context_provider(): array { return [ 'All unlocked' => [ 'locked' => [ @@ -447,7 +447,7 @@ class accesslib_has_capability_test extends \advanced_testcase { * * @return array */ - public function login_as_provider(): array { + public static function login_as_provider(): array { return [ [ 'system', diff --git a/lib/tests/accesslib_test.php b/lib/tests/accesslib_test.php index 03910611e93..d07ae89f1b9 100644 --- a/lib/tests/accesslib_test.php +++ b/lib/tests/accesslib_test.php @@ -2077,7 +2077,7 @@ class accesslib_test extends advanced_testcase { * * @return array */ - public function deprecated_capabilities_use_cases() { + public static function deprecated_capabilities_use_cases(): array { return [ 'capability missing' => [ 'fake/access:missingcapability', @@ -2895,7 +2895,7 @@ class accesslib_test extends advanced_testcase { get_enrolled_users($systemcontext, '', USERSWITHOUTGROUP); } - public function get_enrolled_sql_provider() { + public static function get_enrolled_sql_provider(): array { return array( array( // Two users who are enrolled. @@ -4348,7 +4348,7 @@ class accesslib_test extends advanced_testcase { * * @return array */ - public function get_get_with_capability_join_override_cases() { + public static function get_get_with_capability_join_override_cases(): array { return [ 'no overrides' => [true, []], 'one override' => [true, ['moodle/course:viewscales']], @@ -4550,7 +4550,7 @@ class accesslib_test extends advanced_testcase { * * @return array */ - public function is_parent_of_provider(): array { + public static function is_parent_of_provider(): array { $provideboth = function(string $desc, string $contextpath, string $testpath, bool $expected): array { return [ "includeself: true; {$desc}" => [ @@ -4653,7 +4653,7 @@ class accesslib_test extends advanced_testcase { * * @return array */ - public function is_child_of_provider(): array { + public static function is_child_of_provider(): array { $provideboth = function(string $desc, string $contextpath, string $testpath, bool $expected): array { return [ "includeself: true; {$desc}" => [ diff --git a/lib/tests/adminlib_test.php b/lib/tests/adminlib_test.php index cd60aced38c..aba43145b6d 100644 --- a/lib/tests/adminlib_test.php +++ b/lib/tests/adminlib_test.php @@ -35,7 +35,7 @@ class adminlib_test extends \advanced_testcase { * * @return array */ - public function db_should_replace_dataprovider() { + public static function db_should_replace_dataprovider(): array { return [ // Skipped tables. ['block_instances', '', false], @@ -86,7 +86,7 @@ class adminlib_test extends \advanced_testcase { * @covers ::db_should_replace * @return array */ - public function db_should_replace_additional_skip_tables_dataprovider() { + public static function db_should_replace_additional_skip_tables_dataprovider(): array { return [ // Skipped tables. ['block_instances', '', false], diff --git a/lib/tests/behat_lib_test.php b/lib/tests/behat_lib_test.php index fefaf4c3629..9b9f47375c7 100644 --- a/lib/tests/behat_lib_test.php +++ b/lib/tests/behat_lib_test.php @@ -77,7 +77,7 @@ class behat_lib_test extends advanced_testcase { * * @return array Array of values to test behat_is_requested_url() function. */ - public function url_provider() { + public static function url_provider(): array { return [ // Tests for common ports. ['http://behat.moodle.org', true, ['behat.moodle.org', 80, '']], diff --git a/lib/tests/client_test.php b/lib/tests/client_test.php index 2f6a7183847..e2249c03144 100644 --- a/lib/tests/client_test.php +++ b/lib/tests/client_test.php @@ -29,7 +29,7 @@ class client_test extends advanced_testcase { * * @return array */ - public function map_response_provider(): array { + public static function map_response_provider(): array { return [ "Nested objects syntax a-b-c syntax " => [ [ diff --git a/lib/tests/completionlib_test.php b/lib/tests/completionlib_test.php index 7c47d3441e1..902f25572e6 100644 --- a/lib/tests/completionlib_test.php +++ b/lib/tests/completionlib_test.php @@ -331,7 +331,7 @@ class completionlib_test extends advanced_testcase { * * @return array[] */ - public function internal_get_state_provider() { + public static function internal_get_state_provider(): array { return [ 'View required, but not viewed yet' => [ COMPLETION_VIEW_REQUIRED, 1, '', COMPLETION_INCOMPLETE @@ -392,7 +392,7 @@ class completionlib_test extends advanced_testcase { * * @return array */ - public function internal_get_state_with_grade_criteria_provider() { + public static function internal_get_state_with_grade_criteria_provider(): array { return [ "Passing grade enabled and achieve. State should be COMPLETION_COMPLETE_PASS" => [ [ @@ -701,7 +701,7 @@ class completionlib_test extends advanced_testcase { * * @return array[] */ - public function get_data_provider() { + public static function get_data_provider(): array { return [ 'No completion record' => [ false, true, false, COMPLETION_INCOMPLETE @@ -1600,7 +1600,7 @@ class completionlib_test extends advanced_testcase { * * @return array[] */ - public function get_grade_completion_provider() { + public static function get_grade_completion_provider(): array { return [ 'Grade not required' => [false, false, null, null, null], 'Grade required, but has no grade yet' => [true, false, null, null, COMPLETION_INCOMPLETE], diff --git a/lib/tests/component_test.php b/lib/tests/component_test.php index 3836a2f9b32..4e13f67d8e6 100644 --- a/lib/tests/component_test.php +++ b/lib/tests/component_test.php @@ -228,7 +228,7 @@ final class component_test extends advanced_testcase { * * @return array */ - public function is_valid_plugin_name_provider(): array { + public static function is_valid_plugin_name_provider(): array { return [ [['mod', 'example1'], true], [['mod', 'feedback360'], true], @@ -696,7 +696,7 @@ final class component_test extends advanced_testcase { /** * Data provider for classloader test */ - public function classloader_provider() { + public static function classloader_provider(): array { global $CFG; // As part of these tests, we Check that there are no unexpected problems with overlapping PSR namespaces. @@ -795,7 +795,7 @@ final class component_test extends advanced_testcase { /** * Data provider for psr_classloader test */ - public function psr_classloader_provider() { + public static function psr_classloader_provider(): array { global $CFG; // As part of these tests, we Check that there are no unexpected problems with overlapping PSR namespaces. @@ -968,7 +968,7 @@ final class component_test extends advanced_testcase { /** * Data provider for get_class_file test */ - public function get_class_file_provider() { + public static function get_class_file_provider(): array { global $CFG; return [ diff --git a/lib/tests/configonlylib_test.php b/lib/tests/configonlylib_test.php index 2bd8c8ca04d..5a9151faaa4 100644 --- a/lib/tests/configonlylib_test.php +++ b/lib/tests/configonlylib_test.php @@ -186,7 +186,7 @@ class configonlylib_test extends \advanced_testcase { * * @return array */ - public function min_is_revision_valid_and_current_provider(): array { + public static function min_is_revision_valid_and_current_provider(): array { return [ 'Negative value' => [-1, false], 'Empty value' => [0, false], diff --git a/lib/tests/core_renderer_template_exploit_test.php b/lib/tests/core_renderer_template_exploit_test.php index c003e52d8b8..94391f6c83b 100644 --- a/lib/tests/core_renderer_template_exploit_test.php +++ b/lib/tests/core_renderer_template_exploit_test.php @@ -30,7 +30,7 @@ class core_renderer_template_exploit_test extends \advanced_testcase { * text by the helper before being passed to other another helper. This prevents * nested calls to helpers. */ - public function get_template_testcases() { + public static function get_template_testcases(): array { // Different helper implementations to test various combinations of nested // calls to render the templates. $norender = function($text) { @@ -386,9 +386,10 @@ class core_renderer_template_exploit_test extends \advanced_testcase { } /** - * Test that the mustache_helper_collection class correctly strips - * @dataProvider get_template_testcases() - * @param string $templates The template to add + * Test that the mustache_helper_collection class correctly strips. + * + * @dataProvider get_template_testcases + * @param array $templates The template to add * @param string $torender The name of the template to render * @param array $context The template context * @param array $helpers Mustache helpers to add diff --git a/lib/tests/cronlib_test.php b/lib/tests/cronlib_test.php index bd77d3ba71b..94e6051cde5 100644 --- a/lib/tests/cronlib_test.php +++ b/lib/tests/cronlib_test.php @@ -21,6 +21,8 @@ defined('MOODLE_INTERNAL') || die(); global $CFG; require_once($CFG->libdir.'/cronlib.php'); +use stdClass; + /** * Unit tests for the cron. * @@ -29,14 +31,13 @@ require_once($CFG->libdir.'/cronlib.php'); * @copyright 2013 Tim Gusak * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class cronlib_test extends \basic_testcase { - +final class cronlib_test extends \basic_testcase { /** * Data provider for cron_delete_from_temp. * * @return array Provider data */ - public function cron_delete_from_temp_provider() { + public static function cron_delete_from_temp_provider(): array { global $CFG; $tmpdir = realpath($CFG->tempdir); @@ -50,45 +51,45 @@ class cronlib_test extends \basic_testcase { $nodes = array(); // Really old directory to remove. - $nodes[] = $this->generate_test_path('/dir1/dir1_1/dir1_1_1/dir1_1_1_1/', true, $lastweekstime * 52, false); + $nodes[] = self::generate_test_path('/dir1/dir1_1/dir1_1_1/dir1_1_1_1/', true, $lastweekstime * 52, false); // New Directory to keep. - $nodes[] = $this->generate_test_path('/dir1/dir1_2/', true, $time, true); + $nodes[] = self::generate_test_path('/dir1/dir1_2/', true, $time, true); // Directory a little less than 1 week old, keep. - $nodes[] = $this->generate_test_path('/dir2/', true, $afterlastweekstime, true); + $nodes[] = self::generate_test_path('/dir2/', true, $afterlastweekstime, true); // Directory older than 1 week old, remove. - $nodes[] = $this->generate_test_path('/dir3/', true, $beforelastweekstime, false); + $nodes[] = self::generate_test_path('/dir3/', true, $beforelastweekstime, false); // File older than 1 week old, remove. - $nodes[] = $this->generate_test_path('/dir1/dir1_1/dir1_1_1/file1_1_1_1', false, $beforelastweekstime, false); + $nodes[] = self::generate_test_path('/dir1/dir1_1/dir1_1_1/file1_1_1_1', false, $beforelastweekstime, false); // New File to keep. - $nodes[] = $this->generate_test_path('/dir1/dir1_1/dir1_1_1/file1_1_1_2', false, $time, true); + $nodes[] = self::generate_test_path('/dir1/dir1_1/dir1_1_1/file1_1_1_2', false, $time, true); // File older than 1 week old, remove. - $nodes[] = $this->generate_test_path('/dir1/dir1_2/file1_1_2_1', false, $beforelastweekstime, false); + $nodes[] = self::generate_test_path('/dir1/dir1_2/file1_1_2_1', false, $beforelastweekstime, false); // New file to keep. - $nodes[] = $this->generate_test_path('/dir1/dir1_2/file1_1_2_2', false, $time, true); + $nodes[] = self::generate_test_path('/dir1/dir1_2/file1_1_2_2', false, $time, true); // New file to keep. - $nodes[] = $this->generate_test_path('/file1', false, $time, true); + $nodes[] = self::generate_test_path('/file1', false, $time, true); // File older than 1 week, keep. - $nodes[] = $this->generate_test_path('/file2', false, $beforelastweekstime, false); + $nodes[] = self::generate_test_path('/file2', false, $beforelastweekstime, false); // Directory older than 1 week to keep. // Note: Since this directory contains a directory that contains a file that is also older than a week // the directory won't be deleted since it's mtime will be updated when the file is deleted. - $nodes[] = $this->generate_test_path('/dir4/dir4_1', true, $beforelastweekstime, true); + $nodes[] = self::generate_test_path('/dir4/dir4_1', true, $beforelastweekstime, true); - $nodes[] = $this->generate_test_path('/dir4/dir4_1/dir4_1_1/', true, $beforelastweekstime, true); + $nodes[] = self::generate_test_path('/dir4/dir4_1/dir4_1_1/', true, $beforelastweekstime, true); // File older than 1 week to remove. - $nodes[] = $this->generate_test_path('/dir4/dir4_1/dir4_1_1/file4_1_1_1', false, $beforelastweekstime, false); + $nodes[] = self::generate_test_path('/dir4/dir4_1/dir4_1_1/file4_1_1_1', false, $beforelastweekstime, false); $expectednodes = array(); foreach ($nodes as $node) { @@ -108,16 +109,10 @@ class cronlib_test extends \basic_testcase { } sort($expectednodes); - $data = array( - array( - $nodes, - $expectednodes - ), - array( - array(), - array() - ) - ); + $data = [ + [$nodes, $expectednodes], + [[], []], + ]; return $data; } @@ -130,13 +125,13 @@ class cronlib_test extends \basic_testcase { * @param int $time modified time of the node in epoch * @param bool $keep Should the node exist after the delete function has run */ - private function generate_test_path($path, $isdir = false, $time = 0, $keep = false) { - $node = new \stdClass(); - $node->path = $path; - $node->isdir = $isdir; - $node->time = $time; - $node->keep = $keep; - return $node; + private static function generate_test_path($path, $isdir = false, $time = 0, $keep = false): stdClass { + return (object) [ + 'path' => $path, + 'isdir' => $isdir, + 'time' => $time, + 'keep' => $keep, + ]; } /** * Test removing files and directories from tempdir. diff --git a/lib/tests/curl_security_helper_test.php b/lib/tests/curl_security_helper_test.php index aa88abd7e99..f76c9928953 100644 --- a/lib/tests/curl_security_helper_test.php +++ b/lib/tests/curl_security_helper_test.php @@ -62,7 +62,7 @@ class curl_security_helper_test extends \advanced_testcase { * * @return array */ - public function curl_security_url_data_provider() { + public static function curl_security_url_data_provider(): array { $simpledns = ['localhost' => ['127.0.0.1']]; $multiplerecorddns = [ 'sub.example.com' => ['1.2.3.4', '5.6.7.8'] @@ -180,7 +180,7 @@ class curl_security_helper_test extends \advanced_testcase { * * @return array */ - public function curl_security_settings_data_provider() { + public static function curl_security_settings_data_provider(): array { // Format: blocked hosts, allowed ports, expected result. return [ ["", "", false], @@ -212,7 +212,7 @@ class curl_security_helper_test extends \advanced_testcase { * * @return array */ - public function curl_security_host_data_provider() { + public static function curl_security_host_data_provider(): array { return [ // IPv4 hosts. ["127.0.0.1", "127.0.0.1", true], @@ -266,7 +266,7 @@ class curl_security_helper_test extends \advanced_testcase { * * @return array */ - public function curl_security_port_data_provider() { + public static function curl_security_port_data_provider(): array { return [ ["", "80\n443", true], [" ", "80\n443", true], diff --git a/lib/tests/datalib_test.php b/lib/tests/datalib_test.php index 9f36dd925f1..32e1d948ed6 100644 --- a/lib/tests/datalib_test.php +++ b/lib/tests/datalib_test.php @@ -900,7 +900,7 @@ class datalib_test extends \advanced_testcase { * * @return array */ - public function get_safe_orderby_provider(): array { + public static function get_safe_orderby_provider(): array { $orderbymap = [ 'courseid' => 'c.id', 'somecustomvalue' => 'c.startdate, c.shortname', @@ -988,7 +988,7 @@ class datalib_test extends \advanced_testcase { * * @return array */ - public function get_safe_orderby_multiple_provider(): array { + public static function get_safe_orderby_multiple_provider(): array { $orderbymap = [ 'courseid' => 'c.id', 'firstname' => 'u.firstname', diff --git a/lib/tests/date_test.php b/lib/tests/date_test.php index 74060fbe07e..5fe2fa7e7f2 100644 --- a/lib/tests/date_test.php +++ b/lib/tests/date_test.php @@ -386,7 +386,7 @@ class date_test extends advanced_testcase { $this->assertSame('Etc/GMT-1', date_default_timezone_get()); } - public function legacyUserTimezoneProvider() { + public static function legacyUserTimezoneProvider(): array { return [ ['', 'Australia/Perth'], // Fallback on default timezone. ['-13.0', 'Australia/Perth'], // Fallback on default timezone. diff --git a/lib/tests/encryption_test.php b/lib/tests/encryption_test.php index 7fc05634885..eacd65f0ac8 100644 --- a/lib/tests/encryption_test.php +++ b/lib/tests/encryption_test.php @@ -74,8 +74,10 @@ class encryption_test extends \basic_testcase { * * @return array[] Array of method options for test */ - public function encryption_method_provider(): array { - return ['Sodium' => [encryption::METHOD_SODIUM], 'OpenSSL' => [encryption::METHOD_OPENSSL]]; + public static function encryption_method_provider(): array { + return [ + 'Sodium' => [encryption::METHOD_SODIUM], + ]; } /** diff --git a/lib/tests/external/output/icon_system/load_fontawesome_map_test.php b/lib/tests/external/output/icon_system/load_fontawesome_map_test.php index 5e970a42f4b..0b5072d63de 100644 --- a/lib/tests/external/output/icon_system/load_fontawesome_map_test.php +++ b/lib/tests/external/output/icon_system/load_fontawesome_map_test.php @@ -89,7 +89,7 @@ class load_fontawesome_map_test extends externallib_advanced_testcase { * * @return array */ - public function valid_fontawesome_theme_provider(): array { + public static function valid_fontawesome_theme_provider(): array { return [ 'Boost theme' => ['boost'], 'Classic theme (extends boost)' => ['classic'], diff --git a/lib/tests/external/record_userfeedback_action_test.php b/lib/tests/external/record_userfeedback_action_test.php index fa99bebe79d..758dbc7916f 100644 --- a/lib/tests/external/record_userfeedback_action_test.php +++ b/lib/tests/external/record_userfeedback_action_test.php @@ -48,7 +48,7 @@ class record_userfeedback_action_test extends externallib_advanced_testcase { * * @return array */ - public function record_userfeedback_action_provider() { + public static function record_userfeedback_action_provider(): array { return [ 'give action' => ['give'], 'remind action' => ['remind'], diff --git a/lib/tests/filestorage_zip_archive_test.php b/lib/tests/filestorage_zip_archive_test.php index 06eb9db2fed..681127ce36c 100644 --- a/lib/tests/filestorage_zip_archive_test.php +++ b/lib/tests/filestorage_zip_archive_test.php @@ -55,7 +55,7 @@ class filestorage_zip_archive_test extends \advanced_testcase { * * @return array Array of tested pathnames and expected results. */ - public function pathname_provider() { + public static function pathname_provider(): array { return [ // Test a string. ['my file.pdf', 'my file.pdf'], diff --git a/lib/tests/gradelib_test.php b/lib/tests/gradelib_test.php index 9c4d1d8ce66..0bb9fa7f437 100644 --- a/lib/tests/gradelib_test.php +++ b/lib/tests/gradelib_test.php @@ -188,7 +188,7 @@ class gradelib_test extends \advanced_testcase { * * @return array */ - public function grade_get_date_for_user_grade_provider(): array { + public static function grade_get_date_for_user_grade_provider(): array { $u1 = (object) [ 'id' => 42, ]; diff --git a/lib/tests/graphlib_test.php b/lib/tests/graphlib_test.php index a8838cebc64..e8b307b9898 100644 --- a/lib/tests/graphlib_test.php +++ b/lib/tests/graphlib_test.php @@ -36,7 +36,7 @@ class graphlib_test extends \basic_testcase { * * @return array */ - public function create_data(): array { + public static function create_data(): array { return [ 'data' => [ diff --git a/lib/tests/htmlpurifier_test.php b/lib/tests/htmlpurifier_test.php index c047044f031..6d5ddd6f034 100644 --- a/lib/tests/htmlpurifier_test.php +++ b/lib/tests/htmlpurifier_test.php @@ -353,7 +353,7 @@ class htmlpurifier_test extends \basic_testcase { /** * Test cases for the test_media_tags test. */ - public function media_tags_provider() { + public static function media_tags_provider(): array { // Takes an array of attributes, then generates a test for each of them. $generatetestcases = function($prefix, array $attrs, array $templates) { return array_reduce($attrs, function($carry, $attr) use ($prefix, $templates) { diff --git a/lib/tests/ip_utils_test.php b/lib/tests/ip_utils_test.php index f189857607d..c177c22bc62 100644 --- a/lib/tests/ip_utils_test.php +++ b/lib/tests/ip_utils_test.php @@ -41,7 +41,7 @@ class ip_utils_test extends \basic_testcase { * * @return array */ - public function domain_name_data_provider() { + public static function domain_name_data_provider(): array { return [ ["com", true], ["i.net", true], // Single char, alpha tertiary domain. @@ -91,7 +91,7 @@ class ip_utils_test extends \basic_testcase { * * @return array */ - public function domain_matching_patterns_data_provider() { + public static function domain_matching_patterns_data_provider(): array { return [ ["*.com", true], ["*.example.com", true], @@ -136,7 +136,7 @@ class ip_utils_test extends \basic_testcase { * * @return array */ - public function ip_address_data_provider() { + public static function ip_address_data_provider(): array { return [ ["127.0.0.1", true], ["10.1", false], @@ -183,7 +183,7 @@ class ip_utils_test extends \basic_testcase { * * @return array */ - public function ipv4_address_data_provider() { + public static function ipv4_address_data_provider(): array { return [ ["127.0.0.1", true], ["0.0.0.0", true], @@ -219,7 +219,7 @@ class ip_utils_test extends \basic_testcase { * * @return array */ - public function ipv4_range_data_provider() { + public static function ipv4_range_data_provider(): array { return [ ["127.0.0.1/24", true], ["127.0.0.20-20", true], @@ -260,7 +260,7 @@ class ip_utils_test extends \basic_testcase { * * @return array */ - public function ipv6_address_data_provider() { + public static function ipv6_address_data_provider(): array { return [ ["::", true], ["::0", true], @@ -300,7 +300,7 @@ class ip_utils_test extends \basic_testcase { * * @return array */ - public function ipv6_range_data_provider() { + public static function ipv6_range_data_provider(): array { return [ ["::/128", true], ["::1/128", true], @@ -352,7 +352,7 @@ class ip_utils_test extends \basic_testcase { * * @return array */ - public function data_domain_addresses() { + public static function data_domain_addresses(): array { return [ [true, 'example.com'], [true, 'ExAmPle.com'], @@ -378,7 +378,7 @@ class ip_utils_test extends \basic_testcase { * * @return array */ - public function data_is_ip_in_subnet_list() { + public static function data_is_ip_in_subnet_list(): array { return [ [true, '1.1.1.1', '1.1.1.1', "\n"], [false, '1.1.1.1', '2.2.2.2', "\n"], diff --git a/lib/tests/ldaplib_test.php b/lib/tests/ldaplib_test.php index c0e33b1bd3f..5da201b74bb 100644 --- a/lib/tests/ldaplib_test.php +++ b/lib/tests/ldaplib_test.php @@ -184,7 +184,7 @@ class ldaplib_test extends \advanced_testcase { * * @return array of testcases. */ - public function ldap_normalise_objectclass_provider() { + public static function ldap_normalise_objectclass_provider(): array { return array( 'Empty value' => array( array(null), diff --git a/lib/tests/modinfolib_test.php b/lib/tests/modinfolib_test.php index fbd2ed54278..6e72a0ed885 100644 --- a/lib/tests/modinfolib_test.php +++ b/lib/tests/modinfolib_test.php @@ -978,7 +978,7 @@ class modinfolib_test extends advanced_testcase { * * @return array */ - public function get_section_info_by_id_provider() { + public static function get_section_info_by_id_provider(): array { return [ 'Valid section id' => [ 'sectionnum' => 1, diff --git a/lib/tests/moodle_page_test.php b/lib/tests/moodle_page_test.php index 94b4a88ae06..87e007f47fc 100644 --- a/lib/tests/moodle_page_test.php +++ b/lib/tests/moodle_page_test.php @@ -330,7 +330,7 @@ class moodle_page_test extends \advanced_testcase { * * @return array */ - public function set_title_provider(): array { + public static function set_title_provider(): array { return [ 'Do not append the site name' => [ 'shortname', false, '', false @@ -780,7 +780,7 @@ class moodle_page_test extends \advanced_testcase { * * @return array */ - public function get_user_theme_provider() { + public static function get_user_theme_provider(): array { return [ 'User not a member of any cohort' => [ 'usertheme' => '', diff --git a/lib/tests/moodle_url_test.php b/lib/tests/moodle_url_test.php index 61b39455e64..a71a0007ccf 100644 --- a/lib/tests/moodle_url_test.php +++ b/lib/tests/moodle_url_test.php @@ -341,7 +341,7 @@ class moodle_url_test extends \advanced_testcase { * * @return array[] */ - public function make_pluginfile_url_provider() { + public static function make_pluginfile_url_provider(): array { $baseurl = "https://www.example.com/moodle/pluginfile.php"; $tokenbaseurl = "https://www.example.com/moodle/tokenpluginfile.php"; return [ diff --git a/lib/tests/moodlelib_test.php b/lib/tests/moodlelib_test.php index 081adc996c0..6408f15970a 100644 --- a/lib/tests/moodlelib_test.php +++ b/lib/tests/moodlelib_test.php @@ -1102,7 +1102,7 @@ final class moodlelib_test extends \advanced_testcase { * * @return array of ($filename, $length, $expected, $includehash) */ - public function shorten_filename_provider() { + public static function shorten_filename_provider(): array { $filename = 'sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium totam rem'; $shortfilename = 'sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque'; @@ -1205,7 +1205,7 @@ final class moodlelib_test extends \advanced_testcase { * * @return array of ($filename, $length, $expected, $includehash) */ - public function shorten_filenames_provider() { + public static function shorten_filenames_provider(): array { $shortfilename = 'sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque'; $longfilename = 'sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium totam rem'; $extfilename = $longfilename.'.zip'; @@ -3327,7 +3327,7 @@ EOF; /** * A data provider for testing email messageid */ - public function generate_email_messageid_provider() { + public static function generate_email_messageid_provider(): array { return array( 'nopath' => array( 'wwwroot' => 'http://www.example.com', @@ -3394,7 +3394,7 @@ EOF; /** * A data provider for testing email diversion */ - public function diverted_emails_provider() { + public static function diverted_emails_provider(): array { return array( 'nodiverts' => array( 'divertallemailsto' => null, @@ -3599,7 +3599,7 @@ EOF; * * @return array */ - public function email_to_user_attachment_provider(): array { + public static function email_to_user_attachment_provider(): array { global $CFG; // Return all paths that can be used to send attachments from. @@ -3972,7 +3972,7 @@ EOF; * * @return array of test cases. */ - public function count_words_testcases(): array { + public static function count_words_testcases(): array { // Copy-pasting example from MDL-64240. $copypasted = <<Snoot is booped

@@ -4047,7 +4047,7 @@ EOT; * * @return array of test cases. */ - public function count_letters_testcases(): array { + public static function count_letters_testcases(): array { return [ [0, ''], [1, 'x'], @@ -4257,7 +4257,7 @@ EOT; /** * Data provider for private ips. */ - public function data_private_ips() { + public static function data_private_ips(): array { return array( array('10.0.0.0'), array('172.16.0.0'), @@ -4282,7 +4282,7 @@ EOT; /** * Data provider for public ips. */ - public function data_public_ips() { + public static function data_public_ips(): array { return array( array('2400:cb00:2048:1::8d65:71b3'), array('2400:6180:0:d0::1b:2001'), @@ -4335,7 +4335,7 @@ EOT; * * @return array Returns an array of test data for the above function. */ - public function data_can_send_from_real_email_address() { + public static function data_can_send_from_real_email_address(): array { return [ // Test from email is in allowed domain. // Test that from display is set to show no one. @@ -4481,7 +4481,7 @@ EOT; * * @return array Returns an array of test data for the above function. */ - public function data_email_is_not_allowed_for_allowemailaddresses() { + public static function data_email_is_not_allowed_for_allowemailaddresses(): array { return [ // Test allowed domain empty list. [ @@ -4560,7 +4560,7 @@ EOT; * * @return array Returns an array of test data for the above function. */ - public function data_email_is_not_allowed_for_denyemailaddresses() { + public static function data_email_is_not_allowed_for_denyemailaddresses(): array { return [ // Test denied domain empty list. [ @@ -4738,7 +4738,7 @@ EOT; * * @return array */ - public function component_class_callback_default_provider() { + public static function component_class_callback_default_provider(): array { return [ 'null' => [null], 'empty string' => [''], @@ -4754,7 +4754,7 @@ EOT; * * @return array */ - public function component_class_callback_data_provider() { + public static function component_class_callback_data_provider(): array { return [ 'empty string' => [''], 'string' => ['This is a string'], @@ -4769,7 +4769,7 @@ EOT; * * @return array */ - public function component_class_callback_multiple_params_provider() { + public static function component_class_callback_multiple_params_provider(): array { return [ 'empty array' => [ [], @@ -4814,7 +4814,7 @@ EOT; * * @return array of (string)case => [(mixed)callable, (string|bool)expected description] */ - public function callable_names_provider() { + public static function callable_names_provider(): array { return [ 'integer' => [ 386, @@ -4832,10 +4832,6 @@ EOT; ['my_foobar_class', 'my_foobar_method'], 'my_foobar_class::my_foobar_method', ], - 'static_method_of_object' => [ - [$this, 'my_foobar_method'], - 'core\moodlelib_test::my_foobar_method', - ], 'method_of_object' => [ [new lang_string('parentlanguage', 'core_langconfig'), 'my_foobar_method'], 'lang_string::my_foobar_method', @@ -4851,12 +4847,19 @@ EOT; ]; } + /** + * Test that get_callable_name works with a static method on an instance. + */ + public function test_get_callable_name_this(): void { + $this->assertSame('core\moodlelib_test::foo', get_callable_name([$this, 'foo'])); + } + /** * Data provider for \core_moodlelib_testcase::test_get_complete_user_data(). * * @return array */ - public function user_data_provider() { + public static function user_data_provider(): array { return [ 'Fetch data using a valid username' => [ 'username', 's1', true @@ -4987,7 +4990,7 @@ EOT; /** * Data provider for the test_get_time_interval_string() method. */ - public function get_time_interval_string_provider() { + public static function get_time_interval_string_provider(): array { return [ 'Time is after the reference time by 1 minute, omitted format' => [ 'time1' => 12345660, @@ -5114,7 +5117,7 @@ EOT; * * @return array of ($size, $expected) */ - public function display_size_provider() { + public static function display_size_provider(): array { return [ [0, '0 bytes'], @@ -5156,7 +5159,7 @@ EOT; * * @return array of ($size, $units, $expected) */ - public function display_size_fixed_provider(): array { + public static function display_size_fixed_provider(): array { return [ [0, 'KB', '0.0 KB'], [1, 'MB', '0.0 MB'], @@ -5186,7 +5189,7 @@ EOT; * * @return array of ($size, $decimalplaces, $units, $expected) */ - public function display_size_dp_provider(): array { + public static function display_size_dp_provider(): array { return [ [0, 1, 'KB', '0.0 KB'], [1, 6, 'MB', '0.000001 MB'], @@ -5232,7 +5235,7 @@ EOT; * * @return array */ - public function get_list_of_plugins_provider(): array { + public static function get_list_of_plugins_provider(): array { return [ 'Standard excludes' => [ ['amdd', 'class', 'local', 'test'], @@ -5532,7 +5535,7 @@ EOT; * * @return array of test cases. */ - public function is_proxybypass_provider(): array { + public static function is_proxybypass_provider(): array { return [ 'Proxybypass contains the same IP as the beginning of the URL' => [ diff --git a/lib/tests/myprofilelib_test.php b/lib/tests/myprofilelib_test.php index 04a96be0609..7e4c8cdef0c 100644 --- a/lib/tests/myprofilelib_test.php +++ b/lib/tests/myprofilelib_test.php @@ -229,7 +229,7 @@ class myprofilelib_test extends \advanced_testcase { * * @return array[] */ - public function core_myprofile_navigation_contact_timezone_provider(): array { + public static function core_myprofile_navigation_contact_timezone_provider(): array { return [ 'Hidden field' => ['timezone', '99', '99', null], 'Forced timezone' => ['', 'Europe/London', 'Pacific/Tahiti', 'Europe/London'], diff --git a/lib/tests/navigation/output/primary_test.php b/lib/tests/navigation/output/primary_test.php index 33b82783dff..374efb3b62c 100644 --- a/lib/tests/navigation/output/primary_test.php +++ b/lib/tests/navigation/output/primary_test.php @@ -113,7 +113,7 @@ class primary_test extends \advanced_testcase { * * @return array */ - public function primary_export_provider(): array { + public static function primary_export_provider(): array { return [ "Export the menu data when: custom menu exists; multiple langs installed; user is not logged in." => [ true, true, '', ['mobileprimarynav', 'moremenu', 'lang', 'user'] @@ -180,7 +180,7 @@ class primary_test extends \advanced_testcase { * * @return array */ - public function custom_menu_provider(): array { + public static function custom_menu_provider(): array { return [ 'Simple custom menu' => [ "Course search|/course/search.php diff --git a/lib/tests/navigation/views/primary_test.php b/lib/tests/navigation/views/primary_test.php index 2551a9031b6..b28cee7a78f 100644 --- a/lib/tests/navigation/views/primary_test.php +++ b/lib/tests/navigation/views/primary_test.php @@ -59,7 +59,7 @@ class primary_test extends \advanced_testcase { /** * Data provider for the test_setting_initialise function */ - public function setting_initialise_provider() { + public static function setting_initialise_provider(): array { return [ 'Testing as a guest user' => ['guest', ['home']], 'Testing as an admin' => ['admin', ['home', 'myhome', 'mycourses', 'siteadminnode']], @@ -153,7 +153,7 @@ class primary_test extends \advanced_testcase { * * @return array */ - public function search_and_set_active_node_provider(): array { + public static function search_and_set_active_node_provider(): array { return [ 'Test by activating node which is part of the tree' => ['tenthchild', 'tenthchild'], diff --git a/lib/tests/navigation/views/secondary_test.php b/lib/tests/navigation/views/secondary_test.php index e25e995d2f2..55f98d2d32c 100644 --- a/lib/tests/navigation/views/secondary_test.php +++ b/lib/tests/navigation/views/secondary_test.php @@ -74,7 +74,7 @@ class secondary_test extends \advanced_testcase { * Data provider for test_get_leaf_nodes * @return array */ - public function leaf_nodes_order_provider(): array { + public static function leaf_nodes_order_provider(): array { return [ 'Initialise the order with whole numbers' => [3, 2, 1], 'Initialise the order with a mix of whole and float numbers' => [2.1, 2, 1], @@ -140,7 +140,7 @@ class secondary_test extends \advanced_testcase { * Data provider for the test_setting_initialise function * @return array */ - public function setting_initialise_provider(): array { + public static function setting_initialise_provider(): array { return [ 'Testing in a course context' => ['course', 'coursehome', 'courseheader', 'Course'], 'Testing in a course context using a single activity course format' => @@ -233,7 +233,7 @@ class secondary_test extends \advanced_testcase { * * @return array */ - public function active_node_scan_provider(): array { + public static function active_node_scan_provider(): array { return [ 'Test by activating node adjacent to root node' => ['firstchild', 'firstchild'], @@ -292,7 +292,7 @@ class secondary_test extends \advanced_testcase { * * @return array */ - public function force_nodes_into_more_menu_provider(): array { + public static function force_nodes_into_more_menu_provider(): array { return [ 'The total number of navigation nodes exceeds the max display limit (5); ' . 'navnode2 and navnode4 are forced into "more" menu by default.' => @@ -476,7 +476,7 @@ class secondary_test extends \advanced_testcase { * * @return \string[][] */ - public function nodes_match_current_url_provider(): array { + public static function nodes_match_current_url_provider(): array { return [ "Match url to a node that is a deep nested" => [ '/view/course.php', @@ -534,7 +534,7 @@ class secondary_test extends \advanced_testcase { * * @return array[] */ - public function get_menu_array_provider(): array { + public static function get_menu_array_provider(): array { return [ "Fetch information from a node with action and no children" => [ 'child1', @@ -640,7 +640,7 @@ class secondary_test extends \advanced_testcase { * * @return array */ - public function get_node_with_first_action_provider(): array { + public static function get_node_with_first_action_provider(): array { return [ "Search for action when parent has no action and multiple children with actions" => [ "child3", @@ -700,7 +700,7 @@ class secondary_test extends \advanced_testcase { * * @return array */ - public function add_external_nodes_to_secondary_provider() { + public static function add_external_nodes_to_secondary_provider(): array { return [ "Container node with internal action and external children" => [ [ @@ -870,7 +870,7 @@ class secondary_test extends \advanced_testcase { * * @return string[] */ - public function get_overflow_menu_data_provider(): array { + public static function get_overflow_menu_data_provider(): array { return [ "Active node is the course home node" => [ '/coursehome.php', @@ -936,7 +936,7 @@ class secondary_test extends \advanced_testcase { * * @return array Provider information. */ - public function get_overflow_menu_data_course_admin_provider(): array { + public static function get_overflow_menu_data_course_admin_provider(): array { return [ "Backup page returns overflow" => [ '/backup/backup.php', diff --git a/lib/tests/navigationlib_test.php b/lib/tests/navigationlib_test.php index 3b75dabddf8..8a22c3f6bd5 100644 --- a/lib/tests/navigationlib_test.php +++ b/lib/tests/navigationlib_test.php @@ -588,7 +588,7 @@ class navigationlib_test extends \advanced_testcase { * * @return array */ - public function set_force_into_more_menu_provider(): array { + public static function set_force_into_more_menu_provider(): array { return [ 'Navigation node without any children nodes; Force into "more" menu => true.' => [ @@ -625,7 +625,7 @@ class navigationlib_test extends \advanced_testcase { * * @return array */ - public function is_action_link_provider(): array { + public static function is_action_link_provider(): array { return [ 'The navigation node has an action link.' => [ @@ -678,7 +678,7 @@ class navigationlib_test extends \advanced_testcase { * * @return array */ - public function action_link_actions_provider(): array { + public static function action_link_actions_provider(): array { return [ 'The navigation node has an action link with an action attached.' => [ diff --git a/lib/tests/oauth2_test.php b/lib/tests/oauth2_test.php index b54766439ff..873ceda8526 100644 --- a/lib/tests/oauth2_test.php +++ b/lib/tests/oauth2_test.php @@ -119,7 +119,7 @@ class oauth2_test extends \advanced_testcase { * * @return array */ - public function system_oauth_client_provider() { + public static function system_oauth_client_provider(): array { return [ [ (object) [ @@ -306,7 +306,7 @@ class oauth2_test extends \advanced_testcase { * * @return array */ - public function create_endpoints_for_standard_issuer_provider(): array { + public static function create_endpoints_for_standard_issuer_provider(): array { return [ 'Google' => [ 'type' => 'google', @@ -449,7 +449,7 @@ class oauth2_test extends \advanced_testcase { * * @return array */ - public function create_custom_profile_fields(): array { + public static function create_custom_profile_fields(): array { return [ 'data' => [ diff --git a/lib/tests/output/activity_header_test.php b/lib/tests/output/activity_header_test.php index aa9717c2176..588dca4c2e0 100644 --- a/lib/tests/output/activity_header_test.php +++ b/lib/tests/output/activity_header_test.php @@ -60,7 +60,7 @@ class activity_header_test extends \advanced_testcase { * Provider for the test_set_title unit test. * @return array */ - public function set_title_provider(): array { + public static function set_title_provider(): array { return [ "Set the title with a plain text" => [ "Activity title", "Activity title" @@ -129,7 +129,7 @@ class activity_header_test extends \advanced_testcase { * * @return array[] */ - public function get_heading_level_provider(): array { + public static function get_heading_level_provider(): array { return [ 'Title not allowed' => [false, '', 2], 'Title allowed, no title' => [true, '', 2], diff --git a/lib/tests/output/icon_system_test.php b/lib/tests/output/icon_system_test.php index 6d83c67e725..45056b9ba2d 100644 --- a/lib/tests/output/icon_system_test.php +++ b/lib/tests/output/icon_system_test.php @@ -160,7 +160,7 @@ class icon_system_test extends advanced_testcase { * * @return array */ - public function icon_system_provider(): array { + public static function icon_system_provider(): array { return [ 'icon_system => icon_system_standard' => [ icon_system::class, @@ -211,8 +211,8 @@ class icon_system_test extends advanced_testcase { * * @return array */ - public function is_valid_subsystem_provider(): array { - return $this->icon_system_provider(); + public static function is_valid_subsystem_provider(): array { + return self::icon_system_provider(); } /** @@ -220,9 +220,9 @@ class icon_system_test extends advanced_testcase { * * @return array */ - public function invalid_instance_provider(): array { + public static function invalid_instance_provider(): array { return array_filter( - $this->icon_system_provider(), + self::icon_system_provider(), function($data) { return !$data[2]; }, @@ -235,9 +235,9 @@ class icon_system_test extends advanced_testcase { * * @return array */ - public function valid_instance_provider(): array { + public static function valid_instance_provider(): array { return array_filter( - $this->icon_system_provider(), + self::icon_system_provider(), function($data) { return $data[2]; }, diff --git a/lib/tests/output/language_menu_test.php b/lib/tests/output/language_menu_test.php index 7587227f8f3..d8b3e10c5bf 100644 --- a/lib/tests/output/language_menu_test.php +++ b/lib/tests/output/language_menu_test.php @@ -101,7 +101,7 @@ class language_menu_test extends \advanced_testcase { * * @return array */ - public function get_lang_menu_provider(): array { + public static function get_lang_menu_provider(): array { return [ 'Lang menu with only the current language' => [ false, 'en', [] diff --git a/lib/tests/output/mustache_helper_collection_test.php b/lib/tests/output/mustache_helper_collection_test.php index c8b6773e2db..e27a1ca6e44 100644 --- a/lib/tests/output/mustache_helper_collection_test.php +++ b/lib/tests/output/mustache_helper_collection_test.php @@ -31,7 +31,7 @@ class mustache_helper_collection_test extends \advanced_testcase { * text by the helper before being passed to other another helper. This prevents * nested calls to helpers. */ - public function get_strip_disallowed_helpers_testcases() { + public static function get_strip_disallowed_helpers_testcases(): array { return [ 'no disallowed' => [ 'disallowed' => [], @@ -123,7 +123,7 @@ class mustache_helper_collection_test extends \advanced_testcase { /** * Test that the mustache_helper_collection class correctly strips - * @dataProvider get_strip_disallowed_helpers_testcases() + * @dataProvider get_strip_disallowed_helpers_testcases * @param string[] $disallowed The list of helpers to strip * @param string $input The input string for the helper * @param string $expected The expected output of the string after disallowed strip diff --git a/lib/tests/output/mustache_template_finder_test.php b/lib/tests/output/mustache_template_finder_test.php index ce270719439..c9492a3c9b7 100644 --- a/lib/tests/output/mustache_template_finder_test.php +++ b/lib/tests/output/mustache_template_finder_test.php @@ -35,7 +35,7 @@ class mustache_template_finder_test extends \advanced_testcase { * * @return array */ - public function valid_template_directories_provider(): array { + public static function valid_template_directories_provider(): array { return [ 'plugin: mod_assign' => [ 'component' => 'mod_assign', @@ -111,7 +111,7 @@ class mustache_template_finder_test extends \advanced_testcase { * * @return array */ - public function valid_template_filepath_provider(): array { + public static function valid_template_filepath_provider(): array { return [ 'Standard core template' => [ 'template' => 'core/modal', diff --git a/lib/tests/output/mustache_template_source_loader_test.php b/lib/tests/output/mustache_template_source_loader_test.php index a3fabdd007d..5e753b4f6cf 100644 --- a/lib/tests/output/mustache_template_source_loader_test.php +++ b/lib/tests/output/mustache_template_source_loader_test.php @@ -134,13 +134,13 @@ TBC; /** * Data provider for the test_load function. */ - public function load_test_cases() { + public static function load_test_cases(): array { $cache = [ 'core' => [ 'test' => '{{! a comment }}The rest of the template' ] ]; - $loader = $this->build_loader_from_static_cache($cache); + $loader = self::build_loader_from_static_cache($cache); return [ 'with comments' => [ @@ -177,7 +177,7 @@ TBC; /** * Data provider for the load_with_dependencies function. */ - public function load_with_dependencies_test_cases() { + public static function load_with_dependencies_test_cases(): array { // Create a bunch of templates that include one another in various ways. There is // multiple instances of recursive inclusions to test that the code doensn't get // stuck in an infinite loop. @@ -205,7 +205,7 @@ TBC; 'bim' => $bim ] ]; - $loader = $this->build_loader_from_static_cache($cache); + $loader = self::build_loader_from_static_cache($cache); return [ 'no template includes w comments' => [ @@ -344,7 +344,7 @@ TBC; /** * Data provider for the test_load function. */ - public function scan_template_source_for_dependencies_test_cases() { + public static function scan_template_source_for_dependencies_test_cases(): array { $foo = '{{! a comment }}{{> core/bar }}{{< test/bop }}{{/ test/bop}}{{#str}} help, core {{/str}}'; $bar = '{{! a comment }}{{> core/baz }}'; $baz = '{{! a comment }}{{#str}} hide, core {{/str}}'; @@ -388,7 +388,7 @@ TEMPLATE; 'multiline5' => $multiline5, ] ]; - $loader = $this->build_loader_from_static_cache($cache); + $loader = self::build_loader_from_static_cache($cache); return [ 'single template include' => [ @@ -488,7 +488,7 @@ TEMPLATE; /** * Test the scan_template_source_for_dependencies function. * - * @dataProvider scan_template_source_for_dependencies_test_cases() + * @dataProvider scan_template_source_for_dependencies_test_cases * @param mustache_template_source_loader $loader The loader * @param string $source The template to test * @param string $expected The expected output @@ -510,7 +510,7 @@ TEMPLATE; * @param array $cache A cache of templates * @return mustache_template_source_loader */ - private function build_loader_from_static_cache(array $cache) : mustache_template_source_loader { + private static function build_loader_from_static_cache(array $cache): mustache_template_source_loader { return new mustache_template_source_loader(function($component, $name, $themename) use ($cache) { return $cache[$component][$name]; }); diff --git a/lib/tests/output/participants_action_bar_test.php b/lib/tests/output/participants_action_bar_test.php index 6a1468ec556..fb3e1c5a09b 100644 --- a/lib/tests/output/participants_action_bar_test.php +++ b/lib/tests/output/participants_action_bar_test.php @@ -69,7 +69,7 @@ class participants_action_bar_test extends \advanced_testcase { * Provider for test_get_content_for_select * @return array[] */ - public function get_content_for_select_provider() { + public static function get_content_for_select_provider(): array { return [ 'Get dropdown content when in a course context' => [ 'course', 3, ['Enrolments', 'Groups', 'Permissions'] diff --git a/lib/tests/outputcomponents_test.php b/lib/tests/outputcomponents_test.php index caacd08bd36..da1116dfb44 100644 --- a/lib/tests/outputcomponents_test.php +++ b/lib/tests/outputcomponents_test.php @@ -678,7 +678,7 @@ EOF; * * @return array */ - public function block_contents_is_fake_provider() { + public static function block_contents_is_fake_provider(): array { return [ 'Null' => [null, false], 'Not set' => [false, false], diff --git a/lib/tests/plugininfo/base_test.php b/lib/tests/plugininfo/base_test.php index 72f7c86f897..e79f6b9b6fa 100644 --- a/lib/tests/plugininfo/base_test.php +++ b/lib/tests/plugininfo/base_test.php @@ -83,7 +83,7 @@ class base_test extends \advanced_testcase { * * @return array */ - public function load_disk_version_invalid_supported_version_provider(): array { + public static function load_disk_version_invalid_supported_version_provider(): array { return [ 'Invalid supported range.' => [ 'supported' => [31, 29], @@ -149,7 +149,7 @@ class base_test extends \advanced_testcase { * * @return array */ - public function load_disk_version_invalid_incompatible_version_provider(): array { + public static function load_disk_version_invalid_incompatible_version_provider(): array { return [ [[38]], [['38']], @@ -197,7 +197,7 @@ class base_test extends \advanced_testcase { * * @return array */ - public function load_disk_version_branch_supports_provider(): array { + public static function load_disk_version_branch_supports_provider(): array { return [ 'Range, branch in support, lowest' => [ 'supported' => [29, 31], diff --git a/lib/tests/plugininfo/repository_test.php b/lib/tests/plugininfo/repository_test.php index eb70cc6aa97..fecd9d9c73c 100644 --- a/lib/tests/plugininfo/repository_test.php +++ b/lib/tests/plugininfo/repository_test.php @@ -56,7 +56,7 @@ class repository_test extends \advanced_testcase { * * @return array */ - public function enable_plugin_provider(): array { + public static function enable_plugin_provider(): array { return [ 'Disable an enable and visible repository' => [ 'pluginname' => 'contentbank', diff --git a/lib/tests/questionlib_test.php b/lib/tests/questionlib_test.php index 0c0bebc91d2..fa8924b9a54 100644 --- a/lib/tests/questionlib_test.php +++ b/lib/tests/questionlib_test.php @@ -1536,7 +1536,7 @@ class questionlib_test extends \advanced_testcase { * * @return array */ - public function question_capability_on_question_provider() { + public static function question_capability_on_question_provider(): array { return [ 'Unrelated capability which is present' => [ 'capabilities' => [ @@ -2023,7 +2023,7 @@ class questionlib_test extends \advanced_testcase { * * @return array test cases. */ - public function find_next_unused_idnumber_cases(): array { + public static function find_next_unused_idnumber_cases(): array { return [ [null, null], ['id', null], diff --git a/lib/tests/rtlcss_test.php b/lib/tests/rtlcss_test.php index bc6d327755f..0cf82b808d5 100644 --- a/lib/tests/rtlcss_test.php +++ b/lib/tests/rtlcss_test.php @@ -38,7 +38,7 @@ class rtlcss_test extends basic_testcase { * Data provider. * @return array */ - public function background_image_provider() { + public static function background_image_provider(): array { return [ /* Not supported by MoodleHQ/RTLCSS yet. [[ @@ -78,7 +78,7 @@ class rtlcss_test extends basic_testcase { * Data provider. * @return array */ - public function background_position_provider() { + public static function background_position_provider(): array { return [ [[ 'should' => 'Should complement percentage horizontal position ', @@ -182,7 +182,7 @@ class rtlcss_test extends basic_testcase { * Data provider. * @return array */ - public function background_provider() { + public static function background_provider(): array { return [ [[ 'should' => 'Should treat 0 as 0%', @@ -271,7 +271,7 @@ class rtlcss_test extends basic_testcase { * Data provider. * @return array */ - public function directives_provider() { + public static function directives_provider(): array { return [ [[ 'should' => 'Should ignore flipping - rule level (default)', @@ -356,7 +356,7 @@ class rtlcss_test extends basic_testcase { * Data provider. * @return array */ - public function properties_provider() { + public static function properties_provider(): array { return [ [[ 'should' => 'Should mirror property name: border-top-right-radius', @@ -419,7 +419,7 @@ class rtlcss_test extends basic_testcase { * Data provider. * @return array */ - public function special_provider() { + public static function special_provider(): array { return [ /* Not supported by MoodleHQ/RTLCSS yet. [[ @@ -437,7 +437,7 @@ class rtlcss_test extends basic_testcase { * Data provider. * @return array */ - public function transform_origin_provider() { + public static function transform_origin_provider(): array { return [ [[ 'should' => 'Should mirror (x-offset: 0 means 0%)', @@ -612,7 +612,7 @@ class rtlcss_test extends basic_testcase { * Data provider. * @return array */ - public function transforms_provider() { + public static function transforms_provider(): array { return [ /* Not supported by MoodleHQ/RTLCSS yet. [[ @@ -896,7 +896,7 @@ class rtlcss_test extends basic_testcase { * Data provider. * @return array */ - public function values_nsyntax_provider() { + public static function values_nsyntax_provider(): array { return [ [[ 'should' => 'Should mirror property value: border-radius (4 values)', @@ -1017,7 +1017,7 @@ class rtlcss_test extends basic_testcase { * Data provider. * @return array */ - public function values_provider() { + public static function values_provider(): array { return [ [[ 'should' => 'Should mirror property value: clear', diff --git a/lib/tests/scss_test.php b/lib/tests/scss_test.php index ea53368e423..cb550143877 100644 --- a/lib/tests/scss_test.php +++ b/lib/tests/scss_test.php @@ -32,7 +32,7 @@ class scss_test extends \advanced_testcase { * Data provider for is_valid_file * @return array */ - public function is_valid_file_provider() { + public static function is_valid_file_provider(): array { $themedirectory = \core_component::get_component_directory('theme_boost'); $realroot = realpath($themedirectory); return [ @@ -66,7 +66,7 @@ class scss_test extends \advanced_testcase { /** * Test cases for SassC compilation. */ - public function scss_compilation_provider() { + public static function scss_compilation_provider(): array { return [ 'simple' => [ 'scss' => '$font-stack: Helvetica, sans-serif; diff --git a/lib/tests/session_manager_test.php b/lib/tests/session_manager_test.php index 1d13d0fc5fb..d0eb3803df8 100644 --- a/lib/tests/session_manager_test.php +++ b/lib/tests/session_manager_test.php @@ -794,7 +794,7 @@ class session_manager_test extends \advanced_testcase { * * @return array */ - public function sessionlocks_info_provider() : array { + public static function sessionlocks_info_provider(): array { return [ [ 'url' => null, diff --git a/lib/tests/sessionlib_test.php b/lib/tests/sessionlib_test.php index 4a9e436c040..27b1491fe53 100644 --- a/lib/tests/sessionlib_test.php +++ b/lib/tests/sessionlib_test.php @@ -149,7 +149,7 @@ class sessionlib_test extends \advanced_testcase { * * @return array of config and secure result */ - public function moodle_cookie_secure_provider() { + public static function moodle_cookie_secure_provider(): array { return array( array( // Non ssl, not set. diff --git a/lib/tests/setuplib_test.php b/lib/tests/setuplib_test.php index 3ede21f43a2..977d216b59f 100644 --- a/lib/tests/setuplib_test.php +++ b/lib/tests/setuplib_test.php @@ -426,7 +426,7 @@ class setuplib_test extends \advanced_testcase { * * @return array An array of arrays contain test data */ - public function data_for_test_get_real_size() { + public static function data_for_test_get_real_size(): array { return array( array('8KB', 8192), array('8Kb', 8192), diff --git a/lib/tests/statslib_test.php b/lib/tests/statslib_test.php index c3551156f12..5e154f29607 100644 --- a/lib/tests/statslib_test.php +++ b/lib/tests/statslib_test.php @@ -187,7 +187,7 @@ class statslib_test extends \advanced_testcase { * * @return array of fixture XML log file names. */ - public function daily_log_provider() { + public static function daily_log_provider(): array { $logfiles = array(); $fileno = array('00', '01', '02', '03', '04', '05', '06', '07', '08'); @@ -203,7 +203,7 @@ class statslib_test extends \advanced_testcase { * * @return array Dates and timezones for which the first day of the week will be calculated */ - public function get_base_weekly_provider() { + public static function get_base_weekly_provider(): array { return [ [ "startwday" => 0, diff --git a/lib/tests/string_manager_standard_test.php b/lib/tests/string_manager_standard_test.php index 2e296bb46ca..2c1b9401385 100644 --- a/lib/tests/string_manager_standard_test.php +++ b/lib/tests/string_manager_standard_test.php @@ -97,14 +97,12 @@ class string_manager_standard_test extends \advanced_testcase { * * @return array */ - public function get_deprecated_strings_provider() { + public static function get_deprecated_strings_provider(): array { global $CFG; - $teststringman = testable_core_string_manager::instance($CFG->langotherroot, $CFG->langlocalroot, array()); + $teststringman = testable_core_string_manager::instance($CFG->langotherroot, $CFG->langlocalroot, []); $allstrings = $teststringman->get_all_deprecated_strings(); - return array_map(function($string) { - return [$string]; - }, $allstrings); + return array_map(fn ($string): array => [$string], $allstrings); } /** diff --git a/lib/tests/tablelib_test.php b/lib/tests/tablelib_test.php index b7328a56a43..ec5f9245a99 100644 --- a/lib/tests/tablelib_test.php +++ b/lib/tests/tablelib_test.php @@ -363,7 +363,7 @@ class tablelib_test extends \advanced_testcase { * * @return array */ - public function fullname_column_provider() { + public static function fullname_column_provider(): array { return [ ['language'], ['alternatename lastname'], @@ -782,7 +782,7 @@ class tablelib_test extends \advanced_testcase { * * @return array */ - public function initials_provider(): array { + public static function initials_provider(): array { return [ [null, null, null], ['A', null, 'A'], diff --git a/lib/tests/task/database_logger_test.php b/lib/tests/task/database_logger_test.php index 3ea897eb7fd..f4c93f6196e 100644 --- a/lib/tests/task/database_logger_test.php +++ b/lib/tests/task/database_logger_test.php @@ -236,7 +236,7 @@ class database_logger_test extends \advanced_testcase { * * @return array */ - public function delete_task_logs_provider() : array { + public static function delete_task_logs_provider(): array { return [ [ [0], diff --git a/lib/tests/task/scheduled_task_test.php b/lib/tests/task/scheduled_task_test.php index fc2ac0fe3cf..4e78495648e 100644 --- a/lib/tests/task/scheduled_task_test.php +++ b/lib/tests/task/scheduled_task_test.php @@ -949,7 +949,7 @@ class scheduled_task_test extends \advanced_testcase { * * @return array[] */ - public function is_component_enabled_provider(): array { + public static function is_component_enabled_provider(): array { return [ 'Enabled component' => ['auth_cas', true], 'Disabled component' => ['auth_ldap', false], diff --git a/lib/tests/text_test.php b/lib/tests/text_test.php index 148575e8c63..3d13c425b7f 100644 --- a/lib/tests/text_test.php +++ b/lib/tests/text_test.php @@ -607,7 +607,7 @@ class text_test extends advanced_testcase { /** * Tests the static checker is_charset_supported * - * @dataProvider is_charset_supported_provider() + * @dataProvider is_charset_supported_provider * @param string $charset * @param bool $expected * @covers ::is_charset_supported() @@ -621,7 +621,7 @@ class text_test extends advanced_testcase { * Provider for the test_is_charset_supported() * @return array[] */ - public function is_charset_supported_provider() { + public static function is_charset_supported_provider(): array { return [ "Check unsupported windows charset" => [ "cp1250", false diff --git a/lib/tests/upgrade_util_test.php b/lib/tests/upgrade_util_test.php index a851661bfd2..c1bf4fb556c 100644 --- a/lib/tests/upgrade_util_test.php +++ b/lib/tests/upgrade_util_test.php @@ -43,7 +43,7 @@ class upgrade_util_test extends \advanced_testcase { /** * Test PHP/cURL validation. * - * @dataProvider validate_php_curl_tls_testcases() + * @dataProvider validate_php_curl_tls_testcases * @param array $curlinfo server curl_version array * @param int $zts 0 or 1 as defined by PHP_ZTS * @param bool $expected expected result @@ -55,7 +55,7 @@ class upgrade_util_test extends \advanced_testcase { /** * Test cases for validate_php_curl_tls test. */ - public function validate_php_curl_tls_testcases() { + public static function validate_php_curl_tls_testcases(): array { $base = curl_version(); return [ @@ -130,7 +130,7 @@ class upgrade_util_test extends \advanced_testcase { * * @return array of testcases */ - public function can_use_tls12_testcases() { + public static function can_use_tls12_testcases(): array { return [ // Bad versions. ['OpenSSL/0.9.8o', null, false], diff --git a/lib/tests/upgradelib_test.php b/lib/tests/upgradelib_test.php index ff04fd23df1..2e3615f733f 100644 --- a/lib/tests/upgradelib_test.php +++ b/lib/tests/upgradelib_test.php @@ -744,7 +744,7 @@ class upgradelib_test extends advanced_testcase { * * @return array */ - public function serialized_strings_dataprovider() { + public static function serialized_strings_dataprovider(): array { return [ 'A configuration that uses the old object' => [ 'O:6:"object":3:{s:4:"text";s:32:"Nothing that anyone cares about.";s:5:"title";s:16:"Really old block";s:6:"format";s:1:"1";}', @@ -1423,7 +1423,7 @@ class upgradelib_test extends advanced_testcase { * * @return array */ - public function usermenu_items_dataprovider(): array { + public static function usermenu_items_dataprovider(): array { return [ 'Add new item to empty usermenu' => [ '', diff --git a/lib/tests/user_menu_test.php b/lib/tests/user_menu_test.php index 7167cad6d81..8e94abd8d4d 100644 --- a/lib/tests/user_menu_test.php +++ b/lib/tests/user_menu_test.php @@ -30,7 +30,7 @@ class user_menu_test extends \advanced_testcase { * * @return array containing testing data */ - public function custom_user_menu_data() { + public static function custom_user_menu_data(): array { return array( // These are fillers only. array('###', 0, 1), diff --git a/lib/tests/useragent_test.php b/lib/tests/useragent_test.php index 024b8a4ff3a..d3bfc40da1e 100644 --- a/lib/tests/useragent_test.php +++ b/lib/tests/useragent_test.php @@ -36,7 +36,7 @@ class useragent_test extends advanced_testcase { * * @return array */ - public function user_agents_providers() { + public static function user_agents_providers(): array { // Note: When adding new entries to this list, please ensure that any new browser versions are added to the corresponding list. // This ensures that regression tests are applied to all known user agents. return array( diff --git a/lib/tests/weblib_format_text_test.php b/lib/tests/weblib_format_text_test.php index b39c8aff386..b799d9a0409 100644 --- a/lib/tests/weblib_format_text_test.php +++ b/lib/tests/weblib_format_text_test.php @@ -149,7 +149,7 @@ class weblib_format_text_test extends \advanced_testcase { * * @return array of testcases */ - public function format_text_blanktarget_testcases() { + public static function format_text_blanktarget_testcases(): array { return [ 'Simple link' => [ 'Hey, that\'s pretty good!', @@ -230,7 +230,7 @@ class weblib_format_text_test extends \advanced_testcase { * * @return array of testcases (string)testcasename => [(string)input, (string)nocleaned, (string)cleaned] */ - public function format_text_cleaning_testcases() { + public static function format_text_cleaning_testcases(): array { return [ 'JavaScript' => [ 'Hello world', diff --git a/lib/tests/weblib_test.php b/lib/tests/weblib_test.php index cf15ba15733..b97896bc0d5 100644 --- a/lib/tests/weblib_test.php +++ b/lib/tests/weblib_test.php @@ -451,7 +451,7 @@ class weblib_test extends advanced_testcase { /** * Data provider for trusttext_pre_edit() tests. */ - public function trusttext_pre_edit_provider(): array { + public static function trusttext_pre_edit_provider(): array { return [ [true, 0, 'editingteacher', FORMAT_HTML, 1], [true, 0, 'editingteacher', FORMAT_MOODLE, 1], @@ -826,7 +826,7 @@ EXPECTED; /** * Data provider for test_content_to_text. */ - public static function provider_content_to_text() { + public static function provider_content_to_text(): array { return array( array('asd', false, 'asd'), // Trim '\r\n '. @@ -852,7 +852,7 @@ EXPECTED; * * @return array Returns aray of test data for the test_validate_email function */ - public function data_validate_email() { + public static function data_validate_email(): array { return [ // Test addresses that should pass. [ @@ -1020,7 +1020,7 @@ EXPECTED; /** * Data provider for test_get_file_argument. */ - public static function provider_get_file_argument() { + public static function provider_get_file_argument(): array { return array( // Serving SCORM content w/o HTTP GET params. array(array( @@ -1268,7 +1268,7 @@ EXPECTED; * * @return string[][] */ - public function get_html_lang_attribute_value_provider() { + public static function get_html_lang_attribute_value_provider(): array { return [ 'Empty lang code' => [' ', 'en'], 'English' => ['en', 'en'], @@ -1295,7 +1295,7 @@ EXPECTED; * * @return array */ - public function strip_querystring_provider(): array { + public static function strip_querystring_provider(): array { return [ 'Null' => [null, ''], 'Empty string' => ['', ''], diff --git a/lib/xapi/tests/external/post_statement_test.php b/lib/xapi/tests/external/post_statement_test.php index f3986ec77db..c3118bca97c 100644 --- a/lib/xapi/tests/external/post_statement_test.php +++ b/lib/xapi/tests/external/post_statement_test.php @@ -187,7 +187,7 @@ class post_statement_test extends externallib_advanced_testcase { * * @return array */ - public function components_provider() : array { + public static function components_provider(): array { return [ 'Inexistent component' => [ 'inexistent_component', [] @@ -233,7 +233,7 @@ class post_statement_test extends externallib_advanced_testcase { * * @return array */ - public function invalid_json_provider() : array { + public static function invalid_json_provider(): array { return [ 'Wrong json' => [ 'This is not { a json object /' @@ -376,7 +376,7 @@ class post_statement_test extends externallib_advanced_testcase { * * @return array */ - public function statement_provider() : array { + public static function statement_provider(): array { return [ // Single statement with group statements enabled. 'Single, Valid actor, valid verb' => [ @@ -449,7 +449,7 @@ class post_statement_test extends externallib_advanced_testcase { * * @return array */ - public function group_statement_provider() : array { + public static function group_statement_provider(): array { return [ // Single statement with group statements enabled. 'Group statement + group statement without group support' => [ diff --git a/lib/xapi/tests/iri_test.php b/lib/xapi/tests/iri_test.php index c90a0d1ba9d..0e85b92f496 100644 --- a/lib/xapi/tests/iri_test.php +++ b/lib/xapi/tests/iri_test.php @@ -76,7 +76,7 @@ class iri_test extends advanced_testcase { * * @return array */ - public function iri_samples_provider() : array { + public static function iri_samples_provider(): array { global $CFG; return [ @@ -120,7 +120,7 @@ class iri_test extends advanced_testcase { * * @return array */ - public function iri_check_provider() : array { + public static function iri_check_provider(): array { return [ 'Real IRI http' => [ 'http://adlnet.gov/expapi/activities/example', diff --git a/lib/xapi/tests/local/statement/item_activity_test.php b/lib/xapi/tests/local/statement/item_activity_test.php index e1b7b7aed5c..60a8a815cc3 100644 --- a/lib/xapi/tests/local/statement/item_activity_test.php +++ b/lib/xapi/tests/local/statement/item_activity_test.php @@ -113,7 +113,7 @@ class item_activity_test extends advanced_testcase { * * @return array */ - public function create_from_id_provider() : array { + public static function create_from_id_provider(): array { return [ 'Fake IRI with no definition' => [ 'paella', false, @@ -155,7 +155,7 @@ class item_activity_test extends advanced_testcase { * * @return array */ - public function invalid_data_provider() : array { + public static function invalid_data_provider(): array { return [ 'Invalid Avtivity objectType' => [ 'Invalid Type!', iri::generate('paella', 'activity'), diff --git a/lib/xapi/tests/local/statement/item_agent_test.php b/lib/xapi/tests/local/statement/item_agent_test.php index 53aed334015..7e17eeeab4e 100644 --- a/lib/xapi/tests/local/statement/item_agent_test.php +++ b/lib/xapi/tests/local/statement/item_agent_test.php @@ -143,7 +143,7 @@ class item_agent_test extends advanced_testcase { * * @return array */ - public function invalid_data_provider() : array { + public static function invalid_data_provider(): array { return [ 'Wrong objecttype' => [ 'Invalid', true, true @@ -203,7 +203,7 @@ class item_agent_test extends advanced_testcase { * * @return array */ - public function unspupported_create_provider() : array { + public static function unspupported_create_provider(): array { return [ 'Both mbox and account' => [ true, true, false, false diff --git a/lib/xapi/tests/local/statement/item_attachment_test.php b/lib/xapi/tests/local/statement/item_attachment_test.php index 581ed8940c0..74e90e1d79d 100644 --- a/lib/xapi/tests/local/statement/item_attachment_test.php +++ b/lib/xapi/tests/local/statement/item_attachment_test.php @@ -94,7 +94,7 @@ class item_attachment_test extends advanced_testcase { * * @return array */ - public function invalid_values_data() : array { + public static function invalid_values_data(): array { return [ 'No usageType attachment' => [ 'usageType', null diff --git a/lib/xapi/tests/local/statement/item_definition_test.php b/lib/xapi/tests/local/statement/item_definition_test.php index 92ea49b1df7..cbc2a52b9b2 100644 --- a/lib/xapi/tests/local/statement/item_definition_test.php +++ b/lib/xapi/tests/local/statement/item_definition_test.php @@ -72,7 +72,7 @@ class item_definition_test extends advanced_testcase { * * @return array */ - public function creation_provider() : array { + public static function creation_provider(): array { return [ 'No interactionType' => [''], 'Choice' => ['choice'], diff --git a/lib/xapi/tests/local/statement/item_group_test.php b/lib/xapi/tests/local/statement/item_group_test.php index e55509009d0..b7bef6d34a5 100644 --- a/lib/xapi/tests/local/statement/item_group_test.php +++ b/lib/xapi/tests/local/statement/item_group_test.php @@ -143,7 +143,7 @@ class item_group_test extends advanced_testcase { * * @return array */ - public function invalid_data_provider() : array { + public static function invalid_data_provider(): array { return [ 'Wrong objecttype' => [ 'Invalid', true, true diff --git a/lib/xapi/tests/local/statement/item_object_test.php b/lib/xapi/tests/local/statement/item_object_test.php index 2081c884b78..a9de796cfe2 100644 --- a/lib/xapi/tests/local/statement/item_object_test.php +++ b/lib/xapi/tests/local/statement/item_object_test.php @@ -117,7 +117,7 @@ class item_object_test extends advanced_testcase { * * @return array */ - public function invalid_data_provider() : array { + public static function invalid_data_provider(): array { return [ 'Empty or null id' => [ '', diff --git a/lib/xapi/tests/local/statement/item_result_test.php b/lib/xapi/tests/local/statement/item_result_test.php index 15a12127500..b061548581e 100644 --- a/lib/xapi/tests/local/statement/item_result_test.php +++ b/lib/xapi/tests/local/statement/item_result_test.php @@ -98,7 +98,7 @@ class item_result_test extends advanced_testcase { * * @return array */ - public function duration_values_data() : array { + public static function duration_values_data(): array { return [ 'No duration' => [ null, null, false diff --git a/lib/xapi/tests/local/statement/item_verb_test.php b/lib/xapi/tests/local/statement/item_verb_test.php index deaecfecfe0..07892e95edb 100644 --- a/lib/xapi/tests/local/statement/item_verb_test.php +++ b/lib/xapi/tests/local/statement/item_verb_test.php @@ -75,7 +75,7 @@ class item_verb_test extends advanced_testcase { * * @return array */ - public function create_from_id_provider() : array { + public static function create_from_id_provider(): array { return [ 'Fake IRI' => [ 'cook', @@ -105,7 +105,7 @@ class item_verb_test extends advanced_testcase { * * @return array */ - public function invalid_data_provider() : array { + public static function invalid_data_provider(): array { return [ 'Empty or null id' => [ '', diff --git a/lib/xapi/tests/local/statement_test.php b/lib/xapi/tests/local/statement_test.php index d1b5e47d226..c8c1d110b93 100644 --- a/lib/xapi/tests/local/statement_test.php +++ b/lib/xapi/tests/local/statement_test.php @@ -184,7 +184,7 @@ class statement_test extends advanced_testcase { * * @return array */ - public function create_provider() : array { + public static function create_provider(): array { return [ 'Agent statement with no extras' => [ true, [], [] @@ -413,7 +413,7 @@ class statement_test extends advanced_testcase { * * @return array */ - public function invalid_gets_provider() : array { + public static function invalid_gets_provider(): array { return [ 'Method get_user on empty statement' => ['get_user', true], 'Method get_all_users on empty statement' => ['get_all_users', true], @@ -532,7 +532,7 @@ class statement_test extends advanced_testcase { * * @return array */ - public function invalid_data_provider() : array { + public static function invalid_data_provider(): array { return [ 'No actor, no verb, no object' => [false, false, false], 'No actor, verb, no object' => [false, true, false], diff --git a/login/tests/login_lib_test.php b/login/tests/login_lib_test.php index d86b611a118..041bd4dde38 100644 --- a/login/tests/login_lib_test.php +++ b/login/tests/login_lib_test.php @@ -233,7 +233,7 @@ class login_lib_test extends \advanced_testcase { /** * Data provider for \core_login_lib_testcase::test_core_login_validate_forgot_password_data(). */ - public function forgot_password_data_provider() { + public static function forgot_password_data_provider(): array { return [ 'Both username and password supplied' => [ [ diff --git a/media/player/videojs/tests/player_test.php b/media/player/videojs/tests/player_test.php index 893e63b3e43..079f2cfe71f 100644 --- a/media/player/videojs/tests/player_test.php +++ b/media/player/videojs/tests/player_test.php @@ -289,7 +289,7 @@ class player_test extends \advanced_testcase { * * @return array */ - public function youtube_start_time_provider(): array { + public static function youtube_start_time_provider(): array { return [ ['https://www.youtube.com/watch?v=JNJMF1l3udM&t=1h11s', 3611], ['https://www.youtube.com/watch?v=dv2f_xfmbD8&index=4&list=PLxcO_MFWQBDcyn9xpbmx601YSDlDcTcr0&t=1m5s', 65], diff --git a/message/tests/api_test.php b/message/tests/api_test.php index 967349fbd1b..14c8b6db1bb 100644 --- a/message/tests/api_test.php +++ b/message/tests/api_test.php @@ -1840,7 +1840,7 @@ final class api_test extends \advanced_testcase { * This provides sets of data to for testing. * @return array */ - public function get_conversations_mixed_provider() { + public static function get_conversations_mixed_provider(): array { return array( 'Test that conversations with messages contacts is correctly ordered.' => array( 'users' => array( @@ -5834,7 +5834,7 @@ final class api_test extends \advanced_testcase { /** * Data provider for test_get_conversation_counts(). */ - public function get_conversation_counts_test_cases() { + public static function get_conversation_counts_test_cases(): array { $typeindividual = api::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL; $typegroup = api::MESSAGE_CONVERSATION_TYPE_GROUP; $typeself = api::MESSAGE_CONVERSATION_TYPE_SELF; diff --git a/message/tests/externallib_test.php b/message/tests/externallib_test.php index 2c22e5dbef9..99a477550ed 100644 --- a/message/tests/externallib_test.php +++ b/message/tests/externallib_test.php @@ -5137,7 +5137,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Data provider for test_get_conversation_counts(). */ - public function get_conversation_counts_test_cases() { + public static function get_conversation_counts_test_cases(): array { $typeindividual = \core_message\api::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL; $typegroup = \core_message\api::MESSAGE_CONVERSATION_TYPE_GROUP; $typeself = \core_message\api::MESSAGE_CONVERSATION_TYPE_SELF; @@ -5500,7 +5500,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Test the get_conversation_counts() function. * - * @dataProvider get_conversation_counts_test_cases() + * @dataProvider get_conversation_counts_test_cases * @param array $conversationconfigs Conversations to create * @param int $deletemessagesuser The user who is deleting the messages * @param array $deletemessages The list of messages to delete (by index) diff --git a/message/tests/helper_test.php b/message/tests/helper_test.php index 6d08f834c88..af66d381c34 100644 --- a/message/tests/helper_test.php +++ b/message/tests/helper_test.php @@ -228,7 +228,7 @@ class helper_test extends \advanced_testcase { * * @return array */ - public function prevent_unclosed_html_tags_data(): array { + public static function prevent_unclosed_html_tags_data(): array { return [ 'Prevent unclosed html elements' => [ '

Title

Paragraph

Bold', '

Title

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: // - -- // - --[] @@ -284,7 +284,7 @@ class instance_test extends advanced_testcase { * * @return array */ - public function is_currently_open_provider(): array { + public static function is_currently_open_provider(): array { return [ 'No opening or closing time set: Is open' => [null, null, true], 'Opening time set in the past, no closing: Is open' => [-DAYSECS, null, true], @@ -363,7 +363,7 @@ class instance_test extends advanced_testcase { * * @return array */ - public function user_must_wait_to_join_provider(): array { + public static function user_must_wait_to_join_provider(): array { return [ 'Admins must never wait to join (waiting disabled)' => [true, false, false, false], 'Admins must never wait to join (waiting enabled)' => [true, false, true, false], @@ -407,7 +407,7 @@ class instance_test extends advanced_testcase { * * @return array */ - public function does_current_user_count_towards_user_limit_provider(): array { + public static function does_current_user_count_towards_user_limit_provider(): array { return [ 'Admin does not count' => [true, false, false], 'Moderator does not count' => [false, true, false], @@ -452,7 +452,7 @@ class instance_test extends advanced_testcase { * * @return array */ - public function get_current_user_password_provider(): array { + public static function get_current_user_password_provider(): array { return [ 'Admin is a moderator' => [true, false, true], 'Moderator is a moderator' => [false, true, true], @@ -493,7 +493,7 @@ class instance_test extends advanced_testcase { * * @return array */ - public function get_current_user_role_provider(): array { + public static function get_current_user_role_provider(): array { return [ 'Admin is a moderator' => [true, false, true], 'Moderator is a moderator' => [false, true, true], @@ -534,7 +534,7 @@ class instance_test extends advanced_testcase { * * @return array */ - public function allow_recording_start_stop_provider(): array { + public static function allow_recording_start_stop_provider(): array { return [ 'Meeting is not recorded: No start/stop' => [false, false, false], 'Meeting recorded, Buttons shown: Allow' => [true, true, true], diff --git a/mod/bigbluebuttonbn/tests/local/bigbluebutton/recordings/recording_data_test.php b/mod/bigbluebuttonbn/tests/local/bigbluebutton/recordings/recording_data_test.php index 4622c9d9e83..64a990f0cd9 100644 --- a/mod/bigbluebuttonbn/tests/local/bigbluebutton/recordings/recording_data_test.php +++ b/mod/bigbluebuttonbn/tests/local/bigbluebutton/recordings/recording_data_test.php @@ -44,7 +44,7 @@ class recording_data_test extends \advanced_testcase { * * @return \string[][] */ - public function type_text_provider(): array { + public static function type_text_provider(): array { return [ ['Presentation', 'presentation'], ['Video', 'video'], diff --git a/mod/bigbluebuttonbn/tests/meeting_test.php b/mod/bigbluebuttonbn/tests/meeting_test.php index d19dd8618d7..f6fa0283767 100644 --- a/mod/bigbluebuttonbn/tests/meeting_test.php +++ b/mod/bigbluebuttonbn/tests/meeting_test.php @@ -57,7 +57,7 @@ class meeting_test extends \advanced_testcase { * * @return array[] */ - public function get_instance_types_meeting_info(): array { + public static function get_instance_types_meeting_info(): array { return [ 'Instance Type ALL - No Group' => [ 'type' => instance::TYPE_ALL, @@ -417,7 +417,7 @@ class meeting_test extends \advanced_testcase { * * @return array[] */ - public function get_data_can_join_with_dates(): array { + public static function get_data_can_join_with_dates(): array { return [ 'Instance Type ALL - No Group - Closed in past' => [ 'type' => instance::TYPE_ALL, diff --git a/mod/bigbluebuttonbn/tests/recording_test.php b/mod/bigbluebuttonbn/tests/recording_test.php index fa4ff52fd64..8479a25cc1f 100644 --- a/mod/bigbluebuttonbn/tests/recording_test.php +++ b/mod/bigbluebuttonbn/tests/recording_test.php @@ -103,7 +103,7 @@ class recording_test extends \advanced_testcase { * * @return array[] */ - public function get_status_provider(): array { + public static function get_status_provider(): array { return [ [recording::RECORDING_STATUS_PROCESSED], [recording::RECORDING_STATUS_DISMISSED], @@ -137,7 +137,7 @@ class recording_test extends \advanced_testcase { * * @return array[] */ - public function get_allrecordings_types_provider(): array { + public static function get_allrecordings_types_provider(): array { return [ 'Instance Type ALL' => [ 'type' => instance::TYPE_ALL diff --git a/mod/chat/tests/format_message_test.php b/mod/chat/tests/format_message_test.php index d27691b4f36..3a27b0ec689 100644 --- a/mod/chat/tests/format_message_test.php +++ b/mod/chat/tests/format_message_test.php @@ -33,7 +33,7 @@ class format_message_test extends \advanced_testcase { const USER_CURRENT = 1; const USER_OTHER = 2; - public function chat_format_message_manually_provider() { + public static function chat_format_message_manually_provider(): array { $dateregexp = '\d{2}:\d{2}'; return [ 'Beep everyone' => [ diff --git a/mod/choice/tests/custom_completion_test.php b/mod/choice/tests/custom_completion_test.php index 0de6b5ebf02..120d3e2f400 100644 --- a/mod/choice/tests/custom_completion_test.php +++ b/mod/choice/tests/custom_completion_test.php @@ -43,7 +43,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 @@ -166,7 +166,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/choice/tests/dates_test.php b/mod/choice/tests/dates_test.php index b5c0d27f92e..dd6eab7d692 100644 --- a/mod/choice/tests/dates_test.php +++ b/mod/choice/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/data/tests/custom_completion_test.php b/mod/data/tests/custom_completion_test.php index 8cd39265c54..2f41dad7a5b 100644 --- a/mod/data/tests/custom_completion_test.php +++ b/mod/data/tests/custom_completion_test.php @@ -51,7 +51,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, 0, null, coding_exception::class @@ -173,7 +173,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 entries available' => [ COMPLETION_ENABLED, ['completionentries'] diff --git a/mod/data/tests/dates_test.php b/mod/data/tests/dates_test.php index 6fdd3494079..2a769e7f169 100644 --- a/mod/data/tests/dates_test.php +++ b/mod/data/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/data/tests/event/events_test.php b/mod/data/tests/event/events_test.php index 6df9fb43650..a8a2353f1b0 100644 --- a/mod/data/tests/event/events_test.php +++ b/mod/data/tests/event/events_test.php @@ -370,7 +370,7 @@ class events_test extends \advanced_testcase { * * @return array[] */ - public function preset_importer_provider(): array { + public static function preset_importer_provider(): array { // Image gallery preset is: ['title' => 'text', 'description' => 'textarea', 'image' => 'picture']; $titlefield = new \stdClass(); diff --git a/mod/data/tests/external/get_mapping_information_test.php b/mod/data/tests/external/get_mapping_information_test.php index cbadf5966b2..b41fb5718a0 100644 --- a/mod/data/tests/external/get_mapping_information_test.php +++ b/mod/data/tests/external/get_mapping_information_test.php @@ -40,7 +40,7 @@ class get_mapping_information_test extends \advanced_testcase { * * @return array[] */ - public function get_mapping_information_provider(): array { + public static function get_mapping_information_provider(): array { // Image gallery preset is: ['title' => 'text', 'description' => 'textarea', 'image' => 'picture']; $titlefield = new \stdClass(); diff --git a/mod/data/tests/generator_test.php b/mod/data/tests/generator_test.php index eed49e5aec1..62b84bfdc81 100644 --- a/mod/data/tests/generator_test.php +++ b/mod/data/tests/generator_test.php @@ -300,7 +300,7 @@ class generator_test extends \advanced_testcase { * * @return array */ - public function create_preset_provider(): array { + public static function create_preset_provider(): array { return [ 'Create using the default configuration' => [ 'record' => null, diff --git a/mod/data/tests/lib_test.php b/mod/data/tests/lib_test.php index 154deae9e11..799e9ccbc5a 100644 --- a/mod/data/tests/lib_test.php +++ b/mod/data/tests/lib_test.php @@ -746,7 +746,7 @@ class lib_test extends \advanced_testcase { * * @return array */ - public function data_get_config_provider() { + public static function data_get_config_provider(): array { $initialdata = (object) [ 'template_foo' => true, 'template_bar' => false, @@ -837,7 +837,7 @@ class lib_test extends \advanced_testcase { * * @return array */ - public function data_set_config_provider() { + public static function data_set_config_provider(): array { $basevalue = (object) ['id' => rand(1, 1000)]; $config = [ 'template_foo' => true, diff --git a/mod/data/tests/manager_test.php b/mod/data/tests/manager_test.php index 5dcc4a3849b..14d8067b961 100644 --- a/mod/data/tests/manager_test.php +++ b/mod/data/tests/manager_test.php @@ -482,7 +482,7 @@ class manager_test extends \advanced_testcase { * * @return array */ - public function can_view_preset_provider(): array { + public static function can_view_preset_provider(): array { return [ // User presets. 'Teacher owned preset without user id param' => [ @@ -737,7 +737,7 @@ class manager_test extends \advanced_testcase { * * @return array */ - public function reset_template_provider(): array { + public static function reset_template_provider(): array { return [ // User presets. 'listtemplate' => [ diff --git a/mod/data/tests/preset_importer_test.php b/mod/data/tests/preset_importer_test.php index 34cefbb5084..d99d3f37de6 100644 --- a/mod/data/tests/preset_importer_test.php +++ b/mod/data/tests/preset_importer_test.php @@ -28,14 +28,13 @@ use mod_data\local\importer\preset_importer; * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @coversDefaultClass \mod_data\local\importer\preset_importer */ -class preset_importer_test extends \advanced_testcase { - +final class preset_importer_test extends \advanced_testcase { /** * Data provider for build providers for test_needs_mapping and test_set_affected_fields. * * @return array[] */ - public function preset_importer_provider(): array { + public static function preset_importer_provider(): array { // Image gallery preset is: ['title' => 'text', 'description' => 'textarea', 'image' => 'picture']; $titlefield = new \stdClass(); @@ -107,8 +106,8 @@ class preset_importer_test extends \advanced_testcase { * * @return array[] */ - public function needs_mapping_provider(): array { - $basedprovider = $this->preset_importer_provider(); + public static function needs_mapping_provider(): array { + $basedprovider = static::preset_importer_provider(); $basedprovider['Empty database / Empty importer']['needsmapping'] = false; $basedprovider['Empty database / Importer with fields']['needsmapping'] = false; @@ -182,8 +181,8 @@ class preset_importer_test extends \advanced_testcase { * * @return array[] */ - public function set_affected_provider(): array { - $basedprovider = $this->preset_importer_provider(); + public static function set_affected_provider(): array { + $basedprovider = static::preset_importer_provider(); $basedprovider['Empty database / Empty importer']['fieldstocreate'] = 0; $basedprovider['Empty database / Empty importer']['fieldstoremove'] = 0; @@ -353,7 +352,7 @@ class preset_importer_test extends \advanced_testcase { * * @return array[] */ - public function get_field_names_provider(): array { + public static function get_field_names_provider(): array { return [ 'Empty list' => [ 'fields' => [], diff --git a/mod/data/tests/preset_test.php b/mod/data/tests/preset_test.php index 37f98566703..018e6bdf3b6 100644 --- a/mod/data/tests/preset_test.php +++ b/mod/data/tests/preset_test.php @@ -495,7 +495,7 @@ class preset_test extends \advanced_testcase { * * @return array */ - public function is_directory_a_preset_provider(): array { + public static function is_directory_a_preset_provider(): array { global $CFG; return [ @@ -608,7 +608,7 @@ class preset_test extends \advanced_testcase { * * @return array */ - public function generate_preset_xml_provider(): array { + public static function generate_preset_xml_provider(): array { return [ 'Generate preset.xml with the default params and empty description' => [ 'params' => [], diff --git a/mod/data/tests/template_test.php b/mod/data/tests/template_test.php index 660a2f3e59b..ed27d746213 100644 --- a/mod/data/tests/template_test.php +++ b/mod/data/tests/template_test.php @@ -169,7 +169,7 @@ class template_test extends \advanced_testcase { * * @return array of scenarios */ - public function parse_entries_provider(): array { + public static function parse_entries_provider(): array { return [ // Teacher scenarios. 'Teacher id tag' => [ @@ -871,7 +871,7 @@ class template_test extends \advanced_testcase { * * @return array of scenarios */ - public function parse_add_entry_provider(): array { + public static function parse_add_entry_provider(): array { return [ // Editing an entry. 'Teacher editing entry tags tag' => [ diff --git a/mod/feedback/tests/custom_completion_test.php b/mod/feedback/tests/custom_completion_test.php index 3719b411588..630b063dc3a 100644 --- a/mod/feedback/tests/custom_completion_test.php +++ b/mod/feedback/tests/custom_completion_test.php @@ -51,7 +51,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 @@ -174,7 +174,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/feedback/tests/dates_test.php b/mod/feedback/tests/dates_test.php index f37ba28a05f..b9c65282386 100644 --- a/mod/feedback/tests/dates_test.php +++ b/mod/feedback/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/feedback/tests/form/create_template_form_test.php b/mod/feedback/tests/form/create_template_form_test.php index 268db0b281c..ae56cce41f7 100644 --- a/mod/feedback/tests/form/create_template_form_test.php +++ b/mod/feedback/tests/form/create_template_form_test.php @@ -102,7 +102,7 @@ class create_template_form_test extends \advanced_testcase { * * @return array */ - public function createtemplate_form_with_modified_capabilities_provider(): array { + public static function createtemplate_form_with_modified_capabilities_provider(): array { return [ "Manager without edititems permission cannot create any templates" => [ ['mod/feedback:edititems'], false @@ -180,7 +180,7 @@ class create_template_form_test extends \advanced_testcase { * * @return array */ - public function createtemplate_form_provider(): array { + public static function createtemplate_form_provider(): array { return [ 'Create a private template as an admin' => [ 'admin', false diff --git a/mod/feedback/tests/form/use_template_form_test.php b/mod/feedback/tests/form/use_template_form_test.php index f57fe7d4aae..d5637b8d21e 100644 --- a/mod/feedback/tests/form/use_template_form_test.php +++ b/mod/feedback/tests/form/use_template_form_test.php @@ -100,7 +100,7 @@ class use_template_form_test extends \advanced_testcase { * * @return array */ - public function usetemplate_form_provider() { + public static function usetemplate_form_provider(): array { return [ 'Test submission with a private template as an admin' => [ 'admin', true, true diff --git a/mod/folder/tests/lib_test.php b/mod/folder/tests/lib_test.php index 15825f7388d..b0b1c17adff 100644 --- a/mod/folder/tests/lib_test.php +++ b/mod/folder/tests/lib_test.php @@ -376,7 +376,7 @@ class lib_test extends \advanced_testcase { * * @return array */ - public function folder_get_recent_mod_activity_provider(): array { + public static function folder_get_recent_mod_activity_provider(): array { return [ 'Teacher with force download' => [ 'forcedownload' => 1, diff --git a/mod/forum/tests/backup_forum_activity_task_test.php b/mod/forum/tests/backup_forum_activity_task_test.php index d0990a31d46..28c021717e5 100644 --- a/mod/forum/tests/backup_forum_activity_task_test.php +++ b/mod/forum/tests/backup_forum_activity_task_test.php @@ -49,7 +49,7 @@ class backup_forum_activity_task_test extends \advanced_testcase { $this->assertEquals($expectation, backup_forum_activity_task::encode_content_links($content)); } - public function encode_content_links_provider() { + public static function encode_content_links_provider(): array { global $CFG; $altwwwroot = 'http://invalid.example.com/'; return [ diff --git a/mod/forum/tests/custom_completion_test.php b/mod/forum/tests/custom_completion_test.php index 0f7fd080854..1d5df101112 100644 --- a/mod/forum/tests/custom_completion_test.php +++ b/mod/forum/tests/custom_completion_test.php @@ -55,7 +55,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', 0, COMPLETION_TRACKING_NONE, 0, 0, 0, null, coding_exception::class @@ -214,7 +214,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 discussions available' => [ COMPLETION_ENABLED, ['completiondiscussions'] diff --git a/mod/forum/tests/dates_test.php b/mod/forum/tests/dates_test.php index 6a304e3e867..79a9a04a300 100644 --- a/mod/forum/tests/dates_test.php +++ b/mod/forum/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; $after = $now + DAYSECS; diff --git a/mod/forum/tests/entities_discussion_test.php b/mod/forum/tests/entities_discussion_test.php index 4a0dccfaefc..f4b448af8ce 100644 --- a/mod/forum/tests/entities_discussion_test.php +++ b/mod/forum/tests/entities_discussion_test.php @@ -159,7 +159,7 @@ class entities_discussion_test extends \advanced_testcase { * * @return array start/end time offsets and the expected results. */ - public function diplay_period_options_provider() { + public static function diplay_period_options_provider(): array { return array( ["No dates set", 0, 0, true, false, true], ["Only started date in the future", 100, 0, false, false, false], diff --git a/mod/forum/tests/exporters_post_test.php b/mod/forum/tests/exporters_post_test.php index ef2c33a51cd..8387b834b27 100644 --- a/mod/forum/tests/exporters_post_test.php +++ b/mod/forum/tests/exporters_post_test.php @@ -201,7 +201,7 @@ class exporters_post_test extends \advanced_testcase { * * @return array */ - public function export_post_provider(): array { + public static function export_post_provider(): array { return [ 'Simple export' => [ ], diff --git a/mod/forum/tests/grade/forum_gradeitem_test.php b/mod/forum/tests/grade/forum_gradeitem_test.php index 86d9c6ee1d8..3d62c316ea1 100644 --- a/mod/forum/tests/grade/forum_gradeitem_test.php +++ b/mod/forum/tests/grade/forum_gradeitem_test.php @@ -216,7 +216,7 @@ class forum_gradeitem_test extends \advanced_testcase { * * @return array */ - public function should_grade_only_active_users_provider(): array { + public static function should_grade_only_active_users_provider(): array { return [ 'Enabled showonlyactiveenrol setting; enabled showonlyactiveenrol preference; view suspended users capability' => [ diff --git a/mod/forum/tests/grade/gradeitems_test.php b/mod/forum/tests/grade/gradeitems_test.php index 404791ac8a4..1bbe060d919 100644 --- a/mod/forum/tests/grade/gradeitems_test.php +++ b/mod/forum/tests/grade/gradeitems_test.php @@ -77,7 +77,7 @@ class gradeitems_test extends advanced_testcase { * * @return array */ - public function is_advancedgrading_itemname_provider(): array { + public static function is_advancedgrading_itemname_provider(): array { return [ 'rating is not advanced' => [ 'rating', diff --git a/mod/forum/tests/h5p/canedit_test.php b/mod/forum/tests/h5p/canedit_test.php index 1973bf8eeb6..2602f615fd3 100644 --- a/mod/forum/tests/h5p/canedit_test.php +++ b/mod/forum/tests/h5p/canedit_test.php @@ -123,7 +123,7 @@ class canedit_test extends \advanced_testcase { * * @return array */ - public function can_edit_content_provider(): array { + public static function can_edit_content_provider(): array { return [ // Component = mod_forum. 'mod_forum: Admin user is author' => [ diff --git a/mod/forum/tests/lib_test.php b/mod/forum/tests/lib_test.php index 1c13e3711c1..d2d70243861 100644 --- a/mod/forum/tests/lib_test.php +++ b/mod/forum/tests/lib_test.php @@ -3242,7 +3242,7 @@ class lib_test extends \advanced_testcase { * * @return array */ - public function forum_discussion_is_locked_provider() { + public static function forum_discussion_is_locked_provider(): array { return [ 'Unlocked: lockdiscussionafter is false' => [ ['lockdiscussionafter' => false], @@ -3296,7 +3296,7 @@ class lib_test extends \advanced_testcase { * * @return array */ - public function forum_is_cutoff_date_reached_provider() { + public static function forum_is_cutoff_date_reached_provider(): array { $now = time(); return [ 'cutoffdate is unset' => [ @@ -3344,7 +3344,7 @@ class lib_test extends \advanced_testcase { * * @return array */ - public function forum_is_due_date_reached_provider() { + public static function forum_is_due_date_reached_provider(): array { $now = time(); return [ 'duedate is unset' => [ @@ -4091,7 +4091,7 @@ class lib_test extends \advanced_testcase { * * @return array */ - public function forum_check_throttling_early_returns_provider() { + public static function forum_check_throttling_early_returns_provider(): array { return [ 'Empty blockafter' => [(object)['id' => 1, 'course' => SITEID, 'blockafter' => 0]], 'Empty blockperiod' => [(object)['id' => 1, 'course' => SITEID, 'blockafter' => DAYSECS, 'blockperiod' => 0]], @@ -4114,7 +4114,7 @@ class lib_test extends \advanced_testcase { * * @return array */ - public function forum_check_throttling_early_exceptions_provider() { + public static function forum_check_throttling_early_exceptions_provider(): array { return [ 'Non-object forum' => ['a'], 'Forum ID not set' => [(object)['id' => false]], diff --git a/mod/forum/tests/mail_test.php b/mod/forum/tests/mail_test.php index 0a4db889641..ac8ea0576f9 100644 --- a/mod/forum/tests/mail_test.php +++ b/mod/forum/tests/mail_test.php @@ -991,7 +991,7 @@ class mail_test extends \advanced_testcase { /** * dataProvider for test_forum_post_email_templates(). */ - public function forum_post_email_templates_provider() { + public static function forum_post_email_templates_provider(): array { // Base information, we'll build variations based on it. $base = array( 'user' => array('firstname' => 'Love', 'lastname' => 'Moodle', 'mailformat' => 0, 'maildigest' => 0), diff --git a/mod/forum/tests/output_email_test.php b/mod/forum/tests/output_email_test.php index 1169e2e032c..1c997632677 100644 --- a/mod/forum/tests/output_email_test.php +++ b/mod/forum/tests/output_email_test.php @@ -29,7 +29,7 @@ class output_email_test extends \advanced_testcase { /** * Data provider for the postdate function tests. */ - public function postdate_provider() { + public static function postdate_provider(): array { return array( 'Timed discussions disabled, timestart unset' => array( 'globalconfig' => array( diff --git a/mod/forum/tests/subscriptions_test.php b/mod/forum/tests/subscriptions_test.php index 1194b60b92b..0bab898dff0 100644 --- a/mod/forum/tests/subscriptions_test.php +++ b/mod/forum/tests/subscriptions_test.php @@ -1311,7 +1311,7 @@ class subscriptions_test extends \advanced_testcase { $this->assertGreaterThan($suppliedcmcount, $calculatedcmcount); } - public function is_subscribable_forums() { + public static function is_subscribable_forums(): array { return [ [ 'forcesubscribe' => FORUM_DISALLOWSUBSCRIBE, @@ -1328,9 +1328,9 @@ class subscriptions_test extends \advanced_testcase { ]; } - public function is_subscribable_provider() { + public static function is_subscribable_provider(): array { $data = []; - foreach ($this->is_subscribable_forums() as $forum) { + foreach (self::is_subscribable_forums() as $forum) { $data[] = [$forum]; } @@ -1369,7 +1369,7 @@ class subscriptions_test extends \advanced_testcase { $this->assertFalse(\mod_forum\subscriptions::is_subscribable($forum)); } - public function is_subscribable_loggedin_provider() { + public static function is_subscribable_loggedin_provider(): array { return [ [ ['forcesubscribe' => FORUM_DISALLOWSUBSCRIBE], diff --git a/mod/glossary/tests/custom_completion_test.php b/mod/glossary/tests/custom_completion_test.php index c9af3d71cd7..87d7cd2ec70 100644 --- a/mod/glossary/tests/custom_completion_test.php +++ b/mod/glossary/tests/custom_completion_test.php @@ -51,7 +51,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, 0, null, coding_exception::class @@ -174,7 +174,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, ['completionentries'] diff --git a/mod/h5pactivity/tests/event/report_viewed_test.php b/mod/h5pactivity/tests/event/report_viewed_test.php index afb5703b70a..a5de5faf978 100644 --- a/mod/h5pactivity/tests/event/report_viewed_test.php +++ b/mod/h5pactivity/tests/event/report_viewed_test.php @@ -114,7 +114,7 @@ class report_viewed_test extends advanced_testcase { * * @return array */ - public function report_viewed_data(): array { + public static function report_viewed_data(): array { return [ // Exception cases. 'Event withour other data (exception)' => [ diff --git a/mod/h5pactivity/tests/external/get_attempts_test.php b/mod/h5pactivity/tests/external/get_attempts_test.php index 86b5a108b45..170da5c827b 100644 --- a/mod/h5pactivity/tests/external/get_attempts_test.php +++ b/mod/h5pactivity/tests/external/get_attempts_test.php @@ -154,7 +154,7 @@ class get_attempts_test extends externallib_advanced_testcase { * * @return array */ - public function execute_data(): array { + public static function execute_data(): array { return [ // Teacher checking a user with attempts. 'Manual grade, Teacher asking participant with attempts' => [ @@ -458,7 +458,7 @@ class get_attempts_test extends externallib_advanced_testcase { * * @return array */ - public function execute_multipleusers_data(): array { + public static function execute_multipleusers_data(): array { return [ // Teacher checks. 'Teacher checking students with attempts' => [ diff --git a/mod/h5pactivity/tests/external/get_h5pactivity_access_information_test.php b/mod/h5pactivity/tests/external/get_h5pactivity_access_information_test.php index 6f7be0dd8b3..816b3ee05f4 100644 --- a/mod/h5pactivity/tests/external/get_h5pactivity_access_information_test.php +++ b/mod/h5pactivity/tests/external/get_h5pactivity_access_information_test.php @@ -90,7 +90,7 @@ class get_h5pactivity_access_information_test extends externallib_advanced_testc * * @return array */ - public function get_h5pactivity_access_information_data(): array { + public static function get_h5pactivity_access_information_data(): array { return [ 'Admin, tracking enabled' => [ '', 1, ['canview', 'canreviewattempts', 'canaddinstance'] diff --git a/mod/h5pactivity/tests/external/get_results_test.php b/mod/h5pactivity/tests/external/get_results_test.php index 081501e5229..031a724ae4f 100644 --- a/mod/h5pactivity/tests/external/get_results_test.php +++ b/mod/h5pactivity/tests/external/get_results_test.php @@ -146,7 +146,7 @@ class get_results_test extends externallib_advanced_testcase { * * @return array */ - public function execute_data(): array { + public static function execute_data(): array { return [ 'Teacher reviewing an attempt' => [ 1, manager::REVIEWCOMPLETION, 'editingteacher', 'student', true, 1 @@ -277,7 +277,7 @@ class get_results_test extends externallib_advanced_testcase { * * @return array */ - public function execute_multipleattempts_data(): array { + public static function execute_multipleattempts_data(): array { return [ // Teacher cases. 'Teacher reviewing students attempts' => [ @@ -408,7 +408,7 @@ class get_results_test extends externallib_advanced_testcase { * * @return array */ - public function execute_mixactivities_data(): array { + public static function execute_mixactivities_data(): array { return [ // Teacher cases. 'Correct activity id' => [ diff --git a/mod/h5pactivity/tests/external/get_user_attempts_test.php b/mod/h5pactivity/tests/external/get_user_attempts_test.php index faff92273f4..e76b868d519 100644 --- a/mod/h5pactivity/tests/external/get_user_attempts_test.php +++ b/mod/h5pactivity/tests/external/get_user_attempts_test.php @@ -145,7 +145,7 @@ class get_user_attempts_test extends externallib_advanced_testcase { * * @return array */ - public function execute_multipleusers_data(): array { + public static function execute_multipleusers_data(): array { return [ // Teacher checks. 'Teacher checking students with attempts' => [ @@ -188,7 +188,7 @@ class get_user_attempts_test extends externallib_advanced_testcase { * * @return array[] */ - public function execute_with_sortorder(): array { + public static function execute_with_sortorder(): array { return [ 'Sort by id' => ['id', ['user01', 'user02']], 'Sort by id desc' => ['id desc', ['user02', 'user01']], diff --git a/mod/h5pactivity/tests/local/attempt_test.php b/mod/h5pactivity/tests/local/attempt_test.php index e4ff6b8d9a2..8278ae1165d 100644 --- a/mod/h5pactivity/tests/local/attempt_test.php +++ b/mod/h5pactivity/tests/local/attempt_test.php @@ -159,7 +159,7 @@ class attempt_test extends \advanced_testcase { * * @return array */ - public function save_statement_data(): array { + public static function save_statement_data(): array { return [ 'Statement without definition and result' => [ '', false, false, [false, 0, 0, 0, 0, null, null] @@ -291,7 +291,7 @@ class attempt_test extends \advanced_testcase { * * @return array */ - public function delete_all_attempts_data(): array { + public static function delete_all_attempts_data(): array { return [ 'Delete all attempts from activity' => [ false, [0, 0, 2, 2, 2, 4] @@ -392,7 +392,7 @@ class attempt_test extends \advanced_testcase { * * @return array */ - public function basic_setters_data(): array { + public static function basic_setters_data(): array { return [ 'Set attempt duration' => [ 'duration', 25, 35 diff --git a/mod/h5pactivity/tests/local/grader_test.php b/mod/h5pactivity/tests/local/grader_test.php index 36389c0c423..870a5119c97 100644 --- a/mod/h5pactivity/tests/local/grader_test.php +++ b/mod/h5pactivity/tests/local/grader_test.php @@ -160,7 +160,7 @@ class grader_test extends \advanced_testcase { * * @return array */ - public function grade_item_update_data(): array { + public static function grade_item_update_data(): array { return [ 'Change idnumber' => [ 100, false, 'newidnumber' @@ -258,7 +258,7 @@ class grader_test extends \advanced_testcase { * * @return array */ - public function update_grades_data(): array { + public static function update_grades_data(): array { return [ // Quantitative grade, all attempts completed. 'Same grademax, all users, all completed' => [ diff --git a/mod/h5pactivity/tests/local/manager_test.php b/mod/h5pactivity/tests/local/manager_test.php index 53bdee4cbab..77bdce412cf 100644 --- a/mod/h5pactivity/tests/local/manager_test.php +++ b/mod/h5pactivity/tests/local/manager_test.php @@ -95,7 +95,7 @@ class manager_test extends \advanced_testcase { * * @return array */ - public function is_tracking_enabled_data(): array { + public static function is_tracking_enabled_data(): array { return [ 'Logged student, tracking enabled' => [ true, 'student', 1, true @@ -209,7 +209,7 @@ class manager_test extends \advanced_testcase { * * @return array */ - public function get_users_scaled_score_data(): array { + public static function get_users_scaled_score_data(): array { return [ 'Tracking with max attempt method' => [ 1, manager::GRADEHIGHESTATTEMPT, [1.00000, 31, 2], [0.66667, 32, 2] @@ -286,7 +286,7 @@ class manager_test extends \advanced_testcase { * * @return array */ - public function get_selected_attempt_data(): array { + public static function get_selected_attempt_data(): array { return [ 'Tracking with max attempt method' => [ 1, manager::GRADEHIGHESTATTEMPT, manager::GRADEHIGHESTATTEMPT @@ -395,7 +395,7 @@ class manager_test extends \advanced_testcase { * * @return array */ - public function can_view_all_attempts_data(): array { + public static function can_view_all_attempts_data(): array { return [ // No tracking cases. 'No tracking with admin using $USER' => [ @@ -467,7 +467,7 @@ class manager_test extends \advanced_testcase { * * @return array */ - public function can_view_own_attempts_data(): array { + public static function can_view_own_attempts_data(): array { return [ // No tracking cases. 'No tracking, review none, using $USER, without attempts' => [ @@ -606,7 +606,7 @@ class manager_test extends \advanced_testcase { * * @return array */ - public function count_attempts_all_data(): array { + public static function count_attempts_all_data(): array { return [ 'Students with both view and submit capability' => [true, true, false, 6], 'Students without view but with submit capability' => [false, true, false, 0], @@ -672,7 +672,7 @@ class manager_test extends \advanced_testcase { * * @return array */ - public function get_active_users_join_data(): array { + public static function get_active_users_join_data(): array { return [ 'All potential users' => [ 'allpotentialusers' => true, @@ -895,7 +895,7 @@ class manager_test extends \advanced_testcase { * * @return array */ - public function get_report_data(): array { + public static function get_report_data(): array { return [ // No tracking scenarios. 'No tracking, review none, no attempts, teacher' => [ @@ -1030,7 +1030,7 @@ class manager_test extends \advanced_testcase { * * @return array */ - public function get_report_data_groupmode(): array { + public static function get_report_data_groupmode(): array { return [ // No tracking scenarios. 'course groupmode is SEPARATEGROUPS' => [false], @@ -1088,7 +1088,7 @@ class manager_test extends \advanced_testcase { * * @return array */ - public function get_attempt_data(): array { + public static function get_attempt_data(): array { return [ 'Get the current activity attempt' => [ 'current', 'current' diff --git a/mod/h5pactivity/tests/restore_test.php b/mod/h5pactivity/tests/restore_test.php index 6b3d7778895..a060b1f08a5 100644 --- a/mod/h5pactivity/tests/restore_test.php +++ b/mod/h5pactivity/tests/restore_test.php @@ -155,7 +155,7 @@ class restore_test extends advanced_testcase { * * @return array */ - public function backup_restore_data(): array { + public static function backup_restore_data(): array { return [ 'Activity attempts and restore with userdata' => [ true, true, [1, 1, 3], [1, 1, 3] diff --git a/mod/label/tests/lib_test.php b/mod/label/tests/lib_test.php index 90f16ed8464..911651554ab 100644 --- a/mod/label/tests/lib_test.php +++ b/mod/label/tests/lib_test.php @@ -231,7 +231,7 @@ class lib_test extends \advanced_testcase { * * @return array */ - public function label_get_name_data_provider(): array { + public static function label_get_name_data_provider(): array { return [ 'simple' => [ 'content' => '

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 = << diff --git a/mod/quiz/accessrule/seb/tests/access_manager_test.php b/mod/quiz/accessrule/seb/tests/access_manager_test.php index 3a7743add70..8fd5e308349 100644 --- a/mod/quiz/accessrule/seb/tests/access_manager_test.php +++ b/mod/quiz/accessrule/seb/tests/access_manager_test.php @@ -343,7 +343,7 @@ class access_manager_test extends \advanced_testcase { * * @return array */ - public function should_validate_basic_header_data_provider() { + public static function should_validate_basic_header_data_provider(): array { return [ [settings_provider::USE_SEB_NO, false], [settings_provider::USE_SEB_CONFIG_MANUALLY, false], @@ -377,7 +377,7 @@ class access_manager_test extends \advanced_testcase { * * @return array */ - public function should_validate_config_key_data_provider() { + public static function should_validate_config_key_data_provider(): array { return [ [settings_provider::USE_SEB_NO, false], [settings_provider::USE_SEB_CONFIG_MANUALLY, true], @@ -410,7 +410,7 @@ class access_manager_test extends \advanced_testcase { * * @return array */ - public function should_validate_browser_exam_key_data_provider() { + public static function should_validate_browser_exam_key_data_provider(): array { return [ [settings_provider::USE_SEB_NO, false], [settings_provider::USE_SEB_CONFIG_MANUALLY, false], diff --git a/mod/quiz/accessrule/seb/tests/config_key_test.php b/mod/quiz/accessrule/seb/tests/config_key_test.php index cf21162b42a..1e4f2f7572d 100644 --- a/mod/quiz/accessrule/seb/tests/config_key_test.php +++ b/mod/quiz/accessrule/seb/tests/config_key_test.php @@ -59,7 +59,7 @@ class config_key_test extends \advanced_testcase { * * @return array */ - public function real_ck_hash_provider() : array { + public static function real_ck_hash_provider(): array { return [ 'unencrypted_mac2.1.4' => ['unencrypted_mac_001.seb', '4fa9af8ec8759eb7c680752ef4ee5eaf1a860628608fccae2715d519849f9292', ''], diff --git a/mod/quiz/accessrule/seb/tests/external/validate_quiz_access_test.php b/mod/quiz/accessrule/seb/tests/external/validate_quiz_access_test.php index 4a470a4d381..ec765772125 100644 --- a/mod/quiz/accessrule/seb/tests/external/validate_quiz_access_test.php +++ b/mod/quiz/accessrule/seb/tests/external/validate_quiz_access_test.php @@ -56,7 +56,7 @@ class validate_quiz_access_test extends \advanced_testcase { * * @return array */ - public function bad_parameters_provider(): array { + public static function bad_parameters_provider(): array { return [ 'no params' => [ 'cmid' => null, diff --git a/mod/quiz/accessrule/seb/tests/property_list_test.php b/mod/quiz/accessrule/seb/tests/property_list_test.php index 50eef499869..b6def63d989 100644 --- a/mod/quiz/accessrule/seb/tests/property_list_test.php +++ b/mod/quiz/accessrule/seb/tests/property_list_test.php @@ -304,7 +304,7 @@ class property_list_test extends \advanced_testcase { * * @return array Array with test data. */ - public function good_update_data_provider() : array { + public static function good_update_data_provider(): array { return [ 'Update string' => ['testKeytestValue', 'testKey', 'newValue'], 'Update bool' => ['testKey', 'testKey', false], @@ -317,7 +317,7 @@ class property_list_test extends \advanced_testcase { * * @return array Array with test data. */ - public function bad_update_data_provider() : array { + public static function bad_update_data_provider(): array { return [ 'Update string with bool' => ['testKeytestValue', 'testKey', true, 'testValue', @@ -379,7 +379,7 @@ class property_list_test extends \advanced_testcase { * * @return array */ - public function json_data_provider() : array { + public static function json_data_provider(): array { $data = "blahblah"; $base64data = base64_encode($data); diff --git a/mod/quiz/accessrule/seb/tests/quiz_settings_test.php b/mod/quiz/accessrule/seb/tests/quiz_settings_test.php index 57335a77f8d..7fa0ba32a45 100644 --- a/mod/quiz/accessrule/seb/tests/quiz_settings_test.php +++ b/mod/quiz/accessrule/seb/tests/quiz_settings_test.php @@ -528,7 +528,7 @@ class quiz_settings_test extends \advanced_testcase { * * @return array */ - public function bad_browser_exam_key_provider() : array { + public static function bad_browser_exam_key_provider(): array { return [ 'Short string' => ['fdsf434r', 'A key should be a 64-character hex string.'], @@ -544,7 +544,7 @@ class quiz_settings_test extends \advanced_testcase { * * @return array Test data. */ - public function filter_rules_provider() : array { + public static function filter_rules_provider(): array { return [ 'enabled simple expessions' => [ (object) [ diff --git a/mod/quiz/accessrule/seb/tests/rule_test.php b/mod/quiz/accessrule/seb/tests/rule_test.php index dccca8fc453..307bb2c6182 100644 --- a/mod/quiz/accessrule/seb/tests/rule_test.php +++ b/mod/quiz/accessrule/seb/tests/rule_test.php @@ -87,7 +87,7 @@ class rule_test extends \advanced_testcase { * * @return array */ - public function valid_form_data_provider() : array { + public static function valid_form_data_provider(): array { return [ 'valid seb_requiresafeexambrowser' => ['seb_requiresafeexambrowser', '0'], 'valid seb_linkquitseb0' => ['seb_linkquitseb', 'http://safeexambrowser.org/macosx'], @@ -103,7 +103,7 @@ class rule_test extends \advanced_testcase { * * @return array */ - public function invalid_form_data_provider() : array { + public static function invalid_form_data_provider(): array { return [ 'invalid seb_requiresafeexambrowser' => ['seb_requiresafeexambrowser', 'Uh oh!'], 'invalid seb_linkquitseb0' => ['seb_linkquitseb', '\0'], diff --git a/mod/quiz/accessrule/seb/tests/settings_provider_test.php b/mod/quiz/accessrule/seb/tests/settings_provider_test.php index 7f63c36393d..a87afffb818 100644 --- a/mod/quiz/accessrule/seb/tests/settings_provider_test.php +++ b/mod/quiz/accessrule/seb/tests/settings_provider_test.php @@ -93,7 +93,7 @@ class settings_provider_test extends \advanced_testcase { * * @return array */ - public function settings_capability_data_provider() { + public static function settings_capability_data_provider(): array { $data = []; // Build first level SEB config settings. Any of this setting let us use SEB manual config. diff --git a/mod/quiz/accessrule/timelimit/tests/rule_test.php b/mod/quiz/accessrule/timelimit/tests/rule_test.php index 36a075bc841..a2b4ff77d5c 100644 --- a/mod/quiz/accessrule/timelimit/tests/rule_test.php +++ b/mod/quiz/accessrule/timelimit/tests/rule_test.php @@ -63,7 +63,7 @@ class rule_test extends \basic_testcase { * * @return array of ($timetoclose, $timelimit, $displaylimit, $actuallimit) */ - public function time_limit_access_rule_with_time_close_provider() { + public static function time_limit_access_rule_with_time_close_provider(): array { return [ 'Close time is earlier than time limit' => [1800, 3600, 3600, 1800], 'Close time is on time limit' => [3600, 3600, 3600, 3600], diff --git a/mod/quiz/report/overview/tests/report_test.php b/mod/quiz/report/overview/tests/report_test.php index f82d457f069..e040be3331b 100644 --- a/mod/quiz/report/overview/tests/report_test.php +++ b/mod/quiz/report/overview/tests/report_test.php @@ -53,7 +53,7 @@ class report_test extends \advanced_testcase { * * @return array the data for the test sub-cases. */ - public function report_sql_cases(): array { + public static function report_sql_cases(): array { return [[null], ['csv']]; // Only need to test on or off, not all download types. } @@ -247,7 +247,7 @@ class report_test extends \advanced_testcase { * Bands provider. * @return array */ - public function get_bands_count_and_width_provider(): array { + public static function get_bands_count_and_width_provider(): array { return [ [10, [20, .5]], [20, [20, 1]], diff --git a/mod/quiz/tests/dates_test.php b/mod/quiz/tests/dates_test.php index b550f1690ed..5b0c135612c 100644 --- a/mod/quiz/tests/dates_test.php +++ b/mod/quiz/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/quiz/tests/locallib_test.php b/mod/quiz/tests/locallib_test.php index 06e1b5b06e7..a3c9f687a8d 100644 --- a/mod/quiz/tests/locallib_test.php +++ b/mod/quiz/tests/locallib_test.php @@ -58,7 +58,7 @@ class locallib_test extends \advanced_testcase { format_float(0.247, 3)); } - public function quiz_attempt_state_data_provider() { + public static function quiz_attempt_state_data_provider(): array { return [ [quiz_attempt::IN_PROGRESS, null, null, mod_quiz_display_options::DURING], [quiz_attempt::FINISHED, -90, null, mod_quiz_display_options::IMMEDIATELY_AFTER], diff --git a/mod/scorm/tests/custom_completion_test.php b/mod/scorm/tests/custom_completion_test.php index cf267af1c76..fdb083d4282 100644 --- a/mod/scorm/tests/custom_completion_test.php +++ b/mod/scorm/tests/custom_completion_test.php @@ -44,7 +44,7 @@ class custom_completion_test extends advanced_testcase { * * @return array[] */ - public function get_state_provider(): array { + public static function get_state_provider(): array { // Prepare various reusable user scorm track data used to mock various completion states/requirements. $completionincomplete = (object) [ @@ -301,7 +301,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 status enabled only' => [ [ diff --git a/mod/scorm/tests/dates_test.php b/mod/scorm/tests/dates_test.php index 363e5444af9..f9cf79c1dcc 100644 --- a/mod/scorm/tests/dates_test.php +++ b/mod/scorm/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/scorm/tests/event/events_test.php b/mod/scorm/tests/event/events_test.php index f05177da285..db1a90fd771 100644 --- a/mod/scorm/tests/event/events_test.php +++ b/mod/scorm/tests/event/events_test.php @@ -392,7 +392,7 @@ class events_test extends \advanced_testcase { /** * dataProvider for test_scoreraw_submitted_event(). */ - public function get_scoreraw_submitted_event_provider() { + public static function get_scoreraw_submitted_event_provider(): array { return array( // SCORM 1.2. // - cmi.core.score.raw. @@ -450,7 +450,7 @@ class events_test extends \advanced_testcase { /** * dataProvider for test_scoreraw_submitted_event_validations(). */ - public function get_scoreraw_submitted_event_validations() { + public static function get_scoreraw_submitted_event_validations(): array { return array( 'scoreraw_submitted => missing cmielement' => array( null, '50', @@ -511,7 +511,7 @@ class events_test extends \advanced_testcase { /** * dataProvider for test_status_submitted_event(). */ - public function get_status_submitted_event_provider() { + public static function get_status_submitted_event_provider(): array { return array( // SCORM 1.2. // 1. Status: cmi.core.lesson_status. @@ -571,7 +571,7 @@ class events_test extends \advanced_testcase { /** * dataProvider for test_status_submitted_event_validations(). */ - public function get_status_submitted_event_validations() { + public static function get_status_submitted_event_validations(): array { return array( 'status_submitted => missing cmielement' => array( null, 'passed', diff --git a/mod/survey/tests/custom_completion_test.php b/mod/survey/tests/custom_completion_test.php index 08b12b7cb04..98373d8e05b 100644 --- a/mod/survey/tests/custom_completion_test.php +++ b/mod/survey/tests/custom_completion_test.php @@ -51,7 +51,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 @@ -174,7 +174,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/wiki/tests/wikiparser_test.php b/mod/wiki/tests/wikiparser_test.php index d267cb5b517..d878a9e4338 100644 --- a/mod/wiki/tests/wikiparser_test.php +++ b/mod/wiki/tests/wikiparser_test.php @@ -64,7 +64,7 @@ class wikiparser_test extends \advanced_testcase { * * @return array */ - public function urls_inside_link_text_provider() { + public static function urls_inside_link_text_provider(): array { return [ 'creole implicit link' => [ 'markup' => 'creole', diff --git a/mod/workshop/tests/dates_test.php b/mod/workshop/tests/dates_test.php index 0484a5d146f..3c49437bf81 100644 --- a/mod/workshop/tests/dates_test.php +++ b/mod/workshop/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/workshop/tests/lib_test.php b/mod/workshop/tests/lib_test.php index ef6c2005f74..eddb14b9c53 100644 --- a/mod/workshop/tests/lib_test.php +++ b/mod/workshop/tests/lib_test.php @@ -537,7 +537,7 @@ class lib_test extends \advanced_testcase { * * @return array of (submissionstart, submissionend, assessmentstart, assessmentend, eventtype, expectedmin, expectedmax) */ - public function mod_workshop_core_calendar_get_valid_event_timestart_range_due_no_limit_provider() { + public static function mod_workshop_core_calendar_get_valid_event_timestart_range_due_no_limit_provider(): array { $submissionstart = time() + DAYSECS; $submissionend = $submissionstart + DAYSECS; $assessmentstart = $submissionend + DAYSECS; @@ -692,7 +692,7 @@ class lib_test extends \advanced_testcase { * * @return array of (submissionstart, submissionend, assessmentstart, assessmentend, eventtype, fieldtoupdate, newtime) */ - public function mod_workshop_core_calendar_event_timestart_updated_provider() { + public static function mod_workshop_core_calendar_event_timestart_updated_provider(): array { $submissionstart = time() + DAYSECS; $submissionend = $submissionstart + DAYSECS; $assessmentstart = $submissionend + DAYSECS; diff --git a/notes/tests/reportbuilder/datasource/notes_test.php b/notes/tests/reportbuilder/datasource/notes_test.php index 1421e8fa45e..28e8ea37183 100644 --- a/notes/tests/reportbuilder/datasource/notes_test.php +++ b/notes/tests/reportbuilder/datasource/notes_test.php @@ -140,7 +140,7 @@ class notes_test extends core_reportbuilder_testcase { * * @return array[] */ - public function datasource_filters_provider(): array { + public static function datasource_filters_provider(): array { return [ 'Filter content' => ['content', 'Cool', 'note:content', [ 'note:content_operator' => text::IS_EQUAL_TO, diff --git a/payment/tests/helper_test.php b/payment/tests/helper_test.php index 80b3c547c8a..bb66e0716cf 100644 --- a/payment/tests/helper_test.php +++ b/payment/tests/helper_test.php @@ -137,7 +137,7 @@ class helper_test extends advanced_testcase { * * @return array */ - public function get_rounded_cost_provider(): array { + public static function get_rounded_cost_provider(): array { return [ 'IRR 0 surcharge' => [5.345, 'IRR', 0, 5], 'IRR 12% surcharge' => [5.345, 'IRR', 12, 6], @@ -151,7 +151,7 @@ class helper_test extends advanced_testcase { * * @return array[] */ - public function get_cost_as_string_provider(): array { + public static function get_cost_as_string_provider(): array { return [ 'IRR 0 surcharge' => [5.345, 'IRR', 0, 'IRR'."\xc2\xa0".'5'], 'IRR 12% surcharge' => [5.345, 'IRR', 12, 'IRR'."\xc2\xa0".'6'], diff --git a/privacy/tests/collection_test.php b/privacy/tests/collection_test.php index 1a1c81025a2..9a7c482c706 100644 --- a/privacy/tests/collection_test.php +++ b/privacy/tests/collection_test.php @@ -199,7 +199,7 @@ class collection_test extends \advanced_testcase { * * @return array */ - public function component_list_provider() { + public static function component_list_provider(): array { return [ ['core_privacy'], ['mod_forum'], diff --git a/privacy/tests/contextlist_base_test.php b/privacy/tests/contextlist_base_test.php index 851710e5533..bdef2e312c4 100644 --- a/privacy/tests/contextlist_base_test.php +++ b/privacy/tests/contextlist_base_test.php @@ -64,7 +64,7 @@ class contextlist_base_test extends advanced_testcase { * * @return array */ - public function get_contextids_provider() { + public static function get_contextids_provider(): array { return [ 'basic' => [ [1, 2, 3, 4, 5], diff --git a/privacy/tests/contextlist_test.php b/privacy/tests/contextlist_test.php index b81cdd631d3..a7038d0066c 100644 --- a/privacy/tests/contextlist_test.php +++ b/privacy/tests/contextlist_test.php @@ -138,7 +138,7 @@ class contextlist_test extends advanced_testcase { * * @return array */ - public function data_guess_id_field_from_sql() { + public static function data_guess_id_field_from_sql(): array { return [ 'easy' => [ 'SELECT contextid FROM {foo}', diff --git a/privacy/tests/manager_test.php b/privacy/tests/manager_test.php index f749609a319..c91002e8ab8 100644 --- a/privacy/tests/manager_test.php +++ b/privacy/tests/manager_test.php @@ -138,7 +138,7 @@ class manager_test extends \advanced_testcase { * * @return array */ - public function component_is_compliant_provider() { + public static function component_is_compliant_provider(): array { return [ 'An empty subsystem' => [ 'core_countries', @@ -294,7 +294,7 @@ class manager_test extends \advanced_testcase { * * @return array */ - public function is_empty_subsystem_provider() { + public static function is_empty_subsystem_provider(): array { return [ 'A subsystem which has no directory' => [ 'core_langconfig', diff --git a/privacy/tests/moodle_content_writer_test.php b/privacy/tests/moodle_content_writer_test.php index e2d8de216fe..939ef1dd546 100644 --- a/privacy/tests/moodle_content_writer_test.php +++ b/privacy/tests/moodle_content_writer_test.php @@ -173,7 +173,7 @@ class moodle_content_writer_test extends advanced_testcase { /** * Data provider for exporting user data. */ - public function export_data_provider() { + public static function export_data_provider(): array { return [ 'basic' => [ (object) [ @@ -308,7 +308,7 @@ class moodle_content_writer_test extends advanced_testcase { * * return array */ - public function export_metadata_provider() { + public static function export_metadata_provider(): array { return [ 'basic' => [ 'key', @@ -472,7 +472,7 @@ class moodle_content_writer_test extends advanced_testcase { * * @return array */ - public function export_file_provider() { + public static function export_file_provider(): array { return [ 'basic' => [ 'intro', @@ -858,7 +858,7 @@ class moodle_content_writer_test extends advanced_testcase { * * @return array */ - public function export_user_preference_provider() { + public static function export_user_preference_provider(): array { return [ 'basic' => [ 'core_privacy', @@ -1024,7 +1024,7 @@ class moodle_content_writer_test extends advanced_testcase { * * @return array */ - public function unescaped_unicode_export_provider() { + public static function unescaped_unicode_export_provider(): array { return [ 'Unicode' => ['ةكءيٓ‌پچژکگیٹڈڑہھےâîûğŞAaÇÖáǽ你好!'], ]; @@ -1193,7 +1193,7 @@ class moodle_content_writer_test extends advanced_testcase { * * @return array */ - public function long_filename_provider() { + public static function long_filename_provider(): array { return [ 'More than 100 characters' => [ 'Etiam sit amet dui vel leo blandit viverra. Proin viverra suscipit velit. Aenean efficitur suscipit nibh nec suscipit', @@ -1290,7 +1290,7 @@ class moodle_content_writer_test extends advanced_testcase { * * @return array */ - public function rewrite_pluginfile_urls_provider() { + public static function rewrite_pluginfile_urls_provider(): array { return [ 'nullcontent' => [ 'intro', diff --git a/privacy/tests/privacy/provider_test.php b/privacy/tests/privacy/provider_test.php index d49735378b2..87125bba89c 100644 --- a/privacy/tests/privacy/provider_test.php +++ b/privacy/tests/privacy/provider_test.php @@ -46,7 +46,7 @@ class provider_test extends \advanced_testcase { * * @return array the array of frankenstyle component names with the relevant class name. */ - public function get_component_list() { + public static function get_component_list(): array { $components = ['core' => [ 'component' => 'core', 'classname' => manager::get_provider_classname_for_component('core') @@ -97,12 +97,12 @@ class provider_test extends \advanced_testcase { * * @return array */ - public function null_provider_provider() { - return array_filter($this->get_component_list(), function($component) { - return static::component_implements( - $component['classname'], - \core_privacy\local\metadata\null_provider::class - ); + public static function null_provider_provider(): array { + return array_filter(self::get_component_list(), function($component): bool { + return static::component_implements( + $component['classname'], + \core_privacy\local\metadata\null_provider::class + ); }); } @@ -218,12 +218,12 @@ class provider_test extends \advanced_testcase { * * @return array */ - public function metadata_provider_provider() { - return array_filter($this->get_component_list(), function($component) { - return static::component_implements( - $component['classname'], - \core_privacy\local\metadata\provider::class - ); + public static function metadata_provider_provider(): array { + return array_filter(self::get_component_list(), function($component): bool { + return static::component_implements( + $component['classname'], + \core_privacy\local\metadata\provider::class + ); }); } @@ -232,12 +232,12 @@ class provider_test extends \advanced_testcase { * * @return array */ - public function is_user_data_provider() { - return array_filter($this->get_component_list(), function($component) { - return static::component_implements( - $component['classname'], - \core_privacy\local\request\core_user_data_provider::class - ); + public static function is_user_data_provider(): array { + return array_filter(self::get_component_list(), function($component): bool { + return static::component_implements( + $component['classname'], + \core_privacy\local\request\core_user_data_provider::class + ); }); } @@ -310,7 +310,7 @@ class provider_test extends \advanced_testcase { } } - $componentlist = $this->metadata_provider_provider(); + $componentlist = self::metadata_provider_provider(); foreach ($componentlist as $componentarray) { $component = $componentarray['component']; $classname = $componentarray['classname']; diff --git a/privacy/tests/request_transform_test.php b/privacy/tests/request_transform_test.php index 4182273158b..da5505a7768 100644 --- a/privacy/tests/request_transform_test.php +++ b/privacy/tests/request_transform_test.php @@ -110,7 +110,7 @@ class request_transform_test extends advanced_testcase { * * @return array */ - public function yesno_provider() { + public static function yesno_provider(): array { return [ 'Bool False' => [ false, diff --git a/privacy/tests/types_database_table_test.php b/privacy/tests/types_database_table_test.php index 9d46af57f61..714a6b5faf9 100644 --- a/privacy/tests/types_database_table_test.php +++ b/privacy/tests/types_database_table_test.php @@ -84,7 +84,7 @@ class types_database_table_test extends \advanced_testcase { * * @return array */ - public function invalid_string_provider() { + public static function invalid_string_provider(): array { return [ 'Space in summary' => [ 'example', @@ -128,7 +128,7 @@ class types_database_table_test extends \advanced_testcase { * * @return array */ - public function valid_string_provider() { + public static function valid_string_provider(): array { return [ 'Valid combination' => [ 'example', diff --git a/privacy/tests/types_external_location_test.php b/privacy/tests/types_external_location_test.php index 87a39072777..34bfa71e52d 100644 --- a/privacy/tests/types_external_location_test.php +++ b/privacy/tests/types_external_location_test.php @@ -84,7 +84,7 @@ class types_external_location_test extends \advanced_testcase { * * @return array */ - public function invalid_string_provider() { + public static function invalid_string_provider(): array { return [ 'Space in summary' => [ 'example', @@ -128,7 +128,7 @@ class types_external_location_test extends \advanced_testcase { * * @return array */ - public function valid_string_provider() { + public static function valid_string_provider(): array { return [ 'Valid combination' => [ 'example', diff --git a/privacy/tests/types_plugintype_link_test.php b/privacy/tests/types_plugintype_link_test.php index 187c5f3b49a..e268941a19b 100644 --- a/privacy/tests/types_plugintype_link_test.php +++ b/privacy/tests/types_plugintype_link_test.php @@ -77,7 +77,7 @@ class types_plugintype_link_test extends \advanced_testcase { * * @return array */ - public function invalid_string_provider() { + public static function invalid_string_provider(): array { return [ 'Space in summary' => [ 'example', @@ -97,7 +97,7 @@ class types_plugintype_link_test extends \advanced_testcase { * * @return array */ - public function valid_string_provider() { + public static function valid_string_provider(): array { return [ 'Valid combination' => [ 'example', diff --git a/privacy/tests/types_subsystem_link_test.php b/privacy/tests/types_subsystem_link_test.php index 53cc24586e3..aaace71ae41 100644 --- a/privacy/tests/types_subsystem_link_test.php +++ b/privacy/tests/types_subsystem_link_test.php @@ -77,7 +77,7 @@ class types_subsystem_link_test extends \advanced_testcase { * * @return array */ - public function invalid_string_provider() { + public static function invalid_string_provider(): array { return [ 'Space in summary' => [ 'example', @@ -97,7 +97,7 @@ class types_subsystem_link_test extends \advanced_testcase { * * @return array */ - public function valid_string_provider() { + public static function valid_string_provider(): array { return [ 'Valid combination' => [ 'example', diff --git a/privacy/tests/types_user_preference_test.php b/privacy/tests/types_user_preference_test.php index 3e2dd30e452..c0c12b4a64b 100644 --- a/privacy/tests/types_user_preference_test.php +++ b/privacy/tests/types_user_preference_test.php @@ -77,7 +77,7 @@ class types_user_preference_test extends \advanced_testcase { * * @return array */ - public function invalid_string_provider() { + public static function invalid_string_provider(): array { return [ 'Space in summary' => [ 'example', @@ -95,7 +95,7 @@ class types_user_preference_test extends \advanced_testcase { * * @return array */ - public function valid_string_provider() { + public static function valid_string_provider(): array { return [ 'Valid combination' => [ 'example', diff --git a/privacy/tests/userlist_base_test.php b/privacy/tests/userlist_base_test.php index 0a5e7bfe8ba..9e8ffaf39d1 100644 --- a/privacy/tests/userlist_base_test.php +++ b/privacy/tests/userlist_base_test.php @@ -64,7 +64,7 @@ class userlist_base_test extends advanced_testcase { * * @return array */ - public function get_userids_provider() { + public static function get_userids_provider(): array { return [ 'basic' => [ [1, 2, 3, 4, 5], diff --git a/question/bank/statistics/tests/helper_test.php b/question/bank/statistics/tests/helper_test.php index 2071ea749c7..e5719ad2dbf 100644 --- a/question/bank/statistics/tests/helper_test.php +++ b/question/bank/statistics/tests/helper_test.php @@ -194,7 +194,7 @@ class helper_test extends \advanced_testcase { * * @return array */ - private function generate_attempt_answers(array $correctanswerflags): array { + private static function generate_attempt_answers(array $correctanswerflags): array { $attempt = []; for ($i = 1; $i <= 4; $i++) { if (isset($correctanswerflags) && $correctanswerflags[$i - 1] == 1) { @@ -266,31 +266,31 @@ class helper_test extends \advanced_testcase { * * @return \Generator */ - public function load_question_facility_provider(): \Generator { + public static function load_question_facility_provider(): \Generator { yield 'Facility case 1' => [ 'Quiz 1 attempts' => [ - $this->generate_attempt_answers([1, 0, 0, 0]), + self::generate_attempt_answers([1, 0, 0, 0]), ], 'Expected quiz 1 facilities' => ['100.00%', '0.00%', '0.00%', '0.00%'], 'Quiz 2 attempts' => [ - $this->generate_attempt_answers([1, 0, 0, 0]), - $this->generate_attempt_answers([1, 1, 0, 0]), + self::generate_attempt_answers([1, 0, 0, 0]), + self::generate_attempt_answers([1, 1, 0, 0]), ], 'Expected quiz 2 facilities' => ['100.00%', '50.00%', '0.00%', '0.00%'], 'Expected average facilities' => ['100.00%', '25.00%', '0.00%', '0.00%'], ]; yield 'Facility case 2' => [ 'Quiz 1 attempts' => [ - $this->generate_attempt_answers([1, 0, 0, 0]), - $this->generate_attempt_answers([1, 1, 0, 0]), - $this->generate_attempt_answers([1, 1, 1, 0]), + self::generate_attempt_answers([1, 0, 0, 0]), + self::generate_attempt_answers([1, 1, 0, 0]), + self::generate_attempt_answers([1, 1, 1, 0]), ], 'Expected quiz 1 facilities' => ['100.00%', '66.67%', '33.33%', '0.00%'], 'Quiz 2 attempts' => [ - $this->generate_attempt_answers([1, 0, 0, 0]), - $this->generate_attempt_answers([1, 1, 0, 0]), - $this->generate_attempt_answers([1, 1, 1, 0]), - $this->generate_attempt_answers([1, 1, 1, 1]), + self::generate_attempt_answers([1, 0, 0, 0]), + self::generate_attempt_answers([1, 1, 0, 0]), + self::generate_attempt_answers([1, 1, 1, 0]), + self::generate_attempt_answers([1, 1, 1, 1]), ], 'Expected quiz 2 facilities' => ['100.00%', '75.00%', '50.00%', '25.00%'], 'Expected average facilities' => ['100.00%', '70.83%', '41.67%', '12.50%'], @@ -359,20 +359,20 @@ class helper_test extends \advanced_testcase { * Data provider for {@see test_load_question_discriminative_efficiency()}. * @return \Generator */ - public function load_question_discriminative_efficiency_provider(): \Generator { + public static function load_question_discriminative_efficiency_provider(): \Generator { yield 'Discriminative efficiency' => [ 'Quiz 1 attempts' => [ - $this->generate_attempt_answers([1, 0, 0, 0]), - $this->generate_attempt_answers([1, 1, 0, 0]), - $this->generate_attempt_answers([1, 0, 1, 0]), - $this->generate_attempt_answers([1, 1, 1, 1]), + self::generate_attempt_answers([1, 0, 0, 0]), + self::generate_attempt_answers([1, 1, 0, 0]), + self::generate_attempt_answers([1, 0, 1, 0]), + self::generate_attempt_answers([1, 1, 1, 1]), ], 'Expected quiz 1 discriminative efficiency' => ['N/A', '33.33%', '33.33%', '100.00%'], 'Quiz 2 attempts' => [ - $this->generate_attempt_answers([1, 1, 1, 1]), - $this->generate_attempt_answers([0, 0, 0, 0]), - $this->generate_attempt_answers([1, 0, 0, 1]), - $this->generate_attempt_answers([0, 1, 1, 0]), + self::generate_attempt_answers([1, 1, 1, 1]), + self::generate_attempt_answers([0, 0, 0, 0]), + self::generate_attempt_answers([1, 0, 0, 1]), + self::generate_attempt_answers([0, 1, 1, 0]), ], 'Expected quiz 2 discriminative efficiency' => ['50.00%', '50.00%', '50.00%', '50.00%'], 'Expected average discriminative efficiency' => ['50.00%', '41.67%', '41.67%', '75.00%'], @@ -465,20 +465,20 @@ class helper_test extends \advanced_testcase { * Data provider for {@see test_load_question_discrimination_index()}. * @return \Generator */ - public function load_question_discrimination_index_provider(): \Generator { + public static function load_question_discrimination_index_provider(): \Generator { yield 'Discrimination Index' => [ 'Quiz 1 attempts' => [ - $this->generate_attempt_answers([1, 0, 0, 0]), - $this->generate_attempt_answers([1, 1, 0, 0]), - $this->generate_attempt_answers([1, 0, 1, 0]), - $this->generate_attempt_answers([1, 1, 1, 1]), + self::generate_attempt_answers([1, 0, 0, 0]), + self::generate_attempt_answers([1, 1, 0, 0]), + self::generate_attempt_answers([1, 0, 1, 0]), + self::generate_attempt_answers([1, 1, 1, 1]), ], 'Expected quiz 1 Discrimination Index' => ['N/A', '30.15%', '30.15%', '81.65%'], 'Quiz 2 attempts' => [ - $this->generate_attempt_answers([1, 1, 1, 1]), - $this->generate_attempt_answers([0, 0, 0, 0]), - $this->generate_attempt_answers([1, 0, 0, 1]), - $this->generate_attempt_answers([0, 1, 1, 0]), + self::generate_attempt_answers([1, 1, 1, 1]), + self::generate_attempt_answers([0, 0, 0, 0]), + self::generate_attempt_answers([1, 0, 0, 1]), + self::generate_attempt_answers([0, 1, 1, 0]), ], 'Expected quiz 2 discrimination Index' => ['44.72%', '44.72%', '44.72%', '44.72%'], 'Expected average discrimination Index' => ['44.72%', '37.44%', '37.44%', '63.19%'], diff --git a/question/bank/tagquestion/tests/external/submit_tags_test.php b/question/bank/tagquestion/tests/external/submit_tags_test.php index f4d5602abe0..ced1fbd2613 100644 --- a/question/bank/tagquestion/tests/external/submit_tags_test.php +++ b/question/bank/tagquestion/tests/external/submit_tags_test.php @@ -192,7 +192,7 @@ class submit_tags_test extends \externallib_advanced_testcase { * * @return array Test cases */ - public function get_submit_tags_form_testcases() { + public static function get_submit_tags_form_testcases(): array { return [ 'course - course' => [ 'editingcontext' => 'course', @@ -274,7 +274,7 @@ class submit_tags_test extends \externallib_advanced_testcase { * Course tags can only be set on a course category or system context question that * is being editing in a course context. * - * @dataProvider get_submit_tags_form_testcases() + * @dataProvider get_submit_tags_form_testcases * @param string $editingcontext The type of the context the question is being edited in * @param string $questioncontext The type of the context the question belongs to * @param string[] $questiontags The tag names to set as question tags diff --git a/question/engine/tests/question_display_options_test.php b/question/engine/tests/question_display_options_test.php index 1923c7bc27d..ece6c30f22a 100644 --- a/question/engine/tests/question_display_options_test.php +++ b/question/engine/tests/question_display_options_test.php @@ -32,7 +32,7 @@ class question_display_options_test extends \advanced_testcase { * * @return array[] */ - public function has_question_identifier_provider(): array { + public static function has_question_identifier_provider(): array { return [ 'Empty string' => ['', false], 'Empty space' => [' ', false], @@ -61,7 +61,7 @@ class question_display_options_test extends \advanced_testcase { * * @return array[] */ - public function add_question_identifier_to_label_provider(): array { + public static function add_question_identifier_to_label_provider(): array { return [ 'Empty string identifier' => ['Hello', '', false, false, "Hello"], 'Null identifier' => ['Hello', null, false, false, "Hello"], diff --git a/question/engine/tests/question_engine_test.php b/question/engine/tests/question_engine_test.php index edb2aa9fcf8..6bc38bd6b55 100644 --- a/question/engine/tests/question_engine_test.php +++ b/question/engine/tests/question_engine_test.php @@ -88,7 +88,7 @@ class question_engine_test extends advanced_testcase { * * @return array */ - public function get_behaviour_unused_display_options_provider(): array { + public static function get_behaviour_unused_display_options_provider(): array { return [ 'interactive' => [ 'interactive', @@ -126,7 +126,7 @@ class question_engine_test extends advanced_testcase { * * @return array */ - public function can_questions_finish_during_the_attempt_provider(): array { + public static function can_questions_finish_during_the_attempt_provider(): array { return [ ['deferredfeedback', false], ['interactive', true], @@ -150,7 +150,7 @@ class question_engine_test extends advanced_testcase { * * @return array */ - public function sort_behaviours_provider(): array { + public static function sort_behaviours_provider(): array { $in = [ 'b1' => 'Behave 1', 'b2' => 'Behave 2', @@ -221,7 +221,7 @@ class question_engine_test extends advanced_testcase { * * @return array */ - public function is_manual_grade_in_range_provider(): array { + public static function is_manual_grade_in_range_provider(): array { return [ 'In range' => [ 'post' => [ @@ -309,7 +309,7 @@ class question_engine_test extends advanced_testcase { * * @return array */ - public function render_question_number_provider(): array { + public static function render_question_number_provider(): array { return [ 'Test with number is i character' => [ 'i', diff --git a/question/engine/tests/questionattempt_with_steps_test.php b/question/engine/tests/questionattempt_with_steps_test.php index 8ddfb7a5181..e0cc0c7f20c 100644 --- a/question/engine/tests/questionattempt_with_steps_test.php +++ b/question/engine/tests/questionattempt_with_steps_test.php @@ -169,7 +169,7 @@ class questionattempt_with_steps_test extends \advanced_testcase { * * @return array test cases */ - public function validate_manual_mark_cases(): array { + public static function validate_manual_mark_cases(): array { // Recall, the DB schema stores question grade information to 7 decimal places. return [ [0, 1, 2, null, ''], diff --git a/question/format/gift/tests/giftformat_test.php b/question/format/gift/tests/giftformat_test.php index ef0321b2ee7..52924ae6730 100644 --- a/question/format/gift/tests/giftformat_test.php +++ b/question/format/gift/tests/giftformat_test.php @@ -366,7 +366,7 @@ class giftformat_test extends \question_testcase { * * @return array Array of 1-element arrays of qtype_multichoice numbering styles */ - public function numberingstyle_provider() { + public static function numberingstyle_provider(): array { return [ ['abc'], ['ABCD'], @@ -1330,7 +1330,7 @@ FALSE#42 is the Ultimate Answer.#You gave the right answer.}"; * * @return array the test cases. */ - public function extract_idnumber_and_tags_from_comment_testcases() { + public static function extract_idnumber_and_tags_from_comment_testcases(): array { return [ 'blank comment' => ['', [], ''], 'nothing in comment' => ['', [], '// A basic comment.'], diff --git a/question/tests/calculated_question_summary_test.php b/question/tests/calculated_question_summary_test.php index b90dcf82366..2d536e7b709 100644 --- a/question/tests/calculated_question_summary_test.php +++ b/question/tests/calculated_question_summary_test.php @@ -33,7 +33,7 @@ class calculated_question_summary_test extends \advanced_testcase { * * @return array */ - public function get_min_max_provider() { + public static function get_min_max_provider(): array { return [ 'negative number and null' => [ [ @@ -105,7 +105,7 @@ class calculated_question_summary_test extends \advanced_testcase { * * @return array */ - public function get_sd_min_max_provider() { + public static function get_sd_min_max_provider(): array { return [ 'null and number' => [ [ diff --git a/question/tests/externallib_test.php b/question/tests/externallib_test.php index f81f2d18504..2c69ffb1469 100644 --- a/question/tests/externallib_test.php +++ b/question/tests/externallib_test.php @@ -102,7 +102,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Data provider for the get_random_question_summaries test. */ - public function get_random_question_summaries_test_cases() { + public static function get_random_question_summaries_test_cases(): array { return [ 'empty category' => [ 'categoryindex' => 'emptycat', @@ -174,7 +174,7 @@ class externallib_test extends externallib_advanced_testcase { * Parent: cat1 * Category: emptycat * - * @dataProvider get_random_question_summaries_test_cases() + * @dataProvider get_random_question_summaries_test_cases * @param string $categoryindex The named index for the category to use * @param bool $includesubcategories If the search should include subcategories * @param string[] $usetagnames The tag names to include in the search diff --git a/question/tests/local/statistics/statistics_bulk_loader_test.php b/question/tests/local/statistics/statistics_bulk_loader_test.php index 1a82648a169..41d1fc4ec92 100644 --- a/question/tests/local/statistics/statistics_bulk_loader_test.php +++ b/question/tests/local/statistics/statistics_bulk_loader_test.php @@ -216,7 +216,7 @@ class statistics_bulk_loader_test extends advanced_testcase { * * @return array */ - private function generate_attempt_answers(array $correctanswerflags): array { + private static function generate_attempt_answers(array $correctanswerflags): array { $attempt = []; for ($i = 1; $i <= 4; $i++) { if (isset($correctanswerflags) && $correctanswerflags[$i - 1] == 1) { @@ -287,31 +287,31 @@ class statistics_bulk_loader_test extends advanced_testcase { * * @return Generator */ - public function load_question_facility_provider(): Generator { + public static function load_question_facility_provider(): Generator { yield 'Facility case 1' => [ 'Quiz 1 attempts' => [ - $this->generate_attempt_answers([1, 0, 0, 0]), + self::generate_attempt_answers([1, 0, 0, 0]), ], 'Expected quiz 1 facilities' => [1.0, 0.0, 0.0, 0.0], 'Quiz 2 attempts' => [ - $this->generate_attempt_answers([1, 0, 0, 0]), - $this->generate_attempt_answers([1, 1, 0, 0]), + self::generate_attempt_answers([1, 0, 0, 0]), + self::generate_attempt_answers([1, 1, 0, 0]), ], 'Expected quiz 2 facilities' => [1.0, 0.5, 0.0, 0.0], 'Expected average facilities' => [1.0, 0.25, 0.0, 0.0], ]; yield 'Facility case 2' => [ 'Quiz 1 attempts' => [ - $this->generate_attempt_answers([1, 0, 0, 0]), - $this->generate_attempt_answers([1, 1, 0, 0]), - $this->generate_attempt_answers([1, 1, 1, 0]), + self::generate_attempt_answers([1, 0, 0, 0]), + self::generate_attempt_answers([1, 1, 0, 0]), + self::generate_attempt_answers([1, 1, 1, 0]), ], 'Expected quiz 1 facilities' => [1.0, 0.6667, 0.3333, 0.0], 'Quiz 2 attempts' => [ - $this->generate_attempt_answers([1, 0, 0, 0]), - $this->generate_attempt_answers([1, 1, 0, 0]), - $this->generate_attempt_answers([1, 1, 1, 0]), - $this->generate_attempt_answers([1, 1, 1, 1]), + self::generate_attempt_answers([1, 0, 0, 0]), + self::generate_attempt_answers([1, 1, 0, 0]), + self::generate_attempt_answers([1, 1, 1, 0]), + self::generate_attempt_answers([1, 1, 1, 1]), ], 'Expected quiz 2 facilities' => [1.0, 0.75, 0.5, 0.25], 'Expected average facilities' => [1.0, 0.7083, 0.4167, 0.1250], @@ -384,20 +384,20 @@ class statistics_bulk_loader_test extends advanced_testcase { * Data provider for {@see test_load_question_discriminative_efficiency()}. * @return Generator */ - public function load_question_discriminative_efficiency_provider(): Generator { + public static function load_question_discriminative_efficiency_provider(): Generator { yield 'Discriminative efficiency' => [ 'Quiz 1 attempts' => [ - $this->generate_attempt_answers([1, 0, 0, 0]), - $this->generate_attempt_answers([1, 1, 0, 0]), - $this->generate_attempt_answers([1, 0, 1, 0]), - $this->generate_attempt_answers([1, 1, 1, 1]), + self::generate_attempt_answers([1, 0, 0, 0]), + self::generate_attempt_answers([1, 1, 0, 0]), + self::generate_attempt_answers([1, 0, 1, 0]), + self::generate_attempt_answers([1, 1, 1, 1]), ], 'Expected quiz 1 discriminative efficiency' => [null, 33.33, 33.33, 100.00], 'Quiz 2 attempts' => [ - $this->generate_attempt_answers([1, 1, 1, 1]), - $this->generate_attempt_answers([0, 0, 0, 0]), - $this->generate_attempt_answers([1, 0, 0, 1]), - $this->generate_attempt_answers([0, 1, 1, 0]), + self::generate_attempt_answers([1, 1, 1, 1]), + self::generate_attempt_answers([0, 0, 0, 0]), + self::generate_attempt_answers([1, 0, 0, 1]), + self::generate_attempt_answers([0, 1, 1, 0]), ], 'Expected quiz 2 discriminative efficiency' => [50.00, 50.00, 50.00, 50.00], 'Expected average discriminative efficiency' => [50.00, 41.67, 41.67, 75.00], @@ -478,20 +478,20 @@ class statistics_bulk_loader_test extends advanced_testcase { * Data provider for {@see test_load_question_discrimination_index()}. * @return Generator */ - public function load_question_discrimination_index_provider(): Generator { + public static function load_question_discrimination_index_provider(): Generator { yield 'Discrimination Index' => [ 'Quiz 1 attempts' => [ - $this->generate_attempt_answers([1, 0, 0, 0]), - $this->generate_attempt_answers([1, 1, 0, 0]), - $this->generate_attempt_answers([1, 0, 1, 0]), - $this->generate_attempt_answers([1, 1, 1, 1]), + self::generate_attempt_answers([1, 0, 0, 0]), + self::generate_attempt_answers([1, 1, 0, 0]), + self::generate_attempt_answers([1, 0, 1, 0]), + self::generate_attempt_answers([1, 1, 1, 1]), ], 'Expected quiz 1 Discrimination Index' => [null, 30.15, 30.15, 81.65], 'Quiz 2 attempts' => [ - $this->generate_attempt_answers([1, 1, 1, 1]), - $this->generate_attempt_answers([0, 0, 0, 0]), - $this->generate_attempt_answers([1, 0, 0, 1]), - $this->generate_attempt_answers([0, 1, 1, 0]), + self::generate_attempt_answers([1, 1, 1, 1]), + self::generate_attempt_answers([0, 0, 0, 0]), + self::generate_attempt_answers([1, 0, 0, 1]), + self::generate_attempt_answers([0, 1, 1, 0]), ], 'Expected quiz 2 discrimination Index' => [44.72, 44.72, 44.72, 44.72], 'Expected average discrimination Index' => [44.72, 37.44, 37.44, 63.19], @@ -575,8 +575,8 @@ class statistics_bulk_loader_test extends advanced_testcase { $this->resetAfterTest(); // Prepare some quizzes and attempts. Exactly what is not important to this test. - $quiz1attempts = [$this->generate_attempt_answers([1, 0, 0, 0])]; - $quiz2attempts = [$this->generate_attempt_answers([1, 1, 1, 1])]; + $quiz1attempts = [self::generate_attempt_answers([1, 0, 0, 0])]; + $quiz2attempts = [self::generate_attempt_answers([1, 1, 1, 1])]; [, , $questions] = $this->prepare_and_submit_quizzes($quiz1attempts, $quiz2attempts); // Prepare some useful arrays. diff --git a/question/tests/random_question_loader_test.php b/question/tests/random_question_loader_test.php index 8e706765ef3..659a14e6324 100644 --- a/question/tests/random_question_loader_test.php +++ b/question/tests/random_question_loader_test.php @@ -219,7 +219,7 @@ class random_question_loader_test extends \advanced_testcase { /** * Data provider for the get_questions test. */ - public function get_questions_test_cases() { + public static function get_questions_test_cases(): array { return [ 'empty category' => [ 'categoryindex' => 'emptycat', @@ -291,7 +291,7 @@ class random_question_loader_test extends \advanced_testcase { * Parent: cat1 * Category: emptycat * - * @dataProvider get_questions_test_cases() + * @dataProvider get_questions_test_cases * @param string $categoryindex The named index for the category to use * @param bool $includesubcategories If the search should include subcategories * @param string[] $usetagnames The tag names to include in the search @@ -429,7 +429,7 @@ class random_question_loader_test extends \advanced_testcase { /** * Data provider for the count_questions test. */ - public function count_questions_test_cases() { + public static function count_questions_test_cases(): array { return [ 'empty category' => [ 'categoryindex' => 'emptycat', @@ -501,7 +501,7 @@ class random_question_loader_test extends \advanced_testcase { * Parent: cat1 * Category: emptycat * - * @dataProvider count_questions_test_cases() + * @dataProvider count_questions_test_cases * @param string $categoryindex The named index for the category to use * @param bool $includesubcategories If the search should include subcategories * @param string[] $usetagnames The tag names to include in the search diff --git a/question/type/ddimageortext/tests/privacy/provider_test.php b/question/type/ddimageortext/tests/privacy/provider_test.php index e19bdfaeb5e..353f014d890 100644 --- a/question/type/ddimageortext/tests/privacy/provider_test.php +++ b/question/type/ddimageortext/tests/privacy/provider_test.php @@ -91,7 +91,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 [ 'default mark 1' => ['defaultmark', 1, 1], 'penalty 33.33333%' => ['penalty', 0.3333333, '33.33333%'], diff --git a/question/type/ddmarker/tests/privacy/provider_test.php b/question/type/ddmarker/tests/privacy/provider_test.php index fcf69c7d15e..94cb4654891 100644 --- a/question/type/ddmarker/tests/privacy/provider_test.php +++ b/question/type/ddmarker/tests/privacy/provider_test.php @@ -91,7 +91,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 [ 'default mark 1.5' => ['defaultmark', 1.5, 1.5], 'penalty 33.33333%' => ['penalty', 0.3333333, '33.33333%'], diff --git a/question/type/ddwtos/tests/privacy/provider_test.php b/question/type/ddwtos/tests/privacy/provider_test.php index 711b7c1744c..1dda6d7f42a 100644 --- a/question/type/ddwtos/tests/privacy/provider_test.php +++ b/question/type/ddwtos/tests/privacy/provider_test.php @@ -91,7 +91,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 [ 'default mark 2' => ['defaultmark', 2, 2], 'penalty 33.33333%' => ['penalty', 0.3333333, '33.33333%'], diff --git a/question/type/essay/tests/form/edit_form_test.php b/question/type/essay/tests/form/edit_form_test.php index f2f6c7bed81..f55765a44e5 100644 --- a/question/type/essay/tests/form/edit_form_test.php +++ b/question/type/essay/tests/form/edit_form_test.php @@ -102,7 +102,7 @@ class edit_form_test extends \advanced_testcase { * * @return array, an array of all possible options. */ - public function user_preference_provider(): array { + public static function user_preference_provider(): array { $valid = []; $invalid = ['attachmentsrequired' => get_string('mustrequirefewer', 'qtype_essay')]; return [ diff --git a/question/type/essay/tests/privacy/provider_test.php b/question/type/essay/tests/privacy/provider_test.php index ef88678dc3b..b5016af5371 100644 --- a/question/type/essay/tests/privacy/provider_test.php +++ b/question/type/essay/tests/privacy/provider_test.php @@ -91,7 +91,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 [ 'default mark 2' => ['defaultmark', 2, 2], 'responseformat editror ' => ['responseformat', 'editor', get_string('formateditor', 'qtype_essay')], diff --git a/question/type/essay/tests/question_test.php b/question/type/essay/tests/question_test.php index c9d582df97f..e44fe021e59 100644 --- a/question/type/essay/tests/question_test.php +++ b/question/type/essay/tests/question_test.php @@ -80,7 +80,7 @@ class question_test extends \advanced_testcase { * * @return array List of data sets (test cases) */ - public function summarise_response_provider(): array { + public static function summarise_response_provider(): array { return [ 'text input required, not attachments required' => [1, 0, 'This is the text input for this essay.', 0, 'This is the text input for this essay.'], @@ -331,7 +331,7 @@ class question_test extends \advanced_testcase { * * (The tests are done with a fixed 14-word response.) * - * @dataProvider get_min_max_wordlimit_test_cases() + * @dataProvider get_min_max_wordlimit_test_cases * @param int $responserequired whether response required (yes = 1, no = 0) * @param int $minwordlimit minimum word limit * @param int $maxwordlimit maximum word limit @@ -353,7 +353,7 @@ class question_test extends \advanced_testcase { * * @return array the test cases. */ - public function get_min_max_wordlimit_test_cases(): array { + public static function get_min_max_wordlimit_test_cases(): array { return [ 'text input required, min/max word limit not set' => [1, 0, 0, ''], 'text input required, min/max word limit valid (within the boundaries)' => [1, 10, 25, ''], @@ -370,7 +370,7 @@ class question_test extends \advanced_testcase { * * (The tests are done with a fixed 14-word response.) * - * @dataProvider get_word_count_message_for_review_test_cases() + * @dataProvider get_word_count_message_for_review_test_cases * @param int|null $minwordlimit minimum word limit * @param int|null $maxwordlimit maximum word limit * @param string $expected error message | null @@ -389,7 +389,7 @@ class question_test extends \advanced_testcase { * * @return array the test cases. */ - public function get_word_count_message_for_review_test_cases() { + public static function get_word_count_message_for_review_test_cases(): array { return [ 'No limit' => [null, null, ''], diff --git a/question/type/gapselect/tests/privacy/provider_test.php b/question/type/gapselect/tests/privacy/provider_test.php index 85734954527..0fa9f6a402d 100644 --- a/question/type/gapselect/tests/privacy/provider_test.php +++ b/question/type/gapselect/tests/privacy/provider_test.php @@ -91,7 +91,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 [ 'default mark 1.5' => ['defaultmark', 1.5, 1.5], 'penalty 25%' => ['penalty', 0.2500000, '25%'], diff --git a/question/type/match/tests/privacy/provider_test.php b/question/type/match/tests/privacy/provider_test.php index 41b0fc5147d..7bffe8e9f90 100644 --- a/question/type/match/tests/privacy/provider_test.php +++ b/question/type/match/tests/privacy/provider_test.php @@ -91,7 +91,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 [ 'default mark 1' => ['defaultmark', 1, 1], 'penalty 33.33333%' => ['penalty', 0.3333333, '33.33333%'], diff --git a/question/type/multichoice/tests/privacy/provider_test.php b/question/type/multichoice/tests/privacy/provider_test.php index 0f2dcb07918..d8fc1877ff5 100644 --- a/question/type/multichoice/tests/privacy/provider_test.php +++ b/question/type/multichoice/tests/privacy/provider_test.php @@ -91,7 +91,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 [ 'default mark 2' => ['defaultmark', 2, 2], 'penalty 33.33333%' => ['penalty', 0.3333333, '33.33333%'], diff --git a/question/type/multichoice/tests/question_type_test.php b/question/type/multichoice/tests/question_type_test.php index 2caba525bb0..0a053e7e117 100644 --- a/question/type/multichoice/tests/question_type_test.php +++ b/question/type/multichoice/tests/question_type_test.php @@ -107,7 +107,7 @@ class question_type_test extends \advanced_testcase { ), $this->qtype->get_possible_responses($q)); } - public function get_question_saving_which() { + public static function get_question_saving_which(): array { return array(array('two_of_four'), array('one_of_four')); } diff --git a/question/type/numerical/tests/answerprocessor_test.php b/question/type/numerical/tests/answerprocessor_test.php index dd764665b5d..d62bc52ca8f 100644 --- a/question/type/numerical/tests/answerprocessor_test.php +++ b/question/type/numerical/tests/answerprocessor_test.php @@ -72,7 +72,7 @@ class answerprocessor_test extends \advanced_testcase { * * @return array */ - public function parse_response_provider(): array { + public static function parse_response_provider(): array { return [ [['3', '142', '', ''], '3.142'], [['', '2', '', ''], '.2'], @@ -191,7 +191,7 @@ class answerprocessor_test extends \advanced_testcase { * * @return array */ - public function apply_units_provider(): array { + public static function apply_units_provider(): array { return [ [3e8, 'm/s', 1, '3x10^8 m/s'], [3e8, '', null, '3x10^8'], @@ -250,7 +250,7 @@ class answerprocessor_test extends \advanced_testcase { * * @return array */ - public function apply_units_provider_with_units(): array { + public static function apply_units_provider_with_units(): array { return [ [3e8, 'm/s', 1, '3x10^8', 'm/s'], [3e8, '', null, '3x10^8', ''], @@ -280,7 +280,7 @@ class answerprocessor_test extends \advanced_testcase { * * return array */ - public function euro_provider(): array { + public static function euro_provider(): array { return [ [[-1000, '', null], '-1 000'], [[3.14159, '', null], '3,14159'], @@ -305,7 +305,7 @@ class answerprocessor_test extends \advanced_testcase { * * @return array */ - public function percent_provider(): array { + public static function percent_provider(): array { return [ [['3', '%', 0.01], '3%'], [['1e-6', '%', 0.01], '1e-6 %'], @@ -334,7 +334,7 @@ class answerprocessor_test extends \advanced_testcase { * * @return array */ - public function currency_provider(): array { + public static function currency_provider(): array { return [ [['1234.56', '£', 1], '£1,234.56'], [['100', '$', 1], '$100'], diff --git a/question/type/shortanswer/tests/privacy/provider_test.php b/question/type/shortanswer/tests/privacy/provider_test.php index 4c1aed9fdaa..beb293198dd 100644 --- a/question/type/shortanswer/tests/privacy/provider_test.php +++ b/question/type/shortanswer/tests/privacy/provider_test.php @@ -91,7 +91,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 [ 'default mark 2' => ['defaultmark', 2, 2], 'penalty 33.33333%' => ['penalty', 0.3333333, '33.33333%'], diff --git a/rating/tests/rating_test.php b/rating/tests/rating_test.php index b2fa6a55d15..f9f034a41d3 100644 --- a/rating/tests/rating_test.php +++ b/rating/tests/rating_test.php @@ -279,7 +279,7 @@ class rating_test extends \advanced_testcase { * * @return array */ - public function get_aggregate_string_provider() { + public static function get_aggregate_string_provider(): array { return [ 'Non-numeric aggregate produces empty string' => [ RATING_AGGREGATE_NONE, diff --git a/reportbuilder/tests/external/system_report_exporter_test.php b/reportbuilder/tests/external/system_report_exporter_test.php index f8ce6f3174c..bef61bc95fd 100644 --- a/reportbuilder/tests/external/system_report_exporter_test.php +++ b/reportbuilder/tests/external/system_report_exporter_test.php @@ -48,7 +48,7 @@ class system_report_exporter_test extends advanced_testcase { * * @return array[] */ - public function export_provider(): array { + public static function export_provider(): array { return [ ['With filters' => true], ['Without filters' => false], diff --git a/reportbuilder/tests/local/entities/user_test.php b/reportbuilder/tests/local/entities/user_test.php index c6a10beb5e3..2401598c5a6 100644 --- a/reportbuilder/tests/local/entities/user_test.php +++ b/reportbuilder/tests/local/entities/user_test.php @@ -71,7 +71,7 @@ class user_test extends advanced_testcase { * * @return array */ - public function get_name_fields_select_provider(): array { + public static function get_name_fields_select_provider(): array { return [ ['firstname lastname', ['firstname', 'lastname']], ['firstname middlename lastname', ['firstname', 'middlename', 'lastname']], diff --git a/reportbuilder/tests/local/filters/autocomplete_test.php b/reportbuilder/tests/local/filters/autocomplete_test.php index e42768eb18f..5216cccc7c4 100644 --- a/reportbuilder/tests/local/filters/autocomplete_test.php +++ b/reportbuilder/tests/local/filters/autocomplete_test.php @@ -37,7 +37,7 @@ class autocomplete_test extends advanced_testcase { * * @return array */ - public function get_sql_filter_provider(): array { + public static function get_sql_filter_provider(): array { return [ [[], ["Course 1 full name", "Course 2 full name", "Course 3 full name", "PHPUnit test site"]], [["course1", "course3"], ["Course 1 full name", "Course 3 full name"]], diff --git a/reportbuilder/tests/local/filters/boolean_select_test.php b/reportbuilder/tests/local/filters/boolean_select_test.php index ee28dfedc86..f808e66c326 100644 --- a/reportbuilder/tests/local/filters/boolean_select_test.php +++ b/reportbuilder/tests/local/filters/boolean_select_test.php @@ -38,7 +38,7 @@ class boolean_select_test extends advanced_testcase { * * @return array */ - public function get_sql_filter_simple_provider(): array { + public static function get_sql_filter_simple_provider(): array { return [ [boolean_select::ANY_VALUE, true], [boolean_select::CHECKED, true], diff --git a/reportbuilder/tests/local/filters/category_test.php b/reportbuilder/tests/local/filters/category_test.php index 06e60ad8b09..ee38d24f39a 100644 --- a/reportbuilder/tests/local/filters/category_test.php +++ b/reportbuilder/tests/local/filters/category_test.php @@ -38,7 +38,7 @@ class category_test extends advanced_testcase { * * @return array */ - public function get_sql_filter_provider(): array { + public static function get_sql_filter_provider(): array { return [ ['One', false, ['One']], ['One', true, ['One', 'Two', 'Three']], diff --git a/reportbuilder/tests/local/filters/select_test.php b/reportbuilder/tests/local/filters/select_test.php index 2038a7bbc9f..475ae6b5851 100644 --- a/reportbuilder/tests/local/filters/select_test.php +++ b/reportbuilder/tests/local/filters/select_test.php @@ -38,7 +38,7 @@ class select_test extends advanced_testcase { * * @return array */ - public function get_sql_filter_simple_provider(): array { + public static function get_sql_filter_simple_provider(): array { return [ [select::ANY_VALUE, null, true], [select::EQUAL_TO, 'starwars', true], diff --git a/reportbuilder/tests/local/filters/text_test.php b/reportbuilder/tests/local/filters/text_test.php index 9a9a5f0d017..0125ebdc7d1 100644 --- a/reportbuilder/tests/local/filters/text_test.php +++ b/reportbuilder/tests/local/filters/text_test.php @@ -38,7 +38,7 @@ class text_test extends advanced_testcase { * * @return array */ - public function get_sql_filter_simple_provider(): array { + public static function get_sql_filter_simple_provider(): array { return [ [text::ANY_VALUE, null, true], [text::CONTAINS, 'looking', true], @@ -101,7 +101,7 @@ class text_test extends advanced_testcase { * * @return array */ - public function get_sql_filter_empty_provider(): array { + public static function get_sql_filter_empty_provider(): array { return [ [text::IS_EMPTY, null, true], [text::IS_EMPTY, '', true], diff --git a/reportbuilder/tests/local/filters/user_test.php b/reportbuilder/tests/local/filters/user_test.php index a9cc75590bf..ea041c402e9 100644 --- a/reportbuilder/tests/local/filters/user_test.php +++ b/reportbuilder/tests/local/filters/user_test.php @@ -38,7 +38,7 @@ class user_test extends advanced_testcase { * * @return array */ - public function get_sql_filter_simple(): array { + public static function get_sql_filter_simple(): array { return [ [user::USER_ANY, ['admin', 'guest', 'user01', 'user02']], [user::USER_CURRENT, ['user01']], diff --git a/reportbuilder/tests/local/helpers/schedule_test.php b/reportbuilder/tests/local/helpers/schedule_test.php index e25dffaf5ac..98d6363f2f4 100644 --- a/reportbuilder/tests/local/helpers/schedule_test.php +++ b/reportbuilder/tests/local/helpers/schedule_test.php @@ -257,7 +257,7 @@ class schedule_test extends advanced_testcase { * * @return string[] */ - public function get_schedule_report_file_format(): array { + public static function get_schedule_report_file_format(): array { return [ ['csv'], ['excel'], diff --git a/reportbuilder/tests/local/helpers/user_filter_manager_test.php b/reportbuilder/tests/local/helpers/user_filter_manager_test.php index c3049ba757d..909c3667877 100644 --- a/reportbuilder/tests/local/helpers/user_filter_manager_test.php +++ b/reportbuilder/tests/local/helpers/user_filter_manager_test.php @@ -46,7 +46,7 @@ class user_filter_manager_test extends advanced_testcase { * * @return array */ - public function get_provider(): array { + public static function get_provider(): array { return [ 'Small value' => ['foo'], 'Large value' => [str_repeat('A', 4000)], @@ -113,7 +113,7 @@ class user_filter_manager_test extends advanced_testcase { * * @return array */ - public function reset_all_provider(): array { + public static function reset_all_provider(): array { return [ 'Small value' => ['foo'], 'Large value' => [str_repeat('A', 4000)], diff --git a/reportbuilder/tests/local/report/action_test.php b/reportbuilder/tests/local/report/action_test.php index 316a3f114e7..1e3735c96ea 100644 --- a/reportbuilder/tests/local/report/action_test.php +++ b/reportbuilder/tests/local/report/action_test.php @@ -63,7 +63,7 @@ class action_test extends advanced_testcase { * * @return array[] */ - public function action_title_provider(): array { + public static function action_title_provider(): array { $title = new lang_string('yes'); return [ 'Specified via constructor' => ['', [], $title], diff --git a/reportbuilder/tests/manager_test.php b/reportbuilder/tests/manager_test.php index 68d01b9eb4c..983661927aa 100644 --- a/reportbuilder/tests/manager_test.php +++ b/reportbuilder/tests/manager_test.php @@ -180,7 +180,7 @@ class manager_test extends core_reportbuilder_testcase { * * @return array */ - public function report_limit_reached_provider(): array { + public static function report_limit_reached_provider(): array { return [ [0, 1, false], [1, 1, true], diff --git a/reportbuilder/tests/task/send_schedule_test.php b/reportbuilder/tests/task/send_schedule_test.php index 0ac88ad57a6..f09ca7c9ead 100644 --- a/reportbuilder/tests/task/send_schedule_test.php +++ b/reportbuilder/tests/task/send_schedule_test.php @@ -44,7 +44,7 @@ class send_schedule_test extends advanced_testcase { * * @return array[] */ - public function execute_report_viewas_user_provider(): array { + public static function execute_report_viewas_user_provider(): array { return [ 'View report as schedule creator' => [schedule::REPORT_VIEWAS_CREATOR, null, 'admin', 'admin'], 'View report as schedule recipient' => [schedule::REPORT_VIEWAS_RECIPIENT, null, 'userone', 'usertwo'], diff --git a/repository/contentbank/tests/search/search_test.php b/repository/contentbank/tests/search/search_test.php index 8cba994618e..76a62d7443c 100644 --- a/repository/contentbank/tests/search/search_test.php +++ b/repository/contentbank/tests/search/search_test.php @@ -75,7 +75,7 @@ class search_test extends \advanced_testcase { * * @return array */ - public function get_search_contents_provider(): array { + public static function get_search_contents_provider(): array { return [ 'Search for existing pattern found within the name of content items' => [ [ diff --git a/repository/dropbox/tests/api_test.php b/repository/dropbox/tests/api_test.php index cec67079f1a..4b128c160c7 100644 --- a/repository/dropbox/tests/api_test.php +++ b/repository/dropbox/tests/api_test.php @@ -29,7 +29,7 @@ class api_test extends \advanced_testcase { * * @return array */ - public function has_additional_results_provider() { + public static function has_additional_results_provider(): array { return [ 'No more results' => [ (object) [ @@ -88,7 +88,7 @@ class api_test extends \advanced_testcase { * * @return array */ - public function check_and_handle_api_errors_provider() { + public static function check_and_handle_api_errors_provider(): array { return [ '200 http_code' => [ ['http_code' => 200], @@ -180,7 +180,7 @@ class api_test extends \advanced_testcase { * * @return array */ - public function supports_thumbnail_provider() { + public static function supports_thumbnail_provider(): array { $tests = [ 'Only files support thumbnails' => [ (object) ['.tag' => 'folder'], diff --git a/repository/googledocs/tests/googledocs_search_content_test.php b/repository/googledocs/tests/googledocs_search_content_test.php index 5dbedae124c..4bdf067cbea 100644 --- a/repository/googledocs/tests/googledocs_search_content_test.php +++ b/repository/googledocs/tests/googledocs_search_content_test.php @@ -105,7 +105,7 @@ class googledocs_search_content_test extends \googledocs_content_testcase { * * @return array */ - public function get_content_nodes_provider(): array { + public static function get_content_nodes_provider(): array { $rootid = \repository_googledocs::REPOSITORY_ROOT_ID; $searchnodeid = \repository_googledocs::SEARCH_ROOT_ID; @@ -118,26 +118,26 @@ class googledocs_search_content_test extends \googledocs_content_testcase { true, [], [ - $this->create_google_drive_shared_drive_object('d85b21c0f86cb5', 'Shared Drive 1'), + self::create_google_drive_shared_drive_object('d85b21c0f86cb5', 'Shared Drive 1'), ], [ - $this->create_google_drive_file_object('d85b21c0f86cb0', 'Test file 3.pdf', + self::create_google_drive_file_object('d85b21c0f86cb0', 'Test file 3.pdf', 'application/pdf', 'pdf', '1000', '', 'https://drive.google.com/uc?id=d85b21c0f86cb0&export=download'), - $this->create_google_drive_folder_object('0c4ad262c65333', 'Test folder 1'), - $this->create_google_drive_file_object('bed5a0f08d412a', 'Test file 1.pdf', + self::create_google_drive_folder_object('0c4ad262c65333', 'Test folder 1'), + self::create_google_drive_file_object('bed5a0f08d412a', 'Test file 1.pdf', 'application/pdf', 'pdf'), - $this->create_google_drive_folder_object('9c4ad262c65333', 'Test folder 2'), + self::create_google_drive_folder_object('9c4ad262c65333', 'Test folder 2'), ], [ - $this->create_folder_content_node_array('0c4ad262c65333', 'Test folder 1', + self::create_folder_content_node_array('0c4ad262c65333', 'Test folder 1', "{$rootid}|Google+Drive/{$searchnodeid}|" . urlencode("{$searchforstring} 'test'")), - $this->create_folder_content_node_array('9c4ad262c65333', 'Test folder 2', + self::create_folder_content_node_array('9c4ad262c65333', 'Test folder 2', "{$rootid}|Google+Drive/{$searchnodeid}|" . urlencode("{$searchforstring} 'test'")), - $this->create_file_content_node_array('bed5a0f08d412a', 'Test file 1.pdf', + self::create_file_content_node_array('bed5a0f08d412a', 'Test file 1.pdf', 'Test file 1.pdf', null, '', 'https://googleusercontent.com/type/application/pdf', '', 'download'), - $this->create_file_content_node_array('d85b21c0f86cb0', 'Test file 3.pdf', + self::create_file_content_node_array('d85b21c0f86cb0', 'Test file 3.pdf', 'Test file 3.pdf', '1000', '', 'https://googleusercontent.com/type/application/pdf', 'https://drive.google.com/uc?id=d85b21c0f86cb0&export=download', 'download'), ], @@ -149,16 +149,16 @@ class googledocs_search_content_test extends \googledocs_content_testcase { [], [], [ - $this->create_google_drive_folder_object('0c4ad262c65333', 'Testing folder 3'), - $this->create_google_drive_folder_object('d85b21c0f86cb0', 'Testing folder 1'), - $this->create_google_drive_folder_object('bed5a0f08d412a', 'Testing folder 2'), + self::create_google_drive_folder_object('0c4ad262c65333', 'Testing folder 3'), + self::create_google_drive_folder_object('d85b21c0f86cb0', 'Testing folder 1'), + self::create_google_drive_folder_object('bed5a0f08d412a', 'Testing folder 2'), ], [ - $this->create_folder_content_node_array('0c4ad262c65333', 'Testing folder 3', + self::create_folder_content_node_array('0c4ad262c65333', 'Testing folder 3', "{$rootid}|Google+Drive/{$searchnodeid}|" . urlencode("{$searchforstring} 'testing'")), - $this->create_folder_content_node_array('d85b21c0f86cb0', 'Testing folder 1', + self::create_folder_content_node_array('d85b21c0f86cb0', 'Testing folder 1', "{$rootid}|Google+Drive/{$searchnodeid}|" . urlencode("{$searchforstring} 'testing'")), - $this->create_folder_content_node_array('bed5a0f08d412a', 'Testing folder 2', + self::create_folder_content_node_array('bed5a0f08d412a', 'Testing folder 2', "{$rootid}|Google+Drive/{$searchnodeid}|" . urlencode("{$searchforstring} 'testing'")), ], ], @@ -168,18 +168,18 @@ class googledocs_search_content_test extends \googledocs_content_testcase { false, ['doc', 'txt'], [ - $this->create_google_drive_shared_drive_object('d85b21c0f86cb5', 'Shared Drive 1'), + self::create_google_drive_shared_drive_object('d85b21c0f86cb5', 'Shared Drive 1'), ], [ - $this->create_google_drive_file_object('d85b21c0f86cb0', 'Testing file 3.pdf', + self::create_google_drive_file_object('d85b21c0f86cb0', 'Testing file 3.pdf', 'application/pdf', 'pdf', '1000'), - $this->create_google_drive_file_object('a85b21c0f86cb0', 'Testing file 1.txt', + self::create_google_drive_file_object('a85b21c0f86cb0', 'Testing file 1.txt', 'text/plain', 'txt', '3000'), - $this->create_google_drive_file_object('f85b21c0f86cb0', 'Testing file 2.doc', + self::create_google_drive_file_object('f85b21c0f86cb0', 'Testing file 2.doc', 'application/msword', 'doc', '2000'), ], [ - $this->create_file_content_node_array('d85b21c0f86cb0', 'Testing file 3.pdf', + self::create_file_content_node_array('d85b21c0f86cb0', 'Testing file 3.pdf', 'Testing file 3.pdf', '1000', '', 'https://googleusercontent.com/type/application/pdf', '', 'download'), ], diff --git a/repository/googledocs/tests/helper_test.php b/repository/googledocs/tests/helper_test.php index 64c32d8ce06..dd761c446af 100644 --- a/repository/googledocs/tests/helper_test.php +++ b/repository/googledocs/tests/helper_test.php @@ -50,7 +50,7 @@ class helper_test extends \repository_googledocs_testcase { * * @return array */ - public function build_node_path_provider(): array { + public static function build_node_path_provider(): array { $rootid = \repository_googledocs::REPOSITORY_ROOT_ID; $mydriveid = \repository_googledocs::MY_DRIVE_ROOT_ID; @@ -105,7 +105,7 @@ class helper_test extends \repository_googledocs_testcase { * * @return array */ - public function explode_node_path_provider(): array { + public static function explode_node_path_provider(): array { $rootid = \repository_googledocs::REPOSITORY_ROOT_ID; @@ -155,7 +155,7 @@ class helper_test extends \repository_googledocs_testcase { * * @return array */ - public function get_browser_provider(): array { + public static function get_browser_provider(): array { $rootid = \repository_googledocs::REPOSITORY_ROOT_ID; $mydriveid = \repository_googledocs::MY_DRIVE_ROOT_ID; @@ -208,17 +208,16 @@ class helper_test extends \repository_googledocs_testcase { * * @return array */ - public function get_node_provider(): array { - + public static function get_node_provider(): array { return [ 'The content object represents a Google Drive folder.' => [ - $this->create_google_drive_folder_object('e3b0c44298fc1c149', 'Folder', ''), + self::create_google_drive_folder_object('e3b0c44298fc1c149', 'Folder', ''), \repository_googledocs\local\node\folder_node::class, ], 'The content object represents a Google Drive file.' => [ - $this->create_google_drive_file_object('de04d58dc5ccc', 'File.pdf', + self::create_google_drive_file_object('de04d58dc5ccc', 'File.pdf', 'application/pdf'), \repository_googledocs\local\node\file_node::class, ], @@ -253,7 +252,7 @@ class helper_test extends \repository_googledocs_testcase { * * @return array */ - public function request_exception_provider(): array { + public static function request_exception_provider(): array { return [ 'The API call throws exception (status: 403; message: Access Not Configured).' => diff --git a/repository/googledocs/tests/local/browser/googledocs_drive_content_test.php b/repository/googledocs/tests/local/browser/googledocs_drive_content_test.php index ad5e43e331f..f7b2d36ffc2 100644 --- a/repository/googledocs/tests/local/browser/googledocs_drive_content_test.php +++ b/repository/googledocs/tests/local/browser/googledocs_drive_content_test.php @@ -100,8 +100,7 @@ class googledocs_drive_content_test extends \googledocs_content_testcase { * * @return array */ - public function get_content_nodes_provider(): array { - + public static function get_content_nodes_provider(): array { $rootid = \repository_googledocs::REPOSITORY_ROOT_ID; $mydriveid = \repository_googledocs::MY_DRIVE_ROOT_ID; @@ -113,25 +112,25 @@ class googledocs_drive_content_test extends \googledocs_content_testcase { true, [], [ - $this->create_google_drive_shared_drive_object('d85b21c0f86cb5', 'Shared Drive 1'), + self::create_google_drive_shared_drive_object('d85b21c0f86cb5', 'Shared Drive 1'), ], [ - $this->create_google_drive_folder_object('1c4ad262c65333', 'Folder 2'), - $this->create_google_drive_file_object('d85b21c0f86cb0', 'File 3.pdf', + self::create_google_drive_folder_object('1c4ad262c65333', 'Folder 2'), + self::create_google_drive_file_object('d85b21c0f86cb0', 'File 3.pdf', 'application/pdf', 'pdf', '1000'), - $this->create_google_drive_folder_object('0c4ad262c65333', 'Folder 1'), - $this->create_google_drive_file_object('bed5a0f08d412a', 'File 1.pdf', + self::create_google_drive_folder_object('0c4ad262c65333', 'Folder 1'), + self::create_google_drive_file_object('bed5a0f08d412a', 'File 1.pdf', 'application/pdf', 'pdf'), ], [ - $this->create_folder_content_node_array('0c4ad262c65333', 'Folder 1', + self::create_folder_content_node_array('0c4ad262c65333', 'Folder 1', "{$rootid}|Google+Drive/{$mydriveid}|My+Drive"), - $this->create_folder_content_node_array('1c4ad262c65333', 'Folder 2', + self::create_folder_content_node_array('1c4ad262c65333', 'Folder 2', "{$rootid}|Google+Drive/{$mydriveid}|My+Drive"), - $this->create_file_content_node_array('bed5a0f08d412a', 'File 1.pdf', 'File 1.pdf', + self::create_file_content_node_array('bed5a0f08d412a', 'File 1.pdf', 'File 1.pdf', null, '', 'https://googleusercontent.com/type/application/pdf', '', 'download'), - $this->create_file_content_node_array('d85b21c0f86cb0', 'File 3.pdf', 'File 3.pdf', + self::create_file_content_node_array('d85b21c0f86cb0', 'File 3.pdf', 'File 3.pdf', '1000', '', 'https://googleusercontent.com/type/application/pdf', '', 'download'), ], @@ -144,16 +143,16 @@ class googledocs_drive_content_test extends \googledocs_content_testcase { [], [], [ - $this->create_google_drive_folder_object('0c4ad262c65333', 'Folder 3'), - $this->create_google_drive_folder_object('d85b21c0f86cb0', 'Folder 1'), - $this->create_google_drive_folder_object('bed5a0f08d412a', 'Folder 2'), + self::create_google_drive_folder_object('0c4ad262c65333', 'Folder 3'), + self::create_google_drive_folder_object('d85b21c0f86cb0', 'Folder 1'), + self::create_google_drive_folder_object('bed5a0f08d412a', 'Folder 2'), ], [ - $this->create_folder_content_node_array('0c4ad262c65333', 'Folder 3', + self::create_folder_content_node_array('0c4ad262c65333', 'Folder 3', "{$rootid}|Google+Drive/{$mydriveid}|My+Drive"), - $this->create_folder_content_node_array('d85b21c0f86cb0', 'Folder 1', + self::create_folder_content_node_array('d85b21c0f86cb0', 'Folder 1', "{$rootid}|Google+Drive/{$mydriveid}|My+Drive"), - $this->create_folder_content_node_array('bed5a0f08d412a', 'Folder 2', + self::create_folder_content_node_array('bed5a0f08d412a', 'Folder 2', "{$rootid}|Google+Drive/{$mydriveid}|My+Drive"), ], ], @@ -165,18 +164,18 @@ class googledocs_drive_content_test extends \googledocs_content_testcase { ['txt'], [], [ - $this->create_google_drive_file_object('d85b21c0f86cb0', 'File 3.pdf', + self::create_google_drive_file_object('d85b21c0f86cb0', 'File 3.pdf', 'application/pdf', 'pdf', '1000'), - $this->create_google_drive_file_object('a85b21c0f86cb0', 'File 1.txt', + self::create_google_drive_file_object('a85b21c0f86cb0', 'File 1.txt', 'text/plain', 'txt', '3000'), - $this->create_google_drive_file_object('f85b21c0f86cb0', 'File 2.doc', + self::create_google_drive_file_object('f85b21c0f86cb0', 'File 2.doc', 'application/msword', 'doc', '2000'), ], [ - $this->create_file_content_node_array('d85b21c0f86cb0', 'File 3.pdf', 'File 3.pdf', + self::create_file_content_node_array('d85b21c0f86cb0', 'File 3.pdf', 'File 3.pdf', '1000', '', 'https://googleusercontent.com/type/application/pdf', '', 'download'), - $this->create_file_content_node_array('f85b21c0f86cb0', 'File 2.doc', 'File 2.doc', + self::create_file_content_node_array('f85b21c0f86cb0', 'File 2.doc', 'File 2.doc', '2000', '', 'https://googleusercontent.com/type/application/msword', '', 'download'), ], @@ -217,7 +216,7 @@ class googledocs_drive_content_test extends \googledocs_content_testcase { * * @return array */ - public function get_navigation_provider(): array { + public static function get_navigation_provider(): array { $rootid = \repository_googledocs::REPOSITORY_ROOT_ID; $mydriveid = \repository_googledocs::MY_DRIVE_ROOT_ID; diff --git a/repository/googledocs/tests/local/browser/googledocs_root_content_test.php b/repository/googledocs/tests/local/browser/googledocs_root_content_test.php index 0ec0b70dff8..fb46d44a5b3 100644 --- a/repository/googledocs/tests/local/browser/googledocs_root_content_test.php +++ b/repository/googledocs/tests/local/browser/googledocs_root_content_test.php @@ -29,8 +29,7 @@ require_once($CFG->dirroot . '/repository/googledocs/lib.php'); * @copyright 2021 Mihail Geshoski * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class googledocs_root_content_test extends \googledocs_content_testcase { - +final class googledocs_root_content_test extends \googledocs_content_testcase { /** * Test get_content_nodes(). * @@ -66,37 +65,34 @@ class googledocs_root_content_test extends \googledocs_content_testcase { * * @return array */ - public function get_content_nodes_provider(): array { - + public static function get_content_nodes_provider(): array { $rootid = \repository_googledocs::REPOSITORY_ROOT_ID; $mydriveid = \repository_googledocs::MY_DRIVE_ROOT_ID; $shareddrivesid = \repository_googledocs::SHARED_DRIVES_ROOT_ID; return [ - 'Shared drives exist.' => + 'Shared drives exist.' => [ [ - [ - $this->create_google_drive_shared_drive_object('d85b21c0f86cb5', 'Shared Drive 1'), - $this->create_google_drive_shared_drive_object('d85b21c0f86cb0', 'Shared Drive 3'), - ], - [ - $this->create_folder_content_node_array($mydriveid, - get_string('mydrive', 'repository_googledocs'), - "{$rootid}|Google+Drive"), - $this->create_folder_content_node_array($shareddrivesid, - get_string('shareddrives', 'repository_googledocs'), - "{$rootid}|Google+Drive"), - ], + self::create_google_drive_shared_drive_object('d85b21c0f86cb5', 'Shared Drive 1'), + self::create_google_drive_shared_drive_object('d85b21c0f86cb0', 'Shared Drive 3'), ], - 'Shared drives do not exist.' => [ - [], - [ - $this->create_folder_content_node_array($mydriveid, - get_string('mydrive', 'repository_googledocs'), - "{$rootid}|Google+Drive"), - ], + self::create_folder_content_node_array($mydriveid, + get_string('mydrive', 'repository_googledocs'), + "{$rootid}|Google+Drive"), + self::create_folder_content_node_array($shareddrivesid, + get_string('shareddrives', 'repository_googledocs'), + "{$rootid}|Google+Drive"), ], + ], + 'Shared drives do not exist.' => [ + [], + [ + self::create_folder_content_node_array($mydriveid, + get_string('mydrive', 'repository_googledocs'), + "{$rootid}|Google+Drive"), + ], + ], ]; } } diff --git a/repository/googledocs/tests/local/browser/googledocs_shared_drives_content_test.php b/repository/googledocs/tests/local/browser/googledocs_shared_drives_content_test.php index 93e1fc4288b..4d07e39c206 100644 --- a/repository/googledocs/tests/local/browser/googledocs_shared_drives_content_test.php +++ b/repository/googledocs/tests/local/browser/googledocs_shared_drives_content_test.php @@ -29,8 +29,7 @@ require_once($CFG->dirroot . '/repository/googledocs/lib.php'); * @copyright 2021 Mihail Geshoski * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class googledocs_shared_drives_content_test extends \googledocs_content_testcase { - +final class googledocs_shared_drives_content_test extends \googledocs_content_testcase { /** * Test get_content_nodes(). * @@ -68,8 +67,7 @@ class googledocs_shared_drives_content_test extends \googledocs_content_testcase * * @return array */ - public function get_content_nodes_provider(): array { - + public static function get_content_nodes_provider(): array { $rootid = \repository_googledocs::REPOSITORY_ROOT_ID; $shareddrivesid = \repository_googledocs::SHARED_DRIVES_ROOT_ID; $shareddrivesstring = get_string('shareddrives', 'repository_googledocs'); @@ -78,34 +76,34 @@ class googledocs_shared_drives_content_test extends \googledocs_content_testcase 'Shared drives exist; ordering applied.' => [ [ - $this->create_google_drive_shared_drive_object('d85b21c0f86cb5', 'Shared Drive 1'), - $this->create_google_drive_shared_drive_object('d85b21c0f86cb0', 'Shared Drive 3'), - $this->create_google_drive_shared_drive_object('bed5a0f08d412a', 'Shared Drive 2'), + self::create_google_drive_shared_drive_object('d85b21c0f86cb5', 'Shared Drive 1'), + self::create_google_drive_shared_drive_object('d85b21c0f86cb0', 'Shared Drive 3'), + self::create_google_drive_shared_drive_object('bed5a0f08d412a', 'Shared Drive 2'), ], true, [ - $this->create_folder_content_node_array('d85b21c0f86cb5', 'Shared Drive 1', + self::create_folder_content_node_array('d85b21c0f86cb5', 'Shared Drive 1', "{$rootid}|Google+Drive/{$shareddrivesid}|" . urlencode($shareddrivesstring)), - $this->create_folder_content_node_array('bed5a0f08d412a', 'Shared Drive 2', + self::create_folder_content_node_array('bed5a0f08d412a', 'Shared Drive 2', "{$rootid}|Google+Drive/{$shareddrivesid}|" . urlencode($shareddrivesstring)), - $this->create_folder_content_node_array('d85b21c0f86cb0', 'Shared Drive 3', + self::create_folder_content_node_array('d85b21c0f86cb0', 'Shared Drive 3', "{$rootid}|Google+Drive/{$shareddrivesid}|" . urlencode($shareddrivesstring)), ], ], 'Shared drives exist; ordering not applied.' => [ [ - $this->create_google_drive_shared_drive_object('0c4ad262c65333', 'Shared Drive 3'), - $this->create_google_drive_shared_drive_object('d85b21c0f86cb0', 'Shared Drive 1'), - $this->create_google_drive_shared_drive_object('bed5a0f08d412a', 'Shared Drive 2'), + self::create_google_drive_shared_drive_object('0c4ad262c65333', 'Shared Drive 3'), + self::create_google_drive_shared_drive_object('d85b21c0f86cb0', 'Shared Drive 1'), + self::create_google_drive_shared_drive_object('bed5a0f08d412a', 'Shared Drive 2'), ], false, [ - $this->create_folder_content_node_array('0c4ad262c65333', 'Shared Drive 3', + self::create_folder_content_node_array('0c4ad262c65333', 'Shared Drive 3', "{$rootid}|Google+Drive/{$shareddrivesid}|" . urlencode($shareddrivesstring)), - $this->create_folder_content_node_array('d85b21c0f86cb0', 'Shared Drive 1', + self::create_folder_content_node_array('d85b21c0f86cb0', 'Shared Drive 1', "{$rootid}|Google+Drive/{$shareddrivesid}|" . urlencode($shareddrivesstring)), - $this->create_folder_content_node_array('bed5a0f08d412a', 'Shared Drive 2', + self::create_folder_content_node_array('bed5a0f08d412a', 'Shared Drive 2', "{$rootid}|Google+Drive/{$shareddrivesid}|" . urlencode($shareddrivesstring)), ], ], diff --git a/repository/googledocs/tests/local/node/file_node_test.php b/repository/googledocs/tests/local/node/file_node_test.php index 188341c15d9..623f5a6f789 100644 --- a/repository/googledocs/tests/local/node/file_node_test.php +++ b/repository/googledocs/tests/local/node/file_node_test.php @@ -28,8 +28,7 @@ require_once($CFG->dirroot . '/repository/googledocs/tests/repository_googledocs * @copyright 2021 Mihail Geshoski * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class file_node_test extends \repository_googledocs_testcase { - +final class file_node_test extends \repository_googledocs_testcase { /** * Test create_node_array(). * @@ -56,55 +55,54 @@ class file_node_test extends \repository_googledocs_testcase { * * @return array */ - public function create_node_array_provider(): array { - + public static function create_node_array_provider(): array { return [ 'Google Drive file with an extension.' => [ - $this->create_google_drive_file_object('d85b21c0f86cb0', 'File.pdf', + self::create_google_drive_file_object('d85b21c0f86cb0', 'File.pdf', 'application/pdf', 'pdf', '1000', '01/01/21 0:30'), [], - $this->create_file_content_node_array('d85b21c0f86cb0', 'File.pdf', 'File.pdf', '1000', + self::create_file_content_node_array('d85b21c0f86cb0', 'File.pdf', 'File.pdf', '1000', '1609432200', 'https://googleusercontent.com/type/application/pdf', '', 'download'), ], 'Google Drive file that has webContentLink and webViewLink.' => [ - $this->create_google_drive_file_object('d85b21c0f86cb0', 'File.pdf', + self::create_google_drive_file_object('d85b21c0f86cb0', 'File.pdf', 'application/pdf', 'pdf', null, '', 'https://drive.google.com/uc?id=d85b21c0f86cb0&export=download', 'https://drive.google.com/file/d/d85b21c0f86cb0/view?usp=drivesdk'), [ 'documentformat' => 'rtf', ], - $this->create_file_content_node_array('d85b21c0f86cb0', 'File.pdf', 'File.pdf', null, + self::create_file_content_node_array('d85b21c0f86cb0', 'File.pdf', 'File.pdf', null, '', 'https://googleusercontent.com/type/application/pdf', 'https://drive.google.com/file/d/d85b21c0f86cb0/view?usp=drivesdk', 'download'), ], 'Google Drive file that has webContentLink and no webViewLink.' => [ - $this->create_google_drive_file_object('d85b21c0f86cb0', 'File.pdf', + self::create_google_drive_file_object('d85b21c0f86cb0', 'File.pdf', 'application/pdf', 'pdf', null, '', 'https://drive.google.com/uc?id=d85b21c0f86cb0&export=download', ''), [], - $this->create_file_content_node_array('d85b21c0f86cb0', 'File.pdf', 'File.pdf', null, + self::create_file_content_node_array('d85b21c0f86cb0', 'File.pdf', 'File.pdf', null, '', 'https://googleusercontent.com/type/application/pdf', 'https://drive.google.com/uc?id=d85b21c0f86cb0&export=download', 'download'), ], 'Google Drive file without an extension (Google document file; documentformat config set to rtf).' => [ - $this->create_google_drive_file_object('d85b21c0f86cb0', 'File', + self::create_google_drive_file_object('d85b21c0f86cb0', 'File', 'application/vnd.google-apps.document', null), [ 'documentformat' => 'rtf', ], - $this->create_file_content_node_array('d85b21c0f86cb0', 'File', 'File.gdoc', '', '', + self::create_file_content_node_array('d85b21c0f86cb0', 'File', 'File.gdoc', '', '', 'https://googleusercontent.com/type/application/vnd.google-apps.document', '', 'application/rtf', 'document'), ], 'Google Drive file without an extension (Google presentation file; presentationformat config not set).' => [ - $this->create_google_drive_file_object('d85b21c0f86cb0', 'File', + self::create_google_drive_file_object('d85b21c0f86cb0', 'File', 'application/vnd.google-apps.presentation', null), [ 'documentformat' => 'rtf', @@ -113,7 +111,7 @@ class file_node_test extends \repository_googledocs_testcase { ], 'Google Drive file without an extension (File type not supported).' => [ - $this->create_google_drive_file_object('d85b21c0f86cb0', 'File', + self::create_google_drive_file_object('d85b21c0f86cb0', 'File', 'application/vnd.google-apps.unknownmimetype', null), [], null, diff --git a/repository/googledocs/tests/local/node/folder_node_test.php b/repository/googledocs/tests/local/node/folder_node_test.php index 51a2ad7a33e..fce98c80d26 100644 --- a/repository/googledocs/tests/local/node/folder_node_test.php +++ b/repository/googledocs/tests/local/node/folder_node_test.php @@ -50,23 +50,26 @@ class folder_node_test extends \repository_googledocs_testcase { * * @return array */ - public function create_node_array_provider(): array { - + public static function create_node_array_provider(): array { $rootid = \repository_googledocs::REPOSITORY_ROOT_ID; return [ 'Google Drive folder with modified date.' => [ - $this->create_google_drive_folder_object('d85b21c0f86cb0', 'Folder', '01/01/21 0:30'), + self::create_google_drive_folder_object('d85b21c0f86cb0', 'Folder', '01/01/21 0:30'), "{$rootid}|Google+Drive", - $this->create_folder_content_node_array('d85b21c0f86cb0', 'Folder', - "{$rootid}|Google+Drive", '1609432200'), + self::create_folder_content_node_array( + 'd85b21c0f86cb0', + 'Folder', + "{$rootid}|Google+Drive", + '1609432200', + ), ], 'Google Drive folder without modified date.' => [ - $this->create_google_drive_folder_object('d85b21c0f86cb0', 'Folder', ''), + self::create_google_drive_folder_object('d85b21c0f86cb0', 'Folder', ''), '', - $this->create_folder_content_node_array('d85b21c0f86cb0', 'Folder', '', ''), + self::create_folder_content_node_array('d85b21c0f86cb0', 'Folder', '', ''), ], ]; } diff --git a/repository/googledocs/tests/repository_googledocs_testcase.php b/repository/googledocs/tests/repository_googledocs_testcase.php index 35fd15a01d7..aa69213a077 100644 --- a/repository/googledocs/tests/repository_googledocs_testcase.php +++ b/repository/googledocs/tests/repository_googledocs_testcase.php @@ -32,9 +32,12 @@ abstract class repository_googledocs_testcase extends \advanced_testcase { * @param string $modified The date of the last modification * @return array The repository folder node array */ - protected function create_folder_content_node_array(string $id, string $name, string $path, - string $modified = ''): array { - + protected static function create_folder_content_node_array( + string $id, + string $name, + string $path, + string $modified = '' + ): array { global $CFG, $OUTPUT; return [ @@ -63,10 +66,17 @@ abstract class repository_googledocs_testcase extends \advanced_testcase { * @param string|null $googledoctype The type of the Google Doc file (if applicable) * @return array The repository file node array */ - protected function create_file_content_node_array(string $id, string $name, string $title, ?string $size = null, - string $modified = '', string $thumbnail = '' , string $link = '', string $exportformat = '', - ?string $googledoctype = null): array { - + protected static function create_file_content_node_array( + string $id, + string $name, + string $title, + ?string $size = null, + string $modified = '', + string $thumbnail = '', + string $link = '', + string $exportformat = '', + ?string $googledoctype = null + ): array { return [ 'id' => $id, 'title' => $title, @@ -75,7 +85,7 @@ abstract class repository_googledocs_testcase extends \advanced_testcase { 'name' => $name, 'link' => $link, 'exportformat' => $exportformat, - 'googledoctype' => $googledoctype + 'googledoctype' => $googledoctype, ]), 'date' => $modified, 'size' => $size, @@ -92,8 +102,8 @@ abstract class repository_googledocs_testcase extends \advanced_testcase { * @param string $name The name of the shared drive * @return \stdClass The shared drive object */ - protected function create_google_drive_shared_drive_object(string $id, string $name): \stdClass { - return (object)[ + protected static function create_google_drive_shared_drive_object(string $id, string $name): \stdClass { + return (object) [ 'kind' => 'drive#drive', 'id' => $id, 'name' => $name, @@ -108,7 +118,7 @@ abstract class repository_googledocs_testcase extends \advanced_testcase { * @param string|null $modified The date of the last modification * @return \stdClass The folder object */ - protected function create_google_drive_folder_object(string $id, string $name, ?string $modified = null): \stdClass { + protected static function create_google_drive_folder_object(string $id, string $name, ?string $modified = null): \stdClass { return (object)[ 'id' => $id, 'name' => $name, @@ -132,10 +142,16 @@ abstract class repository_googledocs_testcase extends \advanced_testcase { * @param string|null $webviewlink The link for opening the file in a browser * @return \stdClass The file object */ - protected function create_google_drive_file_object(string $id, string $name, string $mimetype, - ?string $extension = null, ?string $size = null, ?string $modified = null, ?string $webcontentlink = null, - ?string $webviewlink = null): \stdClass { - + protected static function create_google_drive_file_object( + string $id, + string $name, + string $mimetype, + ?string $extension = null, + ?string $size = null, + ?string $modified = null, + ?string $webcontentlink = null, + ?string $webviewlink = null + ): \stdClass { $googledrivefile = [ 'id' => $id, 'name' => $name, diff --git a/repository/nextcloud/tests/lib_test.php b/repository/nextcloud/tests/lib_test.php index 8f7f0b99f05..70f240c6079 100644 --- a/repository/nextcloud/tests/lib_test.php +++ b/repository/nextcloud/tests/lib_test.php @@ -853,7 +853,7 @@ XML; * * @return array[] */ - public function sync_reference_provider():array { + public static function sync_reference_provider(): array { return [ 'referecncelastsync done recently' => [ [ diff --git a/search/engine/solr/tests/engine_test.php b/search/engine/solr/tests/engine_test.php index 97b505869c7..c3c5300a6ff 100644 --- a/search/engine/solr/tests/engine_test.php +++ b/search/engine/solr/tests/engine_test.php @@ -46,8 +46,7 @@ require_once($CFG->dirroot . '/search/engine/solr/tests/fixtures/testable_engine * * @runTestsInSeparateProcesses */ -class engine_test extends \advanced_testcase { - +final class engine_test extends \advanced_testcase { /** * @var \core_search\manager */ @@ -143,7 +142,7 @@ class engine_test extends \advanced_testcase { /** * Simple data provider to allow tests to be run with file indexing on and off. */ - public function file_indexing_provider() { + public static function file_indexing_provider(): array { return array( 'file-indexing-on' => array(1), 'file-indexing-off' => array(0) diff --git a/search/tests/document_test.php b/search/tests/document_test.php index d7b83d1d030..6ae7dee5fb3 100644 --- a/search/tests/document_test.php +++ b/search/tests/document_test.php @@ -211,7 +211,7 @@ class document_test extends \advanced_testcase { * * @return array */ - public function document_author_visibility_provider(): array { + public static function document_author_visibility_provider(): array { return [ 'Teacher' => [ 'rolename' => 'editingteacher', diff --git a/search/tests/manager_test.php b/search/tests/manager_test.php index c1363e687bc..1d4e34c9f75 100644 --- a/search/tests/manager_test.php +++ b/search/tests/manager_test.php @@ -106,7 +106,7 @@ class manager_test extends \advanced_testcase { * * @return array[] */ - public function data_course_search_url(): array { + public static function data_course_search_url(): array { return [ 'defaults' => [null, null, null, '/course/search.php'], 'enabled' => [true, true, true, '/search/index.php'], @@ -155,7 +155,7 @@ class manager_test extends \advanced_testcase { * * @return array[] */ - public function data_can_replace_course_search(): array { + public static function data_can_replace_course_search(): array { return [ 'defaults' => [null, null, null, false], 'enabled' => [true, true, true, true], @@ -1503,7 +1503,7 @@ class manager_test extends \advanced_testcase { * * @return array */ - public function parse_search_area_id_data_provider() { + public static function parse_search_area_id_data_provider(): array { return [ ['mod_book-chapter', ['mod_book', 'search_chapter']], ['mod_customcert-activity', ['mod_customcert', 'search_activity']], diff --git a/tag/tests/reportbuilder/datasource/tags_test.php b/tag/tests/reportbuilder/datasource/tags_test.php index 2e0c6c94e2e..483c4d223f2 100644 --- a/tag/tests/reportbuilder/datasource/tags_test.php +++ b/tag/tests/reportbuilder/datasource/tags_test.php @@ -146,7 +146,7 @@ class tags_test extends core_reportbuilder_testcase { * * @return array[] */ - public function datasource_filters_provider(): array { + public static function datasource_filters_provider(): array { return [ // Collection. 'Filter collection name' => ['collection:name', [ diff --git a/theme/boost/tests/boostnavbar_test.php b/theme/boost/tests/boostnavbar_test.php index 86e756b54db..1109d35dd7a 100644 --- a/theme/boost/tests/boostnavbar_test.php +++ b/theme/boost/tests/boostnavbar_test.php @@ -31,7 +31,7 @@ class boostnavbar_test extends \advanced_testcase { * * @return array */ - public function remove_no_link_items_provider(): array { + public static function remove_no_link_items_provider(): array { return [ 'All nodes have links links including leaf node. Set to remove section nodes.' => [ [ @@ -231,7 +231,7 @@ class boostnavbar_test extends \advanced_testcase { * * @return array */ - public function remove_duplicate_items_provider(): array { + public static function remove_duplicate_items_provider(): array { global $CFG; return [ @@ -411,7 +411,7 @@ class boostnavbar_test extends \advanced_testcase { * * @return array */ - public function remove_items_that_exist_in_navigation_provider(): array { + public static function remove_items_that_exist_in_navigation_provider(): array { global $CFG; return [ diff --git a/theme/boost/tests/privacy/provider_test.php b/theme/boost/tests/privacy/provider_test.php index 4655f3b5f5a..7da1d3e7a4f 100644 --- a/theme/boost/tests/privacy/provider_test.php +++ b/theme/boost/tests/privacy/provider_test.php @@ -35,7 +35,7 @@ class provider_test extends \core_privacy\tests\provider_testcase { * * @return array[] */ - public function export_user_preference_provider(): array { + public static function export_user_preference_provider(): array { return [ 'Index drawer open' => [provider::DRAWER_OPEN_INDEX, true, 'privacy:drawerindexopen'], 'Index drawer closed' => [provider::DRAWER_OPEN_INDEX, false, 'privacy:drawerindexclosed'], diff --git a/user/profile/field/text/tests/field_class_test.php b/user/profile/field/text/tests/field_class_test.php index bdde7f88d65..834f0b3ef62 100644 --- a/user/profile/field/text/tests/field_class_test.php +++ b/user/profile/field/text/tests/field_class_test.php @@ -60,7 +60,7 @@ class field_class_test extends \advanced_testcase { * * @return string[] */ - public function filter_profile_field_text_provider(): array { + public static function filter_profile_field_text_provider(): array { return [ 'simple_string' => ['Simple string', 'Simple string'], 'format_string' => ['HTML & is escaped', 'HTML & is escaped'], diff --git a/user/tests/externallib_test.php b/user/tests/externallib_test.php index a3ac4614b4d..e0a0020adaa 100644 --- a/user/tests/externallib_test.php +++ b/user/tests/externallib_test.php @@ -553,7 +553,7 @@ class externallib_test extends externallib_advanced_testcase { /** * Data provider for \core_user_externallib_testcase::test_create_users_with_same_emails(). */ - public function create_users_provider_with_same_emails() { + public static function create_users_provider_with_same_emails(): array { return [ 'Same emails allowed, same case' => [ 1, false @@ -639,7 +639,7 @@ class externallib_test extends externallib_advanced_testcase { * * @return array */ - public function data_create_users_invalid_parameter() { + public static function data_create_users_invalid_parameter(): array { return [ 'blank_username' => [ 'data' => [ @@ -898,7 +898,7 @@ class externallib_test extends externallib_advanced_testcase { * * @return array */ - public function users_with_same_emails() { + public static function users_with_same_emails(): array { return [ 'Same emails not allowed: Update name using exactly the same email' => [ 0, 'John', 's1@example.com', 'Johnny', 's1@example.com', false, true diff --git a/user/tests/fields_test.php b/user/tests/fields_test.php index 1d7977be335..5a5fd0fa152 100644 --- a/user/tests/fields_test.php +++ b/user/tests/fields_test.php @@ -549,7 +549,7 @@ class fields_test extends \advanced_testcase { * * @return array */ - public function get_sql_fullname_provider(): array { + public static function get_sql_fullname_provider(): array { return [ ['firstname lastname', 'FN LN'], ['lastname, firstname', 'LN, FN'], diff --git a/user/tests/profilelib_test.php b/user/tests/profilelib_test.php index e8609d71056..458739341cc 100644 --- a/user/tests/profilelib_test.php +++ b/user/tests/profilelib_test.php @@ -281,7 +281,7 @@ class profilelib_test extends \advanced_testcase { * * @return array[] */ - public function profile_get_custom_field_data_by_shortname_case_sensitivity_provider(): array { + public static function profile_get_custom_field_data_by_shortname_case_sensitivity_provider(): array { return [ 'Matching case, case-sensitive search' => ['hello', 'hello', true, true], 'Matching case, case-insensitive search' => ['hello', 'hello', false, true], diff --git a/user/tests/table/participants_search_test.php b/user/tests/table/participants_search_test.php index d3470db902d..81063bf59ac 100644 --- a/user/tests/table/participants_search_test.php +++ b/user/tests/table/participants_search_test.php @@ -796,7 +796,7 @@ final class participants_search_test extends advanced_testcase { * * @return array */ - public function country_provider(): array { + public static function country_provider(): array { $tests = [ 'users' => [ 'user1' => 'DE', @@ -991,7 +991,7 @@ final class participants_search_test extends advanced_testcase { * * @return array */ - public function keywords_provider(): array { + public static function keywords_provider(): array { $tests = [ // Users where the keyword matches basic user fields such as names and email. 'Users with basic names' => (object) [ @@ -1537,7 +1537,7 @@ final class participants_search_test extends advanced_testcase { * * @return array */ - public function status_provider(): array { + public static function status_provider(): array { $tests = [ // Users with different statuses and enrolment methods (so multiple statuses are possible for the same user). 'Users with different enrolment statuses' => (object) [ @@ -1792,7 +1792,7 @@ final class participants_search_test extends advanced_testcase { * * @return array */ - public function enrolments_provider(): array { + public static function enrolments_provider(): array { $tests = [ // Users with different enrolment methods. 'Users with different enrolment methods' => (object) [ @@ -2016,7 +2016,7 @@ final class participants_search_test extends advanced_testcase { * * @return array */ - public function groups_provider(): array { + public static function groups_provider(): array { $tests = [ 'Users in different groups' => (object) [ 'groupsavailable' => [ @@ -2355,7 +2355,7 @@ final class participants_search_test extends advanced_testcase { * * @return array */ - public function groups_separate_provider(): array { + public static function groups_separate_provider(): array { $tests = [ 'Users in different groups with separate groups mode enabled' => (object) [ 'groupsavailable' => [ @@ -2715,7 +2715,7 @@ final class participants_search_test extends advanced_testcase { * * @return array */ - public function accesssince_provider(): array { + public static function accesssince_provider(): array { $tests = [ // Users with different last access times. 'Users in different groups' => (object) [ @@ -3120,7 +3120,7 @@ final class participants_search_test extends advanced_testcase { * * @return array */ - public function filterset_joins_provider(): array { + public static function filterset_joins_provider(): array { $tests = [ // Users with different configurations. 'Users with different configurations' => (object) [ diff --git a/user/tests/userlib_test.php b/user/tests/userlib_test.php index 67969ff99d6..7f481bdfba8 100644 --- a/user/tests/userlib_test.php +++ b/user/tests/userlib_test.php @@ -394,7 +394,7 @@ class userlib_test extends \advanced_testcase { * * @return array */ - public function data_create_user_invalid_username() { + public static function data_create_user_invalid_username(): array { return [ 'empty_string' => [ '', diff --git a/webservice/rest/tests/server_test.php b/webservice/rest/tests/server_test.php index 04724a8cea8..362532f2e9e 100644 --- a/webservice/rest/tests/server_test.php +++ b/webservice/rest/tests/server_test.php @@ -29,13 +29,12 @@ require_once($CFG->dirroot . '/webservice/rest/locallib.php'); * @copyright 2016 Frédéric Massart - FMCorz.net * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class server_test extends \advanced_testcase { - +final class server_test extends \advanced_testcase { /** * Data provider for test_xmlize. * @return array */ - public function xmlize_provider() { + public static function xmlize_provider(): array { $data = []; $data[] = [null, null, '']; $data[] = [new \external_value(PARAM_BOOL), false, "0\n"]; @@ -207,5 +206,4 @@ class server_test extends \advanced_testcase { $method->setAccessible(true); $this->assertEquals($expected, $method->invoke(null, $value, $description)); } - } diff --git a/webservice/tests/lib_test.php b/webservice/tests/lib_test.php index 4fe60afa1bc..4c33fbe9dae 100644 --- a/webservice/tests/lib_test.php +++ b/webservice/tests/lib_test.php @@ -261,7 +261,7 @@ class lib_test extends \advanced_testcase { * * @return array */ - public function get_active_tokens_provider(): array { + public static function get_active_tokens_provider(): array { return [ 'No expiration' => [0, true], 'Active' => [time() + DAYSECS, true],