diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2019-11-28 08:36:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-28 08:36:10 +0100 |
commit | 669302e570024c83140ff5c4f4b1489c5a1c66ed (patch) | |
tree | 010182798f5c83193554031753e063a8a0b35ca1 /apps/files_external | |
parent | 125be68311a319f2b839e5aa4ea29cd642cd1e00 (diff) | |
parent | e3e782b63df4f1d65c86cb3b204b4bdecf93a6cd (diff) | |
download | nextcloud-server-669302e570024c83140ff5c4f4b1489c5a1c66ed.tar.gz nextcloud-server-669302e570024c83140ff5c4f4b1489c5a1c66ed.zip |
Merge pull request #18064 from nextcloud/feature/php74
Add php7.4 support
Diffstat (limited to 'apps/files_external')
22 files changed, 86 insertions, 79 deletions
diff --git a/apps/files_external/tests/Auth/Password/GlobalAuth.php b/apps/files_external/tests/Auth/Password/GlobalAuth.php index c447be7a669..7c28f1b3f53 100644 --- a/apps/files_external/tests/Auth/Password/GlobalAuth.php +++ b/apps/files_external/tests/Auth/Password/GlobalAuth.php @@ -45,7 +45,7 @@ class GlobalAuthTest extends TestCase { */ private $instance; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->l10n = $this->createMock(IL10N::class); $this->credentialsManager = $this->createMock(ICredentialsManager::class); @@ -105,10 +105,10 @@ class GlobalAuthTest extends TestCase { ], $storage->getBackendOptions()); } - /** - * @expectedException \OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException - */ + public function testNoCredentialsPersonal() { + $this->expectException(\OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException::class); + $this->credentialsManager->expects($this->never()) ->method('retrieve'); diff --git a/apps/files_external/tests/Config/UserPlaceholderHandlerTest.php b/apps/files_external/tests/Config/UserPlaceholderHandlerTest.php index dcafdd84e3d..ba064b8fb6f 100644 --- a/apps/files_external/tests/Config/UserPlaceholderHandlerTest.php +++ b/apps/files_external/tests/Config/UserPlaceholderHandlerTest.php @@ -50,7 +50,7 @@ class UserPlaceholderHandlerTest extends \Test\TestCase { /** @var UserPlaceholderHandler */ protected $handler; - public function setUp() { + protected function setUp(): void { parent::setUp(); $this->user = $this->createMock(IUser::class); diff --git a/apps/files_external/tests/Controller/AjaxControllerTest.php b/apps/files_external/tests/Controller/AjaxControllerTest.php index f18ee8323b3..6bb9c3418ee 100644 --- a/apps/files_external/tests/Controller/AjaxControllerTest.php +++ b/apps/files_external/tests/Controller/AjaxControllerTest.php @@ -48,7 +48,7 @@ class AjaxControllerTest extends TestCase { /** @var AjaxController */ private $ajaxController; - public function setUp() { + protected function setUp(): void { $this->request = $this->createMock(IRequest::class); $this->rsa = $this->getMockBuilder('\\OCA\\Files_External\\Lib\\Auth\\PublicKey\\RSA') ->disableOriginalConstructor() diff --git a/apps/files_external/tests/Controller/GlobalStoragesControllerTest.php b/apps/files_external/tests/Controller/GlobalStoragesControllerTest.php index c3a684f2e98..458714e463a 100644 --- a/apps/files_external/tests/Controller/GlobalStoragesControllerTest.php +++ b/apps/files_external/tests/Controller/GlobalStoragesControllerTest.php @@ -34,7 +34,7 @@ use OCP\ILogger; use OCP\IRequest; class GlobalStoragesControllerTest extends StoragesControllerTest { - public function setUp() { + protected function setUp(): void { parent::setUp(); $this->service = $this->getMockBuilder('\OCA\Files_External\Service\GlobalStoragesService') ->disableOriginalConstructor() diff --git a/apps/files_external/tests/Controller/StoragesControllerTest.php b/apps/files_external/tests/Controller/StoragesControllerTest.php index 0340057809d..d865b3e8d0f 100644 --- a/apps/files_external/tests/Controller/StoragesControllerTest.php +++ b/apps/files_external/tests/Controller/StoragesControllerTest.php @@ -46,11 +46,11 @@ abstract class StoragesControllerTest extends \Test\TestCase { */ protected $service; - public function setUp() { + protected function setUp(): void { \OC_Mount_Config::$skipTest = true; } - public function tearDown() { + protected function tearDown(): void { \OC_Mount_Config::$skipTest = false; } diff --git a/apps/files_external/tests/Controller/UserStoragesControllerTest.php b/apps/files_external/tests/Controller/UserStoragesControllerTest.php index 067fd45972c..f130af7c76f 100644 --- a/apps/files_external/tests/Controller/UserStoragesControllerTest.php +++ b/apps/files_external/tests/Controller/UserStoragesControllerTest.php @@ -42,7 +42,7 @@ class UserStoragesControllerTest extends StoragesControllerTest { */ private $oldAllowedBackends; - public function setUp() { + protected function setUp(): void { parent::setUp(); $this->service = $this->getMockBuilder('\OCA\Files_External\Service\UserStoragesService') ->disableOriginalConstructor() diff --git a/apps/files_external/tests/Service/BackendServiceTest.php b/apps/files_external/tests/Service/BackendServiceTest.php index 707ee899419..526098dc2b4 100644 --- a/apps/files_external/tests/Service/BackendServiceTest.php +++ b/apps/files_external/tests/Service/BackendServiceTest.php @@ -37,7 +37,7 @@ class BackendServiceTest extends \Test\TestCase { /** @var \OCP\IConfig|\PHPUnit_Framework_MockObject_MockObject */ protected $config; - protected function setUp() { + protected function setUp(): void { $this->config = $this->createMock(IConfig::class); } @@ -234,9 +234,10 @@ class BackendServiceTest extends \Test\TestCase { /** * @dataProvider invalidConfigPlaceholderProvider - * @expectedException \RuntimeException */ public function testRegisterConfigHandlerInvalid(array $placeholders) { + $this->expectException(\RuntimeException::class); + $service = new BackendService($this->config); $mock = $this->createMock(IConfigHandler::class); $cb = function () use ($mock) { return $mock; }; diff --git a/apps/files_external/tests/Service/DBConfigServiceTest.php b/apps/files_external/tests/Service/DBConfigServiceTest.php index e6115ddec20..7a04a8f61b7 100644 --- a/apps/files_external/tests/Service/DBConfigServiceTest.php +++ b/apps/files_external/tests/Service/DBConfigServiceTest.php @@ -44,13 +44,13 @@ class DBConfigServiceTest extends TestCase { private $mounts = []; - public function setUp() { + protected function setUp(): void { parent::setUp(); $this->connection = \OC::$server->getDatabaseConnection(); $this->dbConfig = new DBConfigService($this->connection, \OC::$server->getCrypto()); } - public function tearDown() { + protected function tearDown(): void { foreach ($this->mounts as $mount) { $this->dbConfig->removeMount($mount); } diff --git a/apps/files_external/tests/Service/GlobalStoragesServiceTest.php b/apps/files_external/tests/Service/GlobalStoragesServiceTest.php index 2760374e59d..37ae71696f0 100644 --- a/apps/files_external/tests/Service/GlobalStoragesServiceTest.php +++ b/apps/files_external/tests/Service/GlobalStoragesServiceTest.php @@ -33,12 +33,12 @@ use OCA\Files_External\Service\GlobalStoragesService; * @group DB */ class GlobalStoragesServiceTest extends StoragesServiceTest { - public function setUp() { + protected function setUp(): void { parent::setUp(); $this->service = new GlobalStoragesService($this->backendService, $this->dbConfig, $this->mountCache); } - public function tearDown() { + protected function tearDown(): void { @unlink($this->dataDir . '/mount.json'); parent::tearDown(); } @@ -471,8 +471,7 @@ class GlobalStoragesServiceTest extends StoragesServiceTest { } } - /** - */ + public function testHooksRenameMountPoint() { $storage = $this->makeTestStorageData(); $storage->setApplicableUsers(['user1', 'user2']); diff --git a/apps/files_external/tests/Service/StoragesServiceTest.php b/apps/files_external/tests/Service/StoragesServiceTest.php index ef0f1852d91..33186724338 100644 --- a/apps/files_external/tests/Service/StoragesServiceTest.php +++ b/apps/files_external/tests/Service/StoragesServiceTest.php @@ -92,7 +92,7 @@ abstract class StoragesServiceTest extends \Test\TestCase { */ protected $mountCache; - public function setUp() { + protected function setUp(): void { parent::setUp(); $this->dbConfig = new CleaningDBConfig(\OC::$server->getDatabaseConnection(), \OC::$server->getCrypto()); self::$hookCalls = array(); @@ -175,7 +175,7 @@ abstract class StoragesServiceTest extends \Test\TestCase { ->willReturn($containerMock); } - public function tearDown() { + protected function tearDown(): void { \OC_Mount_Config::$skipTest = false; self::$hookCalls = array(); if ($this->dbConfig) { @@ -252,10 +252,7 @@ abstract class StoragesServiceTest extends \Test\TestCase { } - /** - * @expectedException \OCA\Files_External\NotFoundException - */ - public function testNonExistingStorage() { + protected function ActualNonExistingStorageTest() { $backend = $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\SMB'); $authMechanism = $this->backendService->getAuthMechanism('identifier:\Auth\Mechanism'); $storage = new StorageConfig(255); @@ -265,6 +262,12 @@ abstract class StoragesServiceTest extends \Test\TestCase { $this->service->updateStorage($storage); } + public function testNonExistingStorage() { + $this->expectException(\OCA\Files_External\NotFoundException::class); + + $this->ActualNonExistingStorageTest(); + } + public function deleteStorageDataProvider() { return [ // regular case, can properly delete the oc_storages entry @@ -334,13 +337,16 @@ abstract class StoragesServiceTest extends \Test\TestCase { $this->assertCount($expectedCountAfterDeletion, $storages, "expected $expectedCountAfterDeletion storages, got " . json_encode($storages)); } - /** - * @expectedException \OCA\Files_External\NotFoundException - */ - public function testDeleteUnexistingStorage() { + protected function actualDeletedUnexistingStorageTest() { $this->service->removeStorage(255); } + public function testDeleteUnexistingStorage() { + $this->expectException(\OCA\Files_External\NotFoundException::class); + + $this->actualDeletedUnexistingStorageTest(); + } + public function testCreateStorage() { $mountPoint = 'mount'; $backendIdentifier = 'identifier:\OCA\Files_External\Lib\Backend\SMB'; diff --git a/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php b/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php index 3a6d22f2ad4..265da46804a 100644 --- a/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php +++ b/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php @@ -60,7 +60,7 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest { const GROUP_ID = 'test_group'; const GROUP_ID2 = 'test_group2'; - public function setUp() { + protected function setUp(): void { parent::setUp(); $this->globalStoragesService = $this->service; @@ -158,10 +158,10 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest { } - /** - * @expectedException \DomainException - */ + public function testAddStorage($storageParams = null) { + $this->expectException(\DomainException::class); + $backend = $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\SMB'); $authMechanism = $this->backendService->getAuthMechanism('identifier:\Auth\Mechanism'); @@ -174,10 +174,10 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest { $this->service->addStorage($storage); } - /** - * @expectedException \DomainException - */ + public function testUpdateStorage($storageParams = null) { + $this->expectException(\DomainException::class); + $backend = $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\SMB'); $authMechanism = $this->backendService->getAuthMechanism('identifier:\Auth\Mechanism'); @@ -194,18 +194,19 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest { $this->service->updateStorage($retrievedStorage); } - /** - * @expectedException \DomainException - */ + public function testNonExistingStorage() { - parent::testNonExistingStorage(); + $this->expectException(\DomainException::class); + + $this->ActualNonExistingStorageTest(); } /** - * @expectedException \DomainException * @dataProvider deleteStorageDataProvider */ public function testDeleteStorage($backendOptions, $rustyStorageId, $expectedCountAfterDeletion) { + $this->expectException(\DomainException::class); + $backend = $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\SMB'); $authMechanism = $this->backendService->getAuthMechanism('identifier:\Auth\Mechanism'); @@ -221,11 +222,11 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest { $this->service->removeStorage($id); } - /** - * @expectedException \DomainException - */ + public function testDeleteUnexistingStorage() { - parent::testDeleteUnexistingStorage(); + $this->expectException(\DomainException::class); + + $this->actualDeletedUnexistingStorageTest(); } public function getUniqueStoragesProvider() { diff --git a/apps/files_external/tests/Service/UserStoragesServiceTest.php b/apps/files_external/tests/Service/UserStoragesServiceTest.php index ea6346151bf..7b9d16211e0 100644 --- a/apps/files_external/tests/Service/UserStoragesServiceTest.php +++ b/apps/files_external/tests/Service/UserStoragesServiceTest.php @@ -50,7 +50,7 @@ class UserStoragesServiceTest extends StoragesServiceTest { */ protected $globalStoragesService; - public function setUp() { + protected function setUp(): void { parent::setUp(); $this->globalStoragesService = new GlobalStoragesService($this->backendService, $this->dbConfig, $this->mountCache); @@ -189,10 +189,10 @@ class UserStoragesServiceTest extends StoragesServiceTest { ); } - /** - * @expectedException \OCA\Files_External\NotFoundException - */ + public function testGetAdminStorage() { + $this->expectException(\OCA\Files_External\NotFoundException::class); + $backend = $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\SMB'); $authMechanism = $this->backendService->getAuthMechanism('identifier:\Auth\Mechanism'); diff --git a/apps/files_external/tests/Settings/AdminTest.php b/apps/files_external/tests/Settings/AdminTest.php index 6236f2d416a..1d24cbbde10 100644 --- a/apps/files_external/tests/Settings/AdminTest.php +++ b/apps/files_external/tests/Settings/AdminTest.php @@ -43,7 +43,7 @@ class AdminTest extends TestCase { /** @var GlobalAuth|\PHPUnit_Framework_MockObject_MockObject */ private $globalAuth; - public function setUp() { + protected function setUp(): void { parent::setUp(); $this->encryptionManager = $this->createMock(IManager::class); $this->globalStoragesService = $this->createMock(GlobalStoragesService::class); diff --git a/apps/files_external/tests/Settings/SectionTest.php b/apps/files_external/tests/Settings/SectionTest.php index b83f8f0feef..b9ce3e3aa9a 100644 --- a/apps/files_external/tests/Settings/SectionTest.php +++ b/apps/files_external/tests/Settings/SectionTest.php @@ -37,7 +37,7 @@ class SectionTest extends TestCase { /** @var Section */ private $section; - public function setUp() { + protected function setUp(): void { parent::setUp(); $this->urlGenerator = $this->getMockBuilder(IURLGenerator::class)->disableOriginalConstructor()->getMock(); $this->l = $this->getMockBuilder(IL10N::class)->disableOriginalConstructor()->getMock(); diff --git a/apps/files_external/tests/Storage/Amazons3Test.php b/apps/files_external/tests/Storage/Amazons3Test.php index 83552ca21a3..985c93423a7 100644 --- a/apps/files_external/tests/Storage/Amazons3Test.php +++ b/apps/files_external/tests/Storage/Amazons3Test.php @@ -40,7 +40,7 @@ class Amazons3Test extends \Test\Files\Storage\Storage { private $config; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->config = include('files_external/tests/config.amazons3.php'); @@ -50,7 +50,7 @@ class Amazons3Test extends \Test\Files\Storage\Storage { $this->instance = new AmazonS3($this->config); } - protected function tearDown() { + protected function tearDown(): void { if ($this->instance) { $this->instance->rmdir(''); } diff --git a/apps/files_external/tests/Storage/FtpTest.php b/apps/files_external/tests/Storage/FtpTest.php index 0e12a5f4afa..b2dd83b75a7 100644 --- a/apps/files_external/tests/Storage/FtpTest.php +++ b/apps/files_external/tests/Storage/FtpTest.php @@ -40,7 +40,7 @@ use OCA\Files_External\Lib\Storage\FTP; class FtpTest extends \Test\Files\Storage\Storage { private $config; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $id = $this->getUniqueID(); @@ -53,7 +53,7 @@ class FtpTest extends \Test\Files\Storage\Storage { $this->instance->mkdir('/'); } - protected function tearDown() { + protected function tearDown(): void { if ($this->instance) { \OCP\Files::rmdirr($this->instance->constructUrl('')); } diff --git a/apps/files_external/tests/Storage/OwncloudTest.php b/apps/files_external/tests/Storage/OwncloudTest.php index 3853d0e6ce1..8a274af165e 100644 --- a/apps/files_external/tests/Storage/OwncloudTest.php +++ b/apps/files_external/tests/Storage/OwncloudTest.php @@ -39,7 +39,7 @@ class OwncloudTest extends \Test\Files\Storage\Storage { private $config; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $id = $this->getUniqueID(); @@ -52,7 +52,7 @@ class OwncloudTest extends \Test\Files\Storage\Storage { $this->instance->mkdir('/'); } - protected function tearDown() { + protected function tearDown(): void { if ($this->instance) { $this->instance->rmdir('/'); } diff --git a/apps/files_external/tests/Storage/SFTP_KeyTest.php b/apps/files_external/tests/Storage/SFTP_KeyTest.php index c67d418f674..4e8e6431a72 100644 --- a/apps/files_external/tests/Storage/SFTP_KeyTest.php +++ b/apps/files_external/tests/Storage/SFTP_KeyTest.php @@ -38,7 +38,7 @@ use OCA\Files_External\Lib\Storage\SFTP_Key; class SFTP_KeyTest extends \Test\Files\Storage\Storage { private $config; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $id = $this->getUniqueID(); @@ -52,7 +52,7 @@ class SFTP_KeyTest extends \Test\Files\Storage\Storage { $this->instance->mkdir('/'); } - protected function tearDown() { + protected function tearDown(): void { if ($this->instance) { $this->instance->rmdir('/'); } @@ -60,10 +60,10 @@ class SFTP_KeyTest extends \Test\Files\Storage\Storage { parent::tearDown(); } - /** - * @expectedException InvalidArgumentException - */ + public function testInvalidAddressShouldThrowException() { + $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...'); } @@ -72,24 +72,24 @@ class SFTP_KeyTest extends \Test\Files\Storage\Storage { $this->assertTrue($this->instance->assertHostAddressValid('localhost')); } - /** - * @expectedException InvalidArgumentException - */ + public function testNegativePortNumberShouldThrowException() { + $this->expectException(\InvalidArgumentException::class); + $this->instance->assertPortNumberValid('-1'); } - /** - * @expectedException InvalidArgumentException - */ + public function testNonNumericalPortNumberShouldThrowException() { + $this->expectException(\InvalidArgumentException::class); + $this->instance->assertPortNumberValid('a'); } - /** - * @expectedException InvalidArgumentException - */ - public function testHighPortNumberShouldThrowException() { + + public function testHighPortNumberShouldThrowException() { + $this->expectException(\InvalidArgumentException::class); + $this->instance->assertPortNumberValid('65536'); } diff --git a/apps/files_external/tests/Storage/SftpTest.php b/apps/files_external/tests/Storage/SftpTest.php index 9ad7cfd56a8..bee514485a5 100644 --- a/apps/files_external/tests/Storage/SftpTest.php +++ b/apps/files_external/tests/Storage/SftpTest.php @@ -45,7 +45,7 @@ class SftpTest extends \Test\Files\Storage\Storage { private $config; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $id = $this->getUniqueID(); @@ -58,7 +58,7 @@ class SftpTest extends \Test\Files\Storage\Storage { $this->instance->mkdir('/'); } - protected function tearDown() { + protected function tearDown(): void { if ($this->instance) { $this->instance->rmdir('/'); } diff --git a/apps/files_external/tests/Storage/SmbTest.php b/apps/files_external/tests/Storage/SmbTest.php index fc59f0ed38b..645cb0e2907 100644 --- a/apps/files_external/tests/Storage/SmbTest.php +++ b/apps/files_external/tests/Storage/SmbTest.php @@ -46,7 +46,7 @@ class SmbTest extends \Test\Files\Storage\Storage { */ protected $instance; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $id = $this->getUniqueID(); @@ -62,7 +62,7 @@ class SmbTest extends \Test\Files\Storage\Storage { $this->instance->mkdir('/'); } - protected function tearDown() { + protected function tearDown(): void { if ($this->instance) { $this->instance->rmdir(''); } diff --git a/apps/files_external/tests/Storage/SwiftTest.php b/apps/files_external/tests/Storage/SwiftTest.php index 6517be493d7..2e1bc5e0ed3 100644 --- a/apps/files_external/tests/Storage/SwiftTest.php +++ b/apps/files_external/tests/Storage/SwiftTest.php @@ -46,7 +46,7 @@ class SwiftTest extends \Test\Files\Storage\Storage { */ protected $instance; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->config = include('files_external/tests/config.swift.php'); @@ -56,7 +56,7 @@ class SwiftTest extends \Test\Files\Storage\Storage { $this->instance = new Swift($this->config); } - protected function tearDown() { + protected function tearDown(): void { if ($this->instance) { try { $container = $this->instance->getContainer(); diff --git a/apps/files_external/tests/Storage/WebdavTest.php b/apps/files_external/tests/Storage/WebdavTest.php index c0d69592c2a..1aae245d675 100644 --- a/apps/files_external/tests/Storage/WebdavTest.php +++ b/apps/files_external/tests/Storage/WebdavTest.php @@ -39,7 +39,7 @@ use OC\Files\Type\Detection; */ class WebdavTest extends \Test\Files\Storage\Storage { - protected function setUp() { + protected function setUp(): void { parent::setUp(); $id = $this->getUniqueID(); @@ -55,7 +55,7 @@ class WebdavTest extends \Test\Files\Storage\Storage { $this->instance->mkdir('/'); } - protected function tearDown() { + protected function tearDown(): void { if ($this->instance) { $this->instance->rmdir('/'); } |