Skip to content

Commit ad8a502

Browse files
IONOS(admin-delegation): implement IDelegatedSettings for systemtags
now this setting can be delegated per php occ admin-delegation:add OCA\\SystemTags\\Settings\\Admin <groupId> Signed-off-by: Misha M.-Kupriyanov <kupriyanov@strato.de>
1 parent 423d91a commit ad8a502

File tree

2 files changed

+54
-5
lines changed

2 files changed

+54
-5
lines changed

apps/systemtags/lib/Settings/Admin.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@
66
namespace OCA\SystemTags\Settings;
77

88
use OCP\AppFramework\Http\TemplateResponse;
9-
use OCP\Settings\ISettings;
9+
use OCP\IL10N;
10+
use OCP\Settings\IDelegatedSettings;
1011
use OCP\Util;
1112

12-
class Admin implements ISettings {
13+
class Admin implements IDelegatedSettings {
1314

15+
public function __construct(
16+
private IL10N $l10n,
17+
) {
18+
}
1419
/**
1520
* @return TemplateResponse
1621
*/
@@ -36,4 +41,12 @@ public function getSection() {
3641
public function getPriority() {
3742
return 70;
3843
}
44+
45+
public function getName(): string {
46+
return $this->l10n->t('Collaborative tags');
47+
}
48+
49+
public function getAuthorizedAppConfig(): array {
50+
return [];
51+
}
3952
}

apps/systemtags/tests/Settings/AdminTest.php

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?php
2+
3+
declare(strict_types=1);
4+
25
/**
36
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
47
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -7,16 +10,18 @@
710

811
use OCA\SystemTags\Settings\Admin;
912
use OCP\AppFramework\Http\TemplateResponse;
13+
use OCP\IL10N;
1014
use Test\TestCase;
1115

1216
class AdminTest extends TestCase {
13-
/** @var Admin */
14-
private $admin;
17+
private Admin $admin;
18+
private IL10N&\PHPUnit\Framework\MockObject\MockObject $l10n;
1519

1620
protected function setUp(): void {
1721
parent::setUp();
1822

19-
$this->admin = new Admin();
23+
$this->l10n = $this->createMock(IL10N::class);
24+
$this->admin = new Admin($this->l10n);
2025
}
2126

2227
public function testGetForm(): void {
@@ -31,4 +36,35 @@ public function testGetSection(): void {
3136
public function testGetPriority(): void {
3237
$this->assertSame(70, $this->admin->getPriority());
3338
}
39+
40+
public function testGetName(): void {
41+
$translatedName = 'Collaborative tags';
42+
$this->l10n->expects($this->once())
43+
->method('t')
44+
->with('Collaborative tags')
45+
->willReturn($translatedName);
46+
47+
$this->assertSame($translatedName, $this->admin->getName());
48+
}
49+
50+
public function testGetAuthorizedAppConfig(): void {
51+
$this->assertEquals([], $this->admin->getAuthorizedAppConfig());
52+
$this->assertIsArray($this->admin->getAuthorizedAppConfig());
53+
}
54+
55+
public function testImplementsIDelegatedSettings(): void {
56+
$this->assertInstanceOf(\OCP\Settings\IDelegatedSettings::class, $this->admin);
57+
$this->assertInstanceOf(\OCP\Settings\ISettings::class, $this->admin);
58+
}
59+
60+
public function testGetNameReturnsString(): void {
61+
$this->l10n->expects($this->once())
62+
->method('t')
63+
->with('Collaborative tags')
64+
->willReturn('Translated Name');
65+
66+
$name = $this->admin->getName();
67+
$this->assertIsString($name);
68+
$this->assertNotEmpty($name);
69+
}
3470
}

0 commit comments

Comments
 (0)