aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/DirectEditing
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/DirectEditing')
-rw-r--r--tests/lib/DirectEditing/ManagerTest.php41
1 files changed, 25 insertions, 16 deletions
diff --git a/tests/lib/DirectEditing/ManagerTest.php b/tests/lib/DirectEditing/ManagerTest.php
index 3dc2e464c37..2ad7f98df49 100644
--- a/tests/lib/DirectEditing/ManagerTest.php
+++ b/tests/lib/DirectEditing/ManagerTest.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -22,6 +23,7 @@ use OCP\IUser;
use OCP\IUserSession;
use OCP\L10N\IFactory;
use OCP\Security\ISecureRandom;
+use OCP\Server;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
@@ -124,7 +126,7 @@ class ManagerTest extends TestCase {
$this->editor = new Editor();
$this->random = $this->createMock(ISecureRandom::class);
- $this->connection = \OC::$server->getDatabaseConnection();
+ $this->connection = Server::get(IDBConnection::class);
$this->userSession = $this->createMock(IUserSession::class);
$this->rootFolder = $this->createMock(IRootFolder::class);
$this->userFolder = $this->createMock(Folder::class);
@@ -156,12 +158,12 @@ class ManagerTest extends TestCase {
$this->manager->registerDirectEditor($this->editor);
}
- public function testEditorRegistration() {
+ public function testEditorRegistration(): void {
$this->assertEquals($this->manager->getEditors(), ['testeditor' => $this->editor]);
}
- public function testCreateToken() {
+ public function testCreateToken(): void {
$expectedToken = 'TOKEN' . time();
$file = $this->createMock(File::class);
$file->expects($this->any())
@@ -173,8 +175,10 @@ class ManagerTest extends TestCase {
$folder = $this->createMock(Folder::class);
$this->userFolder
->method('nodeExists')
- ->withConsecutive(['/File.txt'], ['/'])
- ->willReturnOnConsecutiveCalls(false, true);
+ ->willReturnMap([
+ ['/File.txt', false],
+ ['/', true],
+ ]);
$this->userFolder
->method('get')
->with('/')
@@ -186,7 +190,7 @@ class ManagerTest extends TestCase {
$this->assertEquals($token, $expectedToken);
}
- public function testCreateTokenAccess() {
+ public function testCreateTokenAccess(): void {
$expectedToken = 'TOKEN' . time();
$file = $this->createMock(File::class);
$file->expects($this->any())
@@ -198,8 +202,10 @@ class ManagerTest extends TestCase {
$folder = $this->createMock(Folder::class);
$this->userFolder
->method('nodeExists')
- ->withConsecutive(['/File.txt'], ['/'])
- ->willReturnOnConsecutiveCalls(false, true);
+ ->willReturnMap([
+ ['/File.txt', false],
+ ['/', true],
+ ]);
$this->userFolder
->method('get')
->with('/')
@@ -214,7 +220,7 @@ class ManagerTest extends TestCase {
$this->assertInstanceOf(NotFoundResponse::class, $secondResult);
}
- public function testOpenByPath() {
+ public function testOpenByPath(): void {
$expectedToken = 'TOKEN' . time();
$file = $this->createMock(File::class);
$file->expects($this->any())
@@ -226,11 +232,12 @@ class ManagerTest extends TestCase {
$this->random->expects($this->once())
->method('generate')
->willReturn($expectedToken);
- $folder = $this->createMock(Folder::class);
$this->userFolder
->method('nodeExists')
- ->withConsecutive(['/File.txt'], ['/'])
- ->willReturnOnConsecutiveCalls(false, true);
+ ->willReturnMap([
+ ['/File.txt', false],
+ ['/', true],
+ ]);
$this->userFolder
->method('get')
->with('/File.txt')
@@ -245,7 +252,7 @@ class ManagerTest extends TestCase {
$this->assertInstanceOf(NotFoundResponse::class, $secondResult);
}
- public function testOpenById() {
+ public function testOpenById(): void {
$expectedToken = 'TOKEN' . time();
$fileRead = $this->createMock(File::class);
$fileRead->method('getPermissions')
@@ -277,8 +284,10 @@ class ManagerTest extends TestCase {
]);
$this->userFolder
->method('nodeExists')
- ->withConsecutive(['/File.txt'], ['/'])
- ->willReturnOnConsecutiveCalls(false, true);
+ ->willReturnMap([
+ ['/File.txt', false],
+ ['/', true],
+ ]);
$this->userFolder
->method('get')
->with('/')
@@ -294,7 +303,7 @@ class ManagerTest extends TestCase {
$this->assertInstanceOf(NotFoundResponse::class, $secondResult);
}
- public function testCreateFileAlreadyExists() {
+ public function testCreateFileAlreadyExists(): void {
$this->expectException(\RuntimeException::class);
$this->userFolder
->method('nodeExists')