mirror of
https://github.com/moodle/moodle.git
synced 2025-08-09 10:56:56 +02:00
MDL-83468 phpunit: Fix various tests after phpunit 10
This commit is contained in:
parent
b95a8c6ecc
commit
bc75ef8bbc
51 changed files with 717 additions and 659 deletions
|
@ -49,7 +49,7 @@ final class migration_claim_test extends \advanced_testcase {
|
|||
* Test instantiation and getters of the migration_claim.
|
||||
*
|
||||
* @dataProvider migration_claim_provider
|
||||
* @param array $migrationclaimdata the lti1p1 migration claim.
|
||||
* @param array $lti1p1migrationclaim the lti1p1 migration claim.
|
||||
* @param string $deploymentid string id of the tool deployment.
|
||||
* @param string $platform string url of the issuer.
|
||||
* @param string $clientid string id of the client.
|
||||
|
@ -60,7 +60,7 @@ final class migration_claim_test extends \advanced_testcase {
|
|||
* @covers ::__construct
|
||||
*/
|
||||
public function test_migration_claim(
|
||||
array $migrationclaimdata,
|
||||
array $lti1p1migrationclaim,
|
||||
string $deploymentid,
|
||||
string $platform,
|
||||
string $clientid,
|
||||
|
@ -79,7 +79,7 @@ final class migration_claim_test extends \advanced_testcase {
|
|||
$this->expectException($expected['exception']);
|
||||
$this->expectExceptionMessage($expected['exceptionmessage']);
|
||||
new migration_claim(
|
||||
$migrationclaimdata,
|
||||
$lti1p1migrationclaim,
|
||||
$deploymentid,
|
||||
$platform,
|
||||
$clientid,
|
||||
|
@ -89,7 +89,7 @@ final class migration_claim_test extends \advanced_testcase {
|
|||
);
|
||||
} else {
|
||||
$migrationclaim = new migration_claim(
|
||||
$migrationclaimdata,
|
||||
$lti1p1migrationclaim,
|
||||
$deploymentid,
|
||||
$platform,
|
||||
$clientid,
|
||||
|
|
|
@ -98,28 +98,28 @@ final class application_registration_repository_test extends \advanced_testcase
|
|||
*
|
||||
* @dataProvider save_data_provider
|
||||
* @covers ::save
|
||||
* @param array $regdata the registration data
|
||||
* @param array $registrationdata the registration data
|
||||
*/
|
||||
public function test_save_new(array $regdata): void {
|
||||
public function test_save_new(array $registrationdata): void {
|
||||
$this->resetAfterTest();
|
||||
|
||||
$reg = application_registration::create_draft($regdata['name'], $regdata['uniqueid']);
|
||||
if (isset($regdata['platformid'])) {
|
||||
$reg->set_platformid($regdata['platformid']);
|
||||
$reg = application_registration::create_draft($registrationdata['name'], $registrationdata['uniqueid']);
|
||||
if (isset($registrationdata['platformid'])) {
|
||||
$reg->set_platformid($registrationdata['platformid']);
|
||||
}
|
||||
if (isset($regdata['clientid'])) {
|
||||
$reg->set_clientid($regdata['clientid']);
|
||||
if (isset($registrationdata['clientid'])) {
|
||||
$reg->set_clientid($registrationdata['clientid']);
|
||||
}
|
||||
if (isset($regdata['authenticationrequesturl'])) {
|
||||
$reg->set_authenticationrequesturl($regdata['authenticationrequesturl']);
|
||||
if (isset($registrationdata['authenticationrequesturl'])) {
|
||||
$reg->set_authenticationrequesturl($registrationdata['authenticationrequesturl']);
|
||||
}
|
||||
if (isset($regdata['jwksurl'])) {
|
||||
$reg->set_jwksurl($regdata['jwksurl']);
|
||||
if (isset($registrationdata['jwksurl'])) {
|
||||
$reg->set_jwksurl($registrationdata['jwksurl']);
|
||||
}
|
||||
if (isset($regdata['accesstokenurl'])) {
|
||||
$reg->set_accesstokenurl($regdata['accesstokenurl']);
|
||||
if (isset($registrationdata['accesstokenurl'])) {
|
||||
$reg->set_accesstokenurl($registrationdata['accesstokenurl']);
|
||||
}
|
||||
if (!empty($regdata['setcomplete'])) {
|
||||
if (!empty($registrationdata['setcomplete'])) {
|
||||
$reg->complete_registration();
|
||||
}
|
||||
$repository = new application_registration_repository();
|
||||
|
|
|
@ -126,8 +126,8 @@ final class tool_launch_service_test extends \lti_advantage_testcase {
|
|||
public static function user_launch_provider(): array {
|
||||
return [
|
||||
'New tool: no legacy data, no migration claim sent' => [
|
||||
'legacy_data' => null,
|
||||
'launch_data' => [
|
||||
'legacydata' => null,
|
||||
'launchdata' => [
|
||||
'user' => self::get_mock_launch_users_with_ids(['1p3_1'])[0],
|
||||
'launch_migration_claim' => null,
|
||||
],
|
||||
|
@ -136,14 +136,14 @@ final class tool_launch_service_test extends \lti_advantage_testcase {
|
|||
]
|
||||
],
|
||||
'Migrated tool: Legacy data exists, no change in user_id so omitted from claim' => [
|
||||
'legacy_data' => [
|
||||
'legacydata' => [
|
||||
'consumer_key' => 'CONSUMER_1',
|
||||
'tools' => [
|
||||
['secret' => 'toolsecret1'],
|
||||
['secret' => 'toolsecret2'],
|
||||
]
|
||||
],
|
||||
'launch_data' => [
|
||||
'launchdata' => [
|
||||
'user' => self::get_mock_launch_users_with_ids(['1'])[0],
|
||||
'launch_migration_claim' => [
|
||||
'consumer_key' => 'CONSUMER_1',
|
||||
|
@ -159,14 +159,14 @@ final class tool_launch_service_test extends \lti_advantage_testcase {
|
|||
],
|
||||
|
||||
'Migrated tool: Legacy data exists, platform signs with different valid secret' => [
|
||||
'legacy_data' => [
|
||||
'legacydata' => [
|
||||
'consumer_key' => 'CONSUMER_1',
|
||||
'tools' => [
|
||||
['secret' => 'toolsecret1'],
|
||||
['secret' => 'toolsecret2'],
|
||||
]
|
||||
],
|
||||
'launch_data' => [
|
||||
'launchdata' => [
|
||||
'user' => self::get_mock_launch_users_with_ids(['1p3_1'])[0],
|
||||
'launch_migration_claim' => [
|
||||
'consumer_key' => 'CONSUMER_1',
|
||||
|
@ -181,14 +181,14 @@ final class tool_launch_service_test extends \lti_advantage_testcase {
|
|||
]
|
||||
],
|
||||
'Migrated tool: Legacy data exists, no migration claim sent' => [
|
||||
'legacy_data' => [
|
||||
'legacydata' => [
|
||||
'consumer_key' => 'CONSUMER_1',
|
||||
'tools' => [
|
||||
['secret' => 'toolsecret1'],
|
||||
['secret' => 'toolsecret2'],
|
||||
]
|
||||
],
|
||||
'launch_data' => [
|
||||
'launchdata' => [
|
||||
'user' => self::get_mock_launch_users_with_ids(['1p3_1'])[0],
|
||||
'launch_migration_claim' => null,
|
||||
],
|
||||
|
@ -197,14 +197,14 @@ final class tool_launch_service_test extends \lti_advantage_testcase {
|
|||
]
|
||||
],
|
||||
'Migrated tool: Legacy data exists, migration claim signature generated using invalid secret' => [
|
||||
'legacy_data' => [
|
||||
'legacydata' => [
|
||||
'consumer_key' => 'CONSUMER_1',
|
||||
'tools' => [
|
||||
['secret' => 'toolsecret1'],
|
||||
['secret' => 'toolsecret2'],
|
||||
]
|
||||
],
|
||||
'launch_data' => [
|
||||
'launchdata' => [
|
||||
'user' => self::get_mock_launch_users_with_ids(['1p3_1'])[0],
|
||||
'launch_migration_claim' => [
|
||||
'consumer_key' => 'CONSUMER_1',
|
||||
|
@ -221,14 +221,14 @@ final class tool_launch_service_test extends \lti_advantage_testcase {
|
|||
]
|
||||
],
|
||||
'Migrated tool: Legacy data exists, migration claim signature omitted' => [
|
||||
'legacy_data' => [
|
||||
'legacydata' => [
|
||||
'consumer_key' => 'CONSUMER_1',
|
||||
'tools' => [
|
||||
['secret' => 'toolsecret1'],
|
||||
['secret' => 'toolsecret2'],
|
||||
]
|
||||
],
|
||||
'launch_data' => [
|
||||
'launchdata' => [
|
||||
'user' => self::get_mock_launch_users_with_ids(['1p3_1'])[0],
|
||||
'launch_migration_claim' => [
|
||||
'consumer_key' => 'CONSUMER_1',
|
||||
|
@ -244,14 +244,14 @@ final class tool_launch_service_test extends \lti_advantage_testcase {
|
|||
]
|
||||
],
|
||||
'Migrated tool: Legacy data exists, migration claim missing oauth_consumer_key' => [
|
||||
'legacy_data' => [
|
||||
'legacydata' => [
|
||||
'consumer_key' => 'CONSUMER_1',
|
||||
'tools' => [
|
||||
['secret' => 'toolsecret1'],
|
||||
['secret' => 'toolsecret2'],
|
||||
]
|
||||
],
|
||||
'launch_data' => [
|
||||
'launchdata' => [
|
||||
'user' => self::get_mock_launch_users_with_ids(['1p3_1'])[0],
|
||||
'launch_migration_claim' => [
|
||||
'user_id' => 'user-id-123',
|
||||
|
|
|
@ -800,7 +800,7 @@ final class sync_members_test extends \lti_advantage_testcase {
|
|||
require_once($CFG->dirroot . '/auth/lti/auth.php');
|
||||
return [
|
||||
'Migrated tool, user ids changed, new and existing users present in sync' => [
|
||||
'legacy_data' => [
|
||||
'legacydata' => [
|
||||
'users' => [
|
||||
['user_id' => '1'],
|
||||
['user_id' => '2'],
|
||||
|
@ -811,8 +811,8 @@ final class sync_members_test extends \lti_advantage_testcase {
|
|||
['secret' => 'toolsecret2'],
|
||||
]
|
||||
],
|
||||
'resource_config' => null,
|
||||
'launch_data' => [
|
||||
'resourceconfig' => null,
|
||||
'launchdata' => [
|
||||
'user' => self::get_mock_launch_users_with_ids(['1p3_1'])[0],
|
||||
'launch_migration_claim' => [
|
||||
'consumer_key' => 'CONSUMER_1',
|
||||
|
@ -823,7 +823,7 @@ final class sync_members_test extends \lti_advantage_testcase {
|
|||
'resource_link_id' => '4b6fa'
|
||||
],
|
||||
],
|
||||
'sync_members_data' => [
|
||||
'syncmembers' => [
|
||||
self::get_mock_members_with_ids(['1p3_1'], ['1'])[0],
|
||||
self::get_mock_members_with_ids(['1p3_2'], ['2'])[0],
|
||||
self::get_mock_members_with_ids(['1p3_3'], ['3'])[0],
|
||||
|
@ -851,7 +851,7 @@ final class sync_members_test extends \lti_advantage_testcase {
|
|||
]
|
||||
],
|
||||
'Migrated tool, no change in user ids, new and existing users present in sync' => [
|
||||
'legacy_data' => [
|
||||
'legacydata' => [
|
||||
'users' => [
|
||||
['user_id' => '1'],
|
||||
['user_id' => '2'],
|
||||
|
@ -862,8 +862,8 @@ final class sync_members_test extends \lti_advantage_testcase {
|
|||
['secret' => 'toolsecret2'],
|
||||
]
|
||||
],
|
||||
'resource_config' => null,
|
||||
'launch_data' => [
|
||||
'resourceconfig' => null,
|
||||
'launchdata' => [
|
||||
'user' => self::get_mock_launch_users_with_ids(['1'])[0],
|
||||
'launch_migration_claim' => [
|
||||
'consumer_key' => 'CONSUMER_1',
|
||||
|
@ -873,7 +873,7 @@ final class sync_members_test extends \lti_advantage_testcase {
|
|||
'resource_link_id' => '4b6fa'
|
||||
],
|
||||
],
|
||||
'sync_members_data' => [
|
||||
'syncmembers' => [
|
||||
self::get_mock_members_with_ids(['1'], null)[0],
|
||||
self::get_mock_members_with_ids(['2'], null)[0],
|
||||
self::get_mock_members_with_ids(['3'], null)[0],
|
||||
|
@ -901,7 +901,7 @@ final class sync_members_test extends \lti_advantage_testcase {
|
|||
]
|
||||
],
|
||||
'New tool, no launch migration claim, change in user ids, new and existing users present in sync' => [
|
||||
'legacy_data' => [
|
||||
'legacydata' => [
|
||||
'users' => [
|
||||
['user_id' => '1'],
|
||||
['user_id' => '2'],
|
||||
|
@ -912,12 +912,12 @@ final class sync_members_test extends \lti_advantage_testcase {
|
|||
['secret' => 'toolsecret2'],
|
||||
]
|
||||
],
|
||||
'resource_config' => null,
|
||||
'launch_data' => [
|
||||
'resourceconfig' => null,
|
||||
'launchdata' => [
|
||||
'user' => self::get_mock_launch_users_with_ids(['1p3_1'])[0],
|
||||
'launch_migration_claim' => null,
|
||||
],
|
||||
'sync_members_data' => [
|
||||
'syncmembers' => [
|
||||
self::get_mock_members_with_ids(['1p3_1'], null)[0],
|
||||
self::get_mock_members_with_ids(['1p3_2'], null)[0],
|
||||
self::get_mock_members_with_ids(['1p3_3'], null)[0],
|
||||
|
@ -945,7 +945,7 @@ final class sync_members_test extends \lti_advantage_testcase {
|
|||
]
|
||||
],
|
||||
'New tool, no launch migration claim, no change in user ids, new and existing users present in sync' => [
|
||||
'legacy_data' => [
|
||||
'legacydata' => [
|
||||
'users' => [
|
||||
['user_id' => '1'],
|
||||
['user_id' => '2'],
|
||||
|
@ -956,12 +956,12 @@ final class sync_members_test extends \lti_advantage_testcase {
|
|||
['secret' => 'toolsecret2'],
|
||||
]
|
||||
],
|
||||
'resource_config' => null,
|
||||
'launch_data' => [
|
||||
'resourceconfig' => null,
|
||||
'launchdata' => [
|
||||
'user' => self::get_mock_launch_users_with_ids(['1'])[0],
|
||||
'launch_migration_claim' => null,
|
||||
],
|
||||
'sync_members_data' => [
|
||||
'syncmembers' => [
|
||||
self::get_mock_members_with_ids(['1'], null)[0],
|
||||
self::get_mock_members_with_ids(['2'], null)[0],
|
||||
self::get_mock_members_with_ids(['3'], null)[0],
|
||||
|
@ -989,7 +989,7 @@ final class sync_members_test extends \lti_advantage_testcase {
|
|||
]
|
||||
],
|
||||
'New tool, migration only via member sync, no launch claim, new and existing users present in sync' => [
|
||||
'legacy_data' => [
|
||||
'legacydata' => [
|
||||
'users' => [
|
||||
['user_id' => '1'],
|
||||
['user_id' => '2'],
|
||||
|
@ -1000,12 +1000,12 @@ final class sync_members_test extends \lti_advantage_testcase {
|
|||
['secret' => 'toolsecret2'],
|
||||
]
|
||||
],
|
||||
'resource_config' => null,
|
||||
'launch_data' => [
|
||||
'resourceconfig' => null,
|
||||
'launchdata' => [
|
||||
'user' => self::get_mock_launch_users_with_ids(['1p3_1'])[0],
|
||||
'launch_migration_claim' => null,
|
||||
],
|
||||
'sync_members_data' => [
|
||||
'syncmembers' => [
|
||||
self::get_mock_members_with_ids(['1p3_1'], ['1'])[0],
|
||||
self::get_mock_members_with_ids(['1p3_2'], ['2'])[0],
|
||||
self::get_mock_members_with_ids(['1p3_3'], ['3'])[0],
|
||||
|
@ -1033,16 +1033,16 @@ final class sync_members_test extends \lti_advantage_testcase {
|
|||
]
|
||||
],
|
||||
'Default provisioning modes, mixed bag of users and roles' => [
|
||||
'legacy_data' => null,
|
||||
'resource_config' => [
|
||||
'legacydata' => null,
|
||||
'resourceconfig' => [
|
||||
'provisioningmodelearner' => \auth_plugin_lti::PROVISIONING_MODE_AUTO_ONLY,
|
||||
'provisioningmodeinstructor' => \auth_plugin_lti::PROVISIONING_MODE_PROMPT_NEW_EXISTING
|
||||
],
|
||||
'launch_data' => [
|
||||
'launchdata' => [
|
||||
'user' => self::get_mock_launch_users_with_ids(['1p3_1'])[0],
|
||||
'launch_migration_claim' => null,
|
||||
],
|
||||
'sync_members_data' => [
|
||||
'syncmembers' => [
|
||||
// This user is just an instructor but is also the user who is already linked, via the launch above.
|
||||
self::get_mock_members_with_ids(['1p3_1'], null, true, true, true, false, [
|
||||
'http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor',
|
||||
|
@ -1083,16 +1083,16 @@ final class sync_members_test extends \lti_advantage_testcase {
|
|||
]
|
||||
],
|
||||
'All automatic provisioning, mixed bag of users and roles' => [
|
||||
'legacy_data' => null,
|
||||
'resource_config' => [
|
||||
'legacydata' => null,
|
||||
'resourceconfig' => [
|
||||
'provisioningmodelearner' => \auth_plugin_lti::PROVISIONING_MODE_AUTO_ONLY,
|
||||
'provisioningmodeinstructor' => \auth_plugin_lti::PROVISIONING_MODE_AUTO_ONLY
|
||||
],
|
||||
'launch_data' => [
|
||||
'launchdata' => [
|
||||
'user' => self::get_mock_launch_users_with_ids(['1p3_1'])[0],
|
||||
'launch_migration_claim' => null,
|
||||
],
|
||||
'sync_members_data' => [
|
||||
'syncmembers' => [
|
||||
// This user is just an instructor but is also the user who is already linked, via the launch above.
|
||||
self::get_mock_members_with_ids(['1p3_1'], null, true, true, true, false, [
|
||||
'http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor',
|
||||
|
@ -1133,16 +1133,16 @@ final class sync_members_test extends \lti_advantage_testcase {
|
|||
]
|
||||
],
|
||||
'All prompt provisioning, mixed bag of users and roles' => [
|
||||
'legacy_data' => null,
|
||||
'resource_config' => [
|
||||
'legacydata' => null,
|
||||
'resourceconfig' => [
|
||||
'provisioningmodelearner' => \auth_plugin_lti::PROVISIONING_MODE_PROMPT_NEW_EXISTING,
|
||||
'provisioningmodeinstructor' => \auth_plugin_lti::PROVISIONING_MODE_PROMPT_NEW_EXISTING
|
||||
],
|
||||
'launch_data' => [
|
||||
'launchdata' => [
|
||||
'user' => self::get_mock_launch_users_with_ids(['1p3_1'])[0],
|
||||
'launch_migration_claim' => null,
|
||||
],
|
||||
'sync_members_data' => [
|
||||
'syncmembers' => [
|
||||
// This user is just an instructor but is also the user who is already linked, via the launch above.
|
||||
self::get_mock_members_with_ids(['1p3_1'], null, true, true, true, false, [
|
||||
'http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor',
|
||||
|
@ -1183,7 +1183,7 @@ final class sync_members_test extends \lti_advantage_testcase {
|
|||
]
|
||||
],
|
||||
'All automatic provisioning, with legacy data and migration claim, mixed bag of users and roles' => [
|
||||
'legacy_data' => [
|
||||
'legacydata' => [
|
||||
'users' => [
|
||||
['user_id' => '2'],
|
||||
['user_id' => '3'],
|
||||
|
@ -1196,11 +1196,11 @@ final class sync_members_test extends \lti_advantage_testcase {
|
|||
['secret' => 'toolsecret2'],
|
||||
]
|
||||
],
|
||||
'resource_config' => [
|
||||
'resourceconfig' => [
|
||||
'provisioningmodelearner' => \auth_plugin_lti::PROVISIONING_MODE_AUTO_ONLY,
|
||||
'provisioningmodeinstructor' => \auth_plugin_lti::PROVISIONING_MODE_AUTO_ONLY
|
||||
],
|
||||
'launch_data' => [
|
||||
'launchdata' => [
|
||||
'user' => self::get_mock_launch_users_with_ids(['1p3_1'])[0],
|
||||
'launch_migration_claim' => [
|
||||
'consumer_key' => 'CONSUMER_1',
|
||||
|
@ -1210,7 +1210,7 @@ final class sync_members_test extends \lti_advantage_testcase {
|
|||
'resource_link_id' => '4b6fa'
|
||||
],
|
||||
],
|
||||
'sync_members_data' => [
|
||||
'syncmembers' => [
|
||||
// This user is just an instructor but is also the user who is already linked, via the launch above.
|
||||
self::get_mock_members_with_ids(['1p3_1'], null, true, true, true, false, [
|
||||
'http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue