|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | +/** |
| 5 | + * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors |
| 6 | + * SPDX-License-Identifier: AGPL-3.0-or-later |
| 7 | + */ |
| 8 | +namespace OCA\Files\Tests\Service; |
| 9 | + |
| 10 | +use OCA\Files\Service\ChunkedUploadConfig; |
| 11 | +use OCP\IConfig; |
| 12 | +use PHPUnit\Framework\Attributes\DataProvider; |
| 13 | +use PHPUnit\Framework\MockObject\MockObject; |
| 14 | +use Test\TestCase; |
| 15 | + |
| 16 | +class ChunkedUploadConfigTest extends TestCase { |
| 17 | + private IConfig&MockObject $config; |
| 18 | + |
| 19 | + protected function setUp(): void { |
| 20 | + parent::setUp(); |
| 21 | + |
| 22 | + $this->config = $this->createMock(IConfig::class); |
| 23 | + $this->overwriteService(IConfig::class, $this->config); |
| 24 | + } |
| 25 | + |
| 26 | + protected function tearDown(): void { |
| 27 | + $this->restoreAllServices(); |
| 28 | + parent::tearDown(); |
| 29 | + } |
| 30 | + |
| 31 | + public static function dataGetMaxParallelCount(): array { |
| 32 | + return [ |
| 33 | + 'configured positive value' => [3, 3], |
| 34 | + 'boundary minimum' => [1, 1], |
| 35 | + 'zero becomes one' => [0, 1], |
| 36 | + 'negative becomes one' => [-2, 1], |
| 37 | + 'large value passes through' => [100, 100], |
| 38 | + ]; |
| 39 | + } |
| 40 | + |
| 41 | + #[DataProvider('dataGetMaxParallelCount')] |
| 42 | + public function testGetMaxParallelCount(int $configuredValue, int $expectedValue): void { |
| 43 | + $this->config->expects($this->once()) |
| 44 | + ->method('getSystemValueInt') |
| 45 | + ->with('files.chunked_upload.max_parallel_count', 5) |
| 46 | + ->willReturn($configuredValue); |
| 47 | + |
| 48 | + $this->assertSame($expectedValue, ChunkedUploadConfig::getMaxParallelCount()); |
| 49 | + } |
| 50 | +} |
0 commit comments