aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/tests/LockingTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_sharing/tests/LockingTest.php')
-rw-r--r--apps/files_sharing/tests/LockingTest.php59
1 files changed, 22 insertions, 37 deletions
diff --git a/apps/files_sharing/tests/LockingTest.php b/apps/files_sharing/tests/LockingTest.php
index 4af5e3e2cee..280c364a136 100644
--- a/apps/files_sharing/tests/LockingTest.php
+++ b/apps/files_sharing/tests/LockingTest.php
@@ -1,34 +1,20 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Joas Schilling <coding@schilljs.com>
- * @author Lukas Reschke <lukas@statuscode.ch>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
-
namespace OCA\Files_Sharing\Tests;
use OC\Files\Filesystem;
use OC\Files\View;
+use OCP\Constants;
+use OCP\IUserManager;
use OCP\Lock\ILockingProvider;
+use OCP\Lock\LockedException;
+use OCP\Server;
+use OCP\Share\IShare;
/**
* Class LockingTest
@@ -46,11 +32,11 @@ class LockingTest extends TestCase {
private $ownerUid;
private $recipientUid;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->userBackend = new \Test\Util\User\Dummy();
- \OC::$server->getUserManager()->registerBackend($this->userBackend);
+ Server::get(IUserManager::class)->registerBackend($this->userBackend);
$this->ownerUid = $this->getUniqueID('owner_');
$this->recipientUid = $this->getUniqueID('recipient_');
@@ -63,26 +49,26 @@ class LockingTest extends TestCase {
$fileId = Filesystem::getFileInfo('/foo/bar.txt')->getId();
$this->share(
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
'/foo/bar.txt',
$this->ownerUid,
$this->recipientUid,
- \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE
+ Constants::PERMISSION_READ | Constants::PERMISSION_UPDATE | Constants::PERMISSION_SHARE
);
$this->loginAsUser($this->recipientUid);
$this->assertTrue(Filesystem::file_exists('bar.txt'));
}
- public function tearDown() {
- \OC::$server->getUserManager()->removeBackend($this->userBackend);
+ protected function tearDown(): void {
+ Server::get(IUserManager::class)->removeBackend($this->userBackend);
parent::tearDown();
}
- /**
- * @expectedException \OCP\Lock\LockedException
- */
- public function testLockAsRecipient() {
+
+ public function testLockAsRecipient(): void {
+ $this->expectException(LockedException::class);
+
$this->loginAsUser($this->ownerUid);
Filesystem::initMountPoints($this->recipientUid);
@@ -92,7 +78,7 @@ class LockingTest extends TestCase {
Filesystem::rename('/foo', '/asd');
}
- public function testUnLockAsRecipient() {
+ public function testUnLockAsRecipient(): void {
$this->loginAsUser($this->ownerUid);
Filesystem::initMountPoints($this->recipientUid);
@@ -103,14 +89,13 @@ class LockingTest extends TestCase {
$this->assertTrue(Filesystem::rename('/foo', '/asd'));
}
- public function testChangeLock() {
-
+ public function testChangeLock(): void {
Filesystem::initMountPoints($this->recipientUid);
$recipientView = new View('/' . $this->recipientUid . '/files');
$recipientView->lockFile('bar.txt', ILockingProvider::LOCK_SHARED);
$recipientView->changeLock('bar.txt', ILockingProvider::LOCK_EXCLUSIVE);
$recipientView->unlockFile('bar.txt', ILockingProvider::LOCK_EXCLUSIVE);
- $this->assertTrue(true);
+ $this->addToAssertionCount(1);
}
}