@@ -11,29 +11,29 @@ |
||
| 11 | 11 | use OCP\User\IAvailabilityCoordinator; |
| 12 | 12 | |
| 13 | 13 | class Capabilities implements ICapability { |
| 14 | - public function __construct( |
|
| 15 | - private IConfig $config, |
|
| 16 | - private IAvailabilityCoordinator $coordinator, |
|
| 17 | - ) { |
|
| 18 | - } |
|
| 14 | + public function __construct( |
|
| 15 | + private IConfig $config, |
|
| 16 | + private IAvailabilityCoordinator $coordinator, |
|
| 17 | + ) { |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * @return array{dav: array{chunking: string, public_shares_chunking: bool, bulkupload?: string, absence-supported?: bool, absence-replacement?: bool}} |
|
| 22 | - */ |
|
| 23 | - public function getCapabilities() { |
|
| 24 | - $capabilities = [ |
|
| 25 | - 'dav' => [ |
|
| 26 | - 'chunking' => '1.0', |
|
| 27 | - 'public_shares_chunking' => false, |
|
| 28 | - ] |
|
| 29 | - ]; |
|
| 30 | - if ($this->config->getSystemValueBool('bulkupload.enabled', true)) { |
|
| 31 | - $capabilities['dav']['bulkupload'] = '1.0'; |
|
| 32 | - } |
|
| 33 | - if ($this->coordinator->isEnabled()) { |
|
| 34 | - $capabilities['dav']['absence-supported'] = true; |
|
| 35 | - $capabilities['dav']['absence-replacement'] = true; |
|
| 36 | - } |
|
| 37 | - return $capabilities; |
|
| 38 | - } |
|
| 20 | + /** |
|
| 21 | + * @return array{dav: array{chunking: string, public_shares_chunking: bool, bulkupload?: string, absence-supported?: bool, absence-replacement?: bool}} |
|
| 22 | + */ |
|
| 23 | + public function getCapabilities() { |
|
| 24 | + $capabilities = [ |
|
| 25 | + 'dav' => [ |
|
| 26 | + 'chunking' => '1.0', |
|
| 27 | + 'public_shares_chunking' => false, |
|
| 28 | + ] |
|
| 29 | + ]; |
|
| 30 | + if ($this->config->getSystemValueBool('bulkupload.enabled', true)) { |
|
| 31 | + $capabilities['dav']['bulkupload'] = '1.0'; |
|
| 32 | + } |
|
| 33 | + if ($this->coordinator->isEnabled()) { |
|
| 34 | + $capabilities['dav']['absence-supported'] = true; |
|
| 35 | + $capabilities['dav']['absence-replacement'] = true; |
|
| 36 | + } |
|
| 37 | + return $capabilities; |
|
| 38 | + } |
|
| 39 | 39 | } |
@@ -16,66 +16,66 @@ |
||
| 16 | 16 | * @package OCA\DAV\Tests\unit |
| 17 | 17 | */ |
| 18 | 18 | class CapabilitiesTest extends TestCase { |
| 19 | - public function testGetCapabilities(): void { |
|
| 20 | - $config = $this->createMock(IConfig::class); |
|
| 21 | - $config->expects($this->once()) |
|
| 22 | - ->method('getSystemValueBool') |
|
| 23 | - ->with('bulkupload.enabled', $this->isType('bool')) |
|
| 24 | - ->willReturn(false); |
|
| 25 | - $coordinator = $this->createMock(IAvailabilityCoordinator::class); |
|
| 26 | - $coordinator->expects($this->once()) |
|
| 27 | - ->method('isEnabled') |
|
| 28 | - ->willReturn(false); |
|
| 29 | - $capabilities = new Capabilities($config, $coordinator); |
|
| 30 | - $expected = [ |
|
| 31 | - 'dav' => [ |
|
| 32 | - 'chunking' => '1.0', |
|
| 33 | - 'public_shares_chunking' => false, |
|
| 34 | - ], |
|
| 35 | - ]; |
|
| 36 | - $this->assertSame($expected, $capabilities->getCapabilities()); |
|
| 37 | - } |
|
| 19 | + public function testGetCapabilities(): void { |
|
| 20 | + $config = $this->createMock(IConfig::class); |
|
| 21 | + $config->expects($this->once()) |
|
| 22 | + ->method('getSystemValueBool') |
|
| 23 | + ->with('bulkupload.enabled', $this->isType('bool')) |
|
| 24 | + ->willReturn(false); |
|
| 25 | + $coordinator = $this->createMock(IAvailabilityCoordinator::class); |
|
| 26 | + $coordinator->expects($this->once()) |
|
| 27 | + ->method('isEnabled') |
|
| 28 | + ->willReturn(false); |
|
| 29 | + $capabilities = new Capabilities($config, $coordinator); |
|
| 30 | + $expected = [ |
|
| 31 | + 'dav' => [ |
|
| 32 | + 'chunking' => '1.0', |
|
| 33 | + 'public_shares_chunking' => false, |
|
| 34 | + ], |
|
| 35 | + ]; |
|
| 36 | + $this->assertSame($expected, $capabilities->getCapabilities()); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - public function testGetCapabilitiesWithBulkUpload(): void { |
|
| 40 | - $config = $this->createMock(IConfig::class); |
|
| 41 | - $config->expects($this->once()) |
|
| 42 | - ->method('getSystemValueBool') |
|
| 43 | - ->with('bulkupload.enabled', $this->isType('bool')) |
|
| 44 | - ->willReturn(true); |
|
| 45 | - $coordinator = $this->createMock(IAvailabilityCoordinator::class); |
|
| 46 | - $coordinator->expects($this->once()) |
|
| 47 | - ->method('isEnabled') |
|
| 48 | - ->willReturn(false); |
|
| 49 | - $capabilities = new Capabilities($config, $coordinator); |
|
| 50 | - $expected = [ |
|
| 51 | - 'dav' => [ |
|
| 52 | - 'chunking' => '1.0', |
|
| 53 | - 'public_shares_chunking' => false, |
|
| 54 | - 'bulkupload' => '1.0', |
|
| 55 | - ], |
|
| 56 | - ]; |
|
| 57 | - $this->assertSame($expected, $capabilities->getCapabilities()); |
|
| 58 | - } |
|
| 39 | + public function testGetCapabilitiesWithBulkUpload(): void { |
|
| 40 | + $config = $this->createMock(IConfig::class); |
|
| 41 | + $config->expects($this->once()) |
|
| 42 | + ->method('getSystemValueBool') |
|
| 43 | + ->with('bulkupload.enabled', $this->isType('bool')) |
|
| 44 | + ->willReturn(true); |
|
| 45 | + $coordinator = $this->createMock(IAvailabilityCoordinator::class); |
|
| 46 | + $coordinator->expects($this->once()) |
|
| 47 | + ->method('isEnabled') |
|
| 48 | + ->willReturn(false); |
|
| 49 | + $capabilities = new Capabilities($config, $coordinator); |
|
| 50 | + $expected = [ |
|
| 51 | + 'dav' => [ |
|
| 52 | + 'chunking' => '1.0', |
|
| 53 | + 'public_shares_chunking' => false, |
|
| 54 | + 'bulkupload' => '1.0', |
|
| 55 | + ], |
|
| 56 | + ]; |
|
| 57 | + $this->assertSame($expected, $capabilities->getCapabilities()); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - public function testGetCapabilitiesWithAbsence(): void { |
|
| 61 | - $config = $this->createMock(IConfig::class); |
|
| 62 | - $config->expects($this->once()) |
|
| 63 | - ->method('getSystemValueBool') |
|
| 64 | - ->with('bulkupload.enabled', $this->isType('bool')) |
|
| 65 | - ->willReturn(false); |
|
| 66 | - $coordinator = $this->createMock(IAvailabilityCoordinator::class); |
|
| 67 | - $coordinator->expects($this->once()) |
|
| 68 | - ->method('isEnabled') |
|
| 69 | - ->willReturn(true); |
|
| 70 | - $capabilities = new Capabilities($config, $coordinator); |
|
| 71 | - $expected = [ |
|
| 72 | - 'dav' => [ |
|
| 73 | - 'chunking' => '1.0', |
|
| 74 | - 'public_shares_chunking' => false, |
|
| 75 | - 'absence-supported' => true, |
|
| 76 | - 'absence-replacement' => true, |
|
| 77 | - ], |
|
| 78 | - ]; |
|
| 79 | - $this->assertSame($expected, $capabilities->getCapabilities()); |
|
| 80 | - } |
|
| 60 | + public function testGetCapabilitiesWithAbsence(): void { |
|
| 61 | + $config = $this->createMock(IConfig::class); |
|
| 62 | + $config->expects($this->once()) |
|
| 63 | + ->method('getSystemValueBool') |
|
| 64 | + ->with('bulkupload.enabled', $this->isType('bool')) |
|
| 65 | + ->willReturn(false); |
|
| 66 | + $coordinator = $this->createMock(IAvailabilityCoordinator::class); |
|
| 67 | + $coordinator->expects($this->once()) |
|
| 68 | + ->method('isEnabled') |
|
| 69 | + ->willReturn(true); |
|
| 70 | + $capabilities = new Capabilities($config, $coordinator); |
|
| 71 | + $expected = [ |
|
| 72 | + 'dav' => [ |
|
| 73 | + 'chunking' => '1.0', |
|
| 74 | + 'public_shares_chunking' => false, |
|
| 75 | + 'absence-supported' => true, |
|
| 76 | + 'absence-replacement' => true, |
|
| 77 | + ], |
|
| 78 | + ]; |
|
| 79 | + $this->assertSame($expected, $capabilities->getCapabilities()); |
|
| 80 | + } |
|
| 81 | 81 | } |