Skip to content

Commit 42676b5

Browse files
test(capabilities): update and add tests for show-confetti capability
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 3a2a9dc commit 42676b5

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

tests/php/Unit/CapabilitiesTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99
* SPDX-License-Identifier: AGPL-3.0-or-later
1010
*/
1111

12+
use OCA\Libresign\AppInfo\Application;
1213
use OCA\Libresign\Capabilities;
1314
use OCA\Libresign\Service\Envelope\EnvelopeService;
1415
use OCA\Libresign\Service\SignatureTextService;
1516
use OCA\Libresign\Service\SignerElementsService;
1617
use OCP\App\IAppManager;
18+
use OCP\IAppConfig;
1719
use PHPUnit\Framework\Attributes\DataProvider;
1820
use PHPUnit\Framework\MockObject\MockObject;
1921

@@ -23,12 +25,14 @@ final class CapabilitiesTest extends \OCA\Libresign\Tests\Unit\TestCase {
2325
private SignatureTextService&MockObject $signatureTextService;
2426
private IAppManager&MockObject $appManager;
2527
private EnvelopeService&MockObject $envelopeService;
28+
private IAppConfig&MockObject $appConfig;
2629

2730
public function setUp(): void {
2831
$this->signerElementsService = $this->createMock(SignerElementsService::class);
2932
$this->signatureTextService = $this->createMock(SignatureTextService::class);
3033
$this->appManager = $this->createMock(IAppManager::class);
3134
$this->envelopeService = $this->createMock(EnvelopeService::class);
35+
$this->appConfig = $this->createMock(IAppConfig::class);
3236
}
3337

3438

@@ -38,6 +42,7 @@ private function getClass(): Capabilities {
3842
$this->signatureTextService,
3943
$this->appManager,
4044
$this->envelopeService,
45+
$this->appConfig,
4146
);
4247
return $this->capabilities;
4348
}
@@ -55,4 +60,20 @@ public static function providerSignElementsIsAvailable(): array {
5560
[false, false],
5661
];
5762
}
63+
64+
#[DataProvider('providerShowConfetti')]
65+
public function testShowConfetti(bool $configValue, bool $expected): void {
66+
$this->appConfig->method('getValueBool')
67+
->with(Application::APP_ID, 'show_confetti_after_signing', true)
68+
->willReturn($configValue);
69+
$capabilities = $this->getClass()->getCapabilities();
70+
$this->assertEquals($expected, $capabilities['libresign']['config']['show-confetti']);
71+
}
72+
73+
public static function providerShowConfetti(): array {
74+
return [
75+
[true, true],
76+
[false, false],
77+
];
78+
}
5879
}

0 commit comments

Comments
 (0)