summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2017-04-20 13:48:14 +0200
committerJoas Schilling <coding@schilljs.com>2017-04-20 13:48:14 +0200
commitec2f2b75bedc222c3063d958deb0c35c043c5f1f (patch)
tree6403916c8e0f612c64a1e739c8402526ce75b62e /tests
parent06e60f88c5adbe6190aafbd34ac641a76bebc37d (diff)
downloadnextcloud-server-ec2f2b75bedc222c3063d958deb0c35c043c5f1f.tar.gz
nextcloud-server-ec2f2b75bedc222c3063d958deb0c35c043c5f1f.zip
Make sure we use a new encryption module all the time
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Files/Storage/Wrapper/EncryptionTest.php23
1 files changed, 16 insertions, 7 deletions
diff --git a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
index eb665af8dda..d310f110b94 100644
--- a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
+++ b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
@@ -943,7 +943,7 @@ class EncryptionTest extends Storage {
* @dataProvider dataTestShouldEncrypt
*
* @param bool $encryptMountPoint
- * @param \PHPUnit_Framework_MockObject_MockObject | IEncryptionModule $encryptionModule
+ * @param mixed $encryptionModule
* @param bool $encryptionModuleShouldEncrypt
* @param bool $expected
*/
@@ -985,8 +985,15 @@ class EncryptionTest extends Storage {
->setMethods(['getFullPath', 'getEncryptionModule'])
->getMock();
+ if ($encryptionModule === true) {
+ /** @var IEncryptionModule|\PHPUnit_Framework_MockObject_MockObject $encryptionModule */
+ $encryptionModule = $this->createMock(IEncryptionModule::class);
+ }
+
$wrapper->method('getFullPath')->with($path)->willReturn($fullPath);
- $wrapper->method('getEncryptionModule')->with($fullPath)
+ $wrapper->expects($encryptMountPoint ? $this->once() : $this->never())
+ ->method('getEncryptionModule')
+ ->with($fullPath)
->willReturnCallback(
function() use ($encryptionModule) {
if ($encryptionModule === false) {
@@ -999,12 +1006,15 @@ class EncryptionTest extends Storage {
->willReturn($encryptMountPoint);
if ($encryptionModule !== null && $encryptionModule !== false) {
- $encryptionModule->method('shouldEncrypt')->with($fullPath)
+ $encryptionModule
+ ->method('shouldEncrypt')
+ ->with($fullPath)
->willReturn($encryptionModuleShouldEncrypt);
}
if ($encryptionModule === null) {
- $encryptionManager->expects($this->once())->method('getEncryptionModule')
+ $encryptionManager->expects($this->once())
+ ->method('getEncryptionModule')
->willReturn($defaultEncryptionModule);
}
$defaultEncryptionModule->method('shouldEncrypt')->willReturn(true);
@@ -1015,12 +1025,11 @@ class EncryptionTest extends Storage {
}
public function dataTestShouldEncrypt() {
- $encryptionModule = $this->createMock(IEncryptionModule::class);
return [
[false, false, false, false],
[true, false, false, false],
- [true, $encryptionModule, false, false],
- [true, $encryptionModule, true, true],
+ [true, true, false, false],
+ [true, true, true, true],
[true, null, false, true],
];
}