|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +/** |
| 6 | + * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors |
| 7 | + * SPDX-License-Identifier: AGPL-3.0-or-later |
| 8 | + */ |
| 9 | + |
| 10 | +namespace OCA\Files_External\Tests; |
| 11 | + |
| 12 | +use OCA\Files_External\Lib\Storage\FTP; |
| 13 | +use PHPUnit\Framework\Attributes\DataProvider; |
| 14 | +use Test\TestCase; |
| 15 | + |
| 16 | +class FtpTest extends TestCase { |
| 17 | + public static function portProvider(): array { |
| 18 | + $parameters = [ |
| 19 | + 'host' => 'somehost', |
| 20 | + 'user' => 'someuser', |
| 21 | + 'password' => 'somepassword', |
| 22 | + ]; |
| 23 | + |
| 24 | + return [ |
| 25 | + 'no port given' => [$parameters, 21], |
| 26 | + 'empty port' => [array_merge($parameters, ['port' => '']), 21], |
| 27 | + 'null port' => [array_merge($parameters, ['port' => null]), 21], |
| 28 | + 'non numeric port' => [array_merge($parameters, ['port' => 'ftp']), 21], |
| 29 | + 'numeric string port' => [array_merge($parameters, ['port' => '2121']), 2121], |
| 30 | + 'integer port' => [array_merge($parameters, ['port' => 2121]), 2121], |
| 31 | + ]; |
| 32 | + } |
| 33 | + |
| 34 | + #[DataProvider('portProvider')] |
| 35 | + public function testPort(array $parameters, int $expectedPort): void { |
| 36 | + $instance = new FTP($parameters); |
| 37 | + |
| 38 | + $this->assertSame($expectedPort, self::invokePrivate($instance, 'port')); |
| 39 | + } |
| 40 | +} |
0 commit comments