mirror of
https://github.com/moodle/moodle.git
synced 2025-08-11 03:46:42 +02:00
MDL-82207 phpunit: fix various @covers annotations (take#1)
This fixes various (not all) wrong @covers annotations that are reported as warnings by PHPUnit when it's run with code-coverage enabled. When possible, the preferred solution is to change to @covers at class level, that is the recommended way. If multiple classes are involved, then a mix of @coversDefaultClass and @covers at method level are used (always trying to use the minimum needed patch). This is the first of a series of issues created as sub-tasks of MDL-82142.
This commit is contained in:
parent
ad7fc69c25
commit
ad5fe71868
53 changed files with 75 additions and 128 deletions
|
@ -5260,7 +5260,7 @@ class accesslib_test extends advanced_testcase {
|
|||
/**
|
||||
* Test get_navigation_filter_context.
|
||||
*
|
||||
* @covers ::get_navigation_filter_context
|
||||
* @covers \core\context_helper::get_navigation_filter_context
|
||||
*/
|
||||
public function test_get_navigation_filter_context(): void {
|
||||
$this->resetAfterTest();
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace core;
|
|||
* @category test
|
||||
* @copyright 2012 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @covers \auth_plugin_base
|
||||
*/
|
||||
class authlib_test extends \advanced_testcase {
|
||||
public function test_lockout(): void {
|
||||
|
@ -507,7 +508,6 @@ class authlib_test extends \advanced_testcase {
|
|||
|
||||
/**
|
||||
* Test the find_cli_user method
|
||||
* @covers ::find_cli_user
|
||||
*/
|
||||
public function test_find_cli_user(): void {
|
||||
global $CFG, $USER;
|
||||
|
@ -540,7 +540,6 @@ class authlib_test extends \advanced_testcase {
|
|||
|
||||
/**
|
||||
* Test the get_enabled_auth_plugin_classes method
|
||||
* @covers ::get_enabled_auth_plugin_classes
|
||||
*/
|
||||
public function test_get_enabled_auth_plugin_classes(): void {
|
||||
global $CFG;
|
||||
|
|
|
@ -26,7 +26,7 @@ use core\check\security\passwordpolicy;
|
|||
* @category check
|
||||
* @copyright 2020 Brendan Heywood <brendan@catalyst-au.net>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @covers \core\check
|
||||
* @covers \core\check\check
|
||||
*/
|
||||
class check_test extends \advanced_testcase {
|
||||
|
||||
|
|
|
@ -147,7 +147,7 @@ class configonlylib_test extends \advanced_testcase {
|
|||
/**
|
||||
* Test the min_get_minimum_version function.
|
||||
*
|
||||
* @covers ::min_get_minimum_version
|
||||
* @covers ::min_get_minimum_revision
|
||||
*/
|
||||
public function test_min_get_minimum_version(): void {
|
||||
// This is fairly hard to write a test for, but we can at least check that it returns a number
|
||||
|
@ -161,7 +161,7 @@ class configonlylib_test extends \advanced_testcase {
|
|||
/**
|
||||
* Test the min_get_maximum_version function.
|
||||
*
|
||||
* @covers ::min_get_maximum_version
|
||||
* @covers ::min_get_maximum_revision
|
||||
*/
|
||||
public function test_min_get_maximum_version(): void {
|
||||
// The maximum version should be set to a time in the near future.
|
||||
|
|
|
@ -33,7 +33,7 @@ use stdClass;
|
|||
* @category test
|
||||
* @copyright 2020 Andrew Nicols <andrew@nicols.co.uk>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @covers \core\content\exportable_items\exportable_filearea
|
||||
* @covers \core\content\export\exportable_items\exportable_filearea
|
||||
*/
|
||||
class exportable_filearea_test extends advanced_testcase {
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ use stored_file;
|
|||
* @category test
|
||||
* @copyright 2020 Andrew Nicols <andrew@nicols.co.uk>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @covers \core\content\exportable_items\exportable_stored_file
|
||||
* @covers \core\content\export\exportable_items\exportable_stored_file
|
||||
*/
|
||||
class exportable_stored_file_test extends advanced_testcase {
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ use stdClass;
|
|||
* @category test
|
||||
* @copyright 2020 Andrew Nicols <andrew@nicols.co.uk>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @covers \core\content\exportable_items\exportable_textarea
|
||||
* @covers \core\content\export\exportable_items\exportable_textarea
|
||||
*/
|
||||
class exportable_textarea_test extends advanced_testcase {
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ use moodle_page;
|
|||
*/
|
||||
final class core_renderer_test extends \advanced_testcase {
|
||||
/**
|
||||
* @covers \core\hook\before_standard_top_of_body_html_generation
|
||||
* @covers \core\hook\output\before_standard_top_of_body_html_generation
|
||||
*/
|
||||
public function test_standard_top_of_body_html(): void {
|
||||
$page = new moodle_page();
|
||||
|
@ -42,7 +42,7 @@ final class core_renderer_test extends \advanced_testcase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers \core\hook\before_standard_top_of_body_html_generation
|
||||
* @covers \core\hook\output\before_standard_top_of_body_html_generation
|
||||
*/
|
||||
public function test_before_standard_top_of_body_html_generation_hooked(): void {
|
||||
require_once(__DIR__ . '/fixtures/core_renderer/before_standard_top_of_body_html_generation_callbacks.php');
|
||||
|
@ -63,7 +63,7 @@ final class core_renderer_test extends \advanced_testcase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers \core\hook\before_footer_html_generation
|
||||
* @covers \core\hook\output\before_footer_html_generation
|
||||
*/
|
||||
public function test_before_footer_html_generation(): void {
|
||||
$this->resetAfterTest();
|
||||
|
@ -79,7 +79,7 @@ final class core_renderer_test extends \advanced_testcase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers \core\hook\before_footer_html_generation
|
||||
* @covers \core\hook\output\before_footer_html_generation
|
||||
*/
|
||||
public function test_before_footer_html_generation_hooked(): void {
|
||||
$this->resetAfterTest();
|
||||
|
@ -104,7 +104,7 @@ final class core_renderer_test extends \advanced_testcase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers \core\hook\before_standard_footer_html_generation
|
||||
* @covers \core\hook\output\before_standard_footer_html_generation
|
||||
*/
|
||||
public function before_standard_footer_html_generation(): void {
|
||||
$page = new moodle_page();
|
||||
|
@ -116,7 +116,7 @@ final class core_renderer_test extends \advanced_testcase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers \core\hook\before_standard_footer_html_generation
|
||||
* @covers \core\hook\output\before_standard_footer_html_generation
|
||||
*/
|
||||
public function test_before_standard_footer_html_generation_hooked(): void {
|
||||
require_once(__DIR__ . '/fixtures/core_renderer/before_standard_footer_html_generation_callbacks.php');
|
||||
|
@ -137,7 +137,7 @@ final class core_renderer_test extends \advanced_testcase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers \core\hook\after_standard_main_region_html_generation
|
||||
* @covers \core\hook\output\after_standard_main_region_html_generation
|
||||
*/
|
||||
public function test_after_standard_main_region_html_generation(): void {
|
||||
$page = new moodle_page();
|
||||
|
@ -149,7 +149,7 @@ final class core_renderer_test extends \advanced_testcase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers \core\hook\after_standard_main_region_html_generation
|
||||
* @covers \core\hook\output\after_standard_main_region_html_generation
|
||||
*/
|
||||
public function test_after_standard_main_region_html_generation_hooked(): void {
|
||||
require_once(__DIR__ . '/fixtures/core_renderer/after_standard_main_region_html_generation_callbacks.php');
|
||||
|
@ -170,7 +170,7 @@ final class core_renderer_test extends \advanced_testcase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers \core\hook\before_html_attributes
|
||||
* @covers \core\hook\output\before_html_attributes
|
||||
*/
|
||||
public function test_htmlattributes(): void {
|
||||
$page = new moodle_page();
|
||||
|
@ -182,7 +182,7 @@ final class core_renderer_test extends \advanced_testcase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers \core\hook\before_html_attributes
|
||||
* @covers \core\hook\output\before_html_attributes
|
||||
*/
|
||||
public function test_htmlattributes_hooked(): void {
|
||||
require_once(__DIR__ . '/fixtures/core_renderer/htmlattributes_callbacks.php');
|
||||
|
|
|
@ -35,9 +35,6 @@ class cron_test extends \advanced_testcase {
|
|||
|
||||
/**
|
||||
* Test the setup_user function.
|
||||
*
|
||||
* @covers ::setup_user
|
||||
* @covers ::reset_user_cache
|
||||
*/
|
||||
public function test_setup_user(): void {
|
||||
// This function uses the $GLOBALS super global. Disable the VariableNameLowerCase sniff for this function.
|
||||
|
|
|
@ -29,7 +29,7 @@ use \core\oauth2\user_field_mapping;
|
|||
* @package core
|
||||
* @copyright 2017 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
|
||||
* @coversDefaultClass \core\oauth2\api
|
||||
* @covers \core\oauth2\api
|
||||
*/
|
||||
class oauth2_test extends \advanced_testcase {
|
||||
|
||||
|
@ -256,8 +256,6 @@ class oauth2_test extends \advanced_testcase {
|
|||
* Test endpoints creation for issuers.
|
||||
* @dataProvider create_endpoints_for_standard_issuer_provider
|
||||
*
|
||||
* @covers ::create_endpoints_for_standard_issuer
|
||||
*
|
||||
* @param string $type Issuer type to create.
|
||||
* @param string|null $discoveryurl Expected discovery URL or null if this endpoint doesn't exist.
|
||||
* @param bool $hasmappingfields True if it's expected the issuer to create has mapping fields.
|
||||
|
@ -495,7 +493,7 @@ class oauth2_test extends \advanced_testcase {
|
|||
* Test getting the list of internal fields.
|
||||
*
|
||||
* @dataProvider create_custom_profile_fields
|
||||
* @covers ::get_internalfield_list
|
||||
* @covers \core\oauth2\user_field_mapping::get_internalfield_list
|
||||
* @param array $given Categories and profile fields.
|
||||
* @param array $expected Expected value.
|
||||
*/
|
||||
|
@ -522,7 +520,7 @@ class oauth2_test extends \advanced_testcase {
|
|||
* Test getting the list of internal fields with flat array.
|
||||
*
|
||||
* @dataProvider create_custom_profile_fields
|
||||
* @covers ::get_internalfields
|
||||
* @covers \core\oauth2\user_field_mapping::get_internalfields
|
||||
* @param array $given Categories and profile fields.
|
||||
* @param array $expected Expected value.
|
||||
*/
|
||||
|
@ -542,7 +540,7 @@ class oauth2_test extends \advanced_testcase {
|
|||
/**
|
||||
* Test getting the list of empty external/custom profile fields.
|
||||
*
|
||||
* @covers ::get_internalfields
|
||||
* @covers \core\oauth2\user_field_mapping::get_internalfields
|
||||
*/
|
||||
public function test_get_empty_internalfield_list(): void {
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ class choicelist_test extends advanced_testcase {
|
|||
/**
|
||||
* Test for a choice without options.
|
||||
*
|
||||
* @covers ::_construct
|
||||
* @covers ::__construct
|
||||
* @covers ::add_option
|
||||
* @covers ::export_for_template
|
||||
*/
|
||||
|
@ -57,7 +57,7 @@ class choicelist_test extends advanced_testcase {
|
|||
/**
|
||||
* Test for a choice with basic options.
|
||||
*
|
||||
* @covers ::_construct
|
||||
* @covers ::__construct
|
||||
* @covers ::add_option
|
||||
* @covers ::export_for_template
|
||||
*/
|
||||
|
@ -82,7 +82,7 @@ class choicelist_test extends advanced_testcase {
|
|||
/**
|
||||
* Test for a choice with extras options definition.
|
||||
*
|
||||
* @covers ::_construct
|
||||
* @covers ::__construct
|
||||
* @covers ::add_option
|
||||
* @covers ::set_option_extras
|
||||
* @covers ::export_for_template
|
||||
|
@ -126,7 +126,7 @@ class choicelist_test extends advanced_testcase {
|
|||
/**
|
||||
* Test for a choice with option selected.
|
||||
*
|
||||
* @covers ::_construct
|
||||
* @covers ::__construct
|
||||
* @covers ::add_option
|
||||
* @covers ::set_selected_value
|
||||
* @covers ::get_selected_value
|
||||
|
@ -196,7 +196,7 @@ class choicelist_test extends advanced_testcase {
|
|||
/**
|
||||
* Test for a choice with option selected.
|
||||
*
|
||||
* @covers ::_construct
|
||||
* @covers ::__construct
|
||||
* @covers ::add_option
|
||||
* @covers ::set_selected_value
|
||||
* @covers ::get_selected_value
|
||||
|
|
|
@ -24,6 +24,7 @@ use TCPDF_STATIC;
|
|||
* @package core
|
||||
* @copyright 2021 Brendan Heywood (brendan@catalyst-au.net)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @covers \pdf
|
||||
*/
|
||||
class pdflib_test extends \advanced_testcase {
|
||||
|
||||
|
@ -70,7 +71,7 @@ class pdflib_test extends \advanced_testcase {
|
|||
/**
|
||||
* Test get_export_fontlist function.
|
||||
*
|
||||
* @covers ::get_export_fontlist
|
||||
* @covers \pdf::get_export_fontlist
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
|
|
@ -27,6 +27,7 @@ use testable_plugininfo_base;
|
|||
* @package core
|
||||
* @copyright 2019 Andrew Nicols
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @covers \core\plugininfo\base
|
||||
*/
|
||||
class base_test extends \advanced_testcase {
|
||||
|
||||
|
@ -277,7 +278,6 @@ class base_test extends \advanced_testcase {
|
|||
|
||||
/**
|
||||
* Ensure that plugintype_supports_ordering() returns true.
|
||||
* @covers ::plugintype_supports_ordering
|
||||
*/
|
||||
public function test_plugintype_supports_ordering(): void {
|
||||
$this->assertFalse(base::plugintype_supports_ordering());
|
||||
|
|
|
@ -32,8 +32,6 @@ class block_test extends advanced_testcase {
|
|||
|
||||
/**
|
||||
* Test the get_enabled_plugins method.
|
||||
*
|
||||
* @covers ::get_enabled_plugins
|
||||
*/
|
||||
public function test_get_enabled_plugins(): void {
|
||||
$this->resetAfterTest();
|
||||
|
|
|
@ -32,8 +32,6 @@ class media_test extends advanced_testcase {
|
|||
|
||||
/**
|
||||
* Test the get_enabled_plugins method.
|
||||
*
|
||||
* @covers ::get_enabled_plugins
|
||||
*/
|
||||
public function test_get_enabled_plugins(): void {
|
||||
$this->resetAfterTest();
|
||||
|
|
|
@ -29,6 +29,7 @@ use core\moodlenet\share_recorder;
|
|||
* @category test
|
||||
* @copyright 2023 David Woloszyn <david.woloszyn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @coversDefaultClass \core\privacy\provider
|
||||
*/
|
||||
class provider_test extends provider_testcase {
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ require_once($CFG->libdir . '/tests/fixtures/testable_flexible_table.php');
|
|||
* @category test
|
||||
* @copyright 2013 Damyon Wiese <damyon@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @covers \flexible_table
|
||||
*/
|
||||
class tablelib_test extends \advanced_testcase {
|
||||
protected function generate_columns($cols) {
|
||||
|
@ -796,9 +797,6 @@ class tablelib_test extends \advanced_testcase {
|
|||
|
||||
/**
|
||||
* Data test for set and render caption for table.
|
||||
*
|
||||
* @covers ::set_caption_for_table
|
||||
* @covers ::render_caption_for_table
|
||||
*/
|
||||
public function test_set_and_render_caption_for_table(): void {
|
||||
$data = $this->generate_data(10, 2);
|
||||
|
|
|
@ -921,8 +921,7 @@ final class adhoc_task_test extends \advanced_testcase {
|
|||
/**
|
||||
* Test send messages when adhoc task reaches the max fail delay time.
|
||||
*
|
||||
* @covers ::adhoc_task_failed
|
||||
* @covers ::send_failed_task_max_delay_message
|
||||
* @covers \core\task\failed_task_callbacks::send_failed_task_max_delay_message
|
||||
*/
|
||||
public function test_adhoc_message_max_fail_delay(): void {
|
||||
$this->resetAfterTest();
|
||||
|
|
|
@ -35,7 +35,7 @@ class automated_backup_task_test extends \advanced_testcase {
|
|||
/**
|
||||
* Test the automated backup and report tasks.
|
||||
*
|
||||
* @covers \automated_backup_report_task::execute
|
||||
* @covers \core\task\automated_backup_report_task::execute
|
||||
* @covers \backup_cron_automated_helper::send_backup_status_to_admin
|
||||
* @covers \backup_cron_automated_helper::run_automated_backup
|
||||
* @covers \backup_cron_automated_helper::check_and_push_automated_backups
|
||||
|
|
|
@ -140,7 +140,6 @@ class file_temp_cleanup_task_test extends \basic_testcase {
|
|||
* @dataProvider cron_delete_from_temp_provider
|
||||
* @param array $nodes List of files and directories
|
||||
* @param array $expected The expected results
|
||||
* @covers ::execute
|
||||
*/
|
||||
public function test_cron_delete_from_temp($nodes, $expected): void {
|
||||
global $CFG;
|
||||
|
|
|
@ -26,7 +26,7 @@ require_once(__DIR__ . '/../fixtures/task_fixtures.php');
|
|||
* @category test
|
||||
* @copyright 2013 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @coversDefaultClass \core\task\scheduled_task
|
||||
* @covers \core\task\scheduled_task
|
||||
*/
|
||||
class scheduled_task_test extends \advanced_testcase {
|
||||
|
||||
|
@ -65,8 +65,6 @@ class scheduled_task_test extends \advanced_testcase {
|
|||
* @param int[] $expected
|
||||
*
|
||||
* @dataProvider eval_cron_provider
|
||||
*
|
||||
* @covers ::eval_cron_field
|
||||
*/
|
||||
public function test_eval_cron_field(string $field, int $min, int $max, array $expected): void {
|
||||
$testclass = new scheduled_test_task();
|
||||
|
@ -242,7 +240,6 @@ class scheduled_task_test extends \advanced_testcase {
|
|||
* @param string $month Month restriction list for task
|
||||
* @param string|int $expected Expected run time (strtotime format or time int)
|
||||
* @dataProvider get_next_scheduled_time_detail_provider
|
||||
* @covers ::get_next_scheduled_time
|
||||
*/
|
||||
public function test_get_next_scheduled_time_detail(string $now, string $minute, string $hour,
|
||||
string $day, string $dayofweek, string $month, string|int $expected): void {
|
||||
|
@ -271,8 +268,6 @@ class scheduled_task_test extends \advanced_testcase {
|
|||
*
|
||||
* We want frequent tasks to keep progressing as normal and not randomly stop for an hour, or
|
||||
* suddenly decide they need to happen in the past.
|
||||
*
|
||||
* @covers ::get_next_scheduled_time
|
||||
*/
|
||||
public function test_get_next_scheduled_time_dst_continuity(): void {
|
||||
$this->resetAfterTest();
|
||||
|
@ -987,10 +982,6 @@ class scheduled_task_test extends \advanced_testcase {
|
|||
|
||||
/**
|
||||
* Test disabling and enabling individual tasks.
|
||||
*
|
||||
* @covers ::disable
|
||||
* @covers ::enable
|
||||
* @covers ::has_default_configuration
|
||||
*/
|
||||
public function test_disable_and_enable_task(): void {
|
||||
$this->resetAfterTest();
|
||||
|
@ -1038,9 +1029,6 @@ class scheduled_task_test extends \advanced_testcase {
|
|||
|
||||
/**
|
||||
* Test send messages when a task reaches the max fail delay time.
|
||||
*
|
||||
* @covers ::scheduled_task_failed
|
||||
* @covers ::send_failed_task_max_delay_message
|
||||
*/
|
||||
public function test_message_max_fail_delay(): void {
|
||||
$this->resetAfterTest();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue