From 5b03e6e38c0f5f3f383701cc7916fbf5ebe66b14 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Thu, 17 Oct 2024 10:32:26 +0800 Subject: [PATCH] MDL-81520 mod_assign: Update tests to not extend assign_provider test --- .../comments/tests/privacy/provider_test.php | 2 ++ .../editpdf/tests/privacy/provider_test.php | 27 +++++++++---------- .../file/tests/privacy/provider_test.php | 26 ++++++++---------- .../comments/tests/privacy/provider_test.php | 16 +++-------- .../file/tests/privacy/provider_test.php | 17 +++--------- .../tests/privacy/provider_test.php | 18 +++---------- mod/assign/tests/locallib_test.php | 3 +-- mod/assign/tests/privacy/provider_test.php | 12 +++------ mod/assign/upgrade.txt | 8 ++++++ 9 files changed, 47 insertions(+), 82 deletions(-) diff --git a/mod/assign/feedback/comments/tests/privacy/provider_test.php b/mod/assign/feedback/comments/tests/privacy/provider_test.php index 6b550ef8d09..6bfedb1482b 100644 --- a/mod/assign/feedback/comments/tests/privacy/provider_test.php +++ b/mod/assign/feedback/comments/tests/privacy/provider_test.php @@ -21,8 +21,10 @@ use mod_assign\tests\provider_testcase; /** * Unit tests for mod/assign/feedback/comments/classes/privacy/ * + * @package assignfeedback_comments * @copyright 2018 Adrian Greeve * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @covers \assignfeedback_comments\privacy\provider */ final class provider_test extends provider_testcase { /** diff --git a/mod/assign/feedback/editpdf/tests/privacy/provider_test.php b/mod/assign/feedback/editpdf/tests/privacy/provider_test.php index b6ef289967c..30ff05571e1 100644 --- a/mod/assign/feedback/editpdf/tests/privacy/provider_test.php +++ b/mod/assign/feedback/editpdf/tests/privacy/provider_test.php @@ -14,32 +14,29 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * Unit tests for assignfeedback_editpdf. - * - * @package assignfeedback_editpdf - * @copyright 2018 Adrian Greeve - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ namespace assignfeedback_editpdf\privacy; -defined('MOODLE_INTERNAL') || die(); - -global $CFG; -require_once($CFG->dirroot . '/mod/assign/locallib.php'); -require_once($CFG->dirroot . '/mod/assign/tests/privacy/provider_test.php'); - use assignfeedback_editpdf\page_editor; use mod_assign\privacy\assign_plugin_request_data; /** - * Unit tests for mod/assign/feedback/editpdf/classes/privacy/ + * Unit tests for mod/assign/feedback/editpdf/classes/privacy/provider. * + * @package assignfeedback_editpdf * @copyright 2018 Adrian Greeve * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @covers \assignfeedback_editpdf\privacy\provider */ -final class provider_test extends \mod_assign\privacy\provider_test { +final class provider_test extends \mod_assign\tests\provider_testcase { + #[\Override] + public static function setUpBeforeClass(): void { + global $CFG; + parent::setUpBeforeClass(); + require_once($CFG->dirroot . '/mod/assign/locallib.php'); + } + + #[\Override] public function setUp(): void { // Skip this test if ghostscript is not supported. $result = \assignfeedback_editpdf\pdf::test_gs_path(false); diff --git a/mod/assign/feedback/file/tests/privacy/provider_test.php b/mod/assign/feedback/file/tests/privacy/provider_test.php index 433632ce986..4a23e03d0a5 100644 --- a/mod/assign/feedback/file/tests/privacy/provider_test.php +++ b/mod/assign/feedback/file/tests/privacy/provider_test.php @@ -14,30 +14,26 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * Unit tests for assignfeedback_file. - * - * @package assignfeedback_file - * @copyright 2018 Adrian Greeve - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ namespace assignfeedback_file\privacy; -defined('MOODLE_INTERNAL') || die(); - -global $CFG; -require_once($CFG->dirroot . '/mod/assign/locallib.php'); -require_once($CFG->dirroot . '/mod/assign/tests/privacy/provider_test.php'); - use mod_assign\privacy\assign_plugin_request_data; /** - * Unit tests for mod/assign/feedback/file/classes/privacy/ + * Unit tests for mod/assign/feedback/file/classes/privacy/provider. * * @copyright 2018 Adrian Greeve * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package assignfeedback_file + * @covers \assignfeedback_file\privacy\provider */ -final class provider_test extends \mod_assign\privacy\provider_test { +final class provider_test extends \mod_assign\tests\provider_testcase { + #[\Override] + public static function setUpBeforeClass(): void { + global $CFG; + + parent::setUpBeforeClass(); + require_once($CFG->dirroot . '/mod/assign/locallib.php'); + } /** * Convenience function for creating feedback data. diff --git a/mod/assign/submission/comments/tests/privacy/provider_test.php b/mod/assign/submission/comments/tests/privacy/provider_test.php index af92191ad67..b7a7a113268 100644 --- a/mod/assign/submission/comments/tests/privacy/provider_test.php +++ b/mod/assign/submission/comments/tests/privacy/provider_test.php @@ -14,29 +14,19 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * Unit tests for assignsubmission_comments. - * - * @package assignsubmission_comments - * @copyright 2018 Adrian Greeve - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ namespace assignsubmission_comments\privacy; -defined('MOODLE_INTERNAL') || die(); - -global $CFG; -require_once($CFG->dirroot . '/mod/assign/tests/privacy/provider_test.php'); - use mod_assign\privacy\useridlist; /** * Unit tests for mod/assign/submission/comments/classes/privacy/ * + * @package assignsubmission_comments * @copyright 2018 Adrian Greeve * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @covers \assignsubmission_comments\privacy\provider */ -final class provider_test extends \mod_assign\privacy\provider_test { +final class provider_test extends \mod_assign\tests\provider_testcase { /** * Convenience function for creating feedback data. diff --git a/mod/assign/submission/file/tests/privacy/provider_test.php b/mod/assign/submission/file/tests/privacy/provider_test.php index a26dd1a4de3..f1dcdccb0ba 100644 --- a/mod/assign/submission/file/tests/privacy/provider_test.php +++ b/mod/assign/submission/file/tests/privacy/provider_test.php @@ -14,28 +14,17 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * Unit tests for assignsubmission_file. - * - * @package assignsubmission_file - * @copyright 2018 Adrian Greeve - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ namespace assignsubmission_file\privacy; -defined('MOODLE_INTERNAL') || die(); - -global $CFG; -require_once($CFG->dirroot . '/mod/assign/tests/privacy/provider_test.php'); - /** * Unit tests for mod/assign/submission/file/classes/privacy/ * + * @package assignsubmission_file * @copyright 2018 Adrian Greeve * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @covers \assignsubmission_file\privacy\provider */ -final class provider_test extends \mod_assign\privacy\provider_test { - +final class provider_test extends \mod_assign\tests\provider_testcase { /** * Convenience function for creating feedback data. * diff --git a/mod/assign/submission/onlinetext/tests/privacy/provider_test.php b/mod/assign/submission/onlinetext/tests/privacy/provider_test.php index c14befc90f0..85c8a504b39 100644 --- a/mod/assign/submission/onlinetext/tests/privacy/provider_test.php +++ b/mod/assign/submission/onlinetext/tests/privacy/provider_test.php @@ -14,27 +14,17 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * Unit tests for assignsubmission_onlinetext. - * - * @package assignsubmission_onlinetext - * @copyright 2018 Adrian Greeve - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ namespace assignsubmission_onlinetext\privacy; -defined('MOODLE_INTERNAL') || die(); - -global $CFG; -require_once($CFG->dirroot . '/mod/assign/tests/privacy/provider_test.php'); - /** - * Unit tests for mod/assign/submission/onlinetext/classes/privacy/ + * Unit tests for mod/assign/submission/onlinetext/classes/privacy/provider. * * @copyright 2018 Adrian Greeve * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package assignsubmission_onlinetext + * @covers \assignsubmission_onlinetext\privacy\provider */ -final class provider_test extends \mod_assign\privacy\provider_test { +final class provider_test extends \mod_assign\tests\provider_testcase { /** * Convenience function for creating feedback data. diff --git a/mod/assign/tests/locallib_test.php b/mod/assign/tests/locallib_test.php index a6a0f1e7b66..a8e7f6fa451 100644 --- a/mod/assign/tests/locallib_test.php +++ b/mod/assign/tests/locallib_test.php @@ -40,8 +40,7 @@ require_once($CFG->dirroot . '/mod/assign/tests/generator.php'); * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class locallib_test extends \advanced_testcase { - +final class locallib_test extends \advanced_testcase { // Use the generator helper. use mod_assign_test_generator; diff --git a/mod/assign/tests/privacy/provider_test.php b/mod/assign/tests/privacy/provider_test.php index 9a17ed8dc5f..201e5bcbd9a 100644 --- a/mod/assign/tests/privacy/provider_test.php +++ b/mod/assign/tests/privacy/provider_test.php @@ -14,14 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * Base class for unit tests for mod_assign. - * - * @package mod_assign - * @copyright 2018 Adrian Greeve - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - namespace mod_assign\privacy; use core_privacy\local\request\writer; @@ -32,10 +24,12 @@ use mod_assign\tests\provider_testcase; /** * Unit tests for mod/assign/classes/privacy/ * + * @package mod_assign * @copyright 2018 Adrian Greeve * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @covers \mod_assign\privacy\provider */ -class provider_test extends provider_testcase { +final class provider_test extends provider_testcase { /** * Test that getting the contexts for a user works. */ diff --git a/mod/assign/upgrade.txt b/mod/assign/upgrade.txt index a2ac4572b6e..92559a6c81e 100644 --- a/mod/assign/upgrade.txt +++ b/mod/assign/upgrade.txt @@ -1,5 +1,13 @@ This files describes API changes in the assign code. +=== 4.4.5 === +* The unit test for the privacy provider has been marked as final. + A number of core tests had been incorrectly configured to extend this test + but should instead be extending `\mod_assign\tests\provider_testcase`. + Any community plugins extending the `\mod_assign\privacy\provider_test` test + class should be updated to extend `\mod_assign\tests\provider_testcase` instead. + See MDL-81520 for further information. + === 4.3 === * The following deprecated methods have been removed and should not be used any more: - `assign::add_to_log`