Skip to content

Commit

Permalink
Fix Moodle plugin CI errors in local_o365
Browse files Browse the repository at this point in the history
  • Loading branch information
weilai-irl committed Oct 24, 2024
1 parent 4265edf commit b0660bd
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions local/o365/tests/usersync_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use advanced_testcase;
use local_o365\feature\usersync\main;
use local_o365\oauth2\token;
use local_o365\rest\unified;
use local_o365\tests\mockhttpclient;

/**
Expand Down Expand Up @@ -107,7 +108,7 @@ protected function get_entra_id_userinfo($i = 0) {
'mail' => 'testuser' . $i . '@example.onmicrosoft.com',
'surname' => 'User' . $i,
'preferredLanguage' => ($i == 3) ? 'sa-IN' : 'en-US',
'useridentifier' => 'testuser' . $i . '@example.onmicrosoft.com',
'userPrincipalName' => 'testuser' . $i . '@example.onmicrosoft.com',
];
}

Expand All @@ -132,7 +133,7 @@ public static function dataprovider_create_user_from_entra_id_data(): array {
'givenName' => 'Test',
'mail' => '[email protected]',
'surname' => 'User1',
'useridentifier' => '[email protected]',
'userPrincipalName' => '[email protected]',
],
[
'auth' => 'oidc',
Expand Down Expand Up @@ -161,7 +162,7 @@ public static function dataprovider_create_user_from_entra_id_data(): array {
'givenName' => 'Test',
'mail' => '[email protected]',
'surname' => 'User2',
'useridentifier' => '[email protected]',
'userPrincipalName' => '[email protected]',
],
[
'auth' => 'oidc',
Expand Down Expand Up @@ -189,7 +190,7 @@ public static function dataprovider_create_user_from_entra_id_data(): array {
'givenName' => 'Test',
'mail' => '[email protected]',
'surname' => 'User3',
'useridentifier' => '[email protected]',
'userPrincipalName' => '[email protected]',
],
[
'auth' => 'oidc',
Expand All @@ -216,7 +217,7 @@ public static function dataprovider_create_user_from_entra_id_data(): array {
'givenName' => 'Test',
'mail' => '[email protected]',
'surname' => 'User4',
'useridentifier' => '[email protected]',
'userPrincipalName' => '[email protected]',
],
[
'auth' => 'oidc',
Expand Down Expand Up @@ -291,7 +292,7 @@ public function test_sync_users_create(): void {
'username' => 'testuser' . $i . '@example.onmicrosoft.com',
'userid' => $muser['id'],
'scope' => 'test',
'tokenresource' => \local_o365\rest\unified::get_tokenresource(),
'tokenresource' => unified::get_tokenresource(),
'token' => '000',
'expiry' => '9999999999',
'refreshtoken' => 'fsdfsdf' . $i,
Expand All @@ -311,7 +312,7 @@ public function test_sync_users_create(): void {
$httpclient = new mockhttpclient();
$httpclient->set_response($response);

$apiclient = new \local_o365\rest\unified($this->get_mock_token(), $httpclient);
$apiclient = new unified($this->get_mock_token(), $httpclient);
$usersync = new main($clientdata, $httpclient);
$users = $apiclient->get_users();
$usersync->sync_users($users);
Expand All @@ -321,6 +322,7 @@ public function test_sync_users_create(): void {

$createduser = ['auth' => 'oidc', 'username' => '[email protected]'];
$this->assertTrue($DB->record_exists('user', $createduser));

$createduser = $DB->get_record('user', $createduser);
$this->assertEquals('Test', $createduser->firstname);
$this->assertEquals('User3', $createduser->lastname);
Expand Down

0 comments on commit b0660bd

Please sign in to comment.