Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion IONOS
Submodule IONOS updated 1 files
+1 −0 configure.sh
17 changes: 15 additions & 2 deletions apps/systemtags/lib/Settings/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@
namespace OCA\SystemTags\Settings;

use OCP\AppFramework\Http\TemplateResponse;
use OCP\Settings\ISettings;
use OCP\IL10N;
use OCP\Settings\IDelegatedSettings;
use OCP\Util;

class Admin implements ISettings {
class Admin implements IDelegatedSettings {

public function __construct(
private IL10N $l10n,
) {
}
/**
* @return TemplateResponse
*/
Expand All @@ -36,4 +41,12 @@ public function getSection() {
public function getPriority() {
return 70;
}

public function getName(): string {
return $this->l10n->t('Collaborative tags');
}

public function getAuthorizedAppConfig(): array {
return [];
}
}
42 changes: 39 additions & 3 deletions apps/systemtags/tests/Settings/AdminTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand All @@ -7,16 +10,18 @@

use OCA\SystemTags\Settings\Admin;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IL10N;
use Test\TestCase;

class AdminTest extends TestCase {
/** @var Admin */
private $admin;
private Admin $admin;
private IL10N&\PHPUnit\Framework\MockObject\MockObject $l10n;

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

$this->admin = new Admin();
$this->l10n = $this->createMock(IL10N::class);
$this->admin = new Admin($this->l10n);
}

public function testGetForm(): void {
Expand All @@ -31,4 +36,35 @@ public function testGetSection(): void {
public function testGetPriority(): void {
$this->assertSame(70, $this->admin->getPriority());
}

public function testGetName(): void {
$translatedName = 'Collaborative tags';
$this->l10n->expects($this->once())
->method('t')
->with('Collaborative tags')
->willReturn($translatedName);

$this->assertSame($translatedName, $this->admin->getName());
}

public function testGetAuthorizedAppConfig(): void {
$this->assertEquals([], $this->admin->getAuthorizedAppConfig());
$this->assertIsArray($this->admin->getAuthorizedAppConfig());
}

public function testImplementsIDelegatedSettings(): void {
$this->assertInstanceOf(\OCP\Settings\IDelegatedSettings::class, $this->admin);
$this->assertInstanceOf(\OCP\Settings\ISettings::class, $this->admin);
}

public function testGetNameReturnsString(): void {
$this->l10n->expects($this->once())
->method('t')
->with('Collaborative tags')
->willReturn('Translated Name');

$name = $this->admin->getName();
$this->assertIsString($name);
$this->assertNotEmpty($name);
}
}
Loading