aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2020-01-14 08:34:39 +0100
committerGitHub <noreply@github.com>2020-01-14 08:34:39 +0100
commite7b308cf0a20f21b804430e86dc1eca3757769ec (patch)
tree2fb4166a6b90d9793fca712f1ce082afe6edbee1 /tests
parent0f6e7a7b2287bc712f56c9ae4fdffc04cdb31857 (diff)
parentab4b9a6df5b031174f4e3bdd62069d7ec26c6066 (diff)
downloadnextcloud-server-e7b308cf0a20f21b804430e86dc1eca3757769ec.tar.gz
nextcloud-server-e7b308cf0a20f21b804430e86dc1eca3757769ec.zip
Merge pull request #18805 from nextcloud/bugfix/direct-edit-create
Check if file already exists during file creation
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/DirectEditing/ManagerTest.php15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/lib/DirectEditing/ManagerTest.php b/tests/lib/DirectEditing/ManagerTest.php
index a97c02f19d2..1f18a25115f 100644
--- a/tests/lib/DirectEditing/ManagerTest.php
+++ b/tests/lib/DirectEditing/ManagerTest.php
@@ -12,6 +12,7 @@ use OCP\DirectEditing\IEditor;
use OCP\DirectEditing\IToken;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
+use OCP\Files\NotFoundException;
use OCP\IDBConnection;
use OCP\IL10N;
use OCP\IUserSession;
@@ -151,6 +152,10 @@ class ManagerTest extends TestCase {
$this->random->expects($this->once())
->method('generate')
->willReturn($expectedToken);
+ $this->userFolder
+ ->method('get')
+ ->with('/File.txt')
+ ->willThrowException(new NotFoundException());
$this->userFolder->expects($this->once())
->method('newFile')
->willReturn($file);
@@ -167,6 +172,10 @@ class ManagerTest extends TestCase {
$this->random->expects($this->once())
->method('generate')
->willReturn($expectedToken);
+ $this->userFolder
+ ->method('get')
+ ->with('/File.txt')
+ ->willThrowException(new NotFoundException());
$this->userFolder->expects($this->once())
->method('newFile')
->willReturn($file);
@@ -177,4 +186,10 @@ class ManagerTest extends TestCase {
$this->assertInstanceOf(NotFoundResponse::class, $secondResult);
}
+ public function testCreateFileAlreadyExists() {
+ $this->expectException(\RuntimeException::class);
+
+ $this->manager->create('/File.txt', 'testeditor', 'createEmpty');
+ }
+
}