From 14f6030140eebed1d439ebd62c79c224c2405196 Mon Sep 17 00:00:00 2001 From: Julius Härtl Date: Fri, 10 Jan 2020 13:06:27 +0100 Subject: CHeck if file already exists during file creation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl Signed-off-by: Roeland Jago Douma --- tests/lib/DirectEditing/ManagerTest.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests/lib') 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'); + } + } -- cgit v1.2.3