/** * Test create_user_from_aaddata method. * * @dataProvider dataprovider_create_user_from_aaddata * @param array $aaddata The Azure AD user data to create the user from. * @param array $expecteduser The expected user data to be created. */ public function test_create_user_from_aaddata($aaddata, $expecteduser) { global $DB; $httpclient = new \local_o365\tests\mockhttpclient(); $apiclient = new \local_o365\rest\azuread($this->get_mock_token(), $httpclient); $apiclient->create_user_from_aaddata($aaddata); $userparams = ['auth' => 'oidc', 'username' => $aaddata['mail']]; $this->assertTrue($DB->record_exists('user', $userparams)); $createduser = $DB->get_record('user', $userparams); foreach ($expecteduser as $k => $v) { $this->assertEquals($v, $createduser->{$k}); } }