From e449be840bd505b9485c12fbf417a6ce6aeeea87 Mon Sep 17 00:00:00 2001 From: Sasha Anastasi Date: Mon, 10 Feb 2025 12:31:31 +1300 Subject: [PATCH 1/2] Replace deprecated testcase classes with core_phpunit --- factor/email/tests/factor_test.php | 2 +- factor/grace/tests/factor_test.php | 2 +- factor/token/tests/factor_test.php | 2 +- factor/totp/tests/factor_test.php | 2 +- tests/plugininfo_factor_test.php | 2 +- tests/secret_manager_test.php | 2 +- tests/tool_mfa_testcase.php | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/factor/email/tests/factor_test.php b/factor/email/tests/factor_test.php index e61ace97..ad919837 100644 --- a/factor/email/tests/factor_test.php +++ b/factor/email/tests/factor_test.php @@ -25,7 +25,7 @@ * @copyright Catalyst IT * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class factor_test extends \advanced_testcase { +class factor_test extends \core_phpunit\testcase { /** * Provides to test_generate_email_ip_address_location test. diff --git a/factor/grace/tests/factor_test.php b/factor/grace/tests/factor_test.php index f5d8b86a..bc63622a 100644 --- a/factor/grace/tests/factor_test.php +++ b/factor/grace/tests/factor_test.php @@ -24,7 +24,7 @@ * @copyright Catalyst IT * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class factor_test extends \advanced_testcase { +class factor_test extends \core_phpunit\testcase { public function test_affecting_factors() { $this->resetAfterTest(true); diff --git a/factor/token/tests/factor_test.php b/factor/token/tests/factor_test.php index c14e8d4e..8be7ed6d 100644 --- a/factor/token/tests/factor_test.php +++ b/factor/token/tests/factor_test.php @@ -25,7 +25,7 @@ * @copyright Catalyst IT * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class factor_test extends \advanced_testcase { +class factor_test extends \core_phpunit\testcase { public function setUp(): void { $this->resetAfterTest(); diff --git a/factor/totp/tests/factor_test.php b/factor/totp/tests/factor_test.php index 2856f5dc..e07c1a11 100644 --- a/factor/totp/tests/factor_test.php +++ b/factor/totp/tests/factor_test.php @@ -37,7 +37,7 @@ * @copyright Catalyst IT * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class factor_test extends \advanced_testcase { +class factor_test extends \core_phpunit\testcase { /** * Test code validation of the TOTP factor diff --git a/tests/plugininfo_factor_test.php b/tests/plugininfo_factor_test.php index 4e5aa27e..e94cf966 100644 --- a/tests/plugininfo_factor_test.php +++ b/tests/plugininfo_factor_test.php @@ -22,7 +22,7 @@ * @copyright Catalyst IT * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class plugininfo_factor_test extends advanced_testcase { +class plugininfo_factor_test extends \core_phpunit\testcase { public function test_get_next_user_factor() { diff --git a/tests/secret_manager_test.php b/tests/secret_manager_test.php index 6ef09c92..84c2a7a2 100644 --- a/tests/secret_manager_test.php +++ b/tests/secret_manager_test.php @@ -24,7 +24,7 @@ * @copyright Catalyst IT * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class secret_manager_test extends \advanced_testcase { +class secret_manager_test extends \core_phpunit\testcase { public function test_create_secret() { global $DB; diff --git a/tests/tool_mfa_testcase.php b/tests/tool_mfa_testcase.php index 5d15a5a9..5b8f5ae4 100644 --- a/tests/tool_mfa_testcase.php +++ b/tests/tool_mfa_testcase.php @@ -31,7 +31,7 @@ * @copyright Catalyst IT * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -abstract class tool_mfa_testcase extends \advanced_testcase { +abstract class tool_mfa_testcase extends \core_phpunit\testcase { /** * Sets the state of the factor, in particular the weight and whether it is enabled From 99b7f11bcbfdd956e53c0827592fa4ada8efa343 Mon Sep 17 00:00:00 2001 From: Sasha Anastasi Date: Tue, 11 Feb 2025 17:03:08 +1300 Subject: [PATCH 2/2] Use importing instead of namespaces in test files --- factor/email/tests/factor_test.php | 4 +--- factor/grace/tests/factor_test.php | 4 +--- factor/token/tests/factor_test.php | 4 +--- factor/totp/tests/factor_test.php | 4 +--- tests/admin_setting_managemfa_test.php | 2 -- tests/manager_test.php | 2 -- tests/object_factor_base_test.php | 1 - tests/secret_manager_test.php | 2 -- tests/tool_mfa_testcase.php | 2 -- 9 files changed, 4 insertions(+), 21 deletions(-) diff --git a/factor/email/tests/factor_test.php b/factor/email/tests/factor_test.php index ad919837..b7434bfc 100644 --- a/factor/email/tests/factor_test.php +++ b/factor/email/tests/factor_test.php @@ -14,8 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -namespace factor_email\tests; - /** * Tests for TOTP factor. * @@ -25,7 +23,7 @@ * @copyright Catalyst IT * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class factor_test extends \core_phpunit\testcase { +class email_factor_test extends \core_phpunit\testcase { /** * Provides to test_generate_email_ip_address_location test. diff --git a/factor/grace/tests/factor_test.php b/factor/grace/tests/factor_test.php index bc63622a..e2137d70 100644 --- a/factor/grace/tests/factor_test.php +++ b/factor/grace/tests/factor_test.php @@ -14,8 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -namespace factor_grace\tests; - /** * Tests for grace factor. * @@ -24,7 +22,7 @@ * @copyright Catalyst IT * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class factor_test extends \core_phpunit\testcase { +class grace_factor_test extends \core_phpunit\testcase { public function test_affecting_factors() { $this->resetAfterTest(true); diff --git a/factor/token/tests/factor_test.php b/factor/token/tests/factor_test.php index 8be7ed6d..8be19fa1 100644 --- a/factor/token/tests/factor_test.php +++ b/factor/token/tests/factor_test.php @@ -14,8 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -namespace factor_token\tests; - /** * Tests for MFA manager class. * @@ -25,7 +23,7 @@ * @copyright Catalyst IT * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class factor_test extends \core_phpunit\testcase { +class token_factor_test extends \core_phpunit\testcase { public function setUp(): void { $this->resetAfterTest(); diff --git a/factor/totp/tests/factor_test.php b/factor/totp/tests/factor_test.php index e07c1a11..e663f8e4 100644 --- a/factor/totp/tests/factor_test.php +++ b/factor/totp/tests/factor_test.php @@ -14,8 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -namespace factor_totp\tests; - defined('MOODLE_INTERNAL') || die(); require_once(__DIR__.'/../extlib/OTPHP/OTPInterface.php'); @@ -37,7 +35,7 @@ * @copyright Catalyst IT * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class factor_test extends \core_phpunit\testcase { +class totp_factor_test extends \core_phpunit\testcase { /** * Test code validation of the TOTP factor diff --git a/tests/admin_setting_managemfa_test.php b/tests/admin_setting_managemfa_test.php index f5fb6c2e..e787b5ce 100644 --- a/tests/admin_setting_managemfa_test.php +++ b/tests/admin_setting_managemfa_test.php @@ -14,8 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -namespace tool_mfa\tests; - defined('MOODLE_INTERNAL') || die(); require_once(__DIR__ . '/tool_mfa_testcase.php'); diff --git a/tests/manager_test.php b/tests/manager_test.php index 1996007c..7cf8404a 100644 --- a/tests/manager_test.php +++ b/tests/manager_test.php @@ -14,8 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -namespace tool_mfa\tests; - defined('MOODLE_INTERNAL') || die(); require_once(__DIR__ . '/tool_mfa_testcase.php'); diff --git a/tests/object_factor_base_test.php b/tests/object_factor_base_test.php index 895b2579..6f4500e8 100644 --- a/tests/object_factor_base_test.php +++ b/tests/object_factor_base_test.php @@ -13,7 +13,6 @@ // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -namespace tool_mfa\tests; defined('MOODLE_INTERNAL') || die(); diff --git a/tests/secret_manager_test.php b/tests/secret_manager_test.php index 84c2a7a2..aa447e4b 100644 --- a/tests/secret_manager_test.php +++ b/tests/secret_manager_test.php @@ -14,8 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -namespace tool_mfa\tests; - /** * Tests for MFA secret manager class. * diff --git a/tests/tool_mfa_testcase.php b/tests/tool_mfa_testcase.php index 5b8f5ae4..1fb48834 100644 --- a/tests/tool_mfa_testcase.php +++ b/tests/tool_mfa_testcase.php @@ -14,8 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -namespace tool_mfa\tests; - defined('MOODLE_INTERNAL') || die(); global $CFG;