summaryrefslogtreecommitdiffstats
path: root/apps/provisioning_api/tests
diff options
context:
space:
mode:
authorChristopher Ng <chrng8@gmail.com>2021-10-14 08:05:17 +0000
committerChristopher Ng <chrng8@gmail.com>2021-10-19 04:44:40 +0000
commit7215148a242815a5064ce5d00a387c634dc936f3 (patch)
tree4edf67253bd8c3bbe3ea2f1fba17e21b221e9282 /apps/provisioning_api/tests
parent382ba66ab5e1a675347e86d93593eb228da253bb (diff)
downloadnextcloud-server-7215148a242815a5064ce5d00a387c634dc936f3.tar.gz
nextcloud-server-7215148a242815a5064ce5d00a387c634dc936f3.zip
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 'apps/provisioning_api/tests')
-rw-r--r--apps/provisioning_api/tests/Controller/UsersControllerTest.php94
1 files changed, 84 insertions, 10 deletions
diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
index 7ae5d0c245f..2ce5cadb57d 100644
--- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php
+++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
@@ -1,4 +1,5 @@
<?php
+
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -38,6 +39,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
+
namespace OCA\Provisioning_API\Tests\Controller;
use Exception;
@@ -165,11 +167,12 @@ class UsersControllerTest extends TestCase {
->with('MyCustomSearch')
->willReturn(['Admin' => [], 'Foo' => [], 'Bar' => []]);
- $expected = ['users' => [
- 'Admin',
- 'Foo',
- 'Bar',
- ],
+ $expected = [
+ 'users' => [
+ 'Admin',
+ 'Foo',
+ 'Bar',
+ ],
];
$this->assertEquals($expected, $this->api->getUsers('MyCustomSearch')->getData());
}
@@ -687,7 +690,7 @@ class UsersControllerTest extends TestCase {
$this->assertTrue(key_exists(
'id',
- $this->api->addUser('NewUser', 'PasswordOfTheNewUser', '', '', ['ExistingGroup'])->getData()
+ $this->api->addUser('NewUser', 'PasswordOfTheNewUser', '', '', ['ExistingGroup'])->getData()
));
}
@@ -711,7 +714,8 @@ class UsersControllerTest extends TestCase {
$this->logger
->expects($this->once())
->method('error')
- ->with('Failed addUser attempt with exception.',
+ ->with(
+ 'Failed addUser attempt with exception.',
[
'app' => 'ocs_api',
'exception' => $exception
@@ -998,6 +1002,11 @@ class UsersControllerTest extends TestCase {
IAccountManager::PROPERTY_PHONE => ['value' => 'phone'],
IAccountManager::PROPERTY_TWITTER => ['value' => 'twitter'],
IAccountManager::PROPERTY_WEBSITE => ['value' => 'website'],
+ IAccountManager::PROPERTY_ORGANISATION => ['value' => 'organisation'],
+ IAccountManager::PROPERTY_ROLE => ['value' => 'role'],
+ IAccountManager::PROPERTY_HEADLINE => ['value' => 'headline'],
+ IAccountManager::PROPERTY_BIOGRAPHY => ['value' => 'biography'],
+ IAccountManager::PROPERTY_PROFILE_ENABLED => ['value' => '1'],
]);
$this->config
->expects($this->at(0))
@@ -1067,6 +1076,11 @@ class UsersControllerTest extends TestCase {
'setPassword' => true,
],
'additional_mail' => [],
+ 'organisation' => 'organisation',
+ 'role' => 'role',
+ 'headline' => 'headline',
+ 'biography' => 'biography',
+ 'profile_enabled' => '1',
'notify_email' => null,
];
$this->assertEquals($expected, $this->invokePrivate($this->api, 'getUserData', ['UID']));
@@ -1166,6 +1180,11 @@ class UsersControllerTest extends TestCase {
IAccountManager::PROPERTY_PHONE => ['value' => 'phone'],
IAccountManager::PROPERTY_TWITTER => ['value' => 'twitter'],
IAccountManager::PROPERTY_WEBSITE => ['value' => 'website'],
+ IAccountManager::PROPERTY_ORGANISATION => ['value' => 'organisation'],
+ IAccountManager::PROPERTY_ROLE => ['value' => 'role'],
+ IAccountManager::PROPERTY_HEADLINE => ['value' => 'headline'],
+ IAccountManager::PROPERTY_BIOGRAPHY => ['value' => 'biography'],
+ IAccountManager::PROPERTY_PROFILE_ENABLED => ['value' => '1'],
]);
$this->l10nFactory
@@ -1196,6 +1215,11 @@ class UsersControllerTest extends TestCase {
'setPassword' => true,
],
'additional_mail' => [],
+ 'organisation' => 'organisation',
+ 'role' => 'role',
+ 'headline' => 'headline',
+ 'biography' => 'biography',
+ 'profile_enabled' => '1',
'notify_email' => null,
];
$this->assertEquals($expected, $this->invokePrivate($this->api, 'getUserData', ['UID']));
@@ -1334,6 +1358,11 @@ class UsersControllerTest extends TestCase {
IAccountManager::PROPERTY_PHONE => ['value' => 'phone'],
IAccountManager::PROPERTY_TWITTER => ['value' => 'twitter'],
IAccountManager::PROPERTY_WEBSITE => ['value' => 'website'],
+ IAccountManager::PROPERTY_ORGANISATION => ['value' => 'organisation'],
+ IAccountManager::PROPERTY_ROLE => ['value' => 'role'],
+ IAccountManager::PROPERTY_HEADLINE => ['value' => 'headline'],
+ IAccountManager::PROPERTY_BIOGRAPHY => ['value' => 'biography'],
+ IAccountManager::PROPERTY_PROFILE_ENABLED => ['value' => '1'],
]);
$this->l10nFactory
@@ -1363,6 +1392,11 @@ class UsersControllerTest extends TestCase {
'setPassword' => false,
],
'additional_mail' => [],
+ 'organisation' => 'organisation',
+ 'role' => 'role',
+ 'headline' => 'headline',
+ 'biography' => 'biography',
+ 'profile_enabled' => '1',
'notify_email' => null,
];
$this->assertEquals($expected, $this->invokePrivate($this->api, 'getUserData', ['UID']));
@@ -1543,6 +1577,11 @@ class UsersControllerTest extends TestCase {
[IAccountManager::PROPERTY_PHONE, '1234', '12345'],
[IAccountManager::PROPERTY_ADDRESS, 'Something street 2', 'Another street 3'],
[IAccountManager::PROPERTY_WEBSITE, 'https://examplesite1', 'https://examplesite2'],
+ [IAccountManager::PROPERTY_ORGANISATION, 'Organisation A', 'Organisation B'],
+ [IAccountManager::PROPERTY_ROLE, 'Human', 'Alien'],
+ [IAccountManager::PROPERTY_HEADLINE, 'Hi', 'Hello'],
+ [IAccountManager::PROPERTY_BIOGRAPHY, 'A biography', 'Another biography'],
+ [IAccountManager::PROPERTY_PROFILE_ENABLED, '1', '0'],
];
}
@@ -1614,6 +1653,11 @@ class UsersControllerTest extends TestCase {
[IAccountManager::PROPERTY_PHONE, IAccountManager::SCOPE_LOCAL, IAccountManager::SCOPE_FEDERATED],
[IAccountManager::PROPERTY_ADDRESS, IAccountManager::SCOPE_LOCAL, IAccountManager::SCOPE_FEDERATED],
[IAccountManager::PROPERTY_WEBSITE, IAccountManager::SCOPE_LOCAL, IAccountManager::SCOPE_FEDERATED],
+ [IAccountManager::PROPERTY_ORGANISATION, IAccountManager::SCOPE_LOCAL, IAccountManager::SCOPE_FEDERATED],
+ [IAccountManager::PROPERTY_ROLE, IAccountManager::SCOPE_LOCAL, IAccountManager::SCOPE_FEDERATED],
+ [IAccountManager::PROPERTY_HEADLINE, IAccountManager::SCOPE_LOCAL, IAccountManager::SCOPE_FEDERATED],
+ [IAccountManager::PROPERTY_BIOGRAPHY, IAccountManager::SCOPE_LOCAL, IAccountManager::SCOPE_FEDERATED],
+ [IAccountManager::PROPERTY_PROFILE_ENABLED, IAccountManager::SCOPE_LOCAL, IAccountManager::SCOPE_FEDERATED],
];
}
@@ -3490,7 +3534,12 @@ class UsersControllerTest extends TestCase {
'phone' => 'phone',
'address' => 'address',
'website' => 'website',
- 'twitter' => 'twitter'
+ 'twitter' => 'twitter',
+ 'organisation' => 'organisation',
+ 'role' => 'role',
+ 'headline' => 'headline',
+ 'biography' => 'biography',
+ 'profile_enabled' => '1'
]
);
@@ -3503,6 +3552,11 @@ class UsersControllerTest extends TestCase {
'address' => 'address',
'website' => 'website',
'twitter' => 'twitter',
+ 'organisation' => 'organisation',
+ 'role' => 'role',
+ 'headline' => 'headline',
+ 'biography' => 'biography',
+ 'profile_enabled' => '1',
'display-name' => 'Demo User'
];
@@ -3560,7 +3614,12 @@ class UsersControllerTest extends TestCase {
'address' => 'address',
'website' => 'website',
'twitter' => 'twitter',
- 'displayname' => 'Demo User'
+ 'displayname' => 'Demo User',
+ 'organisation' => 'organisation',
+ 'role' => 'role',
+ 'headline' => 'headline',
+ 'biography' => 'biography',
+ 'profile_enabled' => '1'
];
$api->expects($this->at(0))->method('getUserData')
@@ -3878,6 +3937,11 @@ class UsersControllerTest extends TestCase {
IAccountManager::PROPERTY_ADDRESS,
IAccountManager::PROPERTY_WEBSITE,
IAccountManager::PROPERTY_TWITTER,
+ IAccountManager::PROPERTY_ORGANISATION,
+ IAccountManager::PROPERTY_ROLE,
+ IAccountManager::PROPERTY_HEADLINE,
+ IAccountManager::PROPERTY_BIOGRAPHY,
+ IAccountManager::PROPERTY_PROFILE_ENABLED,
]],
[true, ISetDisplayNameBackend::class, [
IAccountManager::PROPERTY_DISPLAYNAME,
@@ -3887,6 +3951,11 @@ class UsersControllerTest extends TestCase {
IAccountManager::PROPERTY_ADDRESS,
IAccountManager::PROPERTY_WEBSITE,
IAccountManager::PROPERTY_TWITTER,
+ IAccountManager::PROPERTY_ORGANISATION,
+ IAccountManager::PROPERTY_ROLE,
+ IAccountManager::PROPERTY_HEADLINE,
+ IAccountManager::PROPERTY_BIOGRAPHY,
+ IAccountManager::PROPERTY_PROFILE_ENABLED,
]],
[true, UserInterface::class, [
IAccountManager::PROPERTY_EMAIL,
@@ -3895,6 +3964,11 @@ class UsersControllerTest extends TestCase {
IAccountManager::PROPERTY_ADDRESS,
IAccountManager::PROPERTY_WEBSITE,
IAccountManager::PROPERTY_TWITTER,
+ IAccountManager::PROPERTY_ORGANISATION,
+ IAccountManager::PROPERTY_ROLE,
+ IAccountManager::PROPERTY_HEADLINE,
+ IAccountManager::PROPERTY_BIOGRAPHY,
+ IAccountManager::PROPERTY_PROFILE_ENABLED,
]],
];
}
@@ -3941,7 +4015,7 @@ class UsersControllerTest extends TestCase {
$account = $this->createMock(IAccount::class);
$account->method('getProperty')
- ->will($this->returnValueMap($mockedProperties));
+ ->will($this->returnValueMap($mockedProperties));
$this->accountManager->expects($this->any())->method('getAccount')
->with($targetUser)