summaryrefslogtreecommitdiffstats
path: root/apps/provisioning_api/tests
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2018-01-26 12:47:59 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2018-01-26 12:49:11 +0100
commit119896a8d7be20aa0b7817d6629c3fb97d9c9516 (patch)
tree9486493bf09f8cc8693d4b145ca4e4a4e676b3ff /apps/provisioning_api/tests
parentf3723434eeeafb5a8b01eef6353833b607dace05 (diff)
downloadnextcloud-server-119896a8d7be20aa0b7817d6629c3fb97d9c9516.tar.gz
nextcloud-server-119896a8d7be20aa0b7817d6629c3fb97d9c9516.zip
Fix tests
* Add factory for the federatedfilesharing app Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/provisioning_api/tests')
-rw-r--r--apps/provisioning_api/tests/Controller/UsersControllerTest.php75
1 files changed, 72 insertions, 3 deletions
diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
index c2ad36c455c..a8a5e4a0591 100644
--- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php
+++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
@@ -34,6 +34,9 @@ namespace OCA\Provisioning_API\Tests\Controller;
use Exception;
use OC\Accounts\AccountManager;
use OC\Group\Manager;
+use OCA\FederatedFileSharing\AppInfo\Application;
+use OCA\FederatedFileSharing\FederatedShareProvider;
+use OCA\Provisioning_API\FederatedFileSharingFactory;
use OCP\App\IAppManager;
use OCP\AppFramework\OCS\OCSException;
use OCP\Mail\IEMailTemplate;
@@ -80,6 +83,8 @@ class UsersControllerTest extends TestCase {
private $l10nFactory;
/** @var NewUserMailHelper|PHPUnit_Framework_MockObject_MockObject */
private $newUserMailHelper;
+ /** @var FederatedFileSharingFactory|\PHPUnit_Framework_MockObject_MockObject */
+ private $federatedFileSharingFactory;
protected function setUp() {
parent::setUp();
@@ -94,6 +99,7 @@ class UsersControllerTest extends TestCase {
$this->accountManager = $this->createMock(AccountManager::class);
$this->l10nFactory = $this->createMock(IFactory::class);
$this->newUserMailHelper = $this->createMock(NewUserMailHelper::class);
+ $this->federatedFileSharingFactory = $this->createMock(FederatedFileSharingFactory::class);
$this->api = $this->getMockBuilder(UsersController::class)
->setConstructorArgs([
@@ -107,7 +113,8 @@ class UsersControllerTest extends TestCase {
$this->accountManager,
$this->logger,
$this->l10nFactory,
- $this->newUserMailHelper
+ $this->newUserMailHelper,
+ $this->federatedFileSharingFactory
])
->setMethods(['fillStorageInfo'])
->getMock();
@@ -2877,7 +2884,8 @@ class UsersControllerTest extends TestCase {
$this->accountManager,
$this->logger,
$this->l10nFactory,
- $this->newUserMailHelper
+ $this->newUserMailHelper,
+ $this->federatedFileSharingFactory
])
->setMethods(['getUserData'])
->getMock();
@@ -2938,7 +2946,8 @@ class UsersControllerTest extends TestCase {
$this->accountManager,
$this->logger,
$this->l10nFactory,
- $this->newUserMailHelper
+ $this->newUserMailHelper,
+ $this->federatedFileSharingFactory
])
->setMethods(['getUserData'])
->getMock();
@@ -3318,4 +3327,64 @@ class UsersControllerTest extends TestCase {
$this->api->resendWelcomeMessage('UserToGet');
}
+
+
+ public function dataGetEditableFields() {
+ return [
+ [false, false, []],
+ [false, true, [
+ AccountManager::PROPERTY_PHONE,
+ AccountManager::PROPERTY_ADDRESS,
+ AccountManager::PROPERTY_WEBSITE,
+ AccountManager::PROPERTY_TWITTER,
+ ]],
+ [ true, false, [
+ AccountManager::PROPERTY_DISPLAYNAME,
+ AccountManager::PROPERTY_EMAIL,
+ ]],
+ [ true, true ,[
+ AccountManager::PROPERTY_DISPLAYNAME,
+ AccountManager::PROPERTY_EMAIL,
+ AccountManager::PROPERTY_PHONE,
+ AccountManager::PROPERTY_ADDRESS,
+ AccountManager::PROPERTY_WEBSITE,
+ AccountManager::PROPERTY_TWITTER,
+ ]]
+ ];
+ }
+
+ /**
+ * @dataProvider dataGetEditableFields
+ *
+ * @param bool $allowedToChangeDisplayName
+ * @param bool $federatedSharingEnabled
+ * @param array $expected
+ */
+ public function testGetEditableFields(bool $allowedToChangeDisplayName, bool $federatedSharingEnabled, array $expected) {
+ $this->config
+ ->method('getSystemValue')
+ ->with(
+ $this->equalTo('allow_user_to_change_display_name'),
+ $this->anything()
+ )->willReturn($allowedToChangeDisplayName);
+ $this->appManager
+ ->method('isEnabledForUser')
+ ->with($this->equalTo('federatedfilesharing'))
+ ->willReturn($federatedSharingEnabled);
+
+ $shareprovider = $this->createMock(FederatedShareProvider::class);
+ $shareprovider->method('isLookupServerUploadEnabled')->willReturn(true);
+
+ $federatedFileSharing = $this->createMock(Application::class);
+ $federatedFileSharing
+ ->method('getFederatedShareProvider')
+ ->willReturn($shareprovider);
+
+ $this->federatedFileSharingFactory
+ ->method('get')
+ ->willReturn($federatedFileSharing);
+
+ $expectedResp = new DataResponse($expected);
+ $this->assertEquals($expectedResp, $this->api->getEditableFields());
+ }
}