Browse Source

Add tests for setVersion

tags/v9.0beta1
Lukas Reschke 8 years ago
parent
commit
ca350294a6
1 changed files with 40 additions and 0 deletions
  1. 40
    0
      apps/encryption/tests/lib/KeyManagerTest.php

+ 40
- 0
apps/encryption/tests/lib/KeyManagerTest.php View File

@@ -606,4 +606,44 @@ class KeyManagerTest extends TestCase {
$this->assertSame(1337, $this->instance->getVersion('/admin/files/myfile.txt', $view));
}

public function testSetVersionWithFileInfo() {
$view = $this->getMockBuilder('\\OC\\Files\\View')
->disableOriginalConstructor()->getMock();
$cache = $this->getMockBuilder('\\OCP\\Files\\Cache\\ICache')
->disableOriginalConstructor()->getMock();
$cache->expects($this->once())
->method('update')
->with(123, ['encrypted' => 5, 'encryptedVersion' => 5]);
$storage = $this->getMockBuilder('\\OCP\\Files\\Storage')
->disableOriginalConstructor()->getMock();
$storage->expects($this->once())
->method('getCache')
->willReturn($cache);
$fileInfo = $this->getMockBuilder('\\OC\\Files\\FileInfo')
->disableOriginalConstructor()->getMock();
$fileInfo->expects($this->once())
->method('getStorage')
->willReturn($storage);
$fileInfo->expects($this->once())
->method('getId')
->willReturn(123);
$view->expects($this->once())
->method('getFileInfo')
->with('/admin/files/myfile.txt')
->willReturn($fileInfo);

$this->instance->setVersion('/admin/files/myfile.txt', 5, $view);
}

public function testSetVersionWithoutFileInfo() {
$view = $this->getMockBuilder('\\OC\\Files\\View')
->disableOriginalConstructor()->getMock();
$view->expects($this->once())
->method('getFileInfo')
->with('/admin/files/myfile.txt')
->willReturn(false);

$this->instance->setVersion('/admin/files/myfile.txt', 5, $view);
}

}

Loading…
Cancel
Save