This adds a non-initial-state capability for the windows-compatibile-filemnames feature. It is not required by the webui and it might have performance impacts (always compares system config against windows presets), so it is not included in every page load, but instead for querying from the clients. Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>pull/51568/head
parent
8035c8d6b8
commit
a697da3063
@ -0,0 +1,38 @@ |
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
/** |
||||
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors |
||||
* SPDX-License-Identifier: AGPL-3.0-or-later |
||||
*/ |
||||
namespace OCA\Files; |
||||
|
||||
use OCA\Files\Service\SettingsService; |
||||
use OCP\Capabilities\ICapability; |
||||
use OCP\Capabilities\IInitialStateExcludedCapability; |
||||
|
||||
/** |
||||
* Capabilities not needed for every request. |
||||
* This capabilities might be hard to compute or no used by the webui. |
||||
*/ |
||||
class AdvancedCapabilities implements ICapability, IInitialStateExcludedCapability { |
||||
|
||||
public function __construct( |
||||
protected SettingsService $service, |
||||
) { |
||||
} |
||||
|
||||
/** |
||||
* Return this classes capabilities |
||||
* |
||||
* @return array{files: array{'windows_compatible_filenames': bool}} |
||||
*/ |
||||
public function getCapabilities(): array { |
||||
return [ |
||||
'files' => [ |
||||
'windows_compatible_filenames' => $this->service->hasFilesWindowsSupport(), |
||||
], |
||||
]; |
||||
} |
||||
} |
@ -0,0 +1,47 @@ |
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
/** |
||||
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors |
||||
* SPDX-License-Identifier: AGPL-3.0-or-later |
||||
*/ |
||||
namespace OCA\Files; |
||||
|
||||
use OCA\Files\Service\SettingsService; |
||||
use PHPUnit\Framework\MockObject\MockObject; |
||||
use Test\TestCase; |
||||
|
||||
class AdvancedCapabilitiesTest extends TestCase { |
||||
|
||||
protected SettingsService&MockObject $service; |
||||
protected AdvancedCapabilities $capabilities; |
||||
|
||||
protected function setUp(): void { |
||||
$this->service = $this->createMock(SettingsService::class); |
||||
$this->capabilities = new AdvancedCapabilities($this->service); |
||||
} |
||||
|
||||
/** |
||||
* @dataProvider dataGetCapabilities |
||||
*/ |
||||
public function testGetCapabilities(bool $wcf): void { |
||||
$this->service |
||||
->expects(self::once()) |
||||
->method('hasFilesWindowsSupport') |
||||
->willReturn($wcf); |
||||
|
||||
self::assertEqualsCanonicalizing(['files' => [ 'windows_compatible_filenames' => $wcf ]], $this->capabilities->getCapabilities()); |
||||
} |
||||
|
||||
public static function dataGetCapabilities(): array { |
||||
return [ |
||||
'WCF enabled' => [ |
||||
true, |
||||
], |
||||
'WCF disabled' => [ |
||||
false, |
||||
], |
||||
]; |
||||
} |
||||
} |
Loading…
Reference in new issue