From bc013420578a7317eeaba2b0ac331dfa651e9b42 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Thu, 21 Mar 2019 10:08:01 +0800 Subject: [PATCH] MDL-65130 privacy: Add @covers annotation to tests --- privacy/tests/approved_contextlist_test.php | 6 ++ privacy/tests/approved_userlist_test.php | 10 +++ privacy/tests/collection_test.php | 28 ++++++++- privacy/tests/contextlist_base_test.php | 27 ++++++++ privacy/tests/contextlist_collection_test.php | 29 +++++++++ privacy/tests/contextlist_test.php | 15 +++++ privacy/tests/legacy_polyfill_test.php | 15 +++++ privacy/tests/manager_test.php | 47 ++++++++++++++ privacy/tests/moodle_content_writer_test.php | 63 +++++++++++++++++++ privacy/tests/request_helper_test.php | 13 ++++ privacy/tests/request_transform_test.php | 8 +++ privacy/tests/types_database_table_test.php | 4 ++ .../tests/types_external_location_test.php | 4 ++ privacy/tests/types_plugintype_link_test.php | 4 ++ privacy/tests/types_subsystem_link_test.php | 4 ++ privacy/tests/types_user_preference_test.php | 4 ++ privacy/tests/userlist_base_test.php | 21 +++++++ privacy/tests/userlist_collection.php | 21 +++++++ privacy/tests/userlist_test.php | 7 +++ privacy/tests/writer_test.php | 13 ++++ 20 files changed, 342 insertions(+), 1 deletion(-) diff --git a/privacy/tests/approved_contextlist_test.php b/privacy/tests/approved_contextlist_test.php index 6f4d7d51b63..45f6ad5c789 100644 --- a/privacy/tests/approved_contextlist_test.php +++ b/privacy/tests/approved_contextlist_test.php @@ -34,10 +34,16 @@ use \core_privacy\local\request\approved_contextlist; * * @copyright 2018 Andrew Nicols * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @coversDefaultClass \core_privacy\local\request\approved_contextlist */ class approved_contextlist_test extends advanced_testcase { + /** * The approved contextlist should not be modifiable once set. + * + * @covers ::__construct + * @covers :: + * @covers \core_privacy\local\request\approved_contextlist */ public function test_default_values_set() { $testuser = \core_user::get_user_by_username('admin'); diff --git a/privacy/tests/approved_userlist_test.php b/privacy/tests/approved_userlist_test.php index edb79fd1864..3be87c74e27 100644 --- a/privacy/tests/approved_userlist_test.php +++ b/privacy/tests/approved_userlist_test.php @@ -35,10 +35,15 @@ use \core_privacy\local\request\userlist; * * @copyright 2018 Andrew Nicols * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @coversDefaultClass \core_privacy\local\request\approved_userlist */ class approved_userlist_test extends advanced_testcase { /** * The approved userlist should not be modifiable once set. + * + * @covers ::__construct + * @covers \core_privacy\local\request\approved_userlist + * @covers :: */ public function test_default_values_set() { $this->resetAfterTest(); @@ -68,6 +73,11 @@ class approved_userlist_test extends advanced_testcase { $this->assertEquals($expected, $result); } + /** + * @covers ::create_from_userlist + * @covers \core_privacy\local\request\approved_userlist + * @covers :: + */ public function test_create_from_userlist() { $this->resetAfterTest(); diff --git a/privacy/tests/collection_test.php b/privacy/tests/collection_test.php index 3835175c0aa..b7403f7e1ce 100644 --- a/privacy/tests/collection_test.php +++ b/privacy/tests/collection_test.php @@ -35,12 +35,15 @@ use \core_privacy\local\metadata\types; * * @copyright 2018 Andrew Nicols * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @coversDefaultClass \core_privacy\local\metadata\collection */ class core_privacy_metadata_collection extends advanced_testcase { - /** * Test that adding an unknown type causes the type to be added to the collection. + * + * @covers ::add_type + * @covers :: */ public function test_add_type_generic_type() { $collection = new collection('core_privacy'); @@ -56,6 +59,9 @@ class core_privacy_metadata_collection extends advanced_testcase { /** * Test that adding a known type works as anticipated. + * + * @covers ::add_type + * @covers :: */ public function test_add_type_known_type() { $collection = new collection('core_privacy'); @@ -70,6 +76,9 @@ class core_privacy_metadata_collection extends advanced_testcase { /** * Test that adding multiple types returns them all. + * + * @covers ::add_type + * @covers :: */ public function test_add_type_multiple() { $collection = new collection('core_privacy'); @@ -86,6 +95,9 @@ class core_privacy_metadata_collection extends advanced_testcase { /** * Test that the add_database_table function adds a database table. + * + * @covers ::add_database_table + * @covers :: */ public function test_add_database_table() { $collection = new collection('core_privacy'); @@ -107,6 +119,9 @@ class core_privacy_metadata_collection extends advanced_testcase { /** * Test that the add_user_preference function adds a single user preference. + * + * @covers ::add_user_preference + * @covers :: */ public function test_add_user_preference() { $collection = new collection('core_privacy'); @@ -126,6 +141,9 @@ class core_privacy_metadata_collection extends advanced_testcase { /** * Test that the link_external_location function links an external location. + * + * @covers ::link_external_location + * @covers :: */ public function test_link_external_location() { $collection = new collection('core_privacy'); @@ -147,6 +165,9 @@ class core_privacy_metadata_collection extends advanced_testcase { /** * Test that the link_subsystem function links the subsystem. + * + * @covers ::link_subsystem + * @covers :: */ public function test_link_subsystem() { $collection = new collection('core_privacy'); @@ -166,6 +187,9 @@ class core_privacy_metadata_collection extends advanced_testcase { /** * Test that the link_plugintype function links the plugin. + * + * @covers ::link_plugintype + * @covers :: */ public function test_link_plugintype() { $collection = new collection('core_privacy'); @@ -202,6 +226,8 @@ class core_privacy_metadata_collection extends advanced_testcase { * * @dataProvider component_list_provider * @param string $component The component to test + * @covers ::get_component + * @covers :: */ public function test_get_component($component) { $collection = new collection($component); diff --git a/privacy/tests/contextlist_base_test.php b/privacy/tests/contextlist_base_test.php index 0dc4f793834..742ec33b818 100644 --- a/privacy/tests/contextlist_base_test.php +++ b/privacy/tests/contextlist_base_test.php @@ -34,6 +34,7 @@ use \core_privacy\local\request\contextlist_base; * * @copyright 2018 Andrew Nicols * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @coversDefaultClass \core_privacy\local\request\contextlist_base */ class contextlist_base_test extends advanced_testcase { /** @@ -43,6 +44,8 @@ class contextlist_base_test extends advanced_testcase { * @param array $input List of context IDs * @param array $expected list of contextids * @param int $count Expected count + * @covers ::get_contextids + * @covers :: */ public function test_get_contextids($input, $expected, $count) { $uit = new test_contextlist_base(); @@ -84,6 +87,9 @@ class contextlist_base_test extends advanced_testcase { /** * Ensure that get_contexts returns the correct list of contexts. + * + * @covers ::get_contexts + * @covers :: */ public function test_get_contexts() { global $DB; @@ -114,6 +120,8 @@ class contextlist_base_test extends advanced_testcase { * @param array $input List of context IDs * @param array $expected list of contextids * @param int $count Expected count + * @covers ::count + * @covers :: */ public function test_countable($input, $expected, $count) { $uit = new test_contextlist_base(); @@ -124,6 +132,13 @@ class contextlist_base_test extends advanced_testcase { /** * Ensure that the contextlist_base iterates over the set of contexts. + * + * @covers ::current + * @covers ::key + * @covers ::next + * @covers ::rewind + * @covers ::valid + * @covers :: */ public function test_context_iteration() { global $DB; @@ -144,6 +159,9 @@ class contextlist_base_test extends advanced_testcase { /** * Test that deleting a context results in current returning nothing. + * + * @covers ::current + * @covers :: */ public function test_current_context_one_context() { global $DB; @@ -171,6 +189,9 @@ class contextlist_base_test extends advanced_testcase { /** * Test that deleting a context results in the next record being returned. + * + * @covers ::current + * @covers :: */ public function test_current_context_two_contexts() { global $DB; @@ -206,6 +227,9 @@ class contextlist_base_test extends advanced_testcase { /** * Test that if there are no non-deleted contexts that nothing is returned. + * + * @covers ::get_contexts + * @covers :: */ public function test_get_contexts_all_deleted() { global $DB; @@ -231,6 +255,9 @@ class contextlist_base_test extends advanced_testcase { /** * Test that get_contexts() returns only active contexts. + * + * @covers ::get_contexts + * @covers :: */ public function test_get_contexts_one_deleted() { global $DB; diff --git a/privacy/tests/contextlist_collection_test.php b/privacy/tests/contextlist_collection_test.php index d3736dee690..2eaf5daa5d5 100644 --- a/privacy/tests/contextlist_collection_test.php +++ b/privacy/tests/contextlist_collection_test.php @@ -36,10 +36,14 @@ use \core_privacy\local\request\approved_contextlist; * * @copyright 2018 Andrew Nicols * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @coversDefaultClass \core_privacy\local\request\contextlist_collection */ class contextlist_collection_test extends advanced_testcase { /** * A contextlist_collection should support the contextlist type. + * + * @covers ::add_contextlist + * @covers :: */ public function test_supports_contextlist() { $uit = new contextlist_collection(1); @@ -52,6 +56,9 @@ class contextlist_collection_test extends advanced_testcase { /** * A contextlist_collection should support the approved_contextlist type. + * + * @covers ::add_contextlist + * @covers :: */ public function test_supports_approved_contextlist() { $uit = new contextlist_collection(1); @@ -64,6 +71,9 @@ class contextlist_collection_test extends advanced_testcase { /** * Ensure that get_contextlist_for_component returns the correct contextlist. + * + * @covers ::get_contextlist_for_component + * @covers :: */ public function test_get_contextlist_for_component() { $uit = new contextlist_collection(1); @@ -83,6 +93,9 @@ class contextlist_collection_test extends advanced_testcase { /** * Ensure that get_contextlist_for_component does not die horribly when querying a non-existent component. + * + * @covers ::get_contextlist_for_component + * @covers :: */ public function test_get_contextlist_for_component_not_found() { $uit = new contextlist_collection(1); @@ -92,6 +105,9 @@ class contextlist_collection_test extends advanced_testcase { /** * Ensure that a duplicate contextlist in the collection throws an Exception. + * + * @covers ::add_contextlist + * @covers :: */ public function test_duplicate_addition_throws() { $uit = new contextlist_collection(1); @@ -106,6 +122,9 @@ class contextlist_collection_test extends advanced_testcase { /** * Ensure that the contextlist_collection is countable. + * + * @covers ::count + * @covers :: */ public function test_countable() { $uit = new contextlist_collection(1); @@ -123,6 +142,13 @@ class contextlist_collection_test extends advanced_testcase { /** * Ensure that the contextlist_collection iterates over the set of contextlists. + * + * @covers ::current + * @covers ::key + * @covers ::next + * @covers ::rewind + * @covers ::valid + * @covers :: */ public function test_iteration() { $uit = new contextlist_collection(1); @@ -156,6 +182,9 @@ class contextlist_collection_test extends advanced_testcase { /** * Test that the userid is correctly returned. + * + * @covers ::get_userid + * @covers :: */ public function test_get_userid() { $uit = new contextlist_collection(1); diff --git a/privacy/tests/contextlist_test.php b/privacy/tests/contextlist_test.php index 43d8b74ea9d..26bc701e950 100644 --- a/privacy/tests/contextlist_test.php +++ b/privacy/tests/contextlist_test.php @@ -34,11 +34,15 @@ use \core_privacy\local\request\contextlist; * * @copyright 2018 Andrew Nicols * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @coversDefaultClass \core_privacy\local\request\contextlist */ class contextlist_test extends advanced_testcase { /** * Ensure that valid SQL results in the relevant contexts being added. + * + * @covers ::add_from_sql + * @covers :: */ public function test_add_from_sql() { global $DB; @@ -55,6 +59,9 @@ class contextlist_test extends advanced_testcase { /** * Ensure that valid system context id is added. + * + * @covers ::add_system_context + * @covers :: */ public function test_add_system_context() { $cl = new contextlist(); @@ -69,6 +76,9 @@ class contextlist_test extends advanced_testcase { /** * Ensure that a valid user context id is added. + * + * @covers ::add_user_context + * @covers :: */ public function test_add_user_context() { $this->resetAfterTest(); @@ -88,6 +98,9 @@ class contextlist_test extends advanced_testcase { /** * Ensure that valid user contexts are added. + * + * @covers ::add_user_contexts + * @covers :: */ public function test_add_user_contexts() { $this->resetAfterTest(); @@ -112,6 +125,8 @@ class contextlist_test extends advanced_testcase { * @dataProvider data_guess_id_field_from_sql * @param string $sql Input SQL we try to extract the context id field name from. * @param string $expected Expected detected value. + * @covers ::guess_id_field_from_sql + * @covers :: */ public function test_guess_id_field_from_sql($sql, $expected) { diff --git a/privacy/tests/legacy_polyfill_test.php b/privacy/tests/legacy_polyfill_test.php index 17d0f6feae0..05f83fdb955 100644 --- a/privacy/tests/legacy_polyfill_test.php +++ b/privacy/tests/legacy_polyfill_test.php @@ -37,11 +37,14 @@ use \core_privacy\local\request\approved_contextlist; * * @copyright 2018 Andrew Nicols * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @coversDefaultClass \core_privacy\local\legacy_polyfill */ class core_privacy_legacy_polyfill_test extends advanced_testcase { /** * Test that the null_provider polyfill works and that the static _get_reason can be * successfully called. + * + * @covers ::get_reason */ public function test_null_provider() { $this->assertEquals('thisisareason', test_legacy_polyfill_null_provider::get_reason()); @@ -50,6 +53,8 @@ class core_privacy_legacy_polyfill_test extends advanced_testcase { /** * Test that the metdata\provider polyfill works and that the static _get_metadata can be * successfully called. + * + * @covers ::get_metadata */ public function test_metadata_provider() { $collection = new collection('core_privacy'); @@ -59,6 +64,8 @@ class core_privacy_legacy_polyfill_test extends advanced_testcase { /** * Test that the local\request\user_preference_provider polyfill works and that the static * _export_user_preferences can be successfully called. + * + * @covers ::export_user_preferences */ public function test_user_preference_provider() { $userid = 417; @@ -75,6 +82,8 @@ class core_privacy_legacy_polyfill_test extends advanced_testcase { /** * Test that the local\request\core_user_preference_provider polyfill works and that the static * _get_contexts_for_userid can be successfully called. + * + * @covers ::get_contexts_for_userid */ public function test_get_contexts_for_userid() { $userid = 417; @@ -94,6 +103,8 @@ class core_privacy_legacy_polyfill_test extends advanced_testcase { /** * Test that the local\request\core_user_preference_provider polyfill works and that the static * _export_user_data can be successfully called. + * + * @covers ::export_user_data */ public function test_export_user_data() { $contextlist = new approved_contextlist(\core_user::get_user_by_username('admin'), 'core_privacy', [98]); @@ -110,6 +121,8 @@ class core_privacy_legacy_polyfill_test extends advanced_testcase { /** * Test that the local\request\core_user_preference_provider polyfill works and that the static * _delete_data_for_all_users_in_context can be successfully called. + * + * @covers ::delete_data_for_all_users_in_context */ public function test_delete_data_for_all_users_in_context() { $mock = $this->createMock(test_legacy_polyfill_mock_wrapper::class); @@ -124,6 +137,8 @@ class core_privacy_legacy_polyfill_test extends advanced_testcase { /** * Test that the local\request\core_user_preference_provider polyfill works and that the static * _delete_data_for_user can be successfully called. + * + * @covers ::delete_data_for_user */ public function test_delete_data_for_user() { $contextlist = new approved_contextlist(\core_user::get_user_by_username('admin'), 'core_privacy', [98]); diff --git a/privacy/tests/manager_test.php b/privacy/tests/manager_test.php index 3f1f9acd55b..633ecfe083d 100644 --- a/privacy/tests/manager_test.php +++ b/privacy/tests/manager_test.php @@ -39,6 +39,7 @@ use \core_privacy\local\request\approved_contextlist; * * @copyright 2018 Jake Dallimore * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @coversDefaultClass \core_privacy\manager */ class privacy_manager_testcase extends advanced_testcase { /** @@ -66,6 +67,9 @@ class privacy_manager_testcase extends advanced_testcase { /** * Test collection of metadata for components implementing a metadata provider. + * + * @covers ::get_metadata_for_components + * @covers :: */ public function test_get_metadata_for_components() { // Get a mock manager, in which the core components list is mocked to include all mock plugins. @@ -87,6 +91,9 @@ class privacy_manager_testcase extends advanced_testcase { /** * Test that get_contexts_for_userid() only returns contextlist collections for core providers. + * + * @covers ::get_contexts_for_userid + * @covers :: */ public function test_get_contexts_for_userid() { // Get a mock manager, in which the core components list is mocked to include all mock plugins. @@ -112,6 +119,9 @@ class privacy_manager_testcase extends advanced_testcase { /** * Test verifying the output of component_is_compliant. + * + * @covers ::component_is_compliant + * @covers :: */ public function test_component_is_compliant() { // Get a mock manager, in which the core components list is mocked to include all mock plugins. @@ -157,6 +167,8 @@ class privacy_manager_testcase extends advanced_testcase { * @dataProvider component_is_compliant_provider * @param string $component * @param boolean $expected + * @covers ::component_is_compliant + * @covers :: */ public function test_component_is_compliant_examples($component, $expected) { $manager = new \core_privacy\manager(); @@ -166,6 +178,9 @@ class privacy_manager_testcase extends advanced_testcase { /** * Test verifying only approved contextlists can be used with the export_user_data method. + * + * @covers ::export_user_data + * @covers :: */ public function test_export_user_data() { // Get a mock manager, in which the core components list is mocked to include all mock plugins. @@ -199,6 +214,9 @@ class privacy_manager_testcase extends advanced_testcase { /** * Test verifying only approved contextlists can be used with the delete_data_for_user method. + * + * @covers ::delete_data_for_user + * @covers :: */ public function test_delete_data_for_user() { $this->resetAfterTest(); @@ -230,6 +248,9 @@ class privacy_manager_testcase extends advanced_testcase { * Ensure that all installed plugins can provide metadata. * * This really just checks that all providers can be safely autoloaded. + * + * @covers ::get_metadata_for_components + * @covers :: */ public function test_installed_plugins() { $manager = new \core_privacy\manager(); @@ -239,6 +260,9 @@ class privacy_manager_testcase extends advanced_testcase { /** * Test that the reason for the null provider is returned. + * + * @covers ::get_null_provider_reason + * @covers :: */ public function test_get_null_provider_reason() { $manager = new \core_privacy\manager(); @@ -251,6 +275,9 @@ class privacy_manager_testcase extends advanced_testcase { /** * Test that manager::plugintype_class_callback() can be executed. + * + * @covers ::plugintype_class_callback + * @covers :: */ public function test_plugintype_class_callback() { \core_privacy\manager::plugintype_class_callback('doesnotexist', 'unusable', 'foo', ['bar']); @@ -258,6 +285,9 @@ class privacy_manager_testcase extends advanced_testcase { /** * Test that manager::component_class_callback() can be executed. + * + * @covers ::component_class_callback + * @covers :: */ public function test_component_class_callback() { \core_privacy\manager::component_class_callback('foo_bar', 'unusable', 'foo', ['bar']); @@ -269,6 +299,8 @@ class privacy_manager_testcase extends advanced_testcase { * @dataProvider is_empty_subsystem_provider * @param string $component * @param bool $expected + * @covers ::is_empty_subsystem + * @covers :: */ public function test_is_empty_subsystem($component, $expected) { $this->assertEquals($expected, \core_privacy\manager::is_empty_subsystem($component)); @@ -306,6 +338,9 @@ class privacy_manager_testcase extends advanced_testcase { /** * Test that get_contexts_for_userid() with a failing item. + * + * @covers ::get_contexts_for_userid + * @covers :: */ public function test_get_contexts_for_userid_with_failing() { // Get a mock manager, in which the core components list is mocked to include all mock plugins. @@ -341,6 +376,9 @@ class privacy_manager_testcase extends advanced_testcase { /** * Test that export_user_data() with a failing item. + * + * @covers ::export_user_data + * @covers :: */ public function test_export_user_data_with_failing() { $user = \core_user::get_user_by_username('admin'); @@ -374,6 +412,9 @@ class privacy_manager_testcase extends advanced_testcase { /** * Test that delete_data_for_user() with a failing item. + * + * @covers ::delete_data_for_user + * @covers :: */ public function test_delete_data_for_user_with_failing() { $user = \core_user::get_user_by_username('admin'); @@ -407,6 +448,9 @@ class privacy_manager_testcase extends advanced_testcase { /** * Test that delete_data_for_all_users_in_context() with a failing item. + * + * @covers ::delete_data_for_all_users_in_context + * @covers :: */ public function test_delete_data_for_all_users_in_context_with_failing() { $user = \core_user::get_user_by_username('admin'); @@ -435,6 +479,9 @@ class privacy_manager_testcase extends advanced_testcase { /** * Test that get_metadata_for_components() with a failing item. + * + * @covers ::get_metadata_for_components + * @covers :: */ public function test_get_metadata_for_components_with_failing() { $user = \core_user::get_user_by_username('admin'); diff --git a/privacy/tests/moodle_content_writer_test.php b/privacy/tests/moodle_content_writer_test.php index 4de799c842f..84824c5e27c 100644 --- a/privacy/tests/moodle_content_writer_test.php +++ b/privacy/tests/moodle_content_writer_test.php @@ -35,6 +35,7 @@ use \core_privacy\local\request\moodle_content_writer; * * @copyright 2018 Andrew Nicols * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @coversDefaultClass \core_privacy\local\request\moodle_content_writer */ class moodle_content_writer_test extends advanced_testcase { @@ -43,6 +44,8 @@ class moodle_content_writer_test extends advanced_testcase { * * @dataProvider export_data_provider * @param \stdClass $data Data + * @covers ::export_data + * @covers :: */ public function test_export_data($data) { $context = \context_system::instance(); @@ -67,6 +70,8 @@ class moodle_content_writer_test extends advanced_testcase { * * @dataProvider export_data_provider * @param \stdClass $data Data + * @covers ::export_data + * @covers :: */ public function test_export_data_different_context($data) { $context = \context_user::instance(\core_user::get_user_by_username('admin')->id); @@ -88,6 +93,9 @@ class moodle_content_writer_test extends advanced_testcase { /** * Test that exported is saved within the correct directory locations. + * + * @covers ::export_data + * @covers :: */ public function test_export_data_writes_to_multiple_context() { $subcontext = ['sub', 'context']; @@ -130,6 +138,9 @@ class moodle_content_writer_test extends advanced_testcase { /** * Test that multiple writes to the same location cause the latest version to be written. + * + * @covers ::export_data + * @covers :: */ public function test_export_data_multiple_writes_same_context() { $subcontext = ['sub', 'context']; @@ -185,6 +196,8 @@ class moodle_content_writer_test extends advanced_testcase { * @param string $key Key * @param string $value Value * @param string $description Description + * @covers ::export_metadata + * @covers :: */ public function test_export_metadata($key, $value, $description) { $context = \context_system::instance(); @@ -208,6 +221,9 @@ class moodle_content_writer_test extends advanced_testcase { /** * Test that metadata can be set additively. + * + * @covers ::export_metadata + * @covers :: */ public function test_export_metadata_additive() { $context = \context_system::instance(); @@ -242,6 +258,9 @@ class moodle_content_writer_test extends advanced_testcase { /** * Test that metadata can be set additively. + * + * @covers ::export_metadata + * @covers :: */ public function test_export_metadata_to_multiple_contexts() { $systemcontext = \context_system::instance(); @@ -318,6 +337,9 @@ class moodle_content_writer_test extends advanced_testcase { /** * Exporting a single stored_file should cause that file to be output in the files directory. + * + * @covers ::export_area_files + * @covers :: */ public function test_export_area_files() { $this->resetAfterTest(); @@ -422,6 +444,9 @@ class moodle_content_writer_test extends advanced_testcase { * @param string $filepath File path * @param string $filename File name * @param string $content Content + * + * @covers ::export_file + * @covers :: */ public function test_export_file($filearea, $itemid, $filepath, $filename, $content) { $this->resetAfterTest(); @@ -518,6 +543,8 @@ class moodle_content_writer_test extends advanced_testcase { * @param string $key Key * @param string $value Value * @param string $desc Description + * @covers ::export_user_preference + * @covers :: */ public function test_export_user_preference_context_user($component, $key, $value, $desc) { $admin = \core_user::get_user_by_username('admin'); @@ -550,6 +577,8 @@ class moodle_content_writer_test extends advanced_testcase { * @param string $key Key * @param string $value Value * @param string $desc Description + * @covers ::export_user_preference + * @covers :: */ public function test_export_user_preference_context_coursecat($component, $key, $value, $desc) { global $DB; @@ -583,6 +612,8 @@ class moodle_content_writer_test extends advanced_testcase { * @param string $key Key * @param string $value Value * @param string $desc Description + * @covers ::export_user_preference + * @covers :: */ public function test_export_user_preference_context_course($component, $key, $value, $desc) { global $DB; @@ -617,6 +648,8 @@ class moodle_content_writer_test extends advanced_testcase { * @param string $key Key * @param string $value Value * @param string $desc Description + * @covers ::export_user_preference + * @covers :: */ public function test_export_user_preference_context_module($component, $key, $value, $desc) { global $DB; @@ -652,6 +685,8 @@ class moodle_content_writer_test extends advanced_testcase { * @param string $key Key * @param string $value Value * @param string $desc Description + * @covers ::export_user_preference + * @covers :: */ public function test_export_user_preference_context_block($component, $key, $value, $desc) { global $DB; @@ -681,6 +716,9 @@ class moodle_content_writer_test extends advanced_testcase { * Writing user preferences for two different blocks with the same name and * same parent context should generate two different context paths and export * files. + * + * @covers ::export_user_preference + * @covers :: */ public function test_export_user_preference_context_block_multiple_instances() { $this->resetAfterTest(); @@ -741,6 +779,9 @@ class moodle_content_writer_test extends advanced_testcase { * @param string $key Key * @param string $value Value * @param string $desc Description + * + * @covers ::export_user_preference + * @covers :: */ public function test_export_user_preference_context_system($component, $key, $value, $desc) { $context = \context_system::instance(); @@ -763,6 +804,9 @@ class moodle_content_writer_test extends advanced_testcase { /** * User preferences can be exported against the system. + * + * @covers ::export_user_preference + * @covers :: */ public function test_export_multiple_user_preference_context_system() { $context = \context_system::instance(); @@ -795,6 +839,9 @@ class moodle_content_writer_test extends advanced_testcase { /** * User preferences can be exported against the system. + * + * @covers ::export_user_preference + * @covers :: */ public function test_export_user_preference_replace() { $context = \context_system::instance(); @@ -857,6 +904,8 @@ class moodle_content_writer_test extends advanced_testcase { * * @dataProvider unescaped_unicode_export_provider * @param string $text + * @covers ::export_data + * @covers :: */ public function test_export_data_unescaped_unicode($text) { $context = \context_system::instance(); @@ -883,6 +932,8 @@ class moodle_content_writer_test extends advanced_testcase { * * @dataProvider unescaped_unicode_export_provider * @param string $text + * @covers ::export_metadata + * @covers :: */ public function test_export_metadata_unescaped_unicode($text) { $context = \context_system::instance(); @@ -910,6 +961,8 @@ class moodle_content_writer_test extends advanced_testcase { * * @dataProvider unescaped_unicode_export_provider * @param string $text + * @covers ::export_related_data + * @covers :: */ public function test_export_related_data_unescaped_unicode($text) { $context = \context_system::instance(); @@ -936,6 +989,8 @@ class moodle_content_writer_test extends advanced_testcase { * * @dataProvider unescaped_unicode_export_provider * @param string $text + * @covers ::export_user_preference + * @covers :: */ public function test_export_user_preference_unescaped_unicode($text) { $context = \context_system::instance(); @@ -976,6 +1031,9 @@ class moodle_content_writer_test extends advanced_testcase { * @param string $longtext * @param string $expected * @param string $text + * + * @covers ::export_data + * @covers :: */ public function test_export_data_long_filename($longtext, $expected, $text) { $context = \context_system::instance(); @@ -1006,6 +1064,9 @@ class moodle_content_writer_test extends advanced_testcase { * @param string $longtext * @param string $expected * @param string $text + * + * @covers ::export_related_data + * @covers :: */ public function test_export_related_data_long_filename($longtext, $expected, $text) { $context = \context_system::instance(); @@ -1184,6 +1245,8 @@ class moodle_content_writer_test extends advanced_testcase { * @param int $itemid Which item those files belong to. * @param string $input Raw text as stored in the database. * @param string $expectedoutput Expected output of URL rewriting. + * @covers ::rewrite_pluginfile_urls + * @covers :: */ public function test_rewrite_pluginfile_urls($filearea, $itemid, $input, $expectedoutput) { diff --git a/privacy/tests/request_helper_test.php b/privacy/tests/request_helper_test.php index b5baf4116d2..62f100960d1 100644 --- a/privacy/tests/request_helper_test.php +++ b/privacy/tests/request_helper_test.php @@ -35,10 +35,13 @@ use \core_privacy\local\request\writer; * * @copyright 2018 Andrew Nicols * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @coversDefaultClass \core_privacy\local\request\helper */ class request_helper_test extends advanced_testcase { /** * Test that basic module data is returned. + * + * @covers ::get_context_data */ public function test_get_context_data_context_module() { $this->resetAfterTest(); @@ -76,6 +79,8 @@ class request_helper_test extends advanced_testcase { /** * Test that basic block data is returned. + * + * @covers ::get_context_data */ public function test_get_context_data_context_block() { $this->resetAfterTest(); @@ -95,6 +100,8 @@ class request_helper_test extends advanced_testcase { /** * Test that a course moudle with completion tracking enabled has the completion data returned. + * + * @covers ::get_context_data */ public function test_get_context_data_context_module_completion() { $this->resetAfterTest(); @@ -128,6 +135,8 @@ class request_helper_test extends advanced_testcase { /** * Test that when there are no files to export for a course module context, nothing is exported. + * + * @covers ::export_context_files */ public function test_export_context_files_context_module_no_files() { $this->resetAfterTest(); @@ -152,6 +161,8 @@ class request_helper_test extends advanced_testcase { /** * Test that when there are no files to export for a course context, nothing is exported. + * + * @covers ::export_context_files */ public function test_export_context_files_context_course_no_files() { $this->resetAfterTest(); @@ -170,6 +181,8 @@ class request_helper_test extends advanced_testcase { /** * Test that when there are files to export for a course context, the files are exported. + * + * @covers ::export_context_files */ public function test_export_context_files_context_course_intro_files() { $this->resetAfterTest(); diff --git a/privacy/tests/request_transform_test.php b/privacy/tests/request_transform_test.php index 3926f5f1aed..644b825af9b 100644 --- a/privacy/tests/request_transform_test.php +++ b/privacy/tests/request_transform_test.php @@ -34,6 +34,7 @@ use \core_privacy\local\request\transform; * * @copyright 2018 Andrew Nicols * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @coversDefaultClass \core_privacy\local\request\transform */ class request_transform_test extends advanced_testcase { /** @@ -41,6 +42,8 @@ class request_transform_test extends advanced_testcase { * * We have not determined if we will do this or not, but we provide the functionality and encourgae people to use * it so that it can be retrospectively fitted if required. + * + * @covers ::user */ public function test_user() { // Note: This test currently sucks, but there's no point creating users just to test this. @@ -51,6 +54,8 @@ class request_transform_test extends advanced_testcase { /** * Test that the datetime is translated into a string. + * + * @covers ::datetime */ public function test_datetime() { $time = 1; @@ -71,6 +76,8 @@ class request_transform_test extends advanced_testcase { /** * Test that the date is translated into a string. + * + * @covers ::date */ public function test_date() { $time = 1; @@ -92,6 +99,7 @@ class request_transform_test extends advanced_testcase { * @dataProvider yesno_provider * @param mixed $input The input to test * @param string $expected The expected value + * @covers ::yesno */ public function test_yesno($input, $expected) { $this->assertEquals($expected, transform::yesno($input)); diff --git a/privacy/tests/types_database_table_test.php b/privacy/tests/types_database_table_test.php index 79ee5e736f8..0c262889ba7 100644 --- a/privacy/tests/types_database_table_test.php +++ b/privacy/tests/types_database_table_test.php @@ -34,6 +34,7 @@ use \core_privacy\local\metadata\types\database_table; * * @copyright 2018 Andrew Nicols * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @coversDefaultClass \core_privacy\local\metadata\types\database_table */ class core_privacy_metadata_types_database_table extends advanced_testcase { @@ -44,6 +45,7 @@ class core_privacy_metadata_types_database_table extends advanced_testcase { * @param string $name Name * @param array $fields List of fields * @param string $summary Summary + * @covers ::__construct */ public function test_invalid_configs($name, $fields, $summary) { $record = new database_table($name, $fields, $summary); @@ -57,6 +59,7 @@ class core_privacy_metadata_types_database_table extends advanced_testcase { * @param string $name Name * @param array $fields List of fields * @param string $summary Summary + * @covers ::__construct */ public function test_invalid_configs_debug_normal($name, $fields, $summary) { global $CFG; @@ -74,6 +77,7 @@ class core_privacy_metadata_types_database_table extends advanced_testcase { * @param string $name Name * @param array $fields List of fields * @param string $summary Summary + * @covers ::__construct */ public function test_valid_configs($name, $fields, $summary) { $record = new database_table($name, $fields, $summary); diff --git a/privacy/tests/types_external_location_test.php b/privacy/tests/types_external_location_test.php index 698c4953ed7..051265625e7 100644 --- a/privacy/tests/types_external_location_test.php +++ b/privacy/tests/types_external_location_test.php @@ -34,6 +34,7 @@ use \core_privacy\local\metadata\types\external_location; * * @copyright 2018 Andrew Nicols * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @coversDefaultClass \core_privacy\local\metadata\types\external_location */ class core_privacy_metadata_types_external_location extends advanced_testcase { @@ -44,6 +45,7 @@ class core_privacy_metadata_types_external_location extends advanced_testcase { * @param string $name Name * @param array $fields List of fields * @param string $summary Summary + * @covers ::__construct */ public function test_invalid_configs($name, $fields, $summary) { $record = new external_location($name, $fields, $summary); @@ -57,6 +59,7 @@ class core_privacy_metadata_types_external_location extends advanced_testcase { * @param string $name Name * @param array $fields List of fields * @param string $summary Summary + * @covers ::__construct */ public function test_invalid_configs_debug_normal($name, $fields, $summary) { global $CFG; @@ -74,6 +77,7 @@ class core_privacy_metadata_types_external_location extends advanced_testcase { * @param string $name Name * @param array $fields List of fields * @param string $summary Summary + * @covers ::__construct */ public function test_valid_configs($name, $fields, $summary) { $record = new external_location($name, $fields, $summary); diff --git a/privacy/tests/types_plugintype_link_test.php b/privacy/tests/types_plugintype_link_test.php index 82e30524895..41243620a8d 100644 --- a/privacy/tests/types_plugintype_link_test.php +++ b/privacy/tests/types_plugintype_link_test.php @@ -34,6 +34,7 @@ use \core_privacy\local\metadata\types\plugintype_link; * * @copyright 2018 Andrew Nicols * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @coversDefaultClass \core_privacy\local\metadata\types\plugintype_link */ class core_privacy_metadata_types_plugintype_link extends advanced_testcase { @@ -43,6 +44,7 @@ class core_privacy_metadata_types_plugintype_link extends advanced_testcase { * @dataProvider invalid_string_provider * @param string $name Name * @param string $summary Summary + * @covers ::__construct */ public function test_invalid_configs($name, $privacyfields, $summary) { $record = new plugintype_link($name, $privacyfields, $summary); @@ -55,6 +57,7 @@ class core_privacy_metadata_types_plugintype_link extends advanced_testcase { * @dataProvider invalid_string_provider * @param string $name Name * @param string $summary Summary + * @covers ::__construct */ public function test_invalid_configs_debug_normal($name, $privacyfields, $summary) { global $CFG; @@ -71,6 +74,7 @@ class core_privacy_metadata_types_plugintype_link extends advanced_testcase { * @dataProvider valid_string_provider * @param string $name Name * @param string $summary Summary + * @covers ::__construct */ public function test_valid_configs($name, $privacyfields, $summary) { $record = new plugintype_link($name, $privacyfields, $summary); diff --git a/privacy/tests/types_subsystem_link_test.php b/privacy/tests/types_subsystem_link_test.php index 780aa793a90..8aa03b407a2 100644 --- a/privacy/tests/types_subsystem_link_test.php +++ b/privacy/tests/types_subsystem_link_test.php @@ -34,6 +34,7 @@ use \core_privacy\local\metadata\types\subsystem_link; * * @copyright 2018 Andrew Nicols * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @coversDefaultClass \core_privacy\local\metadata\types\subsystem_link */ class core_privacy_metadata_types_subsystem_link extends advanced_testcase { @@ -43,6 +44,7 @@ class core_privacy_metadata_types_subsystem_link extends advanced_testcase { * @dataProvider invalid_string_provider * @param string $name Name * @param string $summary Summary + * @covers ::__construct */ public function test_invalid_configs($name, $privacyfields, $summary) { $record = new subsystem_link($name, $privacyfields, $summary); @@ -55,6 +57,7 @@ class core_privacy_metadata_types_subsystem_link extends advanced_testcase { * @dataProvider invalid_string_provider * @param string $name Name * @param string $summary Summary + * @covers ::__construct */ public function test_invalid_configs_debug_normal($name, $privacyfields, $summary) { global $CFG; @@ -71,6 +74,7 @@ class core_privacy_metadata_types_subsystem_link extends advanced_testcase { * @dataProvider valid_string_provider * @param string $name Name * @param string $summary Summary + * @covers ::__construct */ public function test_valid_configs($name, $privacyfields, $summary) { $record = new subsystem_link($name, $privacyfields, $summary); diff --git a/privacy/tests/types_user_preference_test.php b/privacy/tests/types_user_preference_test.php index 87f65c51950..0e4206cda9e 100644 --- a/privacy/tests/types_user_preference_test.php +++ b/privacy/tests/types_user_preference_test.php @@ -34,6 +34,7 @@ use \core_privacy\local\metadata\types\user_preference; * * @copyright 2018 Andrew Nicols * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @coversDefaultClass \core_privacy\local\metadata\types\user_preference */ class core_privacy_metadata_types_user_preference extends advanced_testcase { @@ -43,6 +44,7 @@ class core_privacy_metadata_types_user_preference extends advanced_testcase { * @dataProvider invalid_string_provider * @param string $name Name * @param string $summary Summary + * @covers ::__construct */ public function test_invalid_configs($name, $summary) { $record = new user_preference($name, $summary); @@ -55,6 +57,7 @@ class core_privacy_metadata_types_user_preference extends advanced_testcase { * @dataProvider invalid_string_provider * @param string $name Name * @param string $summary Summary + * @covers ::__construct */ public function test_invalid_configs_debug_normal($name, $summary) { global $CFG; @@ -71,6 +74,7 @@ class core_privacy_metadata_types_user_preference extends advanced_testcase { * @dataProvider valid_string_provider * @param string $name Name * @param string $summary Summary + * @covers ::__construct */ public function test_valid_configs($name, $summary) { $record = new user_preference($name, $summary); diff --git a/privacy/tests/userlist_base_test.php b/privacy/tests/userlist_base_test.php index fc18b831320..0a5e7bfe8ba 100644 --- a/privacy/tests/userlist_base_test.php +++ b/privacy/tests/userlist_base_test.php @@ -34,6 +34,7 @@ use \core_privacy\local\request\userlist_base; * * @copyright 2018 Andrew Nicols * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @coversDefaultClass \core_privacy\local\request\userlist_base */ class userlist_base_test extends advanced_testcase { /** @@ -43,6 +44,7 @@ class userlist_base_test extends advanced_testcase { * @param array $input List of user IDs * @param array $expected list of userids * @param int $count Expected count + * @covers ::get_userids */ public function test_get_userids($input, $expected, $count) { $uut = new test_userlist_base(\context_system::instance(), 'core_tests'); @@ -84,6 +86,8 @@ class userlist_base_test extends advanced_testcase { /** * Ensure that get_users returns the correct list of users. + * + * @covers ::get_users */ public function test_get_users() { $this->resetAfterTest(); @@ -121,6 +125,7 @@ class userlist_base_test extends advanced_testcase { * @param array $input List of user IDs * @param array $expected list of userids * @param int $count Expected count + * @covers ::count */ public function test_countable($input, $expected, $count) { $uut = new test_userlist_base(\context_system::instance(), 'core_tests'); @@ -131,6 +136,12 @@ class userlist_base_test extends advanced_testcase { /** * Ensure that the userlist_base iterates over the set of users. + * + * @covers ::current + * @covers ::key + * @covers ::next + * @covers ::rewind + * @covers ::valid */ public function test_user_iteration() { $this->resetAfterTest(); @@ -161,6 +172,8 @@ class userlist_base_test extends advanced_testcase { /** * Test that a deleted user is still returned. * If a user has data then it still must be deleted, even if they are deleted. + * + * @covers ::count */ public function test_current_user_one_user() { $this->resetAfterTest(); @@ -180,6 +193,8 @@ class userlist_base_test extends advanced_testcase { /** * Test that an invalid user returns no entry. + * + * @covers ::count */ public function test_current_user_invalid() { $uut = new test_userlist_base(\context_system::instance(), 'core_tests'); @@ -191,6 +206,8 @@ class userlist_base_test extends advanced_testcase { /** * Test that where an invalid user is listed, the next user in the list is returned instead. + * + * @covers ::count */ public function test_current_user_two_users() { $this->resetAfterTest(); @@ -206,6 +223,8 @@ class userlist_base_test extends advanced_testcase { /** * Ensure that the component specified in the constructor is used and available. + * + * @covers ::set_component */ public function test_set_component_in_constructor() { $uut = new test_userlist_base(\context_system::instance(), 'core_tests'); @@ -214,6 +233,8 @@ class userlist_base_test extends advanced_testcase { /** * Ensure that the context specified in the constructor is available. + * + * @covers ::__construct */ public function test_set_context_in_constructor() { $context = \context_user::instance(\core_user::get_user_by_username('admin')->id); diff --git a/privacy/tests/userlist_collection.php b/privacy/tests/userlist_collection.php index 000ac3d7396..fd5d368fdc6 100644 --- a/privacy/tests/userlist_collection.php +++ b/privacy/tests/userlist_collection.php @@ -36,11 +36,14 @@ use \core_privacy\local\request\approved_userlist; * * @copyright 2018 Andrew Nicols * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @coversDefaultClass \core_privacy\local\request\userlist_collection */ class userlist_collection_test extends advanced_testcase { /** * A userlist_collection should support the userlist type. + * + * @covers ::add_userlist */ public function test_supports_userlist() { $cut = \context_system::instance(); @@ -54,6 +57,8 @@ class userlist_collection_test extends advanced_testcase { /** * A userlist_collection should support the approved_userlist type. + * + * @covers ::add_userlist */ public function test_supports_approved_userlist() { $cut = \context_system::instance(); @@ -67,6 +72,8 @@ class userlist_collection_test extends advanced_testcase { /** * Ensure that get_userlist_for_component returns the correct userlist. + * + * @covers ::get_userlist_for_component */ public function test_get_userlist_for_component() { $cut = \context_system::instance(); @@ -86,6 +93,8 @@ class userlist_collection_test extends advanced_testcase { /** * Ensure that get_userlist_for_component does not die horribly when querying a non-existent component. + * + * @covers ::get_userlist_for_component */ public function test_get_userlist_for_component_not_found() { $cut = \context_system::instance(); @@ -96,6 +105,8 @@ class userlist_collection_test extends advanced_testcase { /** * Ensure that a duplicate userlist in the collection throws an Exception. + * + * @covers ::add_userlist */ public function test_duplicate_addition_throws() { $cut = \context_system::instance(); @@ -110,6 +121,8 @@ class userlist_collection_test extends advanced_testcase { /** * Ensure that the userlist_collection is countable. + * + * @covers ::count */ public function test_countable() { $cut = \context_system::instance(); @@ -123,6 +136,12 @@ class userlist_collection_test extends advanced_testcase { /** * Ensure that the userlist_collection iterates over the set of userlists. + * + * @covers ::current + * @covers ::key + * @covers ::next + * @covers ::rewind + * @covers ::valid */ public function test_iteration() { $cut = \context_system::instance(); @@ -151,6 +170,8 @@ class userlist_collection_test extends advanced_testcase { /** * Test that the context is correctly returned. + * + * @covers ::get_context */ public function test_get_context() { $cut = \context_system::instance(); diff --git a/privacy/tests/userlist_test.php b/privacy/tests/userlist_test.php index 9afc7ea1d7a..8df9c97c82a 100644 --- a/privacy/tests/userlist_test.php +++ b/privacy/tests/userlist_test.php @@ -34,11 +34,14 @@ use \core_privacy\local\request\userlist; * * @copyright 2018 Andrew Nicols * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @coversDefaultClass \core_privacy\local\request\userlist */ class userlist_test extends advanced_testcase { /** * Ensure that valid SQL results in the relevant users being added. + * + * @covers ::add_from_sql */ public function test_add_from_sql() { global $DB; @@ -55,6 +58,8 @@ class userlist_test extends advanced_testcase { /** * Ensure that adding a single user adds that user. + * + * @covers ::add_user */ public function test_add_user() { $this->resetAfterTest(); @@ -72,6 +77,8 @@ class userlist_test extends advanced_testcase { /** * Ensure that adding multiple users by ID adds those users. + * + * @covers ::add_users */ public function test_add_users() { $this->resetAfterTest(); diff --git a/privacy/tests/writer_test.php b/privacy/tests/writer_test.php index 45fbfd99e09..d37c4621fad 100644 --- a/privacy/tests/writer_test.php +++ b/privacy/tests/writer_test.php @@ -38,6 +38,7 @@ use \core_privacy\local\request\writer; * * @copyright 2018 Andrew Nicols * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @coversDefaultClass \core_privacy\local\request\writer */ class writer_test extends advanced_testcase { /** @@ -50,6 +51,9 @@ class writer_test extends advanced_testcase { /** * Test that calling with_context multiple times will return the same write instance. + * + * @covers ::with_context + * @covers :: */ public function test_with_context() { $writer = writer::with_context(\context_system::instance()); @@ -59,6 +63,9 @@ class writer_test extends advanced_testcase { /** * Test that calling with_context multiple times will return the same write instance. + * + * @covers ::with_context + * @covers :: */ public function test_with_context_different_context_same_instance() { $writer = writer::with_context(\context_system::instance()); @@ -68,6 +75,9 @@ class writer_test extends advanced_testcase { /** * Test that calling writer::reset() causes a new copy of the writer to be returned. + * + * @covers ::reset + * @covers :: */ public function test_reset() { $writer = writer::with_context(\context_system::instance()); @@ -78,6 +88,9 @@ class writer_test extends advanced_testcase { /** * Test that the export_user_preference calls the writer against the system context. + * + * @covers ::export_user_preference + * @covers :: */ public function test_export_user_preference_sets_system_context() { $writer = writer::with_context(\context_user::instance(\core_user::get_user_by_username('admin')->id));