aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_external/tests/Storage
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_external/tests/Storage')
-rw-r--r--apps/files_external/tests/Storage/Amazons3MultiPartTest.php13
-rw-r--r--apps/files_external/tests/Storage/Amazons3Test.php13
-rw-r--r--apps/files_external/tests/Storage/FtpTest.php6
-rw-r--r--apps/files_external/tests/Storage/OwncloudTest.php2
-rw-r--r--apps/files_external/tests/Storage/SFTP_KeyTest.php24
-rw-r--r--apps/files_external/tests/Storage/SftpTest.php10
-rw-r--r--apps/files_external/tests/Storage/SmbTest.php20
-rw-r--r--apps/files_external/tests/Storage/SwiftTest.php4
-rw-r--r--apps/files_external/tests/Storage/VersionedAmazonS3Test.php9
-rw-r--r--apps/files_external/tests/Storage/WebdavTest.php8
10 files changed, 65 insertions, 44 deletions
diff --git a/apps/files_external/tests/Storage/Amazons3MultiPartTest.php b/apps/files_external/tests/Storage/Amazons3MultiPartTest.php
index 3db468b0fa0..aa3925899f3 100644
--- a/apps/files_external/tests/Storage/Amazons3MultiPartTest.php
+++ b/apps/files_external/tests/Storage/Amazons3MultiPartTest.php
@@ -1,9 +1,11 @@
<?php
+
+declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
-namespace OCA\files_external\tests\Storage;
+namespace OCA\Files_External\Tests\Storage;
use OCA\Files_External\Lib\Storage\AmazonS3;
@@ -11,6 +13,7 @@ use OCA\Files_External\Lib\Storage\AmazonS3;
* Class Amazons3Test
*
* @group DB
+ * @group S3
*
* @package OCA\Files_External\Tests\Storage
*/
@@ -23,7 +26,7 @@ class Amazons3MultiPartTest extends \Test\Files\Storage\Storage {
parent::setUp();
$this->config = include('files_external/tests/config.amazons3.php');
- if (! is_array($this->config) or ! $this->config['run']) {
+ if (!is_array($this->config) || !$this->config['run']) {
$this->markTestSkipped('AmazonS3 backend not configured');
}
$this->instance = new AmazonS3($this->config + [
@@ -40,11 +43,7 @@ class Amazons3MultiPartTest extends \Test\Files\Storage\Storage {
parent::tearDown();
}
- public function testStat() {
+ public function testStat(): void {
$this->markTestSkipped('S3 doesn\'t update the parents folder mtime');
}
-
- public function testHashInFileName() {
- $this->markTestSkipped('Localstack has a bug with hashes in filename');
- }
}
diff --git a/apps/files_external/tests/Storage/Amazons3Test.php b/apps/files_external/tests/Storage/Amazons3Test.php
index bffe98c3f4d..d02dec0230c 100644
--- a/apps/files_external/tests/Storage/Amazons3Test.php
+++ b/apps/files_external/tests/Storage/Amazons3Test.php
@@ -1,4 +1,6 @@
<?php
+
+declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -12,11 +14,12 @@ use OCA\Files_External\Lib\Storage\AmazonS3;
* Class Amazons3Test
*
* @group DB
+ * @group S3
*
* @package OCA\Files_External\Tests\Storage
*/
class Amazons3Test extends \Test\Files\Storage\Storage {
- private $config;
+ protected $config;
/** @var AmazonS3 */
protected $instance;
@@ -24,7 +27,7 @@ class Amazons3Test extends \Test\Files\Storage\Storage {
parent::setUp();
$this->config = include('files_external/tests/config.amazons3.php');
- if (! is_array($this->config) or ! $this->config['run']) {
+ if (!is_array($this->config) || !$this->config['run']) {
$this->markTestSkipped('AmazonS3 backend not configured');
}
$this->instance = new AmazonS3($this->config);
@@ -38,11 +41,7 @@ class Amazons3Test extends \Test\Files\Storage\Storage {
parent::tearDown();
}
- public function testStat() {
+ public function testStat(): void {
$this->markTestSkipped('S3 doesn\'t update the parents folder mtime');
}
-
- public function testHashInFileName() {
- $this->markTestSkipped('Localstack has a bug with hashes in filename');
- }
}
diff --git a/apps/files_external/tests/Storage/FtpTest.php b/apps/files_external/tests/Storage/FtpTest.php
index 24f7c511e93..095a5236049 100644
--- a/apps/files_external/tests/Storage/FtpTest.php
+++ b/apps/files_external/tests/Storage/FtpTest.php
@@ -1,4 +1,6 @@
<?php
+
+declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -45,7 +47,7 @@ class FtpTest extends \Test\Files\Storage\Storage {
/**
* ftp has no proper way to handle spaces at the end of file names
*/
- public function directoryProvider() {
+ public static function directoryProvider(): array {
return array_filter(parent::directoryProvider(), function ($item) {
return substr($item[0], -1) !== ' ';
});
@@ -55,7 +57,7 @@ class FtpTest extends \Test\Files\Storage\Storage {
/**
* mtime for folders is only with a minute resolution
*/
- public function testStat() {
+ public function testStat(): void {
$textFile = \OC::$SERVERROOT . '/tests/data/lorem.txt';
$ctimeStart = time();
$this->instance->file_put_contents('/lorem.txt', file_get_contents($textFile));
diff --git a/apps/files_external/tests/Storage/OwncloudTest.php b/apps/files_external/tests/Storage/OwncloudTest.php
index 28041a665f8..ab6cd443dba 100644
--- a/apps/files_external/tests/Storage/OwncloudTest.php
+++ b/apps/files_external/tests/Storage/OwncloudTest.php
@@ -1,4 +1,6 @@
<?php
+
+declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
diff --git a/apps/files_external/tests/Storage/SFTP_KeyTest.php b/apps/files_external/tests/Storage/SFTP_KeyTest.php
index c1aaf0b13a3..17e2087f91b 100644
--- a/apps/files_external/tests/Storage/SFTP_KeyTest.php
+++ b/apps/files_external/tests/Storage/SFTP_KeyTest.php
@@ -1,4 +1,6 @@
<?php
+
+declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -40,40 +42,40 @@ class SFTP_KeyTest extends \Test\Files\Storage\Storage {
parent::tearDown();
}
-
- public function testInvalidAddressShouldThrowException() {
+
+ public function testInvalidAddressShouldThrowException(): void {
$this->expectException(\InvalidArgumentException::class);
// I'd use example.com for this, but someone decided to break the spec and make it resolve
$this->instance->assertHostAddressValid('notarealaddress...');
}
- public function testValidAddressShouldPass() {
+ public function testValidAddressShouldPass(): void {
$this->assertTrue($this->instance->assertHostAddressValid('localhost'));
}
-
- public function testNegativePortNumberShouldThrowException() {
+
+ public function testNegativePortNumberShouldThrowException(): void {
$this->expectException(\InvalidArgumentException::class);
$this->instance->assertPortNumberValid('-1');
}
-
- public function testNonNumericalPortNumberShouldThrowException() {
+
+ public function testNonNumericalPortNumberShouldThrowException(): void {
$this->expectException(\InvalidArgumentException::class);
$this->instance->assertPortNumberValid('a');
}
-
- public function testHighPortNumberShouldThrowException() {
+
+ public function testHighPortNumberShouldThrowException(): void {
$this->expectException(\InvalidArgumentException::class);
-
+
$this->instance->assertPortNumberValid('65536');
}
- public function testValidPortNumberShouldPass() {
+ public function testValidPortNumberShouldPass(): void {
$this->assertTrue($this->instance->assertPortNumberValid('22222'));
}
}
diff --git a/apps/files_external/tests/Storage/SftpTest.php b/apps/files_external/tests/Storage/SftpTest.php
index ce7d7461ba8..ebfc8ab3c1f 100644
--- a/apps/files_external/tests/Storage/SftpTest.php
+++ b/apps/files_external/tests/Storage/SftpTest.php
@@ -1,4 +1,6 @@
<?php
+
+declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -44,15 +46,13 @@ class SftpTest extends \Test\Files\Storage\Storage {
parent::tearDown();
}
- /**
- * @dataProvider configProvider
- */
- public function testStorageId($config, $expectedStorageId) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('configProvider')]
+ public function testStorageId($config, $expectedStorageId): void {
$instance = new SFTP($config);
$this->assertEquals($expectedStorageId, $instance->getId());
}
- public function configProvider() {
+ public static function configProvider(): array {
return [
[
// no root path
diff --git a/apps/files_external/tests/Storage/SmbTest.php b/apps/files_external/tests/Storage/SmbTest.php
index 1040158cf19..afcb5c1034f 100644
--- a/apps/files_external/tests/Storage/SmbTest.php
+++ b/apps/files_external/tests/Storage/SmbTest.php
@@ -1,4 +1,6 @@
<?php
+
+declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -49,19 +51,19 @@ class SmbTest extends \Test\Files\Storage\Storage {
parent::tearDown();
}
- public function directoryProvider() {
+ public static function directoryProvider(): array {
// doesn't support leading/trailing spaces
return [['folder']];
}
- public function testRenameWithSpaces() {
+ public function testRenameWithSpaces(): void {
$this->instance->mkdir('with spaces');
$result = $this->instance->rename('with spaces', 'foo bar');
$this->assertTrue($result);
$this->assertTrue($this->instance->is_dir('foo bar'));
}
- public function testStorageId() {
+ public function testStorageId(): void {
$this->instance = new SMB([
'host' => 'testhost',
'user' => 'testuser',
@@ -73,9 +75,9 @@ class SmbTest extends \Test\Files\Storage\Storage {
$this->instance = null;
}
- public function testNotifyGetChanges() {
+ public function testNotifyGetChanges(): void {
$lastError = null;
- for($i = 0; $i < 5; $i++) {
+ for ($i = 0; $i < 5; $i++) {
try {
$this->tryTestNotifyGetChanges();
return;
@@ -130,7 +132,7 @@ class SmbTest extends \Test\Files\Storage\Storage {
}
}
- public function testNotifyListen() {
+ public function testNotifyListen(): void {
$notifyHandler = $this->instance->notify('');
usleep(100 * 1000); //give time for the notify to start
$this->instance->file_put_contents('/newfile.txt', 'test content');
@@ -153,7 +155,7 @@ class SmbTest extends \Test\Files\Storage\Storage {
}
}
- public function testRenameRoot() {
+ public function testRenameRoot(): void {
// root can't be renamed
$this->assertFalse($this->instance->rename('', 'foo1'));
@@ -162,12 +164,12 @@ class SmbTest extends \Test\Files\Storage\Storage {
$this->instance->rmdir('foo2');
}
- public function testUnlinkRoot() {
+ public function testUnlinkRoot(): void {
// root can't be deleted
$this->assertFalse($this->instance->unlink(''));
}
- public function testRmdirRoot() {
+ public function testRmdirRoot(): void {
// root can't be deleted
$this->assertFalse($this->instance->rmdir(''));
}
diff --git a/apps/files_external/tests/Storage/SwiftTest.php b/apps/files_external/tests/Storage/SwiftTest.php
index 53ca499e4eb..17037e76ee3 100644
--- a/apps/files_external/tests/Storage/SwiftTest.php
+++ b/apps/files_external/tests/Storage/SwiftTest.php
@@ -1,4 +1,6 @@
<?php
+
+declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -53,7 +55,7 @@ class SwiftTest extends \Test\Files\Storage\Storage {
parent::tearDown();
}
- public function testStat() {
+ public function testStat(): void {
$this->markTestSkipped('Swift doesn\'t update the parents folder mtime');
}
}
diff --git a/apps/files_external/tests/Storage/VersionedAmazonS3Test.php b/apps/files_external/tests/Storage/VersionedAmazonS3Test.php
index 4d9d1e32067..9d413620292 100644
--- a/apps/files_external/tests/Storage/VersionedAmazonS3Test.php
+++ b/apps/files_external/tests/Storage/VersionedAmazonS3Test.php
@@ -10,6 +10,7 @@ namespace OCA\Files_External\Tests\Storage;
/**
* @group DB
+ * @group S3
*/
class VersionedAmazonS3Test extends Amazons3Test {
protected function setUp(): void {
@@ -25,4 +26,12 @@ class VersionedAmazonS3Test extends Amazons3Test {
$this->markTestSkipped("s3 backend doesn't seem to support versioning");
}
}
+
+ public function testCopyOverWriteDirectory(): void {
+ if (isset($this->config['minio'])) {
+ $this->markTestSkipped('MinIO has a bug with batch deletion on versioned storages, see https://github.com/minio/minio/issues/21366');
+ }
+
+ parent::testCopyOverWriteDirectory();
+ }
}
diff --git a/apps/files_external/tests/Storage/WebdavTest.php b/apps/files_external/tests/Storage/WebdavTest.php
index a063ddebb0d..a8de178effd 100644
--- a/apps/files_external/tests/Storage/WebdavTest.php
+++ b/apps/files_external/tests/Storage/WebdavTest.php
@@ -1,4 +1,6 @@
<?php
+
+declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -8,6 +10,8 @@ namespace OCA\Files_External\Tests\Storage;
use OC\Files\Storage\DAV;
use OC\Files\Type\Detection;
+use OCP\Files\IMimeTypeDetector;
+use OCP\Server;
/**
* Class WebdavTest
@@ -41,11 +45,11 @@ class WebdavTest extends \Test\Files\Storage\Storage {
parent::tearDown();
}
- public function testMimetypeFallback() {
+ public function testMimetypeFallback(): void {
$this->instance->file_put_contents('foo.bar', 'asd');
/** @var Detection $mimeDetector */
- $mimeDetector = \OC::$server->getMimeTypeDetector();
+ $mimeDetector = Server::get(IMimeTypeDetector::class);
$mimeDetector->registerType('bar', 'application/x-bar');
$this->assertEquals('application/x-bar', $this->instance->getMimeType('foo.bar'));