Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[T19] Fixes for totara19 #874

Merged
merged 4 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions tests/auth_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace auth_saml2;

/**
* Unit tests for auth class.
*
Expand All @@ -27,7 +25,7 @@
* @copyright 2021 Moodle Pty Ltd <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class auth_saml2_test extends \core_phpunit\testcase {
class auth_saml2_auth_test extends \core_phpunit\testcase {
/**
* Set up
*/
Expand Down Expand Up @@ -100,7 +98,7 @@ protected function get_mocked_auth(): \auth_saml2\auth {
// exception message. This is needed to check $msg argument and stop
// execution like original method does.
$auth = $this->getMockBuilder(\auth_saml2\auth::class)
->setMethods(['error_page'])->getMock();
->onlyMethods(['error_page'])->getMock();

$auth->expects($this->once())
->method('error_page')
Expand Down Expand Up @@ -800,7 +798,7 @@ public function test_should_login_redirect($cfg, $config, $param, $multiidp, $se
*
* @return array of testcases
*/
public function provider_should_login_redirect(): array {
public static function provider_should_login_redirect(): array {
$midp = (new \moodle_url('/auth/saml2/selectidp.php'))->out();
return [
// Login normal, dual login on.
Expand Down Expand Up @@ -967,7 +965,7 @@ public function test_check_whitelisted_ip_redirect($saml, $remoteip, $whitelist,
*
* @return array
*/
public function provider_check_whitelisted_ip_redirect(): array {
public static function provider_check_whitelisted_ip_redirect(): array {
return [
'saml off, no ip, no redirect' => ['off', '1.2.3.4', '', false],
'saml not specified, junk, no redirect' => [null, '1.2.3.4', 'qwer1234!@#qwer', false],
Expand All @@ -982,7 +980,7 @@ public function provider_check_whitelisted_ip_redirect(): array {
*
* @return array
*/
public function provider_is_access_allowed(): array {
public static function provider_is_access_allowed(): array {
return [
'' => [[
['uid' => 'test'], // User don't have groups attribute.
Expand Down Expand Up @@ -1206,7 +1204,7 @@ public function test_update_custom_user_profile_fields($attributes): void {
*
* @return array of testcases
*/
public function provider_update_custom_user_profile_fields(): array {
public static function provider_update_custom_user_profile_fields(): array {
return [
[['testfield' => ['Test data']]],
[['secondfield' => ['A different string']]],
Expand Down Expand Up @@ -1253,7 +1251,7 @@ public function test_missing_user_custom_profile_fields($attributes): void {
*
* @return array of testcases
*/
public function provider_missing_user_custom_profile_fields(): array {
public static function provider_missing_user_custom_profile_fields(): array {
return array(
array(['missingfield' => array('Test data')]),
array(['secondfield' => array('A different string')]),
Expand Down Expand Up @@ -1292,7 +1290,7 @@ public function test_invalid_map_user_profile_fields($mapping, $attributes): voi
*
* @return array of testcases
*/
public function provider_invalid_map_user_profile_fields(): array {
public static function provider_invalid_map_user_profile_fields(): array {
return [
[
['field' => 'userame', 'mapping' => 'invalid'],
Expand Down
2 changes: 1 addition & 1 deletion tests/form_regenerate_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* @package auth_saml2
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class auth_saml2_form_regenerate_testcase extends \core_phpunit\testcase {
class auth_saml2_form_regenerate_test extends \core_phpunit\testcase {
public function test_regenerate_certificate_form() {
global $CFG, $DB, $USER;
$this->resetAfterTest();
Expand Down
2 changes: 1 addition & 1 deletion tests/generator_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* @copyright 2021 Moodle Pty Ltd <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class generator_testcase extends \core_phpunit\testcase {
class generator_test extends \core_phpunit\testcase {
/**
* Set up
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/group_rule_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* @copyright Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class auth_saml2_group_rule_test_testcase extends \core_phpunit\testcase {
class auth_saml2_group_rule_test extends \core_phpunit\testcase {

/**
* Test we can get list of rules from config string.
Expand Down
2 changes: 1 addition & 1 deletion tests/locallib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* @copyright Brendan Heywood <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class auth_saml2_locallib_testcase extends \core_phpunit\testcase {
class auth_saml2_locallib_test extends \core_phpunit\testcase {
/**
* Regression test for Issue 132.
*/
Expand Down
3 changes: 2 additions & 1 deletion tests/metadata_fetcher_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* @copyright Copyright (c) 2017 Blackboard Inc. (http://www.blackboard.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class auth_saml2_metadata_fetcher_testcase extends \core_phpunit\testcase {
class auth_saml2_metadata_fetcher_test extends \core_phpunit\testcase {

/** @var \Prophecy\Prophet */
protected $prophet;
Expand All @@ -50,6 +50,7 @@ public function setUp(): void {
*/
protected function tearDown(): void {
$this->prophet = null; // Required for Totara 12+ support (see issue #578).
parent::tearDown();
}

public function test_fetch_metadata_404() {
Expand Down
2 changes: 1 addition & 1 deletion tests/metadata_parser_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* @copyright Copyright (c) 2017 Blackboard Inc. (http://www.blackboard.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class auth_saml2_metadata_parser_testcase extends \core_phpunit\testcase {
class auth_saml2_metadata_parser_test extends \core_phpunit\testcase {

public function test_parse_metadata() {
$xml = file_get_contents(__DIR__ . '/fixtures/metadata.xml');
Expand Down
3 changes: 2 additions & 1 deletion tests/metadata_refresh_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* @copyright Copyright (c) 2017 Blackboard Inc. (http://www.blackboard.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class auth_saml2_metadata_refresh_testcase extends \core_phpunit\testcase {
class auth_saml2_metadata_refresh_test extends \core_phpunit\testcase {

/** @var \Prophecy\Prophet */
protected $prophet;
Expand All @@ -52,6 +52,7 @@ public function setUp(): void {
*/
protected function tearDown(): void {
$this->prophet = null; // Required for Totara 12+ support (see issue #578).
parent::tearDown();
}

public function test_metadata_refresh_disabled() {
Expand Down
2 changes: 1 addition & 1 deletion tests/metadata_writer_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* @copyright Copyright (c) 2017 Blackboard Inc. (http://www.blackboard.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class auth_saml2_metadata_writer_testcase extends \core_phpunit\testcase {
class auth_saml2_metadata_writer_test extends \core_phpunit\testcase {

public function test_write_default_path() {
global $CFG;
Expand Down
2 changes: 1 addition & 1 deletion tests/redis_store_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* @copyright Copyright (c) 2017 Blackboard Inc. (http://www.blackboard.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class auth_saml2_redis_store_testcase extends \core_phpunit\testcase {
class auth_saml2_redis_store_test extends \core_phpunit\testcase {

/**
* @var null|\Redis
Expand Down
2 changes: 1 addition & 1 deletion tests/simplesamlphp_upgrade_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* @package auth_saml2
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class auth_saml2_simplesamlphp_upgrade_testcase extends \core_phpunit\testcase {
class auth_saml2_simplesamlphp_upgrade_test extends \core_phpunit\testcase {

/**
* Test to ensure that composer files are removed from compiled extlib/simplesamlphp.
Expand Down
2 changes: 1 addition & 1 deletion tests/ssl_algorithm_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* @copyright Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class auth_saml2_ssl_algorithms_test extends \core_phpunit\testcase {
class auth_saml2_ssl_algorithm_test extends \core_phpunit\testcase {
public function test_default_saml_signature_algorithm_is_valid_saml_signature_algorithm() {
$this->assertTrue(array_key_exists(ssl_algorithms::get_default_saml_signature_algorithm(),
ssl_algorithms::get_valid_saml_signature_algorithms()));
Expand Down
4 changes: 2 additions & 2 deletions tests/user_fields_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public function test_get_supported_fields_with_profile_fields() {
* Test data for self::test_is_custom_profile_field().
* @return array
*/
public function is_custom_profile_field_data_provider(): array {
public static function is_custom_profile_field_data_provider(): array {
return [
['profile_field_test', true],
['profiletest', false],
Expand Down Expand Up @@ -159,7 +159,7 @@ public function test_is_custom_profile_field($value, bool $expected) {
* Test data for self::test_get_short_name().
* @return array
*/
public function get_short_name_data_provider(): array {
public static function get_short_name_data_provider(): array {
return [
['profile_field_test', 'test'],
['profile_field_profile_field_test', 'profile_field_test'],
Expand Down
Loading