aboutsummaryrefslogtreecommitdiffstats
path: root/apps/sharebymail/tests/CapabilitiesTest.php
blob: d38618650b311bc010484fd8889b17e59fd1a3e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
/**
 * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */
namespace OCA\ShareByMail\Tests;

use OCA\ShareByMail\Capabilities;
use OCA\ShareByMail\Settings\SettingsManager;
use OCP\App\IAppManager;
use OCP\Share\IManager;
use Test\TestCase;

class CapabilitiesTest extends TestCase {
	/** @var Capabilities */
	private $capabilities;

	/** @var IManager | \PHPUnit\Framework\MockObject\MockObject */
	private $manager;

	/** @var IManager | \PHPUnit\Framework\MockObject\MockObject */
	private $settingsManager;

	/** @var IAppManager | \PHPUnit\Framework\MockObject\MockObject */
	private $appManager;

	protected function setUp(): void {
		parent::setUp();


		$this->manager = $this::createMock(IManager::class);
		$this->settingsManager = $this::createMock(SettingsManager::class);
		$this->appManager = $this::createMock(IAppManager::class);
		$this->capabilities = new Capabilities($this->manager, $this->settingsManager, $this->appManager);
	}

	public function testGetCapabilities(): void {
		$this->manager->method('shareApiAllowLinks')
			->willReturn(true);
		$this->manager->method('shareApiLinkEnforcePassword')
			->willReturn(false);
		$this->manager->method('shareApiLinkDefaultExpireDateEnforced')
			->willReturn(false);
		$this->settingsManager->method('sendPasswordByMail')
			->willReturn(true);
		$this->appManager->method('isEnabledForUser')
			->willReturn(true);

		$capabilities = [
			'files_sharing' =>
				[
					'sharebymail' =>
						[
							'enabled' => true,
							'send_password_by_mail' => true,
							'upload_files_drop' => [
								'enabled' => true,
							],
							'password' => [
								'enabled' => true,
								'enforced' => false,
							],
							'expire_date' => [
								'enabled' => true,
								'enforced' => false,
							],
						]
				]
		];

		$this->assertSame($capabilities, $this->capabilities->getCapabilities());
	}
}