2016-10-22 08:05:53 -04:00
|
|
|
<?php
|
2025-05-26 16:02:22 -04:00
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2016-10-22 08:05:53 -04:00
|
|
|
/**
|
2024-05-28 06:34:11 -04:00
|
|
|
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2016-10-22 08:05:53 -04:00
|
|
|
*/
|
|
|
|
|
namespace OCA\DAV\Tests\unit;
|
|
|
|
|
|
|
|
|
|
use OCA\DAV\Capabilities;
|
2022-08-29 09:24:58 -04:00
|
|
|
use OCP\IConfig;
|
2024-12-01 16:22:38 -05:00
|
|
|
use OCP\User\IAvailabilityCoordinator;
|
2016-10-22 08:05:53 -04:00
|
|
|
use Test\TestCase;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @package OCA\DAV\Tests\unit
|
|
|
|
|
*/
|
|
|
|
|
class CapabilitiesTest extends TestCase {
|
2023-01-20 02:38:43 -05:00
|
|
|
public function testGetCapabilities(): void {
|
2022-08-29 09:24:58 -04:00
|
|
|
$config = $this->createMock(IConfig::class);
|
|
|
|
|
$config->expects($this->once())
|
|
|
|
|
->method('getSystemValueBool')
|
|
|
|
|
->with('bulkupload.enabled', $this->isType('bool'))
|
|
|
|
|
->willReturn(false);
|
2024-12-01 16:22:38 -05:00
|
|
|
$coordinator = $this->createMock(IAvailabilityCoordinator::class);
|
|
|
|
|
$coordinator->expects($this->once())
|
|
|
|
|
->method('isEnabled')
|
|
|
|
|
->willReturn(false);
|
|
|
|
|
$capabilities = new Capabilities($config, $coordinator);
|
2016-10-22 08:05:53 -04:00
|
|
|
$expected = [
|
|
|
|
|
'dav' => [
|
|
|
|
|
'chunking' => '1.0',
|
2025-04-14 09:41:13 -04:00
|
|
|
'public_shares_chunking' => true,
|
2022-08-29 09:24:58 -04:00
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
$this->assertSame($expected, $capabilities->getCapabilities());
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-20 02:38:43 -05:00
|
|
|
public function testGetCapabilitiesWithBulkUpload(): void {
|
2022-08-29 09:24:58 -04:00
|
|
|
$config = $this->createMock(IConfig::class);
|
|
|
|
|
$config->expects($this->once())
|
|
|
|
|
->method('getSystemValueBool')
|
|
|
|
|
->with('bulkupload.enabled', $this->isType('bool'))
|
|
|
|
|
->willReturn(true);
|
2024-12-01 16:22:38 -05:00
|
|
|
$coordinator = $this->createMock(IAvailabilityCoordinator::class);
|
|
|
|
|
$coordinator->expects($this->once())
|
|
|
|
|
->method('isEnabled')
|
|
|
|
|
->willReturn(false);
|
|
|
|
|
$capabilities = new Capabilities($config, $coordinator);
|
2022-08-29 09:24:58 -04:00
|
|
|
$expected = [
|
|
|
|
|
'dav' => [
|
|
|
|
|
'chunking' => '1.0',
|
2025-04-14 09:41:13 -04:00
|
|
|
'public_shares_chunking' => true,
|
2022-08-29 09:24:58 -04:00
|
|
|
'bulkupload' => '1.0',
|
2016-10-22 08:05:53 -04:00
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
$this->assertSame($expected, $capabilities->getCapabilities());
|
|
|
|
|
}
|
2024-12-01 16:22:38 -05:00
|
|
|
|
|
|
|
|
public function testGetCapabilitiesWithAbsence(): void {
|
|
|
|
|
$config = $this->createMock(IConfig::class);
|
|
|
|
|
$config->expects($this->once())
|
|
|
|
|
->method('getSystemValueBool')
|
|
|
|
|
->with('bulkupload.enabled', $this->isType('bool'))
|
|
|
|
|
->willReturn(false);
|
|
|
|
|
$coordinator = $this->createMock(IAvailabilityCoordinator::class);
|
|
|
|
|
$coordinator->expects($this->once())
|
|
|
|
|
->method('isEnabled')
|
|
|
|
|
->willReturn(true);
|
|
|
|
|
$capabilities = new Capabilities($config, $coordinator);
|
|
|
|
|
$expected = [
|
|
|
|
|
'dav' => [
|
|
|
|
|
'chunking' => '1.0',
|
2025-04-14 09:41:13 -04:00
|
|
|
'public_shares_chunking' => true,
|
2024-12-01 16:22:38 -05:00
|
|
|
'absence-supported' => true,
|
2024-12-01 16:23:51 -05:00
|
|
|
'absence-replacement' => true,
|
2024-12-01 16:22:38 -05:00
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
$this->assertSame($expected, $capabilities->getCapabilities());
|
|
|
|
|
}
|
2016-10-22 08:05:53 -04:00
|
|
|
}
|