Skip to content

Commit 02a50f1

Browse files
committed
test(policy): align service expectations with actor capabilities
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 6a3c483 commit 02a50f1

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

tests/php/Unit/Service/Policy/PolicyServiceTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use OCA\Libresign\Service\Policy\Runtime\PolicyContextFactory;
1818
use OCA\Libresign\Service\Policy\Runtime\PolicyRegistry;
1919
use OCA\Libresign\Service\Policy\Runtime\PolicySource;
20+
use OCP\Group\ISubAdmin;
2021
use OCP\IGroupManager;
2122
use OCP\IL10N;
2223
use OCP\IUser;
@@ -29,6 +30,7 @@
2930
final class PolicyServiceTest extends TestCase {
3031
private IUserManager&MockObject $userManager;
3132
private IGroupManager&MockObject $groupManager;
33+
private ISubAdmin&MockObject $subAdmin;
3234
private IUserSession&MockObject $userSession;
3335
private PolicySource&MockObject $source;
3436
private IL10N&MockObject $l10n;
@@ -39,6 +41,7 @@ protected function setUp(): void {
3941
parent::setUp();
4042
$this->userManager = $this->createMock(IUserManager::class);
4143
$this->groupManager = $this->createMock(IGroupManager::class);
44+
$this->subAdmin = $this->createMock(ISubAdmin::class);
4245
$this->userSession = $this->createMock(IUserSession::class);
4346
$this->source = $this->createMock(PolicySource::class);
4447
$this->l10n = $this->createMock(IL10N::class);
@@ -61,7 +64,7 @@ protected function setUp(): void {
6164
};
6265
});
6366
$this->registry = new PolicyRegistry($container);
64-
$this->contextFactory = new PolicyContextFactory($this->userManager, $this->groupManager, $this->userSession);
67+
$this->contextFactory = new PolicyContextFactory($this->userManager, $this->groupManager, $this->subAdmin, $this->userSession);
6568
}
6669

6770
public function testResolveForUserIdUsesDocMdpGroupPolicyWhenSystemAllowsOverride(): void {
@@ -351,7 +354,6 @@ public function testSaveUserPreferenceForUserIdAllowsSystemAdminBypassWhenGroupB
351354
->willReturn(['finance']);
352355

353356
$this->groupManager
354-
->expects($this->once())
355357
->method('isAdmin')
356358
->with('admin')
357359
->willReturn(true);
@@ -428,7 +430,6 @@ public function testSaveUserPreferenceForUserIdBlocksNonAdminWhenGroupDisallowsU
428430
->willReturn(['finance']);
429431

430432
$this->groupManager
431-
->expects($this->once())
432433
->method('isAdmin')
433434
->with('manager')
434435
->willReturn(false);

0 commit comments

Comments
 (0)