MDL-81521 core: Update all possibly data providers to be static

Note: Some data providers could not be automatically be converted to
being static. These will be handled in a separate issue.
This commit is contained in:
Andrew Nicols
2024-04-13 14:40:07 +08:00
parent eaa25cf51b
commit 3d51aed3e2
387 changed files with 1442 additions and 1404 deletions
+1 -1
View File
@@ -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' => [
],
+4 -4
View File
@@ -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',
@@ -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,
@@ -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',
@@ -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',
+2 -2
View File
@@ -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' => '',
@@ -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],
@@ -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' => [
@@ -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,
@@ -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 [
@@ -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;
+5 -5
View File
@@ -30,7 +30,7 @@ use tool_brickfield\local\tool\tool;
class tool_test extends \advanced_testcase {
/** @var string base 64 image */
protected $base64img = <<<EOF
protected static string $base64img = <<<EOF
<img src="data:image/gif;base64,R0lGODlhPQBEAPeoAJosM//AwO/AwHVYZ/z595kzAP/s7P+goOXMv8+fhw/v739/f+8PD98fH/
8mJl+fn/9ZWb8/PzWlwv///6wWGbImAPgTEMImIN9gUFCEm/gDALULDN8PAD6atYdCTX9gUNKlj8wZAKUsAOzZz+UMAOsJAP/Z2ccMDA8PD/95eX5N
WvsJCOVNQPtfX/8zM8+QePLl38MGBr8JCP+zs9myn/8GBqwpAP/GxgwJCPny78lzYLgjAJ8vAP9fX/+MjMUcAN8zM/9wcM8ZGcATEL+QePdZWf/29u
@@ -118,11 +118,11 @@ EOF;
* Base64 image provider.
* @return array
*/
public function base64_img_provider(): array {
public static function base64_img_provider(): array {
$img = '<img src="myimage.jpg" />';
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('<img src="data:image/gif;base64..."', $truncated);
}
}
@@ -60,7 +60,7 @@ class langstring_test extends advanced_testcase {
*
* @return array
*/
public function fix_syntax_data() : array {
public static function fix_syntax_data(): array {
return [
// Syntax sanity v1 strings.
[
@@ -79,7 +79,7 @@ class phpparser_test extends advanced_testcase {
*
* @return array
*/
public function parse_provider() : array {
public static function parse_provider(): array {
return [
'Invalid PHP code' => [
'No PHP code', [], false
+8 -8
View File
@@ -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
@@ -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;
}
@@ -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' => [
[
+2 -2
View File
@@ -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],
@@ -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' => [
@@ -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" => '<img src="' . $this->getExternalTestFileUrl('/test.jpg', false) . '">',
"content" => '<img src="' . self::getExternalTestFileUrl('/test.jpg', false) . '">',
"outputregex" => '/UPDATE/',
"expectedcontent" => '<img src="' . $this->get_converted_http_link('/test.jpg') . '">',
"expectedcontent" => '<img src="' . self::get_converted_http_link('/test.jpg') . '">',
],
"Test object from another site should be replaced" => [
"content" => '<object data="' . $this->getExternalTestFileUrl('/test.swf', false) . '">',
"content" => '<object data="' . self::getExternalTestFileUrl('/test.swf', false) . '">',
"outputregex" => '/UPDATE/',
"expectedcontent" => '<object data="' . $this->get_converted_http_link('/test.swf') . '">',
"expectedcontent" => '<object data="' . self::get_converted_http_link('/test.swf') . '">',
],
"Test image from a site with international name should be replaced" => [
"content" => '<img src="http://中国互联网络信息中心.中国/logosy/201706/W01.png">',
@@ -79,9 +79,9 @@ class httpsreplace_test extends \advanced_testcase {
"expectedcontent" => '<img src="https://anothersite.com?param=http://asdf.com">',
],
"Search for params should be case insensitive" => [
"content" => '<object DATA="' . $this->getExternalTestFileUrl('/test.swf', false) . '">',
"content" => '<object DATA="' . self::getExternalTestFileUrl('/test.swf', false) . '">',
"outputregex" => '/UPDATE/',
"expectedcontent" => '<object DATA="' . $this->get_converted_http_link('/test.swf') . '">',
"expectedcontent" => '<object DATA="' . self::get_converted_http_link('/test.swf') . '">',
],
"URL should be case insensitive" => [
"content" => '<object data="HTTP://some.site/path?query">',
@@ -89,30 +89,30 @@ class httpsreplace_test extends \advanced_testcase {
"expectedcontent" => '<object data="https://some.site/path?query">',
],
"More params should not interfere" => [
"content" => '<img alt="A picture" src="' . $this->getExternalTestFileUrl('/test.png', false) .
"content" => '<img alt="A picture" src="' . self::getExternalTestFileUrl('/test.png', false) .
'" width="1”><p style="font-size: \'20px\'"></p>',
"outputregex" => '/UPDATE/',
"expectedcontent" => '<img alt="A picture" src="' . $this->get_converted_http_link('/test.png') .
"expectedcontent" => '<img alt="A picture" src="' . self::get_converted_http_link('/test.png') .
'" width="1”><p style="font-size: \'20px\'"></p>',
],
"Broken URL should not be changed" => [
"content" => '<img src="broken.' . $this->getExternalTestFileUrl('/test.png', false) . '">',
"content" => '<img src="broken.' . self::getExternalTestFileUrl('/test.png', false) . '">',
"outputregex" => '/^$/',
"expectedcontent" => '<img src="broken.' . $this->getExternalTestFileUrl('/test.png', false) . '">',
"expectedcontent" => '<img src="broken.' . self::getExternalTestFileUrl('/test.png', false) . '">',
],
"Link URL should not be changed" => [
"content" => '<a href="' . $this->getExternalTestFileUrl('/test.png', false) . '">' .
$this->getExternalTestFileUrl('/test.png', false) . '</a>',
"content" => '<a href="' . self::getExternalTestFileUrl('/test.png', false) . '">' .
self::getExternalTestFileUrl('/test.png', false) . '</a>',
"outputregex" => '/^$/',
"expectedcontent" => '<a href="' . $this->getExternalTestFileUrl('/test.png', false) . '">' .
$this->getExternalTestFileUrl('/test.png', false) . '</a>',
"expectedcontent" => '<a href="' . self::getExternalTestFileUrl('/test.png', false) . '">' .
self::getExternalTestFileUrl('/test.png', false) . '</a>',
],
"Test image from another site should be replaced but link should not" => [
"content" => '<a href="' . $this->getExternalTestFileUrl('/test.png', false) . '"><img src="' .
$this->getExternalTestFileUrl('/test.jpg', false) . '"></a>',
"content" => '<a href="' . self::getExternalTestFileUrl('/test.png', false) . '"><img src="' .
self::getExternalTestFileUrl('/test.jpg', false) . '"></a>',
"outputregex" => '/UPDATE/',
"expectedcontent" => '<a href="' . $this->getExternalTestFileUrl('/test.png', false) . '"><img src="' .
$this->get_converted_http_link('/test.jpg') . '"></a>',
"expectedcontent" => '<a href="' . self::getExternalTestFileUrl('/test.png', false) . '"><img src="' .
self::get_converted_http_link('/test.jpg') . '"></a>',
],
];
}
@@ -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" => '<img src="' . $this->getExternalTestFileUrl('/test.jpg', false) . '">',
"content" => '<img src="' . self::getExternalTestFileUrl('/test.jpg', false) . '">',
"domain" => $testdomain,
"expectedcount" => 0,
],
@@ -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' => [' '],
@@ -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],
+1 -1
View File
@@ -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 [
[
@@ -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],
@@ -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(),
@@ -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',
@@ -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],
@@ -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],
@@ -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',
@@ -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')
@@ -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' => [
[],
+1 -1
View File
@@ -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',
+1 -1
View File
@@ -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',
+3 -3
View File
@@ -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 = [
+5 -5
View File
@@ -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',
@@ -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,
+9 -9
View File
@@ -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'];
+2 -3
View File
@@ -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']],
];
+3 -4
View File
@@ -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],
+55 -46
View File
@@ -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);
+1 -1
View File
@@ -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' => [
[],
+11 -13
View File
@@ -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')
+1 -1
View File
@@ -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 = [];
+61 -58
View File
@@ -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');
@@ -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' => [
@@ -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'),
@@ -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$/';
@@ -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 = [
@@ -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),
+8 -8
View File
@@ -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'
@@ -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", [
@@ -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', ''),
+1 -1
View File
@@ -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,
@@ -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', ''),
@@ -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,
+3 -3
View File
@@ -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 [];
+2 -2
View File
@@ -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' => [
+2 -2
View File
@@ -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' => [
@@ -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;
+6 -6
View File
@@ -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)[
+2 -2
View File
@@ -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' => [
+2 -2
View File
@@ -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)[
+2 -2
View File
@@ -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'];
};
+2 -2
View File
@@ -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' => [
+2 -2
View File
@@ -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 [
+1 -1
View File
@@ -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'],
+2 -2
View File
@@ -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]
@@ -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();
@@ -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', [
@@ -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
+2 -2
View File
@@ -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)' => [
[
@@ -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,
@@ -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',
+1 -1
View File
@@ -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'],
+4 -4
View File
@@ -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' => [],
+2 -2
View File
@@ -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],
+1 -1
View File
@@ -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],
+2 -2
View File
@@ -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
+1 -1
View File
@@ -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' => [
+1 -1
View File
@@ -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',
@@ -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' => [
@@ -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' => [
@@ -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' => [
+27 -33
View File
@@ -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',
+11 -11
View File
@@ -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];
+1 -1
View File
@@ -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,
+18 -18
View File
@@ -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],
+1 -1
View File
@@ -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
@@ -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', [
+3 -3
View File
@@ -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 [
+1 -1
View File
@@ -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')],
+2 -2
View File
@@ -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(
+1 -1
View File
@@ -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" => [
@@ -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' => [
@@ -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' => [
@@ -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' => [
@@ -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' => [
@@ -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',
@@ -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' => [
@@ -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' => [

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