Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Ng <chrng8@gmail.com>2021-10-14 11:05:17 +0300
committerChristopher Ng <chrng8@gmail.com>2021-10-19 07:44:40 +0300
commit7215148a242815a5064ce5d00a387c634dc936f3 (patch)
tree4edf67253bd8c3bbe3ea2f1fba17e21b221e9282 /tests/lib/Accounts
parent382ba66ab5e1a675347e86d93593eb228da253bb (diff)
Add new account properties
- New properties - Organisation - Role - Headline - Biography - Profile Enabled property - Fix errors with building default account properties - Fix L10N factory method `getLanguage` not public error - Update tests Signed-off-by: Christopher Ng <chrng8@gmail.com>
Diffstat (limited to 'tests/lib/Accounts')
-rw-r--r--tests/lib/Accounts/AccountManagerTest.php198
1 files changed, 192 insertions, 6 deletions
diff --git a/tests/lib/Accounts/AccountManagerTest.php b/tests/lib/Accounts/AccountManagerTest.php
index bf79d233131..df1d62b3132 100644
--- a/tests/lib/Accounts/AccountManagerTest.php
+++ b/tests/lib/Accounts/AccountManagerTest.php
@@ -1,4 +1,5 @@
<?php
+
/**
* @author Björn Schießle <schiessle@owncloud.com>
*
@@ -168,6 +169,26 @@ class AccountManagerTest extends TestCase {
'value' => 'https://acme.com',
'scope' => IAccountManager::SCOPE_PRIVATE
],
+ [
+ 'name' => IAccountManager::PROPERTY_ORGANISATION,
+ 'value' => 'Some organisation',
+ 'scope' => IAccountManager::SCOPE_LOCAL
+ ],
+ [
+ 'name' => IAccountManager::PROPERTY_ROLE,
+ 'value' => 'Human',
+ 'scope' => IAccountManager::SCOPE_LOCAL
+ ],
+ [
+ 'name' => IAccountManager::PROPERTY_HEADLINE,
+ 'value' => 'Hi',
+ 'scope' => IAccountManager::SCOPE_LOCAL
+ ],
+ [
+ 'name' => IAccountManager::PROPERTY_BIOGRAPHY,
+ 'value' => 'Biography',
+ 'scope' => IAccountManager::SCOPE_LOCAL
+ ],
],
],
[
@@ -203,6 +224,26 @@ class AccountManagerTest extends TestCase {
'value' => 'https://example.org',
'scope' => IAccountManager::SCOPE_LOCAL
],
+ [
+ 'name' => IAccountManager::PROPERTY_ORGANISATION,
+ 'value' => 'Another organisation',
+ 'scope' => IAccountManager::SCOPE_FEDERATED
+ ],
+ [
+ 'name' => IAccountManager::PROPERTY_ROLE,
+ 'value' => 'Alien',
+ 'scope' => IAccountManager::SCOPE_FEDERATED
+ ],
+ [
+ 'name' => IAccountManager::PROPERTY_HEADLINE,
+ 'value' => 'Hello',
+ 'scope' => IAccountManager::SCOPE_FEDERATED
+ ],
+ [
+ 'name' => IAccountManager::PROPERTY_BIOGRAPHY,
+ 'value' => 'Different biography',
+ 'scope' => IAccountManager::SCOPE_FEDERATED
+ ],
],
],
[
@@ -238,6 +279,26 @@ class AccountManagerTest extends TestCase {
'value' => 'https://example.com',
'scope' => IAccountManager::SCOPE_PUBLISHED
],
+ [
+ 'name' => IAccountManager::PROPERTY_ORGANISATION,
+ 'value' => 'Yet another organisation',
+ 'scope' => IAccountManager::SCOPE_PUBLISHED
+ ],
+ [
+ 'name' => IAccountManager::PROPERTY_ROLE,
+ 'value' => 'Being',
+ 'scope' => IAccountManager::SCOPE_PUBLISHED
+ ],
+ [
+ 'name' => IAccountManager::PROPERTY_HEADLINE,
+ 'value' => 'This is a headline',
+ 'scope' => IAccountManager::SCOPE_PUBLISHED
+ ],
+ [
+ 'name' => IAccountManager::PROPERTY_BIOGRAPHY,
+ 'value' => 'Some long biography',
+ 'scope' => IAccountManager::SCOPE_PUBLISHED
+ ],
],
],
[
@@ -274,6 +335,26 @@ class AccountManagerTest extends TestCase {
'scope' => IAccountManager::SCOPE_FEDERATED
],
[
+ 'name' => IAccountManager::PROPERTY_ORGANISATION,
+ 'value' => 'Organisation A',
+ 'scope' => IAccountManager::SCOPE_LOCAL
+ ],
+ [
+ 'name' => IAccountManager::PROPERTY_ROLE,
+ 'value' => 'Animal',
+ 'scope' => IAccountManager::SCOPE_LOCAL
+ ],
+ [
+ 'name' => IAccountManager::PROPERTY_HEADLINE,
+ 'value' => 'My headline',
+ 'scope' => IAccountManager::SCOPE_LOCAL
+ ],
+ [
+ 'name' => IAccountManager::PROPERTY_BIOGRAPHY,
+ 'value' => 'Short biography',
+ 'scope' => IAccountManager::SCOPE_LOCAL
+ ],
+ [
'name' => IAccountManager::COLLECTION_EMAIL,
'value' => 'k.cheng@emca.com',
'scope' => IAccountManager::SCOPE_LOCAL
@@ -318,6 +399,26 @@ class AccountManagerTest extends TestCase {
'value' => 'https://elpmaxe.org',
'scope' => IAccountManager::SCOPE_PUBLISHED
],
+ [
+ 'name' => IAccountManager::PROPERTY_ORGANISATION,
+ 'value' => 'Organisation B',
+ 'scope' => IAccountManager::SCOPE_FEDERATED
+ ],
+ [
+ 'name' => IAccountManager::PROPERTY_ROLE,
+ 'value' => 'Organism',
+ 'scope' => IAccountManager::SCOPE_FEDERATED
+ ],
+ [
+ 'name' => IAccountManager::PROPERTY_HEADLINE,
+ 'value' => 'Best headline',
+ 'scope' => IAccountManager::SCOPE_FEDERATED
+ ],
+ [
+ 'name' => IAccountManager::PROPERTY_BIOGRAPHY,
+ 'value' => 'Autobiography',
+ 'scope' => IAccountManager::SCOPE_FEDERATED
+ ],
],
],
];
@@ -406,18 +507,103 @@ class AccountManagerTest extends TestCase {
];
}
- public function testAddMissingDefaultValues() {
+ public function testAddMissingDefaults() {
+ $user = $this->createMock(IUser::class);
+
$input = [
- ['value' => 'value1', 'verified' => '0', 'name' => 'key1'],
- ['value' => 'value1', 'name' => 'key2'],
+ [
+ 'name' => IAccountManager::PROPERTY_DISPLAYNAME,
+ 'value' => 'bob',
+ 'verified' => IAccountManager::NOT_VERIFIED,
+ ],
+ [],
+ [],
+ [
+ 'name' => IAccountManager::PROPERTY_EMAIL,
+ 'value' => 'bob@bob.bob',
+ ],
];
$expected = [
- ['value' => 'value1', 'verified' => '0', 'name' => 'key1'],
- ['value' => 'value1', 'name' => 'key2', 'verified' => '0'],
+ [
+ 'name' => IAccountManager::PROPERTY_DISPLAYNAME,
+ 'value' => 'bob',
+ 'scope' => IAccountManager::SCOPE_FEDERATED,
+ 'verified' => IAccountManager::NOT_VERIFIED,
+ ],
+
+ [
+ 'name' => IAccountManager::PROPERTY_ADDRESS,
+ 'value' => '',
+ 'scope' => IAccountManager::SCOPE_LOCAL,
+ 'verified' => IAccountManager::NOT_VERIFIED,
+ ],
+
+ [
+ 'name' => IAccountManager::PROPERTY_WEBSITE,
+ 'value' => '',
+ 'scope' => IAccountManager::SCOPE_LOCAL,
+ 'verified' => IAccountManager::NOT_VERIFIED,
+ ],
+
+ [
+ 'name' => IAccountManager::PROPERTY_EMAIL,
+ 'value' => 'bob@bob.bob',
+ 'scope' => IAccountManager::SCOPE_FEDERATED,
+ 'verified' => IAccountManager::NOT_VERIFIED,
+ ],
+
+ [
+ 'name' => IAccountManager::PROPERTY_AVATAR,
+ 'scope' => IAccountManager::SCOPE_FEDERATED
+ ],
+
+ [
+ 'name' => IAccountManager::PROPERTY_PHONE,
+ 'value' => '',
+ 'scope' => IAccountManager::SCOPE_LOCAL,
+ 'verified' => IAccountManager::NOT_VERIFIED,
+ ],
+
+ [
+ 'name' => IAccountManager::PROPERTY_TWITTER,
+ 'value' => '',
+ 'scope' => IAccountManager::SCOPE_LOCAL,
+ 'verified' => IAccountManager::NOT_VERIFIED,
+ ],
+
+ [
+ 'name' => IAccountManager::PROPERTY_ORGANISATION,
+ 'value' => '',
+ 'scope' => IAccountManager::SCOPE_LOCAL,
+ ],
+
+ [
+ 'name' => IAccountManager::PROPERTY_ROLE,
+ 'value' => '',
+ 'scope' => IAccountManager::SCOPE_LOCAL,
+ ],
+
+ [
+ 'name' => IAccountManager::PROPERTY_HEADLINE,
+ 'value' => '',
+ 'scope' => IAccountManager::SCOPE_LOCAL,
+ ],
+
+ [
+ 'name' => IAccountManager::PROPERTY_BIOGRAPHY,
+ 'value' => '',
+ 'scope' => IAccountManager::SCOPE_LOCAL,
+ ],
+
+ [
+ 'name' => IAccountManager::PROPERTY_PROFILE_ENABLED,
+ 'value' => '1',
+ ],
];
- $result = $this->invokePrivate($this->accountManager, 'addMissingDefaultValues', [$input]);
+ $defaultUserRecord = $this->invokePrivate($this->accountManager, 'buildDefaultUserRecord', [$user]);
+ $result = $this->invokePrivate($this->accountManager, 'addMissingDefaultValues', [$input, $defaultUserRecord]);
$this->assertSame($expected, $result);
}