aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/Encryption
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2020-04-10 14:19:56 +0200
committerChristoph Wurst <christoph@winzerhof-wurst.at>2020-04-10 14:19:56 +0200
commitcaff1023ea72bb2ea94130e18a2a6e2ccf819e5f (patch)
tree186d494c2aea5dea7255d3584ef5d595fc6e6194 /tests/lib/Encryption
parentedf8ce32cffdb920e8171207b342abbd7f1fbe73 (diff)
downloadnextcloud-server-caff1023ea72bb2ea94130e18a2a6e2ccf819e5f.tar.gz
nextcloud-server-caff1023ea72bb2ea94130e18a2a6e2ccf819e5f.zip
Format control structures, classes, methods and function
To continue this formatting madness, here's a tiny patch that adds unified formatting for control structures like if and loops as well as classes, their methods and anonymous functions. This basically forces the constructs to start on the same line. This is not exactly what PSR2 wants, but I think we can have a few exceptions with "our" style. The starting of braces on the same line is pracrically standard for our code. This also removes and empty lines from method/function bodies at the beginning and end. Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'tests/lib/Encryption')
-rw-r--r--tests/lib/Encryption/DecryptAllTest.php13
-rw-r--r--tests/lib/Encryption/EncryptionWrapperTest.php1
-rw-r--r--tests/lib/Encryption/Keys/StorageTest.php10
-rw-r--r--tests/lib/Encryption/ManagerTest.php20
-rw-r--r--tests/lib/Encryption/UpdateTest.php8
-rw-r--r--tests/lib/Encryption/UtilTest.php3
6 files changed, 24 insertions, 31 deletions
diff --git a/tests/lib/Encryption/DecryptAllTest.php b/tests/lib/Encryption/DecryptAllTest.php
index 8e53c4a92e1..3a16327ac18 100644
--- a/tests/lib/Encryption/DecryptAllTest.php
+++ b/tests/lib/Encryption/DecryptAllTest.php
@@ -107,7 +107,6 @@ class DecryptAllTest extends TestCase {
* @param bool $userExistsChecked
*/
public function testDecryptAll($prepareResult, $user, $userExistsChecked) {
-
if ($userExistsChecked) {
$this->userManager->expects($this->once())->method('userExists')->willReturn(true);
} else {
@@ -166,7 +165,6 @@ class DecryptAllTest extends TestCase {
* @param bool $success
*/
public function testPrepareEncryptionModules($success) {
-
$user = 'user1';
$dummyEncryptionModule = $this->getMockBuilder('OCP\Encryption\IEncryptionModule')
@@ -177,7 +175,9 @@ class DecryptAllTest extends TestCase {
->with($this->inputInterface, $this->outputInterface, $user)
->willReturn($success);
- $callback = function () use ($dummyEncryptionModule) {return $dummyEncryptionModule;};
+ $callback = function () use ($dummyEncryptionModule) {
+ return $dummyEncryptionModule;
+ };
$moduleDescription = [
'id' => 'id',
'displayName' => 'displayName',
@@ -305,14 +305,12 @@ class DecryptAllTest extends TestCase {
$progressBar = new ProgressBar($output);
$this->invokePrivate($instance, 'decryptUsersFiles', ['user1', $progressBar, '']);
-
}
/**
* @dataProvider dataTrueFalse
*/
public function testDecryptFile($isEncrypted) {
-
$path = 'test.txt';
/** @var DecryptAll | \PHPUnit_Framework_MockObject_MockObject $instance */
@@ -379,7 +377,9 @@ class DecryptAllTest extends TestCase {
$this->view->expects($this->once())
->method('copy')
->with($path, $path . '.decrypted.42')
- ->willReturnCallback(function () { throw new DecryptionFailedException();});
+ ->willReturnCallback(function () {
+ throw new DecryptionFailedException();
+ });
$this->view->expects($this->never())->method('rename');
$this->view->expects($this->once())
@@ -394,5 +394,4 @@ class DecryptAllTest extends TestCase {
$this->invokePrivate($instance, 'decryptFile', [$path])
);
}
-
}
diff --git a/tests/lib/Encryption/EncryptionWrapperTest.php b/tests/lib/Encryption/EncryptionWrapperTest.php
index 3fc18817327..06d9116255f 100644
--- a/tests/lib/Encryption/EncryptionWrapperTest.php
+++ b/tests/lib/Encryption/EncryptionWrapperTest.php
@@ -93,5 +93,4 @@ class EncryptionWrapperTest extends TestCase {
[false, [Storage\IDisableEncryptionStorage::class]],
];
}
-
}
diff --git a/tests/lib/Encryption/Keys/StorageTest.php b/tests/lib/Encryption/Keys/StorageTest.php
index 2233c25c8f1..fd33077c78b 100644
--- a/tests/lib/Encryption/Keys/StorageTest.php
+++ b/tests/lib/Encryption/Keys/StorageTest.php
@@ -339,7 +339,7 @@ class StorageTest extends TestCase {
$this->util->expects($this->any())
->method('isSystemWideMountPoint')
->willReturnCallback(function ($path, $owner) use ($systemWideMountSource, $systemWideMountTarget) {
- if(strpos($path, 'source.txt') !== false) {
+ if (strpos($path, 'source.txt') !== false) {
return $systemWideMountSource;
}
return $systemWideMountTarget;
@@ -370,7 +370,7 @@ class StorageTest extends TestCase {
$this->util->expects($this->any())
->method('isSystemWideMountPoint')
->willReturnCallback(function ($path, $owner) use ($systemWideMountSource, $systemWideMountTarget) {
- if(strpos($path, 'source.txt') !== false) {
+ if (strpos($path, 'source.txt') !== false) {
return $systemWideMountSource;
}
return $systemWideMountTarget;
@@ -427,7 +427,6 @@ class StorageTest extends TestCase {
* @param string $expected
*/
public function testGetPathToKeys($path, $systemWideMountPoint, $storageRoot, $expected) {
-
$this->invokePrivate($this->storage, 'root_dir', [$storageRoot]);
$this->util->expects($this->any())
@@ -485,7 +484,6 @@ class StorageTest extends TestCase {
* @param string $expected
*/
public function testGetFileKeyDir($isSystemWideMountPoint, $storageRoot, $expected) {
-
$path = '/user1/files/foo/bar.txt';
$owner = 'user1';
$relativePath = '/foo/bar.txt';
@@ -500,7 +498,6 @@ class StorageTest extends TestCase {
$this->assertSame($expected,
$this->invokePrivate($this->storage, 'getFileKeyDir', ['OC_DEFAULT_MODULE', $path])
);
-
}
public function dataTestGetFileKeyDir() {
@@ -518,7 +515,6 @@ class StorageTest extends TestCase {
* @param bool $createBackupDir
*/
public function testBackupUserKeys($createBackupDir) {
-
$storage = $this->getMockBuilder('OC\Encryption\Keys\Storage')
->setConstructorArgs([$this->view, $this->util])
->setMethods(['getTimestamp'])
@@ -546,7 +542,6 @@ class StorageTest extends TestCase {
)->willReturn(true);
$this->assertTrue($storage->backupUserKeys('encryptionModule', 'test', 'user1'));
-
}
public function dataTestBackupUserKeys() {
@@ -554,5 +549,4 @@ class StorageTest extends TestCase {
[true], [false]
];
}
-
}
diff --git a/tests/lib/Encryption/ManagerTest.php b/tests/lib/Encryption/ManagerTest.php
index 5a34e9cb392..47dd7fd01fb 100644
--- a/tests/lib/Encryption/ManagerTest.php
+++ b/tests/lib/Encryption/ManagerTest.php
@@ -60,7 +60,9 @@ class ManagerTest extends TestCase {
$em = $this->createMock(IEncryptionModule::class);
$em->expects($this->any())->method('getId')->willReturn('id');
$em->expects($this->any())->method('getDisplayName')->willReturn('TestDummyModule0');
- $this->manager->registerEncryptionModule('id', 'TestDummyModule0', function () use ($em) {return $em;});
+ $this->manager->registerEncryptionModule('id', 'TestDummyModule0', function () use ($em) {
+ return $em;
+ });
$this->assertFalse($this->manager->isEnabled());
}
@@ -96,7 +98,6 @@ class ManagerTest extends TestCase {
$this->manager->unregisterEncryptionModule('ID0');
$this->assertEmpty($this->manager->getEncryptionModules());
-
}
@@ -117,7 +118,10 @@ class ManagerTest extends TestCase {
$this->config->expects($this->any())
->method('getAppValue')
->with('core', 'default_encryption_module')
- ->willReturnCallback(function () { global $defaultId; return $defaultId; });
+ ->willReturnCallback(function () {
+ global $defaultId;
+ return $defaultId;
+ });
$this->addNewEncryptionModule($this->manager, 0);
$this->assertCount(1, $this->manager->getEncryptionModules());
@@ -138,7 +142,10 @@ class ManagerTest extends TestCase {
$this->config->expects($this->any())
->method('getAppValue')
->with('core', 'default_encryption_module')
- ->willReturnCallback(function () { global $defaultId; return $defaultId; });
+ ->willReturnCallback(function () {
+ global $defaultId;
+ return $defaultId;
+ });
$this->addNewEncryptionModule($this->manager, 0);
$defaultId = 'ID0';
@@ -160,7 +167,10 @@ class ManagerTest extends TestCase {
$this->config->expects($this->any())
->method('getAppValue')
->with('core', 'default_encryption_module')
- ->willReturnCallback(function () { global $defaultId; return $defaultId; });
+ ->willReturnCallback(function () {
+ global $defaultId;
+ return $defaultId;
+ });
$this->addNewEncryptionModule($this->manager, 0);
$this->assertCount(1, $this->manager->getEncryptionModules());
diff --git a/tests/lib/Encryption/UpdateTest.php b/tests/lib/Encryption/UpdateTest.php
index a783c620a5b..d7aa24d1f67 100644
--- a/tests/lib/Encryption/UpdateTest.php
+++ b/tests/lib/Encryption/UpdateTest.php
@@ -88,7 +88,6 @@ class UpdateTest extends TestCase {
* @param integer $numberOfFiles
*/
public function testUpdate($path, $isDir, $allFiles, $numberOfFiles) {
-
$this->encryptionManager->expects($this->once())
->method('getEncryptionModule')
->willReturn($this->encryptionModule);
@@ -97,7 +96,7 @@ class UpdateTest extends TestCase {
->method('is_dir')
->willReturn($isDir);
- if($isDir) {
+ if ($isDir) {
$this->util->expects($this->once())
->method('getAllFiles')
->willReturn($allFiles);
@@ -134,7 +133,6 @@ class UpdateTest extends TestCase {
* @param boolean $encryptionEnabled
*/
public function testPostRename($source, $target, $encryptionEnabled) {
-
$updateMock = $this->getUpdateMock(['update', 'getOwnerPath']);
$this->encryptionManager->expects($this->once())
@@ -153,7 +151,6 @@ class UpdateTest extends TestCase {
$path,
'update needs to be executed for the target destination');
return ['owner', $path];
-
});
$updateMock->expects($this->once())->method('update');
}
@@ -184,7 +181,6 @@ class UpdateTest extends TestCase {
* @param boolean $encryptionEnabled
*/
public function testPostRestore($encryptionEnabled) {
-
$updateMock = $this->getUpdateMock(['update']);
$this->encryptionManager->expects($this->once())
@@ -193,7 +189,6 @@ class UpdateTest extends TestCase {
if ($encryptionEnabled) {
$updateMock->expects($this->once())->method('update');
-
} else {
$updateMock->expects($this->never())->method('update');
}
@@ -232,5 +227,4 @@ class UpdateTest extends TestCase {
]
)->setMethods($methods)->getMock();
}
-
}
diff --git a/tests/lib/Encryption/UtilTest.php b/tests/lib/Encryption/UtilTest.php
index 0ac474faa0f..e1d898f5a86 100644
--- a/tests/lib/Encryption/UtilTest.php
+++ b/tests/lib/Encryption/UtilTest.php
@@ -56,7 +56,6 @@ class UtilTest extends TestCase {
$this->groupManager,
$this->config
);
-
}
/**
@@ -79,7 +78,6 @@ class UtilTest extends TestCase {
* @dataProvider providesHeaders
*/
public function testCreateHeader($expected, $header, $moduleId) {
-
$em = $this->createMock(IEncryptionModule::class);
$em->expects($this->any())->method('getId')->willReturn($moduleId);
@@ -190,5 +188,4 @@ class UtilTest extends TestCase {
['/foo/test.txt.ocTransferId7567.part', '/foo/test.txt'],
];
}
-
}