-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(users): Store and load a user's manager
Co-Authored-By: hamza221 <[email protected]> Signed-off-by: Christoph Wurst <[email protected]>
- Loading branch information
1 parent
1399c88
commit 1381c4c
Showing
19 changed files
with
270 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* @copyright Copyright (c) 2016, ownCloud, Inc. | ||
* | ||
|
@@ -33,18 +36,22 @@ | |
use OCP\Accounts\IAccountProperty; | ||
use OCP\IImage; | ||
use OCP\IUser; | ||
use OCP\IUserManager; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
use Test\TestCase; | ||
|
||
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 @@ public function testCreation($expectedVCard, $displayName = null, $eMailAddress | |
$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 @@ public function testCreation($expectedVCard, $displayName = null, $eMailAddress | |
} | ||
} | ||
|
||
public function testManagerProp(): void { | ||
$user = $this->getUserMock("user", "[email protected]", "[email protected]"); | ||
$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' => '[email protected]', | ||
'email' => '[email protected]', | ||
'x-managersname' => 'Manager', | ||
], | ||
$vCard->jsonSerialize() | ||
); | ||
} | ||
|
||
protected function compareData($expected, $data) { | ||
foreach ($expected as $key => $value) { | ||
$found = false; | ||
|
@@ -182,7 +212,7 @@ public function providesNewUsers() { | |
* @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); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.