-
-
Notifications
You must be signed in to change notification settings - Fork 111
Expand file tree
/
Copy pathCapabilitiesTest.php
More file actions
79 lines (67 loc) · 2.55 KB
/
CapabilitiesTest.php
File metadata and controls
79 lines (67 loc) · 2.55 KB
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
74
75
76
77
78
79
<?php
declare(strict_types=1);
namespace OCA\Libresign\Tests\Unit;
/**
* SPDX-FileCopyrightText: 2025 LibreCode coop and contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
use OCA\Libresign\AppInfo\Application;
use OCA\Libresign\Capabilities;
use OCA\Libresign\Service\Envelope\EnvelopeService;
use OCA\Libresign\Service\SignatureTextService;
use OCA\Libresign\Service\SignerElementsService;
use OCP\App\IAppManager;
use OCP\IAppConfig;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\MockObject\MockObject;
final class CapabilitiesTest extends \OCA\Libresign\Tests\Unit\TestCase {
private Capabilities $capabilities;
private SignerElementsService&MockObject $signerElementsService;
private SignatureTextService&MockObject $signatureTextService;
private IAppManager&MockObject $appManager;
private EnvelopeService&MockObject $envelopeService;
private IAppConfig&MockObject $appConfig;
public function setUp(): void {
$this->signerElementsService = $this->createMock(SignerElementsService::class);
$this->signatureTextService = $this->createMock(SignatureTextService::class);
$this->appManager = $this->createMock(IAppManager::class);
$this->envelopeService = $this->createMock(EnvelopeService::class);
$this->appConfig = $this->createMock(IAppConfig::class);
}
private function getClass(): Capabilities {
$this->capabilities = new Capabilities(
$this->signerElementsService,
$this->signatureTextService,
$this->appManager,
$this->envelopeService,
$this->appConfig,
);
return $this->capabilities;
}
#[DataProvider('providerSignElementsIsAvailable')]
public function testSignElementsIsAvailable($isEnabled, $expected): void {
$this->signerElementsService->method('isSignElementsAvailable')->willReturn($isEnabled);
$capabilities = $this->getClass()->getCapabilities();
$this->assertEquals($expected, $capabilities['libresign']['config']['sign-elements']['is-available']);
}
public static function providerSignElementsIsAvailable(): array {
return [
[true, true],
[false, false],
];
}
#[DataProvider('providerShowConfetti')]
public function testShowConfetti(bool $configValue, bool $expected): void {
$this->appConfig->method('getValueBool')
->with(Application::APP_ID, 'show_confetti_after_signing', true)
->willReturn($configValue);
$capabilities = $this->getClass()->getCapabilities();
$this->assertEquals($expected, $capabilities['libresign']['config']['show-confetti']);
}
public static function providerShowConfetti(): array {
return [
[true, true],
[false, false],
];
}
}