diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2023-05-02 08:59:46 +0200 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2023-05-12 13:56:48 +0200 |
commit | 1381c4c157f3174917c994038ab74074a42a2aa8 (patch) | |
tree | fe70c5181a99330f4f3292ca217b386a2c6ff354 /apps/dav/tests | |
parent | 1399c88ee178d9fd60f3e9356f1d8c498c6c97e1 (diff) | |
download | nextcloud-server-1381c4c157f3174917c994038ab74074a42a2aa8.tar.gz nextcloud-server-1381c4c157f3174917c994038ab74074a42a2aa8.zip |
feat(users): Store and load a user's manager
Co-Authored-By: hamza221 <hamzamahjoubi221@gmail.com>
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'apps/dav/tests')
-rw-r--r-- | apps/dav/tests/unit/CardDAV/ConverterTest.php | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/apps/dav/tests/unit/CardDAV/ConverterTest.php b/apps/dav/tests/unit/CardDAV/ConverterTest.php index f4ef0332c6e..6b589ec3874 100644 --- a/apps/dav/tests/unit/CardDAV/ConverterTest.php +++ b/apps/dav/tests/unit/CardDAV/ConverterTest.php @@ -1,4 +1,7 @@ <?php + +declare(strict_types=1); + /** * @copyright Copyright (c) 2016, ownCloud, Inc. * @@ -33,6 +36,7 @@ use OCP\Accounts\IAccountManager; use OCP\Accounts\IAccountProperty; use OCP\IImage; use OCP\IUser; +use OCP\IUserManager; use PHPUnit\Framework\MockObject\MockObject; use Test\TestCase; @@ -40,11 +44,14 @@ class ConverterTest extends TestCase { /** @var IAccountManager|\PHPUnit\Framework\MockObject\MockObject */ private $accountManager; + /** @var IUserManager|(IUserManager&MockObject)|MockObject */ + private IUserManager|MockObject $userManager; protected function setUp(): void { parent::setUp(); $this->accountManager = $this->createMock(IAccountManager::class); + $this->userManager = $this->createMock(IUserManager::class); } /** @@ -96,7 +103,7 @@ class ConverterTest extends TestCase { $user = $this->getUserMock((string)$displayName, $eMailAddress, $cloudId); $accountManager = $this->getAccountManager($user); - $converter = new Converter($accountManager); + $converter = new Converter($accountManager, $this->userManager); $vCard = $converter->createCardFromUser($user); if ($expectedVCard !== null) { $this->assertInstanceOf('Sabre\VObject\Component\VCard', $vCard); @@ -107,6 +114,29 @@ class ConverterTest extends TestCase { } } + public function testManagerProp(): void { + $user = $this->getUserMock("user", "user@domain.tld", "user@cloud.domain.tld"); + $user->method('getManagerUids') + ->willReturn(['mgr']); + $this->userManager->expects(self::once()) + ->method('getDisplayName') + ->with('mgr') + ->willReturn('Manager'); + $accountManager = $this->getAccountManager($user); + + $converter = new Converter($accountManager, $this->userManager); + $vCard = $converter->createCardFromUser($user); + + $this->compareData( + [ + 'cloud' => 'user@cloud.domain.tld', + 'email' => 'user@domain.tld', + 'x-managersname' => 'Manager', + ], + $vCard->jsonSerialize() + ); + } + protected function compareData($expected, $data) { foreach ($expected as $key => $value) { $found = false; @@ -182,7 +212,7 @@ class ConverterTest extends TestCase { * @param $fullName */ public function testNameSplitter($expected, $fullName): void { - $converter = new Converter($this->accountManager); + $converter = new Converter($this->accountManager, $this->userManager); $r = $converter->splitFullName($fullName); $r = implode(';', $r); $this->assertEquals($expected, $r); |