forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDL-65130 privacy: Add @Covers annotation to tests
- Loading branch information
1 parent
09d02b3
commit bc01342
Showing
20 changed files
with
342 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,10 +34,16 @@ | |
* | ||
* @copyright 2018 Andrew Nicols <[email protected]> | ||
* @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 ::<!public> | ||
* @covers \core_privacy\local\request\approved_contextlist<extended> | ||
*/ | ||
public function test_default_values_set() { | ||
$testuser = \core_user::get_user_by_username('admin'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,10 +35,15 @@ | |
* | ||
* @copyright 2018 Andrew Nicols <[email protected]> | ||
* @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<extended> | ||
* @covers ::<!public> | ||
*/ | ||
public function test_default_values_set() { | ||
$this->resetAfterTest(); | ||
|
@@ -68,6 +73,11 @@ public function test_default_values_set() { | |
$this->assertEquals($expected, $result); | ||
} | ||
|
||
/** | ||
* @covers ::create_from_userlist | ||
* @covers \core_privacy\local\request\approved_userlist<extended> | ||
* @covers ::<!public> | ||
*/ | ||
public function test_create_from_userlist() { | ||
$this->resetAfterTest(); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,12 +35,15 @@ | |
* | ||
* @copyright 2018 Andrew Nicols <[email protected]> | ||
* @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> | ||
*/ | ||
public function test_add_type_generic_type() { | ||
$collection = new collection('core_privacy'); | ||
|
@@ -56,6 +59,9 @@ public function test_add_type_generic_type() { | |
|
||
/** | ||
* Test that adding a known type works as anticipated. | ||
* | ||
* @covers ::add_type | ||
* @covers ::<!public> | ||
*/ | ||
public function test_add_type_known_type() { | ||
$collection = new collection('core_privacy'); | ||
|
@@ -70,6 +76,9 @@ public function test_add_type_known_type() { | |
|
||
/** | ||
* Test that adding multiple types returns them all. | ||
* | ||
* @covers ::add_type | ||
* @covers ::<!public> | ||
*/ | ||
public function test_add_type_multiple() { | ||
$collection = new collection('core_privacy'); | ||
|
@@ -86,6 +95,9 @@ public function test_add_type_multiple() { | |
|
||
/** | ||
* Test that the add_database_table function adds a database table. | ||
* | ||
* @covers ::add_database_table | ||
* @covers ::<!public> | ||
*/ | ||
public function test_add_database_table() { | ||
$collection = new collection('core_privacy'); | ||
|
@@ -107,6 +119,9 @@ public function test_add_database_table() { | |
|
||
/** | ||
* Test that the add_user_preference function adds a single user preference. | ||
* | ||
* @covers ::add_user_preference | ||
* @covers ::<!public> | ||
*/ | ||
public function test_add_user_preference() { | ||
$collection = new collection('core_privacy'); | ||
|
@@ -126,6 +141,9 @@ public function test_add_user_preference() { | |
|
||
/** | ||
* Test that the link_external_location function links an external location. | ||
* | ||
* @covers ::link_external_location | ||
* @covers ::<!public> | ||
*/ | ||
public function test_link_external_location() { | ||
$collection = new collection('core_privacy'); | ||
|
@@ -147,6 +165,9 @@ public function test_link_external_location() { | |
|
||
/** | ||
* Test that the link_subsystem function links the subsystem. | ||
* | ||
* @covers ::link_subsystem | ||
* @covers ::<!public> | ||
*/ | ||
public function test_link_subsystem() { | ||
$collection = new collection('core_privacy'); | ||
|
@@ -166,6 +187,9 @@ public function test_link_subsystem() { | |
|
||
/** | ||
* Test that the link_plugintype function links the plugin. | ||
* | ||
* @covers ::link_plugintype | ||
* @covers ::<!public> | ||
*/ | ||
public function test_link_plugintype() { | ||
$collection = new collection('core_privacy'); | ||
|
@@ -202,6 +226,8 @@ public function component_list_provider() { | |
* | ||
* @dataProvider component_list_provider | ||
* @param string $component The component to test | ||
* @covers ::get_component | ||
* @covers ::<!public> | ||
*/ | ||
public function test_get_component($component) { | ||
$collection = new collection($component); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ | |
* | ||
* @copyright 2018 Andrew Nicols <[email protected]> | ||
* @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> | ||
*/ | ||
public function test_get_contextids($input, $expected, $count) { | ||
$uit = new test_contextlist_base(); | ||
|
@@ -84,6 +87,9 @@ public function get_contextids_provider() { | |
|
||
/** | ||
* Ensure that get_contexts returns the correct list of contexts. | ||
* | ||
* @covers ::get_contexts | ||
* @covers ::<!public> | ||
*/ | ||
public function test_get_contexts() { | ||
global $DB; | ||
|
@@ -114,6 +120,8 @@ public function test_get_contexts() { | |
* @param array $input List of context IDs | ||
* @param array $expected list of contextids | ||
* @param int $count Expected count | ||
* @covers ::count | ||
* @covers ::<!public> | ||
*/ | ||
public function test_countable($input, $expected, $count) { | ||
$uit = new test_contextlist_base(); | ||
|
@@ -124,6 +132,13 @@ public function test_countable($input, $expected, $count) { | |
|
||
/** | ||
* Ensure that the contextlist_base iterates over the set of contexts. | ||
* | ||
* @covers ::current | ||
* @covers ::key | ||
* @covers ::next | ||
* @covers ::rewind | ||
* @covers ::valid | ||
* @covers ::<!public> | ||
*/ | ||
public function test_context_iteration() { | ||
global $DB; | ||
|
@@ -144,6 +159,9 @@ public function test_context_iteration() { | |
|
||
/** | ||
* Test that deleting a context results in current returning nothing. | ||
* | ||
* @covers ::current | ||
* @covers ::<!public> | ||
*/ | ||
public function test_current_context_one_context() { | ||
global $DB; | ||
|
@@ -171,6 +189,9 @@ public function test_current_context_one_context() { | |
|
||
/** | ||
* Test that deleting a context results in the next record being returned. | ||
* | ||
* @covers ::current | ||
* @covers ::<!public> | ||
*/ | ||
public function test_current_context_two_contexts() { | ||
global $DB; | ||
|
@@ -206,6 +227,9 @@ public function test_current_context_two_contexts() { | |
|
||
/** | ||
* Test that if there are no non-deleted contexts that nothing is returned. | ||
* | ||
* @covers ::get_contexts | ||
* @covers ::<!public> | ||
*/ | ||
public function test_get_contexts_all_deleted() { | ||
global $DB; | ||
|
@@ -231,6 +255,9 @@ public function test_get_contexts_all_deleted() { | |
|
||
/** | ||
* Test that get_contexts() returns only active contexts. | ||
* | ||
* @covers ::get_contexts | ||
* @covers ::<!public> | ||
*/ | ||
public function test_get_contexts_one_deleted() { | ||
global $DB; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,10 +36,14 @@ | |
* | ||
* @copyright 2018 Andrew Nicols <[email protected]> | ||
* @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> | ||
*/ | ||
public function test_supports_contextlist() { | ||
$uit = new contextlist_collection(1); | ||
|
@@ -52,6 +56,9 @@ public function test_supports_contextlist() { | |
|
||
/** | ||
* A contextlist_collection should support the approved_contextlist type. | ||
* | ||
* @covers ::add_contextlist | ||
* @covers ::<!public> | ||
*/ | ||
public function test_supports_approved_contextlist() { | ||
$uit = new contextlist_collection(1); | ||
|
@@ -64,6 +71,9 @@ public function test_supports_approved_contextlist() { | |
|
||
/** | ||
* Ensure that get_contextlist_for_component returns the correct contextlist. | ||
* | ||
* @covers ::get_contextlist_for_component | ||
* @covers ::<!public> | ||
*/ | ||
public function test_get_contextlist_for_component() { | ||
$uit = new contextlist_collection(1); | ||
|
@@ -83,6 +93,9 @@ public function test_get_contextlist_for_component() { | |
|
||
/** | ||
* Ensure that get_contextlist_for_component does not die horribly when querying a non-existent component. | ||
* | ||
* @covers ::get_contextlist_for_component | ||
* @covers ::<!public> | ||
*/ | ||
public function test_get_contextlist_for_component_not_found() { | ||
$uit = new contextlist_collection(1); | ||
|
@@ -92,6 +105,9 @@ public function test_get_contextlist_for_component_not_found() { | |
|
||
/** | ||
* Ensure that a duplicate contextlist in the collection throws an Exception. | ||
* | ||
* @covers ::add_contextlist | ||
* @covers ::<!public> | ||
*/ | ||
public function test_duplicate_addition_throws() { | ||
$uit = new contextlist_collection(1); | ||
|
@@ -106,6 +122,9 @@ public function test_duplicate_addition_throws() { | |
|
||
/** | ||
* Ensure that the contextlist_collection is countable. | ||
* | ||
* @covers ::count | ||
* @covers ::<!public> | ||
*/ | ||
public function test_countable() { | ||
$uit = new contextlist_collection(1); | ||
|
@@ -123,6 +142,13 @@ public function test_countable() { | |
|
||
/** | ||
* Ensure that the contextlist_collection iterates over the set of contextlists. | ||
* | ||
* @covers ::current | ||
* @covers ::key | ||
* @covers ::next | ||
* @covers ::rewind | ||
* @covers ::valid | ||
* @covers ::<!public> | ||
*/ | ||
public function test_iteration() { | ||
$uit = new contextlist_collection(1); | ||
|
@@ -156,6 +182,9 @@ public function test_iteration() { | |
|
||
/** | ||
* Test that the userid is correctly returned. | ||
* | ||
* @covers ::get_userid | ||
* @covers ::<!public> | ||
*/ | ||
public function test_get_userid() { | ||
$uit = new contextlist_collection(1); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,11 +34,15 @@ | |
* | ||
* @copyright 2018 Andrew Nicols <[email protected]> | ||
* @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> | ||
*/ | ||
public function test_add_from_sql() { | ||
global $DB; | ||
|
@@ -55,6 +59,9 @@ public function test_add_from_sql() { | |
|
||
/** | ||
* Ensure that valid system context id is added. | ||
* | ||
* @covers ::add_system_context | ||
* @covers ::<!public> | ||
*/ | ||
public function test_add_system_context() { | ||
$cl = new contextlist(); | ||
|
@@ -69,6 +76,9 @@ public function test_add_system_context() { | |
|
||
/** | ||
* Ensure that a valid user context id is added. | ||
* | ||
* @covers ::add_user_context | ||
* @covers ::<!public> | ||
*/ | ||
public function test_add_user_context() { | ||
$this->resetAfterTest(); | ||
|
@@ -88,6 +98,9 @@ public function test_add_user_context() { | |
|
||
/** | ||
* Ensure that valid user contexts are added. | ||
* | ||
* @covers ::add_user_contexts | ||
* @covers ::<!public> | ||
*/ | ||
public function test_add_user_contexts() { | ||
$this->resetAfterTest(); | ||
|
@@ -112,6 +125,8 @@ public function test_add_user_contexts() { | |
* @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> | ||
*/ | ||
public function test_guess_id_field_from_sql($sql, $expected) { | ||
|
||
|
Oops, something went wrong.