mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
Merge branch 'MDL-81521-main' of https://github.com/andrewnicols/moodle
This commit is contained in:
commit
fcb39d60a9
19
.upgradenotes/MDL-81521-2024101701160681.yml
Normal file
19
.upgradenotes/MDL-81521-2024101701160681.yml
Normal file
@ -0,0 +1,19 @@
|
||||
issueNumber: MDL-81521
|
||||
notes:
|
||||
mod_quiz:
|
||||
- message: >
|
||||
The `\mod_quiz\attempt_walkthrough_from_csv_test` unit test has been
|
||||
marked as final and should not be extended by other tests.
|
||||
|
||||
|
||||
All shared functionality has been moved to a new autoloadable test-case:
|
||||
|
||||
`\mod_quiz\tests\attempt_walkthrough_testcase`.
|
||||
|
||||
|
||||
To support this testcase the existing `$files` instance property should be replaced with a
|
||||
new static method, `::get_test_files`.
|
||||
|
||||
Both the existing instance property and the new static method can co-exist.
|
||||
|
||||
type: changed
|
@ -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' => [
|
||||
],
|
||||
|
@ -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',
|
||||
|
@ -368,7 +368,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,
|
||||
@ -531,7 +531,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' => '',
|
||||
|
@ -85,7 +85,7 @@ class set_block_protection_test extends \externallib_advanced_testcase {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function execute_provider(): array {
|
||||
public static function execute_provider(): array {
|
||||
return [
|
||||
[
|
||||
'block_login',
|
||||
|
@ -72,7 +72,7 @@ class set_plugin_order_test extends \externallib_advanced_testcase {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function execute_editor_provider(): array {
|
||||
public static function execute_editor_provider(): array {
|
||||
$pluginmanager = \core_plugin_manager::instance();
|
||||
$allplugins = array_keys($pluginmanager->get_plugins_of_type('editor'));
|
||||
|
||||
@ -142,7 +142,7 @@ class set_plugin_order_test extends \externallib_advanced_testcase {
|
||||
$this->assertIsArray(set_plugin_order::execute($plugin, 1));
|
||||
}
|
||||
|
||||
public function execute_non_orderable_provider(): array {
|
||||
public static function execute_non_orderable_provider(): array {
|
||||
return [
|
||||
// Activities do not support ordering.
|
||||
['mod_assign'],
|
||||
|
@ -66,7 +66,7 @@ class set_plugin_state_test extends \externallib_advanced_testcase {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function execute_standard_provider(): array {
|
||||
public static function execute_standard_provider(): array {
|
||||
$generatetestsfor = function (string $plugin): array {
|
||||
return [
|
||||
[
|
||||
|
@ -110,7 +110,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): void {
|
||||
$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): void {
|
||||
global $CFG;
|
||||
|
@ -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(): void {
|
||||
$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
|
||||
|
@ -633,7 +633,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,
|
||||
@ -815,7 +815,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]);
|
||||
|
||||
@ -1000,7 +1000,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],
|
||||
@ -1090,7 +1090,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'],
|
||||
@ -1442,7 +1442,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],
|
||||
@ -2002,7 +2002,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],
|
||||
@ -2477,7 +2477,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],
|
||||
@ -2514,7 +2514,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;
|
||||
}
|
||||
|
@ -1950,7 +1950,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,
|
||||
@ -1988,7 +1988,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,
|
||||
@ -2023,7 +2023,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' => [
|
||||
[
|
||||
|
@ -580,7 +580,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],
|
||||
@ -705,7 +705,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],
|
||||
|
@ -57,7 +57,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],
|
||||
|
@ -32,7 +32,7 @@ class factor_test extends \advanced_testcase {
|
||||
*
|
||||
* @return array of different country codes and phone numbers.
|
||||
*/
|
||||
public function format_number_provider(): array {
|
||||
public static function format_number_provider(): array {
|
||||
|
||||
return [
|
||||
'Phone number with local format' => [
|
||||
@ -88,7 +88,7 @@ class factor_test extends \advanced_testcase {
|
||||
*
|
||||
* @return array with different phone numebr tests
|
||||
*/
|
||||
public function is_valid_phonenumber_provider(): array {
|
||||
public static function is_valid_phonenumber_provider(): array {
|
||||
return [
|
||||
['+919367788755', true],
|
||||
['8989829304', false],
|
||||
|
@ -276,7 +276,7 @@ class factor_test extends \advanced_testcase {
|
||||
* Increments by 30 minutes to cover half hour and hour cases.
|
||||
* Starting timestamp: 2022-01-15 07:30:00 Australia/Melbourne time.
|
||||
*/
|
||||
public function timestamp_provider() {
|
||||
public static function timestamp_provider(): array {
|
||||
$starttimestamp = 1642192200;
|
||||
foreach (range(0, 23) as $i) {
|
||||
$timestamps[] = [$starttimestamp + ($i * HOURSECS)];
|
||||
|
@ -51,7 +51,7 @@ class admin_setting_managemfa_test extends \advanced_testcase {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_factor_combinations_provider() {
|
||||
public static function get_factor_combinations_provider(): array {
|
||||
$provider = [];
|
||||
|
||||
$factors = [];
|
||||
|
@ -157,7 +157,7 @@ class manager_test extends \advanced_testcase {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function should_redirect_urls_provider() {
|
||||
public static function should_redirect_urls_provider(): array {
|
||||
$badurl1 = new \moodle_url('/');
|
||||
$badparam1 = $badurl1->out();
|
||||
$badurl2 = new \moodle_url('admin/tool/mfa/auth.php');
|
||||
|
@ -52,7 +52,7 @@ class lib_test extends \advanced_testcase {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_endpoints_provider() {
|
||||
public static function get_endpoints_provider(): array {
|
||||
global $CFG;
|
||||
return [
|
||||
[
|
||||
|
@ -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'
|
||||
@ -78,8 +78,8 @@ class remote_resource_test extends \advanced_testcase {
|
||||
* Test confirming the network based operations of a remote_resource.
|
||||
*/
|
||||
public function test_network_features(): void {
|
||||
$url = $this->getExternalTestFileUrl('/test.html');
|
||||
$nonexistenturl = $this->getExternalTestFileUrl('/test.htmlzz');
|
||||
$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',
|
||||
|
@ -196,7 +196,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],
|
||||
|
@ -176,7 +176,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],
|
||||
|
@ -1276,7 +1276,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')
|
||||
|
@ -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']],
|
||||
];
|
||||
|
@ -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],
|
||||
|
@ -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(): void {
|
||||
|
||||
$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(): void {
|
||||
$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);
|
||||
|
@ -136,7 +136,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' => [
|
||||
[],
|
||||
|
@ -342,14 +342,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -418,13 +418,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.
|
||||
@ -508,7 +508,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]),
|
||||
@ -518,7 +518,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -582,13 +582,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -778,8 +778,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',
|
||||
@ -798,7 +797,7 @@ class prediction_test extends \advanced_testcase {
|
||||
)
|
||||
)
|
||||
);
|
||||
return $this->add_prediction_processors($cases);
|
||||
return static::add_prediction_processors($cases);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -956,8 +955,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')
|
||||
|
@ -66,7 +66,7 @@ class auth_ldap_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 = [];
|
||||
|
@ -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,
|
||||
@ -286,12 +289,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],
|
||||
@ -301,7 +304,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
|
||||
@ -312,7 +315,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,
|
||||
@ -324,7 +327,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,
|
||||
@ -345,7 +348,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],
|
||||
@ -374,7 +377,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],
|
||||
@ -396,7 +399,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],
|
||||
@ -425,7 +428,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],
|
||||
@ -454,7 +457,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],
|
||||
@ -483,7 +486,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],
|
||||
@ -512,7 +515,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],
|
||||
@ -540,7 +543,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],
|
||||
@ -569,7 +572,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,
|
||||
@ -591,7 +594,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],
|
||||
@ -601,7 +604,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,
|
||||
@ -622,7 +625,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],
|
||||
@ -643,7 +646,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],
|
||||
@ -654,7 +657,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,
|
||||
@ -667,7 +670,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],
|
||||
@ -678,7 +681,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,
|
||||
@ -691,7 +694,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,
|
||||
@ -810,17 +813,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,
|
||||
@ -830,14 +833,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,
|
||||
@ -847,13 +850,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,
|
||||
@ -863,14 +866,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,
|
||||
@ -885,13 +888,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,
|
||||
@ -906,12 +909,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,
|
||||
@ -926,12 +929,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,
|
||||
@ -946,12 +949,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,
|
||||
@ -966,13 +969,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,
|
||||
@ -982,13 +985,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,
|
||||
@ -998,12 +1001,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,
|
||||
@ -1013,14 +1016,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,
|
||||
@ -1031,12 +1034,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,
|
||||
@ -1056,7 +1059,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.
|
||||
@ -1068,7 +1071,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');
|
||||
@ -1148,17 +1151,17 @@ class auth_test extends \advanced_testcase {
|
||||
*
|
||||
* @return array the test case data.
|
||||
*/
|
||||
public function update_user_account_provider(): array {
|
||||
public static function update_user_account_provider(): array {
|
||||
return [
|
||||
'Full PII included in both auths, no picture in either' => [
|
||||
'first_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]
|
||||
],
|
||||
'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],
|
||||
@ -1171,7 +1174,7 @@ class auth_test extends \advanced_testcase {
|
||||
],
|
||||
'No PII included in both auths, no picture in either' => [
|
||||
'first_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,
|
||||
@ -1179,7 +1182,7 @@ class auth_test extends \advanced_testcase {
|
||||
)[0]
|
||||
],
|
||||
'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,
|
||||
@ -1194,7 +1197,7 @@ class auth_test extends \advanced_testcase {
|
||||
],
|
||||
'First auth no PII, second auth including PII, no picture in either' => [
|
||||
'first_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,
|
||||
@ -1202,7 +1205,7 @@ class auth_test extends \advanced_testcase {
|
||||
)[0]
|
||||
],
|
||||
'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],
|
||||
@ -1215,13 +1218,13 @@ class auth_test extends \advanced_testcase {
|
||||
],
|
||||
'First auth full PII, second auth no PII, no picture in either' => [
|
||||
'first_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]
|
||||
],
|
||||
'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,
|
||||
@ -1236,13 +1239,13 @@ class auth_test extends \advanced_testcase {
|
||||
],
|
||||
'First auth full PII, second auth emails only, no picture in either' => [
|
||||
'first_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]
|
||||
],
|
||||
'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
|
||||
@ -1256,13 +1259,13 @@ class auth_test extends \advanced_testcase {
|
||||
],
|
||||
'First auth full PII, second auth names only, no picture in either' => [
|
||||
'first_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]
|
||||
],
|
||||
'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,
|
||||
@ -1277,13 +1280,13 @@ class auth_test extends \advanced_testcase {
|
||||
],
|
||||
'Full PII included in both auths, picture included in the second auth' => [
|
||||
'first_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]
|
||||
],
|
||||
'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,
|
||||
|
@ -470,7 +470,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' => [
|
||||
@ -635,7 +635,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),
|
||||
|
@ -481,7 +481,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',
|
||||
@ -1231,7 +1231,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,
|
||||
@ -1299,7 +1299,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',
|
||||
@ -1416,7 +1416,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],
|
||||
@ -1587,7 +1587,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],
|
||||
@ -1642,7 +1642,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,
|
||||
@ -1696,7 +1696,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"
|
||||
@ -1743,7 +1743,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", [
|
||||
|
@ -211,7 +211,7 @@ class users_test extends core_reportbuilder_testcase {
|
||||
*
|
||||
* @return array[]
|
||||
*/
|
||||
public function datasource_filters_provider(): array {
|
||||
public static function datasource_filters_provider(): array {
|
||||
return [
|
||||
// User.
|
||||
'Filter user fullname' => ['user:fullname', [
|
||||
|
@ -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', ''),
|
||||
|
@ -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', ''),
|
||||
|
@ -175,7 +175,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,
|
||||
|
6
cache/stores/redis/tests/compressor_test.php
vendored
6
cache/stores/redis/tests/compressor_test.php
vendored
@ -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(): void {
|
||||
$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 [];
|
||||
|
@ -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): void {
|
||||
@ -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' => [
|
||||
|
@ -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): void {
|
||||
@ -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): void {
|
||||
$class = calendar_event_exporter::class;
|
||||
@ -90,7 +90,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;
|
||||
@ -126,7 +126,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): void {
|
||||
$class = calendar_event_exporter::class;
|
||||
|
@ -69,7 +69,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): void {
|
||||
@ -130,7 +130,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): void {
|
||||
@ -156,7 +156,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): void {
|
||||
@ -185,7 +185,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): void {
|
||||
@ -210,7 +210,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): void {
|
||||
@ -505,7 +505,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)[
|
||||
|
@ -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): void {
|
||||
@ -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' => [
|
||||
|
@ -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.
|
||||
@ -346,7 +346,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)[
|
||||
|
@ -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): void {
|
||||
@ -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'];
|
||||
};
|
||||
|
@ -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): void {
|
||||
@ -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' => [
|
||||
|
@ -2797,7 +2797,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 [
|
||||
@ -2868,7 +2868,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 [
|
||||
|
@ -1228,7 +1228,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'],
|
||||
|
@ -116,7 +116,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,
|
||||
@ -154,7 +154,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]
|
||||
|
@ -145,7 +145,7 @@ class cohorts_test extends core_reportbuilder_testcase {
|
||||
*
|
||||
* @return array[]
|
||||
*/
|
||||
public function datasource_filters_provider(): array {
|
||||
public static function datasource_filters_provider(): array {
|
||||
return [
|
||||
// Cohort.
|
||||
'Filter cohort' => ['cohort:cohortselect', [
|
||||
|
@ -136,7 +136,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 [
|
||||
@ -134,7 +134,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
|
||||
|
@ -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]],
|
||||
@ -184,7 +184,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)' => [
|
||||
[
|
||||
|
@ -105,7 +105,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
|
||||
@ -138,7 +138,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
|
||||
@ -171,7 +171,7 @@ class cm_completion_details_test extends advanced_testcase {
|
||||
*
|
||||
* @return array[]
|
||||
*/
|
||||
public function is_manual_provider(): array {
|
||||
public static function is_manual_provider(): array {
|
||||
return [
|
||||
'Automatic' => [
|
||||
COMPLETION_TRACKING_AUTOMATIC, false
|
||||
@ -203,7 +203,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],
|
||||
@ -362,7 +362,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, []
|
||||
@ -523,7 +523,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,
|
||||
|
@ -80,7 +80,7 @@ class generator_test extends \advanced_testcase {
|
||||
* Data provider for test_create_default_completion().
|
||||
* @return array[]
|
||||
*/
|
||||
public function create_default_completion_provider(): array {
|
||||
public static function create_default_completion_provider(): array {
|
||||
global $SITE;
|
||||
|
||||
return [
|
||||
|
@ -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',
|
||||
|
@ -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'],
|
||||
|
@ -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' => [],
|
||||
|
@ -240,7 +240,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],
|
||||
@ -449,7 +449,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],
|
||||
|
@ -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],
|
||||
|
@ -281,7 +281,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',
|
||||
@ -516,7 +516,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
|
||||
@ -604,7 +604,7 @@ class base_test extends advanced_testcase {
|
||||
*
|
||||
* @return array the testing scenarios
|
||||
*/
|
||||
public function get_format_string_provider(): array {
|
||||
public static function get_format_string_provider(): array {
|
||||
return [
|
||||
'Existing in format lang' => [
|
||||
'key' => 'addsection',
|
||||
@ -683,7 +683,7 @@ class base_test extends advanced_testcase {
|
||||
*
|
||||
* @return array the testing scenarios
|
||||
*/
|
||||
public function move_section_after_provider(): array {
|
||||
public static function move_section_after_provider(): array {
|
||||
return [
|
||||
'Move top' => [
|
||||
'movesection' => 'section3',
|
||||
@ -794,7 +794,7 @@ class base_test extends advanced_testcase {
|
||||
*
|
||||
* @return array the testing scenarios
|
||||
*/
|
||||
public function get_non_ajax_cm_action_url_provider(): array {
|
||||
public static function get_non_ajax_cm_action_url_provider(): array {
|
||||
return [
|
||||
'duplicate' => [
|
||||
'action' => 'cmDuplicate',
|
||||
|
@ -184,7 +184,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' => [
|
||||
|
@ -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',
|
||||
|
@ -151,7 +151,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' => [
|
||||
|
@ -143,7 +143,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' => [
|
||||
|
@ -151,7 +151,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' => [
|
||||
|
@ -30,7 +30,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 {
|
||||
/**
|
||||
* Helper method to create an activity into a section and add it to the $sections and $activities arrays.
|
||||
*
|
||||
@ -46,7 +46,6 @@ class stateactions_test extends \advanced_testcase {
|
||||
int $section,
|
||||
bool $visible = true
|
||||
): int {
|
||||
|
||||
$activity = $this->getDataGenerator()->create_module(
|
||||
$type,
|
||||
['course' => $courseid],
|
||||
@ -199,7 +198,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,
|
||||
@ -209,7 +207,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.
|
||||
@ -269,29 +266,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'),
|
||||
);
|
||||
}
|
||||
|
||||
@ -301,7 +298,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.
|
||||
@ -357,8 +354,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');
|
||||
@ -486,8 +482,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'];
|
||||
@ -862,7 +857,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',
|
||||
@ -973,7 +968,7 @@ class stateactions_test extends \advanced_testcase {
|
||||
*
|
||||
* @return array the testing scenarios
|
||||
*/
|
||||
public function cm_duplicate_provider(): array {
|
||||
public static function cm_duplicate_provider(): array {
|
||||
return [
|
||||
'valid cms without target section' => [
|
||||
'targetsection' => '',
|
||||
@ -1299,7 +1294,7 @@ class stateactions_test extends \advanced_testcase {
|
||||
*
|
||||
* @return array the testing scenarios
|
||||
*/
|
||||
public function section_move_after_provider(): array {
|
||||
public static function section_move_after_provider(): array {
|
||||
return [
|
||||
'Move sections down' => [
|
||||
'sectiontomove' => ['section2', 'section4'],
|
||||
|
@ -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];
|
||||
|
@ -191,7 +191,7 @@ class stateactions_test extends \advanced_testcase {
|
||||
*
|
||||
* @return array the testing scenarios
|
||||
*/
|
||||
public function basic_role_provider(): array {
|
||||
public static function basic_role_provider(): array {
|
||||
return [
|
||||
'admin' => [
|
||||
'role' => 'admin',
|
||||
|
@ -1289,7 +1289,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,
|
||||
|
@ -638,7 +638,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()));
|
||||
@ -811,7 +811,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],
|
||||
@ -3560,7 +3560,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 [
|
||||
[
|
||||
@ -3642,7 +3642,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
|
||||
@ -4543,7 +4543,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;
|
||||
|
||||
@ -4654,7 +4654,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.
|
||||
*/
|
||||
@ -4696,7 +4696,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++) {
|
||||
@ -4784,7 +4784,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.
|
||||
@ -4832,7 +4832,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;
|
||||
|
||||
@ -5082,7 +5082,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.
|
||||
@ -5131,7 +5131,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 = [
|
||||
@ -5301,7 +5301,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.
|
||||
@ -5387,7 +5387,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;
|
||||
|
||||
@ -5546,7 +5546,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.
|
||||
@ -5756,7 +5756,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)' =>
|
||||
[
|
||||
@ -5830,7 +5830,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;
|
||||
@ -7044,7 +7044,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
|
||||
@ -7137,7 +7137,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],
|
||||
|
@ -3819,7 +3819,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
|
||||
|
@ -228,7 +228,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 name' => ['course_category:text', [
|
||||
|
@ -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 [
|
||||
|
@ -170,7 +170,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')],
|
||||
|
@ -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 = [];
|
||||
@ -524,7 +524,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(
|
||||
|
@ -405,7 +405,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' => [
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user