From b0660bd35a74c3ed21b48c6dd59b384aa802dd71 Mon Sep 17 00:00:00 2001 From: Lai Wei Date: Thu, 24 Oct 2024 10:13:31 +0100 Subject: [PATCH] Fix Moodle plugin CI errors in local_o365 --- local/o365/tests/usersync_test.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/local/o365/tests/usersync_test.php b/local/o365/tests/usersync_test.php index 8cf364d9e..becf21ba8 100644 --- a/local/o365/tests/usersync_test.php +++ b/local/o365/tests/usersync_test.php @@ -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; /** @@ -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', ]; } @@ -132,7 +133,7 @@ public static function dataprovider_create_user_from_entra_id_data(): array { 'givenName' => 'Test', 'mail' => 'testuser1@example.onmicrosoft.com', 'surname' => 'User1', - 'useridentifier' => 'testuser1@example.onmicrosoft.com', + 'userPrincipalName' => 'testuser1@example.onmicrosoft.com', ], [ 'auth' => 'oidc', @@ -161,7 +162,7 @@ public static function dataprovider_create_user_from_entra_id_data(): array { 'givenName' => 'Test', 'mail' => 'testuser2@example.onmicrosoft.com', 'surname' => 'User2', - 'useridentifier' => 'testuser2@example.onmicrosoft.com', + 'userPrincipalName' => 'testuser2@example.onmicrosoft.com', ], [ 'auth' => 'oidc', @@ -189,7 +190,7 @@ public static function dataprovider_create_user_from_entra_id_data(): array { 'givenName' => 'Test', 'mail' => 'testuser3@example.onmicrosoft.com', 'surname' => 'User3', - 'useridentifier' => 'testuser3@example.onmicrosoft.com', + 'userPrincipalName' => 'testuser3@example.onmicrosoft.com', ], [ 'auth' => 'oidc', @@ -216,7 +217,7 @@ public static function dataprovider_create_user_from_entra_id_data(): array { 'givenName' => 'Test', 'mail' => 'testuser4@example.onmicrosoft.com', 'surname' => 'User4', - 'useridentifier' => 'testuser4@example.onmicrosoft.com', + 'userPrincipalName' => 'testuser4@example.onmicrosoft.com', ], [ 'auth' => 'oidc', @@ -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, @@ -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); @@ -321,6 +322,7 @@ public function test_sync_users_create(): void { $createduser = ['auth' => 'oidc', 'username' => 'testuser3@example.onmicrosoft.com']; $this->assertTrue($DB->record_exists('user', $createduser)); + $createduser = $DB->get_record('user', $createduser); $this->assertEquals('Test', $createduser->firstname); $this->assertEquals('User3', $createduser->lastname);