diff options
Diffstat (limited to 'apps/provisioning_api/tests')
-rw-r--r-- | apps/provisioning_api/tests/Controller/UsersControllerTest.php | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php index 4754c5a468d..d4c2faba98b 100644 --- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php +++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php @@ -66,6 +66,8 @@ use OCP\L10N\IFactory; use OCP\Mail\IEMailTemplate; use OCP\Security\Events\GenerateSecurePasswordEvent; use OCP\Security\ISecureRandom; +use OCP\User\Backend\IGetDisplayNameBackend; +use OCP\User\Backend\ISetDisplayNameBackend; use OCP\UserInterface; use PHPUnit\Framework\MockObject\MockObject; use Psr\Log\LoggerInterface; @@ -1446,6 +1448,10 @@ class UsersControllerTest extends TestCase { ->willReturn($targetUser); $targetUser ->expects($this->once()) + ->method('getBackend') + ->willReturn($this->createMock(ISetDisplayNameBackend::class)); + $targetUser + ->expects($this->once()) ->method('setDisplayName') ->with('NewDisplayName'); $targetUser @@ -3717,20 +3723,27 @@ class UsersControllerTest extends TestCase { public function dataGetEditableFields() { return [ - [false, [ + [false, ISetDisplayNameBackend::class, [ IAccountManager::PROPERTY_PHONE, IAccountManager::PROPERTY_ADDRESS, IAccountManager::PROPERTY_WEBSITE, IAccountManager::PROPERTY_TWITTER, ]], - [ true, [ + [true, ISetDisplayNameBackend::class, [ IAccountManager::PROPERTY_DISPLAYNAME, IAccountManager::PROPERTY_EMAIL, IAccountManager::PROPERTY_PHONE, IAccountManager::PROPERTY_ADDRESS, IAccountManager::PROPERTY_WEBSITE, IAccountManager::PROPERTY_TWITTER, - ]] + ]], + [true, IGetDisplayNameBackend::class, [ + IAccountManager::PROPERTY_EMAIL, + IAccountManager::PROPERTY_PHONE, + IAccountManager::PROPERTY_ADDRESS, + IAccountManager::PROPERTY_WEBSITE, + IAccountManager::PROPERTY_TWITTER, + ]], ]; } @@ -3738,9 +3751,10 @@ class UsersControllerTest extends TestCase { * @dataProvider dataGetEditableFields * * @param bool $allowedToChangeDisplayName + * @param string $userBackend * @param array $expected */ - public function testGetEditableFields(bool $allowedToChangeDisplayName, array $expected) { + public function testGetEditableFields(bool $allowedToChangeDisplayName, string $userBackend, array $expected) { $this->config ->method('getSystemValue') ->with( @@ -3748,8 +3762,19 @@ class UsersControllerTest extends TestCase { $this->anything() )->willReturn($allowedToChangeDisplayName); + $user = $this->createMock(IUser::class); + $this->userSession->method('getUser') + ->willReturn($user); + + $backend = $this->createMock($userBackend); + + $user->method('getUID') + ->willReturn('userId'); + $user->method('getBackend') + ->willReturn($backend); + $expectedResp = new DataResponse($expected); - $this->assertEquals($expectedResp, $this->api->getEditableFields()); + $this->assertEquals($expectedResp, $this->api->getEditableFields('userId')); } private function mockAccount($targetUser, $accountProperties) { |