diff options
author | Joas Schilling <coding@schilljs.com> | 2020-12-01 14:33:22 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2020-12-07 14:19:37 +0100 |
commit | da9462b482c77b71d6623be43a6aa1eda3d7cc06 (patch) | |
tree | fe78e9c97f50180140fb222a8a0c41c3fcd8ddd8 /apps/settings | |
parent | eab710c2fd6febbf946be3ce8376fb386b61ee90 (diff) | |
download | nextcloud-server-da9462b482c77b71d6623be43a6aa1eda3d7cc06.tar.gz nextcloud-server-da9462b482c77b71d6623be43a6aa1eda3d7cc06.zip |
Make code strict
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/settings')
4 files changed, 130 insertions, 135 deletions
diff --git a/apps/settings/lib/BackgroundJobs/VerifyUserData.php b/apps/settings/lib/BackgroundJobs/VerifyUserData.php index 0faa9b56e82..d1b6d835fa4 100644 --- a/apps/settings/lib/BackgroundJobs/VerifyUserData.php +++ b/apps/settings/lib/BackgroundJobs/VerifyUserData.php @@ -30,6 +30,7 @@ namespace OCA\Settings\BackgroundJobs; use OC\Accounts\AccountManager; +use OCP\Accounts\IAccountManager; use OCP\AppFramework\Http; use OCP\BackgroundJob\IJobList; use OCP\BackgroundJob\Job; @@ -114,11 +115,11 @@ class VerifyUserData extends Job { $try = (int)$argument['try'] + 1; switch ($argument['type']) { - case AccountManager::PROPERTY_WEBSITE: + case IAccountManager::PROPERTY_WEBSITE: $result = $this->verifyWebsite($argument); break; - case AccountManager::PROPERTY_TWITTER: - case AccountManager::PROPERTY_EMAIL: + case IAccountManager::PROPERTY_TWITTER: + case IAccountManager::PROPERTY_EMAIL: $result = $this->verifyViaLookupServer($argument, $argument['type']); break; default: @@ -164,9 +165,9 @@ class VerifyUserData extends Job { $userData = $this->accountManager->getUser($user); if ($publishedCodeSanitized === $argument['verificationCode']) { - $userData[AccountManager::PROPERTY_WEBSITE]['verified'] = AccountManager::VERIFIED; + $userData[IAccountManager::PROPERTY_WEBSITE]['verified'] = AccountManager::VERIFIED; } else { - $userData[AccountManager::PROPERTY_WEBSITE]['verified'] = AccountManager::NOT_VERIFIED; + $userData[IAccountManager::PROPERTY_WEBSITE]['verified'] = AccountManager::NOT_VERIFIED; } $this->accountManager->updateUser($user, $userData); diff --git a/apps/settings/lib/Controller/UsersController.php b/apps/settings/lib/Controller/UsersController.php index cad21c5f3b3..e540698c485 100644 --- a/apps/settings/lib/Controller/UsersController.php +++ b/apps/settings/lib/Controller/UsersController.php @@ -1,4 +1,6 @@ <?php + +declare(strict_types=1); /** * @copyright Copyright (c) 2016, ownCloud, Inc. * @@ -30,7 +32,6 @@ // FIXME: disabled for now to be able to inject IGroupManager and also use // getSubAdmin() -//declare(strict_types=1); namespace OCA\Settings\Controller; @@ -46,6 +47,7 @@ use OCA\FederatedFileSharing\FederatedShareProvider; use OCA\Settings\BackgroundJobs\VerifyUserData; use OCA\Settings\Events\BeforeTemplateRenderedEvent; use OCA\User_LDAP\User_Proxy; +use OCP\Accounts\IAccountManager; use OCP\App\IAppManager; use OCP\AppFramework\Controller; use OCP\AppFramework\Http\DataResponse; @@ -140,7 +142,7 @@ class UsersController extends Controller { * * @return TemplateResponse */ - public function usersListByGroup() { + public function usersListByGroup(): TemplateResponse { return $this->usersList(); } @@ -152,7 +154,7 @@ class UsersController extends Controller { * * @return TemplateResponse */ - public function usersList() { + public function usersList(): TemplateResponse { $user = $this->userSession->getUser(); $uid = $user->getUID(); @@ -309,7 +311,7 @@ class UsersController extends Controller { * * @return bool */ - protected function canAdminChangeUserPasswords() { + protected function canAdminChangeUserPasswords(): bool { $isEncryptionEnabled = $this->encryptionManager->isEnabled(); try { $noUserSpecificEncryptionKeys = !$this->encryptionManager->getEncryptionModule()->needDetailedAccessList(); @@ -344,19 +346,19 @@ class UsersController extends Controller { * @param string $twitterScope * @return DataResponse */ - public function setUserSettings($avatarScope, - $displayname, - $displaynameScope, - $phone, - $phoneScope, - $email, - $emailScope, - $website, - $websiteScope, - $address, - $addressScope, - $twitter, - $twitterScope + public function setUserSettings(string $avatarScope, + string $displayname, + string $displaynameScope, + string $phone, + string $phoneScope, + string $email, + string $emailScope, + string $website, + string $websiteScope, + string $address, + string $addressScope, + string $twitter, + string $twitterScope ) { $email = strtolower($email); if (!empty($email) && !$this->mailer->validateMailAddress($email)) { @@ -372,18 +374,18 @@ class UsersController extends Controller { } $user = $this->userSession->getUser(); $data = $this->accountManager->getUser($user); - $data[AccountManager::PROPERTY_AVATAR] = ['scope' => $avatarScope]; + $data[IAccountManager::PROPERTY_AVATAR] = ['scope' => $avatarScope]; if ($this->config->getSystemValue('allow_user_to_change_display_name', true) !== false) { - $data[AccountManager::PROPERTY_DISPLAYNAME] = ['value' => $displayname, 'scope' => $displaynameScope]; - $data[AccountManager::PROPERTY_EMAIL] = ['value' => $email, 'scope' => $emailScope]; + $data[IAccountManager::PROPERTY_DISPLAYNAME] = ['value' => $displayname, 'scope' => $displaynameScope]; + $data[IAccountManager::PROPERTY_EMAIL] = ['value' => $email, 'scope' => $emailScope]; } if ($this->appManager->isEnabledForUser('federatedfilesharing')) { $shareProvider = \OC::$server->query(FederatedShareProvider::class); if ($shareProvider->isLookupServerUploadEnabled()) { - $data[AccountManager::PROPERTY_WEBSITE] = ['value' => $website, 'scope' => $websiteScope]; - $data[AccountManager::PROPERTY_ADDRESS] = ['value' => $address, 'scope' => $addressScope]; - $data[AccountManager::PROPERTY_PHONE] = ['value' => $phone, 'scope' => $phoneScope]; - $data[AccountManager::PROPERTY_TWITTER] = ['value' => $twitter, 'scope' => $twitterScope]; + $data[IAccountManager::PROPERTY_WEBSITE] = ['value' => $website, 'scope' => $websiteScope]; + $data[IAccountManager::PROPERTY_ADDRESS] = ['value' => $address, 'scope' => $addressScope]; + $data[IAccountManager::PROPERTY_PHONE] = ['value' => $phone, 'scope' => $phoneScope]; + $data[IAccountManager::PROPERTY_TWITTER] = ['value' => $twitter, 'scope' => $twitterScope]; } } try { @@ -393,15 +395,15 @@ class UsersController extends Controller { 'status' => 'success', 'data' => [ 'userId' => $user->getUID(), - 'avatarScope' => $data[AccountManager::PROPERTY_AVATAR]['scope'], - 'displayname' => $data[AccountManager::PROPERTY_DISPLAYNAME]['value'], - 'displaynameScope' => $data[AccountManager::PROPERTY_DISPLAYNAME]['scope'], - 'email' => $data[AccountManager::PROPERTY_EMAIL]['value'], - 'emailScope' => $data[AccountManager::PROPERTY_EMAIL]['scope'], - 'website' => $data[AccountManager::PROPERTY_WEBSITE]['value'], - 'websiteScope' => $data[AccountManager::PROPERTY_WEBSITE]['scope'], - 'address' => $data[AccountManager::PROPERTY_ADDRESS]['value'], - 'addressScope' => $data[AccountManager::PROPERTY_ADDRESS]['scope'], + 'avatarScope' => $data[IAccountManager::PROPERTY_AVATAR]['scope'], + 'displayname' => $data[IAccountManager::PROPERTY_DISPLAYNAME]['value'], + 'displaynameScope' => $data[IAccountManager::PROPERTY_DISPLAYNAME]['scope'], + 'email' => $data[IAccountManager::PROPERTY_EMAIL]['value'], + 'emailScope' => $data[IAccountManager::PROPERTY_EMAIL]['scope'], + 'website' => $data[IAccountManager::PROPERTY_WEBSITE]['value'], + 'websiteScope' => $data[IAccountManager::PROPERTY_WEBSITE]['scope'], + 'address' => $data[IAccountManager::PROPERTY_ADDRESS]['value'], + 'addressScope' => $data[IAccountManager::PROPERTY_ADDRESS]['scope'], 'message' => $this->l10n->t('Settings saved') ] ], @@ -423,30 +425,30 @@ class UsersController extends Controller { * @param array $data * @throws ForbiddenException */ - protected function saveUserSettings(IUser $user, array $data) { + protected function saveUserSettings(IUser $user, array $data): void { // keep the user back-end up-to-date with the latest display name and email // address $oldDisplayName = $user->getDisplayName(); $oldDisplayName = is_null($oldDisplayName) ? '' : $oldDisplayName; - if (isset($data[AccountManager::PROPERTY_DISPLAYNAME]['value']) - && $oldDisplayName !== $data[AccountManager::PROPERTY_DISPLAYNAME]['value'] + if (isset($data[IAccountManager::PROPERTY_DISPLAYNAME]['value']) + && $oldDisplayName !== $data[IAccountManager::PROPERTY_DISPLAYNAME]['value'] ) { - $result = $user->setDisplayName($data[AccountManager::PROPERTY_DISPLAYNAME]['value']); + $result = $user->setDisplayName($data[IAccountManager::PROPERTY_DISPLAYNAME]['value']); if ($result === false) { throw new ForbiddenException($this->l10n->t('Unable to change full name')); } } $oldEmailAddress = $user->getEMailAddress(); $oldEmailAddress = is_null($oldEmailAddress) ? '' : strtolower($oldEmailAddress); - if (isset($data[AccountManager::PROPERTY_EMAIL]['value']) - && $oldEmailAddress !== $data[AccountManager::PROPERTY_EMAIL]['value'] + if (isset($data[IAccountManager::PROPERTY_EMAIL]['value']) + && $oldEmailAddress !== $data[IAccountManager::PROPERTY_EMAIL]['value'] ) { // this is the only permission a backend provides and is also used // for the permission of setting a email address if (!$user->canChangeDisplayName()) { throw new ForbiddenException($this->l10n->t('Unable to change email address')); } - $user->setEMailAddress($data[AccountManager::PROPERTY_EMAIL]['value']); + $user->setEMailAddress($data[IAccountManager::PROPERTY_EMAIL]['value']); } $this->accountManager->updateUser($user, $data); } @@ -479,19 +481,19 @@ class UsersController extends Controller { switch ($account) { case 'verify-twitter': - $accountData[AccountManager::PROPERTY_TWITTER]['verified'] = AccountManager::VERIFICATION_IN_PROGRESS; + $accountData[IAccountManager::PROPERTY_TWITTER]['verified'] = AccountManager::VERIFICATION_IN_PROGRESS; $msg = $this->l10n->t('In order to verify your Twitter account, post the following tweet on Twitter (please make sure to post it without any line breaks):'); $code = $codeMd5; - $type = AccountManager::PROPERTY_TWITTER; - $data = $accountData[AccountManager::PROPERTY_TWITTER]['value']; - $accountData[AccountManager::PROPERTY_TWITTER]['signature'] = $signature; + $type = IAccountManager::PROPERTY_TWITTER; + $data = $accountData[IAccountManager::PROPERTY_TWITTER]['value']; + $accountData[IAccountManager::PROPERTY_TWITTER]['signature'] = $signature; break; case 'verify-website': - $accountData[AccountManager::PROPERTY_WEBSITE]['verified'] = AccountManager::VERIFICATION_IN_PROGRESS; + $accountData[IAccountManager::PROPERTY_WEBSITE]['verified'] = AccountManager::VERIFICATION_IN_PROGRESS; $msg = $this->l10n->t('In order to verify your Website, store the following content in your web-root at \'.well-known/CloudIdVerificationCode.txt\' (please make sure that the complete text is in one line):'); - $type = AccountManager::PROPERTY_WEBSITE; - $data = $accountData[AccountManager::PROPERTY_WEBSITE]['value']; - $accountData[AccountManager::PROPERTY_WEBSITE]['signature'] = $signature; + $type = IAccountManager::PROPERTY_WEBSITE; + $data = $accountData[IAccountManager::PROPERTY_WEBSITE]['value']; + $accountData[IAccountManager::PROPERTY_WEBSITE]['signature'] = $signature; break; default: return new DataResponse([], Http::STATUS_BAD_REQUEST); diff --git a/apps/settings/lib/Settings/Personal/PersonalInfo.php b/apps/settings/lib/Settings/Personal/PersonalInfo.php index 06ea440afab..d9f9c2b3a7d 100644 --- a/apps/settings/lib/Settings/Personal/PersonalInfo.php +++ b/apps/settings/lib/Settings/Personal/PersonalInfo.php @@ -1,4 +1,6 @@ <?php + +declare(strict_types=1); /** * @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de> * @@ -33,6 +35,7 @@ namespace OCA\Settings\Settings\Personal; use OC\Accounts\AccountManager; use OCA\FederatedFileSharing\FederatedShareProvider; +use OCP\Accounts\IAccountManager; use OCP\App\IAppManager; use OCP\AppFramework\Http\TemplateResponse; use OCP\Files\FileInfo; @@ -62,14 +65,6 @@ class PersonalInfo implements ISettings { /** @var IL10N */ private $l; - /** - * @param IConfig $config - * @param IUserManager $userManager - * @param IGroupManager $groupManager - * @param AccountManager $accountManager - * @param IFactory $l10nFactory - * @param IL10N $l - */ public function __construct( IConfig $config, IUserManager $userManager, @@ -88,11 +83,7 @@ class PersonalInfo implements ISettings { $this->l = $l; } - /** - * @return TemplateResponse returns the instance with all parameters set, ready to be rendered - * @since 9.1 - */ - public function getForm() { + public function getForm(): TemplateResponse { $federatedFileSharingEnabled = $this->appManager->isEnabledForUser('federatedfilesharing'); $lookupServerUploadEnabled = false; if ($federatedFileSharingEnabled) { @@ -126,23 +117,23 @@ class PersonalInfo implements ISettings { 'quota' => $storageInfo['quota'], 'avatarChangeSupported' => $user->canChangeAvatar(), 'lookupServerUploadEnabled' => $lookupServerUploadEnabled, - 'avatarScope' => $userData[AccountManager::PROPERTY_AVATAR]['scope'], + 'avatarScope' => $userData[IAccountManager::PROPERTY_AVATAR]['scope'], 'displayNameChangeSupported' => $user->canChangeDisplayName(), - 'displayName' => $userData[AccountManager::PROPERTY_DISPLAYNAME]['value'], - 'displayNameScope' => $userData[AccountManager::PROPERTY_DISPLAYNAME]['scope'], - 'email' => $userData[AccountManager::PROPERTY_EMAIL]['value'], - 'emailScope' => $userData[AccountManager::PROPERTY_EMAIL]['scope'], - 'emailVerification' => $userData[AccountManager::PROPERTY_EMAIL]['verified'], - 'phone' => $userData[AccountManager::PROPERTY_PHONE]['value'], - 'phoneScope' => $userData[AccountManager::PROPERTY_PHONE]['scope'], - 'address' => $userData[AccountManager::PROPERTY_ADDRESS]['value'], - 'addressScope' => $userData[AccountManager::PROPERTY_ADDRESS]['scope'], - 'website' => $userData[AccountManager::PROPERTY_WEBSITE]['value'], - 'websiteScope' => $userData[AccountManager::PROPERTY_WEBSITE]['scope'], - 'websiteVerification' => $userData[AccountManager::PROPERTY_WEBSITE]['verified'], - 'twitter' => $userData[AccountManager::PROPERTY_TWITTER]['value'], - 'twitterScope' => $userData[AccountManager::PROPERTY_TWITTER]['scope'], - 'twitterVerification' => $userData[AccountManager::PROPERTY_TWITTER]['verified'], + 'displayName' => $userData[IAccountManager::PROPERTY_DISPLAYNAME]['value'], + 'displayNameScope' => $userData[IAccountManager::PROPERTY_DISPLAYNAME]['scope'], + 'email' => $userData[IAccountManager::PROPERTY_EMAIL]['value'], + 'emailScope' => $userData[IAccountManager::PROPERTY_EMAIL]['scope'], + 'emailVerification' => $userData[IAccountManager::PROPERTY_EMAIL]['verified'], + 'phone' => $userData[IAccountManager::PROPERTY_PHONE]['value'], + 'phoneScope' => $userData[IAccountManager::PROPERTY_PHONE]['scope'], + 'address' => $userData[IAccountManager::PROPERTY_ADDRESS]['value'], + 'addressScope' => $userData[IAccountManager::PROPERTY_ADDRESS]['scope'], + 'website' => $userData[IAccountManager::PROPERTY_WEBSITE]['value'], + 'websiteScope' => $userData[IAccountManager::PROPERTY_WEBSITE]['scope'], + 'websiteVerification' => $userData[IAccountManager::PROPERTY_WEBSITE]['verified'], + 'twitter' => $userData[IAccountManager::PROPERTY_TWITTER]['value'], + 'twitterScope' => $userData[IAccountManager::PROPERTY_TWITTER]['scope'], + 'twitterVerification' => $userData[IAccountManager::PROPERTY_TWITTER]['verified'], 'groups' => $this->getGroups($user), ] + $messageParameters + $languageParameters + $localeParameters; @@ -154,7 +145,7 @@ class PersonalInfo implements ISettings { * @return string the section ID, e.g. 'sharing' * @since 9.1 */ - public function getSection() { + public function getSection(): string { return 'personal-info'; } @@ -166,7 +157,7 @@ class PersonalInfo implements ISettings { * E.g.: 70 * @since 9.1 */ - public function getPriority() { + public function getPriority(): int { return 10; } @@ -176,9 +167,9 @@ class PersonalInfo implements ISettings { * @param IUser $user * @return array */ - private function getGroups(IUser $user) { + private function getGroups(IUser $user): array { $groups = array_map( - function (IGroup $group) { + static function (IGroup $group) { return $group->getDisplayName(); }, $this->groupManager->getUserGroups($user) @@ -195,7 +186,7 @@ class PersonalInfo implements ISettings { * @param IUser $user * @return array */ - private function getLanguages(IUser $user) { + private function getLanguages(IUser $user): array { $forceLanguage = $this->config->getSystemValue('force_language', false); if ($forceLanguage !== false) { return []; @@ -228,7 +219,7 @@ class PersonalInfo implements ISettings { ); } - private function getLocales(IUser $user) { + private function getLocales(IUser $user): array { $forceLanguage = $this->config->getSystemValue('force_locale', false); if ($forceLanguage !== false) { return []; @@ -273,8 +264,8 @@ class PersonalInfo implements ISettings { * @param array $userData * @return array */ - private function getMessageParameters(array $userData) { - $needVerifyMessage = [AccountManager::PROPERTY_EMAIL, AccountManager::PROPERTY_WEBSITE, AccountManager::PROPERTY_TWITTER]; + private function getMessageParameters(array $userData): array { + $needVerifyMessage = [IAccountManager::PROPERTY_EMAIL, IAccountManager::PROPERTY_WEBSITE, IAccountManager::PROPERTY_TWITTER]; $messageParameters = []; foreach ($needVerifyMessage as $property) { switch ($userData[$property]['verified']) { diff --git a/apps/settings/tests/Controller/UsersControllerTest.php b/apps/settings/tests/Controller/UsersControllerTest.php index 4679fd8f7ba..75e71435b0f 100644 --- a/apps/settings/tests/Controller/UsersControllerTest.php +++ b/apps/settings/tests/Controller/UsersControllerTest.php @@ -31,6 +31,7 @@ use OC\Accounts\AccountManager; use OC\Encryption\Exceptions\ModuleDoesNotExistsException; use OC\Group\Manager; use OCA\Settings\Controller\UsersController; +use OCP\Accounts\IAccountManager; use OCP\App\IAppManager; use OCP\AppFramework\Http; use OCP\BackgroundJob\IJobList; @@ -196,41 +197,41 @@ class UsersControllerTest extends \Test\TestCase { ->method('getUser') ->with($user) ->willReturn([ - AccountManager::PROPERTY_DISPLAYNAME => + IAccountManager::PROPERTY_DISPLAYNAME => [ 'value' => 'Display name', 'scope' => AccountManager::VISIBILITY_CONTACTS_ONLY, 'verified' => AccountManager::NOT_VERIFIED, ], - AccountManager::PROPERTY_ADDRESS => + IAccountManager::PROPERTY_ADDRESS => [ 'value' => '', 'scope' => AccountManager::VISIBILITY_PRIVATE, 'verified' => AccountManager::NOT_VERIFIED, ], - AccountManager::PROPERTY_WEBSITE => + IAccountManager::PROPERTY_WEBSITE => [ 'value' => '', 'scope' => AccountManager::VISIBILITY_PRIVATE, 'verified' => AccountManager::NOT_VERIFIED, ], - AccountManager::PROPERTY_EMAIL => + IAccountManager::PROPERTY_EMAIL => [ 'value' => '', 'scope' => AccountManager::VISIBILITY_CONTACTS_ONLY, 'verified' => AccountManager::NOT_VERIFIED, ], - AccountManager::PROPERTY_AVATAR => + IAccountManager::PROPERTY_AVATAR => [ 'scope' => AccountManager::VISIBILITY_CONTACTS_ONLY ], - AccountManager::PROPERTY_PHONE => + IAccountManager::PROPERTY_PHONE => [ 'value' => '', 'scope' => AccountManager::VISIBILITY_PRIVATE, 'verified' => AccountManager::NOT_VERIFIED, ], - AccountManager::PROPERTY_TWITTER => + IAccountManager::PROPERTY_TWITTER => [ 'value' => '', 'scope' => AccountManager::VISIBILITY_PRIVATE, @@ -289,21 +290,21 @@ class UsersControllerTest extends \Test\TestCase { $user->method('getEMailAddress')->willReturn($oldEmailAddress); $user->method('canChangeDisplayName')->willReturn(true); - if ($data[AccountManager::PROPERTY_EMAIL]['value'] === $oldEmailAddress || - ($oldEmailAddress === null && $data[AccountManager::PROPERTY_EMAIL]['value'] === '')) { + if ($data[IAccountManager::PROPERTY_EMAIL]['value'] === $oldEmailAddress || + ($oldEmailAddress === null && $data[IAccountManager::PROPERTY_EMAIL]['value'] === '')) { $user->expects($this->never())->method('setEMailAddress'); } else { $user->expects($this->once())->method('setEMailAddress') - ->with($data[AccountManager::PROPERTY_EMAIL]['value']) + ->with($data[IAccountManager::PROPERTY_EMAIL]['value']) ->willReturn(true); } - if ($data[AccountManager::PROPERTY_DISPLAYNAME]['value'] === $oldDisplayName || - ($oldDisplayName === null && $data[AccountManager::PROPERTY_DISPLAYNAME]['value'] === '')) { + if ($data[IAccountManager::PROPERTY_DISPLAYNAME]['value'] === $oldDisplayName || + ($oldDisplayName === null && $data[IAccountManager::PROPERTY_DISPLAYNAME]['value'] === '')) { $user->expects($this->never())->method('setDisplayName'); } else { $user->expects($this->once())->method('setDisplayName') - ->with($data[AccountManager::PROPERTY_DISPLAYNAME]['value']) + ->with($data[IAccountManager::PROPERTY_DISPLAYNAME]['value']) ->willReturn(true); } @@ -317,48 +318,48 @@ class UsersControllerTest extends \Test\TestCase { return [ [ [ - AccountManager::PROPERTY_EMAIL => ['value' => 'john@example.com'], - AccountManager::PROPERTY_DISPLAYNAME => ['value' => 'john doe'], + IAccountManager::PROPERTY_EMAIL => ['value' => 'john@example.com'], + IAccountManager::PROPERTY_DISPLAYNAME => ['value' => 'john doe'], ], 'john@example.com', 'john doe' ], [ [ - AccountManager::PROPERTY_EMAIL => ['value' => 'john@example.com'], - AccountManager::PROPERTY_DISPLAYNAME => ['value' => 'john doe'], + IAccountManager::PROPERTY_EMAIL => ['value' => 'john@example.com'], + IAccountManager::PROPERTY_DISPLAYNAME => ['value' => 'john doe'], ], 'johnNew@example.com', 'john New doe' ], [ [ - AccountManager::PROPERTY_EMAIL => ['value' => 'john@example.com'], - AccountManager::PROPERTY_DISPLAYNAME => ['value' => 'john doe'], + IAccountManager::PROPERTY_EMAIL => ['value' => 'john@example.com'], + IAccountManager::PROPERTY_DISPLAYNAME => ['value' => 'john doe'], ], 'johnNew@example.com', 'john doe' ], [ [ - AccountManager::PROPERTY_EMAIL => ['value' => 'john@example.com'], - AccountManager::PROPERTY_DISPLAYNAME => ['value' => 'john doe'], + IAccountManager::PROPERTY_EMAIL => ['value' => 'john@example.com'], + IAccountManager::PROPERTY_DISPLAYNAME => ['value' => 'john doe'], ], 'john@example.com', 'john New doe' ], [ [ - AccountManager::PROPERTY_EMAIL => ['value' => ''], - AccountManager::PROPERTY_DISPLAYNAME => ['value' => 'john doe'], + IAccountManager::PROPERTY_EMAIL => ['value' => ''], + IAccountManager::PROPERTY_DISPLAYNAME => ['value' => 'john doe'], ], null, 'john New doe' ], [ [ - AccountManager::PROPERTY_EMAIL => ['value' => 'john@example.com'], - AccountManager::PROPERTY_DISPLAYNAME => ['value' => 'john doe'], + IAccountManager::PROPERTY_EMAIL => ['value' => 'john@example.com'], + IAccountManager::PROPERTY_DISPLAYNAME => ['value' => 'john doe'], ], 'john@example.com', null @@ -391,14 +392,14 @@ class UsersControllerTest extends \Test\TestCase { $user->method('getDisplayName')->willReturn($oldDisplayName); $user->method('getEMailAddress')->willReturn($oldEmailAddress); - if ($data[AccountManager::PROPERTY_EMAIL]['value'] !== $oldEmailAddress) { + if ($data[IAccountManager::PROPERTY_EMAIL]['value'] !== $oldEmailAddress) { $user->method('canChangeDisplayName') ->willReturn($canChangeEmail); } - if ($data[AccountManager::PROPERTY_DISPLAYNAME]['value'] !== $oldDisplayName) { + if ($data[IAccountManager::PROPERTY_DISPLAYNAME]['value'] !== $oldDisplayName) { $user->method('setDisplayName') - ->with($data[AccountManager::PROPERTY_DISPLAYNAME]['value']) + ->with($data[IAccountManager::PROPERTY_DISPLAYNAME]['value']) ->willReturn($setDisplayNameResult); } @@ -410,8 +411,8 @@ class UsersControllerTest extends \Test\TestCase { return [ [ [ - AccountManager::PROPERTY_EMAIL => ['value' => 'john@example.com'], - AccountManager::PROPERTY_DISPLAYNAME => ['value' => 'john doe'], + IAccountManager::PROPERTY_EMAIL => ['value' => 'john@example.com'], + IAccountManager::PROPERTY_DISPLAYNAME => ['value' => 'john doe'], ], 'johnNew@example.com', 'john New doe', @@ -420,8 +421,8 @@ class UsersControllerTest extends \Test\TestCase { ], [ [ - AccountManager::PROPERTY_EMAIL => ['value' => 'john@example.com'], - AccountManager::PROPERTY_DISPLAYNAME => ['value' => 'john doe'], + IAccountManager::PROPERTY_EMAIL => ['value' => 'john@example.com'], + IAccountManager::PROPERTY_DISPLAYNAME => ['value' => 'john doe'], ], 'johnNew@example.com', 'john New doe', @@ -430,8 +431,8 @@ class UsersControllerTest extends \Test\TestCase { ], [ [ - AccountManager::PROPERTY_EMAIL => ['value' => 'john@example.com'], - AccountManager::PROPERTY_DISPLAYNAME => ['value' => 'john doe'], + IAccountManager::PROPERTY_EMAIL => ['value' => 'john@example.com'], + IAccountManager::PROPERTY_DISPLAYNAME => ['value' => 'john doe'], ], 'johnNew@example.com', 'john New doe', @@ -455,7 +456,7 @@ class UsersControllerTest extends \Test\TestCase { $signature = 'theSignature'; $code = $message . ' ' . $signature; - if ($type === AccountManager::PROPERTY_TWITTER) { + if ($type === IAccountManager::PROPERTY_TWITTER) { $code = $message . ' ' . md5($signature); } @@ -492,25 +493,25 @@ class UsersControllerTest extends \Test\TestCase { public function dataTestGetVerificationCode() { $accountDataBefore = [ - AccountManager::PROPERTY_WEBSITE => ['value' => 'https://nextcloud.com', 'verified' => AccountManager::NOT_VERIFIED], - AccountManager::PROPERTY_TWITTER => ['value' => '@nextclouders', 'verified' => AccountManager::NOT_VERIFIED, 'signature' => 'theSignature'], + IAccountManager::PROPERTY_WEBSITE => ['value' => 'https://nextcloud.com', 'verified' => AccountManager::NOT_VERIFIED], + IAccountManager::PROPERTY_TWITTER => ['value' => '@nextclouders', 'verified' => AccountManager::NOT_VERIFIED, 'signature' => 'theSignature'], ]; $accountDataAfterWebsite = [ - AccountManager::PROPERTY_WEBSITE => ['value' => 'https://nextcloud.com', 'verified' => AccountManager::VERIFICATION_IN_PROGRESS, 'signature' => 'theSignature'], - AccountManager::PROPERTY_TWITTER => ['value' => '@nextclouders', 'verified' => AccountManager::NOT_VERIFIED, 'signature' => 'theSignature'], + IAccountManager::PROPERTY_WEBSITE => ['value' => 'https://nextcloud.com', 'verified' => AccountManager::VERIFICATION_IN_PROGRESS, 'signature' => 'theSignature'], + IAccountManager::PROPERTY_TWITTER => ['value' => '@nextclouders', 'verified' => AccountManager::NOT_VERIFIED, 'signature' => 'theSignature'], ]; $accountDataAfterTwitter = [ - AccountManager::PROPERTY_WEBSITE => ['value' => 'https://nextcloud.com', 'verified' => AccountManager::NOT_VERIFIED], - AccountManager::PROPERTY_TWITTER => ['value' => '@nextclouders', 'verified' => AccountManager::VERIFICATION_IN_PROGRESS, 'signature' => 'theSignature'], + IAccountManager::PROPERTY_WEBSITE => ['value' => 'https://nextcloud.com', 'verified' => AccountManager::NOT_VERIFIED], + IAccountManager::PROPERTY_TWITTER => ['value' => '@nextclouders', 'verified' => AccountManager::VERIFICATION_IN_PROGRESS, 'signature' => 'theSignature'], ]; return [ - ['verify-twitter', AccountManager::PROPERTY_TWITTER, $accountDataBefore, $accountDataAfterTwitter, false], - ['verify-website', AccountManager::PROPERTY_WEBSITE, $accountDataBefore, $accountDataAfterWebsite, false], - ['verify-twitter', AccountManager::PROPERTY_TWITTER, $accountDataBefore, $accountDataAfterTwitter, true], - ['verify-website', AccountManager::PROPERTY_WEBSITE, $accountDataBefore, $accountDataAfterWebsite, true], + ['verify-twitter', IAccountManager::PROPERTY_TWITTER, $accountDataBefore, $accountDataAfterTwitter, false], + ['verify-website', IAccountManager::PROPERTY_WEBSITE, $accountDataBefore, $accountDataAfterWebsite, false], + ['verify-twitter', IAccountManager::PROPERTY_TWITTER, $accountDataBefore, $accountDataAfterTwitter, true], + ['verify-website', IAccountManager::PROPERTY_WEBSITE, $accountDataBefore, $accountDataAfterWebsite, true], ]; } |