summaryrefslogtreecommitdiffstats
path: root/apps/encryption/tests
diff options
context:
space:
mode:
Diffstat (limited to 'apps/encryption/tests')
-rw-r--r--apps/encryption/tests/lib/KeyManagerTest.php27
1 files changed, 27 insertions, 0 deletions
diff --git a/apps/encryption/tests/lib/KeyManagerTest.php b/apps/encryption/tests/lib/KeyManagerTest.php
index c69610fb541..a8cb2dcc789 100644
--- a/apps/encryption/tests/lib/KeyManagerTest.php
+++ b/apps/encryption/tests/lib/KeyManagerTest.php
@@ -579,4 +579,31 @@ class KeyManagerTest extends TestCase {
];
}
+ public function testGetVersionWithoutFileInfo() {
+ $view = $this->getMockBuilder('\\OC\\Files\\View')
+ ->disableOriginalConstructor()->getMock();
+ $view->expects($this->once())
+ ->method('getFileInfo')
+ ->with('/admin/files/myfile.txt')
+ ->willReturn(false);
+
+ $this->assertSame(0, $this->instance->getVersion('/admin/files/myfile.txt', $view));
+ }
+
+ public function testGetVersionWithFileInfo() {
+ $view = $this->getMockBuilder('\\OC\\Files\\View')
+ ->disableOriginalConstructor()->getMock();
+ $fileInfo = $this->getMockBuilder('\\OC\\Files\\FileInfo')
+ ->disableOriginalConstructor()->getMock();
+ $fileInfo->expects($this->once())
+ ->method('getEncryptedVersion')
+ ->willReturn(1337);
+ $view->expects($this->once())
+ ->method('getFileInfo')
+ ->with('/admin/files/myfile.txt')
+ ->willReturn($fileInfo);
+
+ $this->assertSame(1337, $this->instance->getVersion('/admin/files/myfile.txt', $view));
+ }
+
}