summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/tests
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2019-11-28 08:36:10 +0100
committerGitHub <noreply@github.com>2019-11-28 08:36:10 +0100
commit669302e570024c83140ff5c4f4b1489c5a1c66ed (patch)
tree010182798f5c83193554031753e063a8a0b35ca1 /apps/files_sharing/tests
parent125be68311a319f2b839e5aa4ea29cd642cd1e00 (diff)
parente3e782b63df4f1d65c86cb3b204b4bdecf93a6cd (diff)
downloadnextcloud-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_sharing/tests')
-rw-r--r--apps/files_sharing/tests/ApiTest.php4
-rw-r--r--apps/files_sharing/tests/CacheTest.php4
-rw-r--r--apps/files_sharing/tests/CapabilitiesTest.php10
-rw-r--r--apps/files_sharing/tests/Collaboration/ShareRecipientSorterTest.php2
-rw-r--r--apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php6
-rw-r--r--apps/files_sharing/tests/Controller/ExternalShareControllerTest.php2
-rw-r--r--apps/files_sharing/tests/Controller/PublicPreviewControllerTest.php2
-rw-r--r--apps/files_sharing/tests/Controller/ShareAPIControllerTest.php260
-rw-r--r--apps/files_sharing/tests/Controller/ShareControllerTest.php10
-rw-r--r--apps/files_sharing/tests/Controller/ShareInfoControllerTest.php2
-rw-r--r--apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php10
-rw-r--r--apps/files_sharing/tests/DeleteOrphanedSharesJobTest.php8
-rw-r--r--apps/files_sharing/tests/ExpireSharesJobTest.php4
-rw-r--r--apps/files_sharing/tests/External/CacheTest.php4
-rw-r--r--apps/files_sharing/tests/External/ManagerTest.php36
-rw-r--r--apps/files_sharing/tests/External/ScannerTest.php2
-rw-r--r--apps/files_sharing/tests/LockingTest.php10
-rw-r--r--apps/files_sharing/tests/Middleware/OCSShareAPIMiddlewareTest.php2
-rw-r--r--apps/files_sharing/tests/Middleware/ShareInfoMiddlewareTest.php2
-rw-r--r--apps/files_sharing/tests/Middleware/SharingCheckMiddlewareTest.php18
-rw-r--r--apps/files_sharing/tests/Migration/SetPasswordColumnTest.php4
-rw-r--r--apps/files_sharing/tests/MountProviderTest.php2
-rw-r--r--apps/files_sharing/tests/PermissionsTest.php4
-rw-r--r--apps/files_sharing/tests/PropagationTestCase.php6
-rw-r--r--apps/files_sharing/tests/ShareTest.php4
-rw-r--r--apps/files_sharing/tests/SharedMountTest.php4
-rw-r--r--apps/files_sharing/tests/SharedStorageTest.php4
-rw-r--r--apps/files_sharing/tests/TestCase.php8
-rw-r--r--apps/files_sharing/tests/UnshareChildrenTest.php4
-rw-r--r--apps/files_sharing/tests/UpdaterTest.php6
-rw-r--r--apps/files_sharing/tests/WatcherTest.php4
31 files changed, 236 insertions, 212 deletions
diff --git a/apps/files_sharing/tests/ApiTest.php b/apps/files_sharing/tests/ApiTest.php
index 5cf3906e565..05acb9c18e2 100644
--- a/apps/files_sharing/tests/ApiTest.php
+++ b/apps/files_sharing/tests/ApiTest.php
@@ -63,7 +63,7 @@ class ApiTest extends TestCase {
/** @var string */
private $subsubfolder;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
\OC::$server->getConfig()->setAppValue('core', 'shareapi_exclude_groups', 'no');
@@ -88,7 +88,7 @@ class ApiTest extends TestCase {
$this->userFolder = \OC::$server->getUserFolder(self::TEST_FILES_SHARING_API_USER1);
}
- protected function tearDown() {
+ protected function tearDown(): void {
if($this->view instanceof \OC\Files\View) {
$this->view->unlink($this->filename);
$this->view->deleteAll($this->folder);
diff --git a/apps/files_sharing/tests/CacheTest.php b/apps/files_sharing/tests/CacheTest.php
index e8d8ae7f63b..d2f96d01eb8 100644
--- a/apps/files_sharing/tests/CacheTest.php
+++ b/apps/files_sharing/tests/CacheTest.php
@@ -62,7 +62,7 @@ class CacheTest extends TestCase {
/** @var \OCP\Share\IManager */
protected $shareManager;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->shareManager = \OC::$server->getShareManager();
@@ -128,7 +128,7 @@ class CacheTest extends TestCase {
$this->sharedCache = $this->sharedStorage->getCache();
}
- protected function tearDown() {
+ protected function tearDown(): void {
if($this->sharedCache) {
$this->sharedCache->clear();
}
diff --git a/apps/files_sharing/tests/CapabilitiesTest.php b/apps/files_sharing/tests/CapabilitiesTest.php
index 493f607dba2..3f8dd85c10b 100644
--- a/apps/files_sharing/tests/CapabilitiesTest.php
+++ b/apps/files_sharing/tests/CapabilitiesTest.php
@@ -92,7 +92,7 @@ class CapabilitiesTest extends \Test\TestCase {
['core', 'shareapi_allow_links', 'yes', 'no'],
];
$result = $this->getResults($map);
- $this->assertInternalType('array', $result['public']);
+ $this->assertIsArray($result['public']);
$this->assertFalse($result['public']['enabled']);
}
@@ -102,7 +102,7 @@ class CapabilitiesTest extends \Test\TestCase {
['core', 'shareapi_allow_links', 'yes', 'yes'],
];
$result = $this->getResults($map);
- $this->assertInternalType('array', $result['public']);
+ $this->assertIsArray($result['public']);
$this->assertTrue($result['public']['enabled']);
}
@@ -138,7 +138,7 @@ class CapabilitiesTest extends \Test\TestCase {
];
$result = $this->getResults($map);
$this->assertArrayHasKey('expire_date', $result['public']);
- $this->assertInternalType('array', $result['public']['expire_date']);
+ $this->assertIsArray($result['public']['expire_date']);
$this->assertFalse($result['public']['expire_date']['enabled']);
}
@@ -152,7 +152,7 @@ class CapabilitiesTest extends \Test\TestCase {
];
$result = $this->getResults($map);
$this->assertArrayHasKey('expire_date', $result['public']);
- $this->assertInternalType('array', $result['public']['expire_date']);
+ $this->assertIsArray($result['public']['expire_date']);
$this->assertTrue($result['public']['expire_date']['enabled']);
$this->assertArrayHasKey('days', $result['public']['expire_date']);
$this->assertFalse($result['public']['expire_date']['enforced']);
@@ -167,7 +167,7 @@ class CapabilitiesTest extends \Test\TestCase {
];
$result = $this->getResults($map);
$this->assertArrayHasKey('expire_date', $result['public']);
- $this->assertInternalType('array', $result['public']['expire_date']);
+ $this->assertIsArray($result['public']['expire_date']);
$this->assertTrue($result['public']['expire_date']['enforced']);
}
diff --git a/apps/files_sharing/tests/Collaboration/ShareRecipientSorterTest.php b/apps/files_sharing/tests/Collaboration/ShareRecipientSorterTest.php
index 8f516788761..146bb565a81 100644
--- a/apps/files_sharing/tests/Collaboration/ShareRecipientSorterTest.php
+++ b/apps/files_sharing/tests/Collaboration/ShareRecipientSorterTest.php
@@ -43,7 +43,7 @@ class ShareRecipientSorterTest extends TestCase {
/** @var ShareRecipientSorter */
protected $sorter;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->shareManager = $this->createMock(IManager::class);
diff --git a/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php b/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php
index 257d9c35dff..102210e3b1e 100644
--- a/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php
+++ b/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php
@@ -57,7 +57,7 @@ class CleanupRemoteStoragesTest extends TestCase {
['notExistingId' => 'shared::c34568c143cdac7d2f06e0800b5280f9', 'share_token' => 'f2c69dad1dc0649f26976fd210fc62e7', 'remote' => 'https://hostname.tld/owncloud7', 'user' => 'user7'],
];
- protected function setup() {
+ protected function setUp(): void {
parent::setUp();
$this->connection = \OC::$server->getDatabaseConnection();
@@ -110,7 +110,7 @@ class CleanupRemoteStoragesTest extends TestCase {
$this->command = new CleanupRemoteStorages($this->connection);
}
- public function tearDown() {
+ protected function tearDown(): void {
$storageQuery = \OC::$server->getDatabaseConnection()->getQueryBuilder();
$storageQuery->delete('storages')
->where($storageQuery->expr()->eq('id', $storageQuery->createParameter('id')));
@@ -133,7 +133,7 @@ class CleanupRemoteStoragesTest extends TestCase {
}
}
- return parent::tearDown();
+ parent::tearDown();
}
private function doesStorageExist($numericId) {
diff --git a/apps/files_sharing/tests/Controller/ExternalShareControllerTest.php b/apps/files_sharing/tests/Controller/ExternalShareControllerTest.php
index 71a4f4adeba..5296a1ad0c3 100644
--- a/apps/files_sharing/tests/Controller/ExternalShareControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ExternalShareControllerTest.php
@@ -43,7 +43,7 @@ class ExternalShareControllerTest extends \Test\TestCase {
/** @var IClientService */
private $clientService;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->request = $this->getMockBuilder('\\OCP\\IRequest')
->disableOriginalConstructor()->getMock();
diff --git a/apps/files_sharing/tests/Controller/PublicPreviewControllerTest.php b/apps/files_sharing/tests/Controller/PublicPreviewControllerTest.php
index ed556172a27..834796bf431 100644
--- a/apps/files_sharing/tests/Controller/PublicPreviewControllerTest.php
+++ b/apps/files_sharing/tests/Controller/PublicPreviewControllerTest.php
@@ -54,7 +54,7 @@ class PublicPreviewControllerTest extends TestCase {
/** @var PublicPreviewController */
private $controller;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->previewManager = $this->createMock(IPreview::class);
diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
index 6452ad50019..ae7fc54599c 100644
--- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
@@ -100,7 +100,7 @@ class ShareAPIControllerTest extends TestCase {
/** @var IServerContainer|\PHPUnit_Framework_MockObject_MockObject */
private $serverContainer;
- protected function setUp() {
+ protected function setUp(): void {
$this->shareManager = $this->createMock(IManager::class);
$this->shareManager
->expects($this->any())
@@ -164,11 +164,11 @@ class ShareAPIControllerTest extends TestCase {
return \OC::$server->getShareManager()->newShare();
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException
- * @expectedExceptionMessage Wrong share ID, share doesn't exist
- */
+
public function testDeleteShareShareNotFound() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectExceptionMessage('Wrong share ID, share doesn\'t exist');
+
$this->shareManager
->expects($this->exactly(3))
->method('getShareById')
@@ -212,16 +212,16 @@ class ShareAPIControllerTest extends TestCase {
$this->assertEquals($expected->getData(), $result->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException
- * @expectedExceptionMessage Could not delete share
- */
+
public function testDeleteShareLocked() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectExceptionMessage('Could not delete share');
+
$node = $this->getMockBuilder(File::class)->getMock();
$share = $this->newShare();
$share->setNode($node);
-
+
$this->shareManager
->expects($this->once())
->method('getShareById')
@@ -237,7 +237,7 @@ class ShareAPIControllerTest extends TestCase {
->method('lock')
->with(\OCP\Lock\ILockingProvider::LOCK_SHARED)
->will($this->throwException(new LockedException('mypath')));
-
+
$this->assertFalse($this->invokePrivate($this->ocs, 'canDeleteFromSelf', [$share]));
$this->assertFalse($this->invokePrivate($this->ocs, 'canDeleteShare', [$share]));
@@ -245,7 +245,7 @@ class ShareAPIControllerTest extends TestCase {
}
/**
- * You can always remove a share that was shared with you
+ * You can always remove a share that was shared with you
*/
public function testDeleteShareWithMe() {
$node = $this->getMockBuilder(File::class)->getMock();
@@ -254,7 +254,7 @@ class ShareAPIControllerTest extends TestCase {
$share->setSharedWith($this->currentUser)
->setShareType(\OCP\Share::SHARE_TYPE_USER)
->setNode($node);
-
+
$this->shareManager
->expects($this->once())
->method('getShareById')
@@ -269,7 +269,7 @@ class ShareAPIControllerTest extends TestCase {
$node->expects($this->once())
->method('lock')
->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
-
+
$this->assertFalse($this->invokePrivate($this->ocs, 'canDeleteFromSelf', [$share]));
$this->assertTrue($this->invokePrivate($this->ocs, 'canDeleteShare', [$share]));
@@ -300,7 +300,7 @@ class ShareAPIControllerTest extends TestCase {
$node->expects($this->once())
->method('lock')
->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
-
+
$this->assertFalse($this->invokePrivate($this->ocs, 'canDeleteFromSelf', [$share]));
$this->assertTrue($this->invokePrivate($this->ocs, 'canDeleteShare', [$share]));
@@ -332,7 +332,7 @@ class ShareAPIControllerTest extends TestCase {
$node->expects($this->once())
->method('lock')
->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
-
+
$this->assertFalse($this->invokePrivate($this->ocs, 'canDeleteFromSelf', [$share]));
$this->assertTrue($this->invokePrivate($this->ocs, 'canDeleteShare', [$share]));
@@ -388,10 +388,10 @@ class ShareAPIControllerTest extends TestCase {
$this->shareManager->expects($this->once())
->method('deleteFromSelf')
->with($share, $this->currentUser);
-
+
$this->shareManager->expects($this->never())
->method('deleteShare');
-
+
$this->assertTrue($this->invokePrivate($this->ocs, 'canDeleteShareFromSelf', [$share]));
$this->assertFalse($this->invokePrivate($this->ocs, 'canDeleteShare', [$share]));
@@ -401,10 +401,11 @@ class ShareAPIControllerTest extends TestCase {
/**
* You cannot remove a share if you're not
* in the group the share is shared with
- * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException
- * @expectedExceptionMessage Wrong share ID, share doesn't exist
*/
public function testDeleteSharedWithGroupIDontBelongTo() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectExceptionMessage('Wrong share ID, share doesn\'t exist');
+
$node = $this->getMockBuilder(File::class)->getMock();
$share = $this->newShare();
@@ -448,10 +449,10 @@ class ShareAPIControllerTest extends TestCase {
$this->shareManager->expects($this->never())
->method('deleteFromSelf');
-
+
$this->shareManager->expects($this->never())
->method('deleteShare');
-
+
$this->assertFalse($this->invokePrivate($this->ocs, 'canDeleteShareFromSelf', [$share]));
$this->assertFalse($this->invokePrivate($this->ocs, 'canDeleteShare', [$share]));
@@ -767,11 +768,11 @@ class ShareAPIControllerTest extends TestCase {
$this->assertEquals($result, $ocs->getShare($share->getId())->getData()[0]);
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException
- * @expectedExceptionMessage Wrong share ID, share doesn't exist
- */
+
public function testGetShareInvalidNode() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectExceptionMessage('Wrong share ID, share doesn\'t exist');
+
$share = \OC::$server->getShareManager()->newShare();
$share->setSharedBy('initiator')
->setSharedWith('recipient')
@@ -1533,19 +1534,19 @@ class ShareAPIControllerTest extends TestCase {
$this->assertEquals($expected, $this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException
- * @expectedExceptionMessage Please specify a file or folder path
- */
+
public function testCreateShareNoPath() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectExceptionMessage('Please specify a file or folder path');
+
$this->ocs->createShare();
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException
- * @expectedExceptionMessage Wrong path, file/folder doesn't exist
- */
+
public function testCreateShareInvalidPath() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectExceptionMessage('Wrong path, file/folder doesn\'t exist');
+
$userFolder = $this->getMockBuilder(Folder::class)->getMock();
$this->rootFolder->expects($this->once())
->method('getUserFolder')
@@ -1560,11 +1561,11 @@ class ShareAPIControllerTest extends TestCase {
$this->ocs->createShare('invalid-path');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException
- * @expectedExceptionMessage invalid permissions
- */
+
public function testCreateShareInvalidPermissions() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectExceptionMessage('invalid permissions');
+
$share = $this->newShare();
$this->shareManager->method('newShare')->willReturn($share);
@@ -1587,11 +1588,11 @@ class ShareAPIControllerTest extends TestCase {
$this->ocs->createShare('valid-path', 32);
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException
- * @expectedExceptionMessage Please specify a valid user
- */
+
public function testCreateShareUserNoShareWith() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectExceptionMessage('Please specify a valid user');
+
$share = $this->newShare();
$this->shareManager->method('newShare')->willReturn($share);
@@ -1602,7 +1603,7 @@ class ShareAPIControllerTest extends TestCase {
->willReturn($userFolder);
$path = $this->getMockBuilder(File::class)->getMock();
- $storage = $this->getMockBuilder(Storage::class)->getMock();
+ $storage = $this->createMock(Storage::class);
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
@@ -1619,11 +1620,11 @@ class ShareAPIControllerTest extends TestCase {
$this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER);
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException
- * @expectedExceptionMessage Please specify a valid user
- */
+
public function testCreateShareUserNoValidShareWith() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectExceptionMessage('Please specify a valid user');
+
$share = $this->newShare();
$this->shareManager->method('newShare')->willReturn($share);
@@ -1634,7 +1635,7 @@ class ShareAPIControllerTest extends TestCase {
->willReturn($userFolder);
$path = $this->getMockBuilder(File::class)->getMock();
- $storage = $this->getMockBuilder(Storage::class)->getMock();
+ $storage = $this->createMock(Storage::class);
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
@@ -1682,7 +1683,7 @@ class ShareAPIControllerTest extends TestCase {
->willReturn($userFolder);
$path = $this->getMockBuilder(File::class)->getMock();
- $storage = $this->getMockBuilder(Storage::class)->getMock();
+ $storage = $this->createMock(Storage::class);
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
@@ -1719,11 +1720,11 @@ class ShareAPIControllerTest extends TestCase {
$this->assertEquals($expected->getData(), $result->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException
- * @expectedExceptionMessage Please specify a valid group
- */
+
public function testCreateShareGroupNoValidShareWith() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectExceptionMessage('Please specify a valid group');
+
$share = $this->newShare();
$this->shareManager->method('newShare')->willReturn($share);
$this->shareManager->method('createShare')->will($this->returnArgument(0));
@@ -1736,7 +1737,7 @@ class ShareAPIControllerTest extends TestCase {
->willReturn($userFolder);
$path = $this->getMockBuilder(File::class)->getMock();
- $storage = $this->getMockBuilder(Storage::class)->getMock();
+ $storage = $this->createMock(Storage::class);
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
@@ -1791,7 +1792,7 @@ class ShareAPIControllerTest extends TestCase {
->willReturn($userFolder);
$path = $this->getMockBuilder(Folder::class)->getMock();
- $storage = $this->getMockBuilder(Storage::class)->getMock();
+ $storage = $this->createMock(Storage::class);
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
@@ -1828,11 +1829,11 @@ class ShareAPIControllerTest extends TestCase {
$this->assertEquals($expected->getData(), $result->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException
- * @expectedExceptionMessage Group sharing is disabled by the administrator
- */
+
public function testCreateShareGroupNotAllowed() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectExceptionMessage('Group sharing is disabled by the administrator');
+
$share = $this->newShare();
$this->shareManager->method('newShare')->willReturn($share);
@@ -1843,7 +1844,7 @@ class ShareAPIControllerTest extends TestCase {
->willReturn($userFolder);
$path = $this->getMockBuilder(Folder::class)->getMock();
- $storage = $this->getMockBuilder(Storage::class)->getMock();
+ $storage = $this->createMock(Storage::class);
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
@@ -1862,11 +1863,11 @@ class ShareAPIControllerTest extends TestCase {
$this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_GROUP, 'invalidGroup');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException
- * @expectedExceptionMessage Public link sharing is disabled by the administrator
- */
+
public function testCreateShareLinkNoLinksAllowed() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectExceptionMessage('Public link sharing is disabled by the administrator');
+
$this->request
->method('getParam')
->will($this->returnValueMap([
@@ -1875,7 +1876,7 @@ class ShareAPIControllerTest extends TestCase {
]));
$path = $this->getMockBuilder(Folder::class)->getMock();
- $storage = $this->getMockBuilder(Storage::class)->getMock();
+ $storage = $this->createMock(Storage::class);
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
@@ -1888,13 +1889,13 @@ class ShareAPIControllerTest extends TestCase {
$this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK);
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSForbiddenException
- * @expectedExceptionMessage Public upload disabled by the administrator
- */
+
public function testCreateShareLinkNoPublicUpload() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSForbiddenException::class);
+ $this->expectExceptionMessage('Public upload disabled by the administrator');
+
$path = $this->getMockBuilder(Folder::class)->getMock();
- $storage = $this->getMockBuilder(Storage::class)->getMock();
+ $storage = $this->createMock(Storage::class);
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
@@ -1908,13 +1909,13 @@ class ShareAPIControllerTest extends TestCase {
$this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'true');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException
- * @expectedExceptionMessage Public upload is only possible for publicly shared folders
- */
+
public function testCreateShareLinkPublicUploadFile() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectExceptionMessage('Public upload is only possible for publicly shared folders');
+
$path = $this->getMockBuilder(File::class)->getMock();
- $storage = $this->getMockBuilder(Storage::class)->getMock();
+ $storage = $this->createMock(Storage::class);
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
@@ -1933,7 +1934,7 @@ class ShareAPIControllerTest extends TestCase {
$ocs = $this->mockFormatShare();
$path = $this->getMockBuilder(Folder::class)->getMock();
- $storage = $this->getMockBuilder(Storage::class)->getMock();
+ $storage = $this->createMock(Storage::class);
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
@@ -1967,7 +1968,7 @@ class ShareAPIControllerTest extends TestCase {
$ocs = $this->mockFormatShare();
$path = $this->getMockBuilder(Folder::class)->getMock();
- $storage = $this->getMockBuilder(Storage::class)->getMock();
+ $storage = $this->createMock(Storage::class);
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
@@ -2001,7 +2002,7 @@ class ShareAPIControllerTest extends TestCase {
$ocs = $this->mockFormatShare();
$path = $this->getMockBuilder(Folder::class)->getMock();
- $storage = $this->getMockBuilder(Storage::class)->getMock();
+ $storage = $this->createMock(Storage::class);
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
@@ -2034,15 +2035,15 @@ class ShareAPIControllerTest extends TestCase {
$this->assertEquals($expected->getData(), $result->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSForbiddenException
- * @expectedExceptionMessage Sharing valid-path sending the password by Nextcloud Talk failed because Nextcloud Talk is not enabled
- */
+
public function testCreateShareLinkSendPasswordByTalkWithTalkDisabled() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSForbiddenException::class);
+ $this->expectExceptionMessage('Sharing valid-path sending the password by Nextcloud Talk failed because Nextcloud Talk is not enabled');
+
$ocs = $this->mockFormatShare();
$path = $this->getMockBuilder(Folder::class)->getMock();
- $storage = $this->getMockBuilder(Storage::class)->getMock();
+ $storage = $this->createMock(Storage::class);
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
@@ -2076,7 +2077,7 @@ class ShareAPIControllerTest extends TestCase {
]));
$path = $this->getMockBuilder(Folder::class)->getMock();
- $storage = $this->getMockBuilder(Storage::class)->getMock();
+ $storage = $this->createMock(Storage::class);
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
@@ -2109,15 +2110,15 @@ class ShareAPIControllerTest extends TestCase {
$this->assertEquals($expected->getData(), $result->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException
- * @expectedExceptionMessage Invalid date, date format must be YYYY-MM-DD
- */
+
public function testCreateShareInvalidExpireDate() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectExceptionMessage('Invalid date, date format must be YYYY-MM-DD');
+
$ocs = $this->mockFormatShare();
$path = $this->getMockBuilder(Folder::class)->getMock();
- $storage = $this->getMockBuilder(Storage::class)->getMock();
+ $storage = $this->createMock(Storage::class);
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
@@ -2145,7 +2146,7 @@ class ShareAPIControllerTest extends TestCase {
->willReturn($userFolder);
$path = $this->getMockBuilder(File::class)->getMock();
- $storage = $this->getMockBuilder(Storage::class)->getMock();
+ $storage = $this->createMock(Storage::class);
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
@@ -2210,11 +2211,11 @@ class ShareAPIControllerTest extends TestCase {
$this->assertEquals($expected->getData(), $result->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSForbiddenException
- * @expectedExceptionMessage Sharing valid-path failed because the back end does not support room shares
- */
+
public function testCreateShareRoomHelperNotAvailable() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSForbiddenException::class);
+ $this->expectExceptionMessage('Sharing valid-path failed because the back end does not support room shares');
+
$ocs = $this->mockFormatShare();
$share = $this->newShare();
@@ -2227,7 +2228,7 @@ class ShareAPIControllerTest extends TestCase {
->willReturn($userFolder);
$path = $this->getMockBuilder(File::class)->getMock();
- $storage = $this->getMockBuilder(Storage::class)->getMock();
+ $storage = $this->createMock(Storage::class);
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
@@ -2251,11 +2252,11 @@ class ShareAPIControllerTest extends TestCase {
$ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_ROOM, 'recipientRoom');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException
- * @expectedExceptionMessage Exception thrown by the helper
- */
+
public function testCreateShareRoomHelperThrowException() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectExceptionMessage('Exception thrown by the helper');
+
$ocs = $this->mockFormatShare();
$share = $this->newShare();
@@ -2268,7 +2269,7 @@ class ShareAPIControllerTest extends TestCase {
->willReturn($userFolder);
$path = $this->getMockBuilder(File::class)->getMock();
- $storage = $this->getMockBuilder(Storage::class)->getMock();
+ $storage = $this->createMock(Storage::class);
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
@@ -2345,7 +2346,7 @@ class ShareAPIControllerTest extends TestCase {
->willReturn($userFolder);
$path = $this->getMockBuilder(Folder::class)->getMock();
- $storage = $this->getMockBuilder(Storage::class)->getMock();
+ $storage = $this->createMock(Storage::class);
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(true);
@@ -2369,11 +2370,11 @@ class ShareAPIControllerTest extends TestCase {
$ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, 'validUser');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException
- * @expectedExceptionMessage Wrong share ID, share doesn't exist
- */
+
public function testUpdateShareCantAccess() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectExceptionMessage('Wrong share ID, share doesn\'t exist');
+
$node = $this->getMockBuilder(Folder::class)->getMock();
$share = $this->newShare();
$share->setNode($node);
@@ -2396,11 +2397,11 @@ class ShareAPIControllerTest extends TestCase {
$this->ocs->updateShare(42);
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSBadRequestException
- * @expectedExceptionMessage Wrong or no update parameter given
- */
+
public function testUpdateNoParametersLink() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSBadRequestException::class);
+ $this->expectExceptionMessage('Wrong or no update parameter given');
+
$node = $this->getMockBuilder(Folder::class)->getMock();
$share = $this->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
@@ -2417,11 +2418,11 @@ class ShareAPIControllerTest extends TestCase {
$this->ocs->updateShare(42);
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSBadRequestException
- * @expectedExceptionMessage Wrong or no update parameter given
- */
+
public function testUpdateNoParametersOther() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSBadRequestException::class);
+ $this->expectExceptionMessage('Wrong or no update parameter given');
+
$node = $this->getMockBuilder(Folder::class)->getMock();
$share = $this->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
@@ -2606,11 +2607,11 @@ class ShareAPIControllerTest extends TestCase {
$this->assertEquals($expected->getData(), $result->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSBadRequestException
- * @expectedExceptionMessage Invalid date. Format must be YYYY-MM-DD
- */
+
public function testUpdateLinkShareInvalidDate() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSBadRequestException::class);
+ $this->expectExceptionMessage('Invalid date. Format must be YYYY-MM-DD');
+
$ocs = $this->mockFormatShare();
$folder = $this->getMockBuilder(Folder::class)->getMock();
@@ -2645,10 +2646,11 @@ class ShareAPIControllerTest extends TestCase {
/**
* @dataProvider publicUploadParamsProvider
- * @expectedException \OCP\AppFramework\OCS\OCSForbiddenException
- * @expectedExceptionMessage Public upload disabled by the administrator
*/
public function testUpdateLinkSharePublicUploadNotAllowed($permissions, $publicUpload, $expireDate, $password) {
+ $this->expectException(\OCP\AppFramework\OCS\OCSForbiddenException::class);
+ $this->expectExceptionMessage('Public upload disabled by the administrator');
+
$ocs = $this->mockFormatShare();
$folder = $this->getMockBuilder(Folder::class)->getMock();
@@ -2665,11 +2667,11 @@ class ShareAPIControllerTest extends TestCase {
$ocs->updateShare(42, $permissions, $password, null, $publicUpload, $expireDate);
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSBadRequestException
- * @expectedExceptionMessage Public upload is only possible for publicly shared folders
- */
+
public function testUpdateLinkSharePublicUploadOnFile() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSBadRequestException::class);
+ $this->expectExceptionMessage('Public upload is only possible for publicly shared folders');
+
$ocs = $this->mockFormatShare();
$file = $this->getMockBuilder(File::class)->getMock();
@@ -2778,11 +2780,11 @@ class ShareAPIControllerTest extends TestCase {
$this->assertEquals($expected->getData(), $result->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSForbiddenException
- * @expectedExceptionMessage Sharing sending the password by Nextcloud Talk failed because Nextcloud Talk is not enabled
- */
+
public function testUpdateLinkShareSendPasswordByTalkWithTalkDisabledDoesNotChangeOther() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSForbiddenException::class);
+ $this->expectExceptionMessage('Sharing sending the password by Nextcloud Talk failed because Nextcloud Talk is not enabled');
+
$ocs = $this->mockFormatShare();
$date = new \DateTime('2000-01-01');
@@ -3381,7 +3383,7 @@ class ShareAPIControllerTest extends TestCase {
$cache = $this->getMockBuilder('OCP\Files\Cache\ICache')->getMock();
$cache->method('getNumericStorageId')->willReturn(100);
- $storage = $this->getMockBuilder(Storage::class)->getMock();
+ $storage = $this->createMock(Storage::class);
$storage->method('getId')->willReturn('storageId');
$storage->method('getCache')->willReturn($cache);
@@ -4150,7 +4152,7 @@ class ShareAPIControllerTest extends TestCase {
$cache = $this->getMockBuilder('OCP\Files\Cache\ICache')->getMock();
$cache->method('getNumericStorageId')->willReturn(100);
- $storage = $this->getMockBuilder(Storage::class)->getMock();
+ $storage = $this->createMock(Storage::class);
$storage->method('getId')->willReturn('storageId');
$storage->method('getCache')->willReturn($cache);
diff --git a/apps/files_sharing/tests/Controller/ShareControllerTest.php b/apps/files_sharing/tests/Controller/ShareControllerTest.php
index 01b20e58572..55981f00238 100644
--- a/apps/files_sharing/tests/Controller/ShareControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ShareControllerTest.php
@@ -93,7 +93,7 @@ class ShareControllerTest extends \Test\TestCase {
/** @var IL10N */
private $l10n;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->appName = 'files_sharing';
@@ -142,7 +142,7 @@ class ShareControllerTest extends \Test\TestCase {
$this->loginAsUser($this->user);
}
- protected function tearDown() {
+ protected function tearDown(): void {
\OC_Util::tearDownFS();
\OC_User::setUserId('');
Filesystem::tearDown();
@@ -532,10 +532,10 @@ class ShareControllerTest extends \Test\TestCase {
self::assertEquals($expectedResponse, $response);
}
- /**
- * @expectedException \OCP\Files\NotFoundException
- */
+
public function testShowShareInvalid() {
+ $this->expectException(\OCP\Files\NotFoundException::class);
+
$this->shareController->setToken('token');
$owner = $this->getMockBuilder(IUser::class)->getMock();
diff --git a/apps/files_sharing/tests/Controller/ShareInfoControllerTest.php b/apps/files_sharing/tests/Controller/ShareInfoControllerTest.php
index 627990a2f90..f2feb6e7fcc 100644
--- a/apps/files_sharing/tests/Controller/ShareInfoControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ShareInfoControllerTest.php
@@ -45,7 +45,7 @@ class ShareInfoControllerTest extends TestCase {
private $shareManager;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->shareManager = $this->createMock(ShareManager::class);
diff --git a/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php
index c5d31e3b59d..99f86525913 100644
--- a/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php
@@ -62,7 +62,7 @@ class ShareesAPIControllerTest extends TestCase {
/** @var ISearch|\PHPUnit_Framework_MockObject_MockObject */
protected $collaboratorSearch;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->uid = 'test123';
@@ -397,11 +397,11 @@ class ShareesAPIControllerTest extends TestCase {
$this->assertSame($expected, $this->invokePrivate($this->sharees, 'isRemoteSharingAllowed', [$itemType]));
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSBadRequestException
- * @expectedExceptionMessage Missing itemType
- */
+
public function testSearchNoItemType() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSBadRequestException::class);
+ $this->expectExceptionMessage('Missing itemType');
+
$this->sharees->search('', null, 1, 10, [], false);
}
diff --git a/apps/files_sharing/tests/DeleteOrphanedSharesJobTest.php b/apps/files_sharing/tests/DeleteOrphanedSharesJobTest.php
index 03f19525e0d..028878e3abd 100644
--- a/apps/files_sharing/tests/DeleteOrphanedSharesJobTest.php
+++ b/apps/files_sharing/tests/DeleteOrphanedSharesJobTest.php
@@ -61,7 +61,7 @@ class DeleteOrphanedSharesJobTest extends \Test\TestCase {
*/
private $user2;
- public static function setUpBeforeClass() {
+ public static function setUpBeforeClass(): void {
$appManager = \OC::$server->getAppManager();
self::$trashBinStatus = $appManager->isEnabledForUser('files_trashbin');
$appManager->disableApp('files_trashbin');
@@ -70,13 +70,13 @@ class DeleteOrphanedSharesJobTest extends \Test\TestCase {
\OC\Files\Filesystem::getLoader()->removeStorageWrapper('oc_trashbin');
}
- public static function tearDownAfterClass() {
+ public static function tearDownAfterClass(): void {
if (self::$trashBinStatus) {
\OC::$server->getAppManager()->enableApp('files_trashbin');
}
}
- protected function setup() {
+ protected function setUp(): void {
parent::setUp();
$this->connection = \OC::$server->getDatabaseConnection();
@@ -95,7 +95,7 @@ class DeleteOrphanedSharesJobTest extends \Test\TestCase {
$this->job = new DeleteOrphanedSharesJob();
}
- protected function tearDown() {
+ protected function tearDown(): void {
$this->connection->executeUpdate('DELETE FROM `*PREFIX*share`');
$userManager = \OC::$server->getUserManager();
diff --git a/apps/files_sharing/tests/ExpireSharesJobTest.php b/apps/files_sharing/tests/ExpireSharesJobTest.php
index e255f08ccf1..0f34f0785a7 100644
--- a/apps/files_sharing/tests/ExpireSharesJobTest.php
+++ b/apps/files_sharing/tests/ExpireSharesJobTest.php
@@ -55,7 +55,7 @@ class ExpireSharesJobTest extends \Test\TestCase {
*/
private $user2;
- protected function setup() {
+ protected function setUp(): void {
parent::setUp();
$this->connection = \OC::$server->getDatabaseConnection();
@@ -74,7 +74,7 @@ class ExpireSharesJobTest extends \Test\TestCase {
$this->job = new ExpireSharesJob();
}
- protected function tearDown() {
+ protected function tearDown(): void {
$this->connection->executeUpdate('DELETE FROM `*PREFIX*share`');
$userManager = \OC::$server->getUserManager();
diff --git a/apps/files_sharing/tests/External/CacheTest.php b/apps/files_sharing/tests/External/CacheTest.php
index 02109e35db1..39ff1ff24f1 100644
--- a/apps/files_sharing/tests/External/CacheTest.php
+++ b/apps/files_sharing/tests/External/CacheTest.php
@@ -56,7 +56,7 @@ class CacheTest extends TestCase {
/** @var ICloudIdManager */
private $cloudIdManager;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->cloudIdManager = new CloudIdManager();
@@ -83,7 +83,7 @@ class CacheTest extends TestCase {
);
}
- protected function tearDown() {
+ protected function tearDown(): void {
if ($this->cache) {
$this->cache->clear();
}
diff --git a/apps/files_sharing/tests/External/ManagerTest.php b/apps/files_sharing/tests/External/ManagerTest.php
index 93c17ca10cf..5e90b358ee9 100644
--- a/apps/files_sharing/tests/External/ManagerTest.php
+++ b/apps/files_sharing/tests/External/ManagerTest.php
@@ -35,6 +35,7 @@ use OCA\Files_Sharing\Tests\TestCase;
use OCP\Federation\ICloudFederationFactory;
use OCP\Federation\ICloudFederationProviderManager;
use OCP\Http\Client\IClientService;
+use OCP\Http\Client\IResponse;
use OCP\IGroupManager;
use OCP\IUserManager;
use Test\Traits\UserTrait;
@@ -78,7 +79,7 @@ class ManagerTest extends TestCase {
private $user;
private $testMountProvider;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->uid = $this->getUniqueID('user');
@@ -172,8 +173,15 @@ class ManagerTest extends TestCase {
$this->clientService->expects($this->at(0))
->method('newClient')
->willReturn($client);
- $response = $this->getMockBuilder('OCP\Http\Client\IResponse')
- ->disableOriginalConstructor()->getMock();
+ $response = $this->createMock(IResponse::class);
+ $response->method('getBody')
+ ->willReturn(json_encode([
+ 'ocs' => [
+ 'meta' => [
+ 'statuscode' => 200,
+ ]
+ ]
+ ]));
$client->expects($this->once())
->method('post')
->with($this->stringStartsWith('http://localhost/ocs/v2.php/cloud/shares/' . $openShares[0]['remote_id']), $this->anything())
@@ -215,8 +223,15 @@ class ManagerTest extends TestCase {
$this->clientService->expects($this->at(0))
->method('newClient')
->willReturn($client);
- $response = $this->getMockBuilder('OCP\Http\Client\IResponse')
- ->disableOriginalConstructor()->getMock();
+ $response = $this->createMock(IResponse::class);
+ $response->method('getBody')
+ ->willReturn(json_encode([
+ 'ocs' => [
+ 'meta' => [
+ 'statuscode' => 200,
+ ]
+ ]
+ ]));
$client->expects($this->once())
->method('post')
->with($this->stringStartsWith('http://localhost/ocs/v2.php/cloud/shares/' . $openShares[1]['remote_id'] . '/decline'), $this->anything())
@@ -255,8 +270,15 @@ class ManagerTest extends TestCase {
$this->clientService->expects($this->at(1))
->method('newClient')
->willReturn($client2);
- $response = $this->getMockBuilder('OCP\Http\Client\IResponse')
- ->disableOriginalConstructor()->getMock();
+ $response = $this->createMock(IResponse::class);
+ $response->method('getBody')
+ ->willReturn(json_encode([
+ 'ocs' => [
+ 'meta' => [
+ 'statuscode' => 200,
+ ]
+ ]
+ ]));
$client1->expects($this->once())
->method('post')
->with($this->stringStartsWith('http://localhost/ocs/v2.php/cloud/shares/' . $openShares[0]['remote_id'] . '/decline'), $this->anything())
diff --git a/apps/files_sharing/tests/External/ScannerTest.php b/apps/files_sharing/tests/External/ScannerTest.php
index fe77182e83f..b9bfb1a84a8 100644
--- a/apps/files_sharing/tests/External/ScannerTest.php
+++ b/apps/files_sharing/tests/External/ScannerTest.php
@@ -33,7 +33,7 @@ class ScannerTest extends TestCase {
/** @var \OC\Files\Cache\Cache|\PHPUnit_Framework_MockObject_MockObject */
protected $cache;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->storage = $this->getMockBuilder('\OCA\Files_Sharing\External\Storage')
diff --git a/apps/files_sharing/tests/LockingTest.php b/apps/files_sharing/tests/LockingTest.php
index 414e8790819..49f49da643f 100644
--- a/apps/files_sharing/tests/LockingTest.php
+++ b/apps/files_sharing/tests/LockingTest.php
@@ -46,7 +46,7 @@ class LockingTest extends TestCase {
private $ownerUid;
private $recipientUid;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->userBackend = new \Test\Util\User\Dummy();
@@ -74,15 +74,15 @@ class LockingTest extends TestCase {
$this->assertTrue(Filesystem::file_exists('bar.txt'));
}
- public function tearDown() {
+ protected function tearDown(): void {
\OC::$server->getUserManager()->removeBackend($this->userBackend);
parent::tearDown();
}
- /**
- * @expectedException \OCP\Lock\LockedException
- */
+
public function testLockAsRecipient() {
+ $this->expectException(\OCP\Lock\LockedException::class);
+
$this->loginAsUser($this->ownerUid);
Filesystem::initMountPoints($this->recipientUid);
diff --git a/apps/files_sharing/tests/Middleware/OCSShareAPIMiddlewareTest.php b/apps/files_sharing/tests/Middleware/OCSShareAPIMiddlewareTest.php
index a1d1f1bf551..31ca88cc4fc 100644
--- a/apps/files_sharing/tests/Middleware/OCSShareAPIMiddlewareTest.php
+++ b/apps/files_sharing/tests/Middleware/OCSShareAPIMiddlewareTest.php
@@ -44,7 +44,7 @@ class OCSShareAPIMiddlewareTest extends \Test\TestCase {
/** @var OCSShareAPIMiddleware */
private $middleware;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->shareManager = $this->createMock(IManager::class);
diff --git a/apps/files_sharing/tests/Middleware/ShareInfoMiddlewareTest.php b/apps/files_sharing/tests/Middleware/ShareInfoMiddlewareTest.php
index 781861aa392..db698d94f11 100644
--- a/apps/files_sharing/tests/Middleware/ShareInfoMiddlewareTest.php
+++ b/apps/files_sharing/tests/Middleware/ShareInfoMiddlewareTest.php
@@ -41,7 +41,7 @@ class ShareInfoMiddlewareTest extends TestCase {
/** @var ShareInfoMiddleware */
private $middleware;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->shareManager = $this->createMock(ShareManager::class);
diff --git a/apps/files_sharing/tests/Middleware/SharingCheckMiddlewareTest.php b/apps/files_sharing/tests/Middleware/SharingCheckMiddlewareTest.php
index f49b472a35c..7a2baba16e0 100644
--- a/apps/files_sharing/tests/Middleware/SharingCheckMiddlewareTest.php
+++ b/apps/files_sharing/tests/Middleware/SharingCheckMiddlewareTest.php
@@ -59,7 +59,7 @@ class SharingCheckMiddlewareTest extends \Test\TestCase {
/** @var IRequest | \PHPUnit_Framework_MockObject_MockObject */
private $request;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
@@ -198,11 +198,11 @@ class SharingCheckMiddlewareTest extends \Test\TestCase {
$this->sharingCheckMiddleware->beforeController($controller, 'myMethod');
}
- /**
- * @expectedException \OCP\Files\NotFoundException
- * @expectedExceptionMessage Sharing is disabled.
- */
+
public function testBeforeControllerWithSharingDisabled() {
+ $this->expectException(\OCP\Files\NotFoundException::class);
+ $this->expectExceptionMessage('Sharing is disabled.');
+
$this->appManager
->expects($this->once())
->method('isEnabledForUser')
@@ -212,11 +212,11 @@ class SharingCheckMiddlewareTest extends \Test\TestCase {
$this->sharingCheckMiddleware->beforeController($this->controllerMock, 'myMethod');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage My Exception message
- */
+
public function testAfterExceptionWithRegularException() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('My Exception message');
+
$this->sharingCheckMiddleware->afterException($this->controllerMock, 'myMethod', new \Exception('My Exception message'));
}
diff --git a/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php b/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php
index c4c78b04a23..b98b0b9fcd8 100644
--- a/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php
+++ b/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php
@@ -47,7 +47,7 @@ class SetPasswordColumnTest extends TestCase {
private $table = 'share';
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->connection = \OC::$server->getDatabaseConnection();
@@ -57,7 +57,7 @@ class SetPasswordColumnTest extends TestCase {
$this->cleanDB();
}
- public function tearDown() {
+ protected function tearDown(): void {
parent::tearDown();
$this->cleanDB();
}
diff --git a/apps/files_sharing/tests/MountProviderTest.php b/apps/files_sharing/tests/MountProviderTest.php
index f4acfdfafe7..06ca2060477 100644
--- a/apps/files_sharing/tests/MountProviderTest.php
+++ b/apps/files_sharing/tests/MountProviderTest.php
@@ -59,7 +59,7 @@ class MountProviderTest extends \Test\TestCase {
/** @var ILogger | \PHPUnit_Framework_MockObject_MockObject */
private $logger;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->getMockBuilder(IConfig::class)->getMock();
diff --git a/apps/files_sharing/tests/PermissionsTest.php b/apps/files_sharing/tests/PermissionsTest.php
index a64d0b25e17..e47cfff68dd 100644
--- a/apps/files_sharing/tests/PermissionsTest.php
+++ b/apps/files_sharing/tests/PermissionsTest.php
@@ -60,7 +60,7 @@ class PermissionsTest extends TestCase {
/** @var Cache */
private $ownerCache;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
@@ -115,7 +115,7 @@ class PermissionsTest extends TestCase {
$this->sharedCacheRestrictedShare = $this->sharedStorageRestrictedShare->getCache();
}
- protected function tearDown() {
+ protected function tearDown(): void {
if ($this->sharedCache) {
$this->sharedCache->clear();
}
diff --git a/apps/files_sharing/tests/PropagationTestCase.php b/apps/files_sharing/tests/PropagationTestCase.php
index 21cea3033af..5f16173725e 100644
--- a/apps/files_sharing/tests/PropagationTestCase.php
+++ b/apps/files_sharing/tests/PropagationTestCase.php
@@ -31,17 +31,17 @@ abstract class PropagationTestCase extends TestCase {
protected $fileIds = []; // [$user=>[$path=>$id]]
protected $fileEtags = []; // [$id=>$etag]
- public static function setUpBeforeClass() {
+ public static function setUpBeforeClass(): void {
parent::setUpBeforeClass();
\OCA\Files_Sharing\Helper::registerHooks();
}
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->setUpShares();
}
- protected function tearDown() {
+ protected function tearDown(): void {
\OC_Hook::clear('OC_Filesystem', 'post_write');
\OC_Hook::clear('OC_Filesystem', 'post_delete');
\OC_Hook::clear('OC_Filesystem', 'post_rename');
diff --git a/apps/files_sharing/tests/ShareTest.php b/apps/files_sharing/tests/ShareTest.php
index 61bec2caea3..f0614d5c984 100644
--- a/apps/files_sharing/tests/ShareTest.php
+++ b/apps/files_sharing/tests/ShareTest.php
@@ -38,7 +38,7 @@ class ShareTest extends TestCase {
private static $tempStorage;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->folder = self::TEST_FOLDER_NAME;
@@ -56,7 +56,7 @@ class ShareTest extends TestCase {
$this->view->file_put_contents($this->folder . $this->subfolder . $this->filename, $this->data);
}
- protected function tearDown() {
+ protected function tearDown(): void {
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
$this->view->unlink($this->filename);
$this->view->deleteAll($this->folder);
diff --git a/apps/files_sharing/tests/SharedMountTest.php b/apps/files_sharing/tests/SharedMountTest.php
index f01e9896efb..17b2abf3fce 100644
--- a/apps/files_sharing/tests/SharedMountTest.php
+++ b/apps/files_sharing/tests/SharedMountTest.php
@@ -44,7 +44,7 @@ class SharedMountTest extends TestCase {
/** @var IUserManager */
private $userManager;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->folder = '/folder_share_storage_test';
@@ -62,7 +62,7 @@ class SharedMountTest extends TestCase {
$this->userManager = \OC::$server->getUserManager();
}
- protected function tearDown() {
+ protected function tearDown(): void {
if ($this->view) {
if ($this->view->file_exists($this->folder)) {
$this->view->unlink($this->folder);
diff --git a/apps/files_sharing/tests/SharedStorageTest.php b/apps/files_sharing/tests/SharedStorageTest.php
index e2cb65d9acc..c4cefee4a34 100644
--- a/apps/files_sharing/tests/SharedStorageTest.php
+++ b/apps/files_sharing/tests/SharedStorageTest.php
@@ -40,7 +40,7 @@ use OCP\Share\IShare;
*/
class SharedStorageTest extends TestCase {
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
\OCA\Files_Trashbin\Trashbin::registerHooks();
$this->folder = '/folder_share_storage_test';
@@ -55,7 +55,7 @@ class SharedStorageTest extends TestCase {
$this->view->file_put_contents($this->folder . $this->filename, "file in subfolder");
}
- protected function tearDown() {
+ protected function tearDown(): void {
if ($this->view) {
if ($this->view->file_exists($this->folder)) {
$this->view->unlink($this->folder);
diff --git a/apps/files_sharing/tests/TestCase.php b/apps/files_sharing/tests/TestCase.php
index 6c5f078f9e7..ce5ceb1f642 100644
--- a/apps/files_sharing/tests/TestCase.php
+++ b/apps/files_sharing/tests/TestCase.php
@@ -68,7 +68,7 @@ abstract class TestCase extends \Test\TestCase {
/** @var \OCP\Files\IRootFolder */
protected $rootFolder;
- public static function setUpBeforeClass() {
+ public static function setUpBeforeClass(): void {
parent::setUpBeforeClass();
$application = new Application();
@@ -107,7 +107,7 @@ abstract class TestCase extends \Test\TestCase {
\OC::$server->getGroupManager()->addBackend($groupBackend);
}
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
//login as user1
@@ -120,7 +120,7 @@ abstract class TestCase extends \Test\TestCase {
$this->rootFolder = \OC::$server->getRootFolder();
}
- protected function tearDown() {
+ protected function tearDown(): void {
$qb = \OC::$server->getDatabaseConnection()->getQueryBuilder();
$qb->delete('share');
$qb->execute();
@@ -128,7 +128,7 @@ abstract class TestCase extends \Test\TestCase {
parent::tearDown();
}
- public static function tearDownAfterClass() {
+ public static function tearDownAfterClass(): void {
// cleanup users
$user = \OC::$server->getUserManager()->get(self::TEST_FILES_SHARING_API_USER1);
if ($user !== null) { $user->delete(); }
diff --git a/apps/files_sharing/tests/UnshareChildrenTest.php b/apps/files_sharing/tests/UnshareChildrenTest.php
index ce7767d1920..92ff48eb3be 100644
--- a/apps/files_sharing/tests/UnshareChildrenTest.php
+++ b/apps/files_sharing/tests/UnshareChildrenTest.php
@@ -42,7 +42,7 @@ class UnshareChildrenTest extends TestCase {
private static $tempStorage;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
\OCP\Util::connectHook('OC_Filesystem', 'post_delete', '\OCA\Files_Sharing\Hooks', 'unshareChildren');
@@ -61,7 +61,7 @@ class UnshareChildrenTest extends TestCase {
$this->view->file_put_contents($this->folder . $this->subfolder . $this->filename, $this->data);
}
- protected function tearDown() {
+ protected function tearDown(): void {
if ($this->view) {
$this->view->deleteAll($this->folder);
}
diff --git a/apps/files_sharing/tests/UpdaterTest.php b/apps/files_sharing/tests/UpdaterTest.php
index 2e044716d07..d20f794883a 100644
--- a/apps/files_sharing/tests/UpdaterTest.php
+++ b/apps/files_sharing/tests/UpdaterTest.php
@@ -38,12 +38,12 @@ class UpdaterTest extends TestCase {
const TEST_FOLDER_NAME = '/folder_share_updater_test';
- public static function setUpBeforeClass() {
+ public static function setUpBeforeClass(): void {
parent::setUpBeforeClass();
\OCA\Files_Sharing\Helper::registerHooks();
}
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->folder = self::TEST_FOLDER_NAME;
@@ -56,7 +56,7 @@ class UpdaterTest extends TestCase {
$this->view->file_put_contents($this->folder . '/' . $this->filename, $this->data);
}
- protected function tearDown() {
+ protected function tearDown(): void {
if ($this->view) {
$this->view->unlink($this->filename);
$this->view->deleteAll($this->folder);
diff --git a/apps/files_sharing/tests/WatcherTest.php b/apps/files_sharing/tests/WatcherTest.php
index 59f84057a14..e332327a917 100644
--- a/apps/files_sharing/tests/WatcherTest.php
+++ b/apps/files_sharing/tests/WatcherTest.php
@@ -53,7 +53,7 @@ class WatcherTest extends TestCase {
/** @var \OCP\Share\IShare */
private $_share;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
@@ -88,7 +88,7 @@ class WatcherTest extends TestCase {
$this->sharedCache = $this->sharedStorage->getCache();
}
- protected function tearDown() {
+ protected function tearDown(): void {
if ($this->sharedCache) {
$this->sharedCache->clear();
}