[Pkg-owncloud-commits] [owncloud] 36/67: add unit tests
David Prévot
taffit at moszumanska.debian.org
Fri Jun 27 23:58:15 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository owncloud.
commit 9c45a3196bff4ae0658cb26e7011589bd17b5454
Author: Bjoern Schiessle <schiessle at owncloud.com>
Date: Tue Jun 24 10:43:07 2014 +0200
add unit tests
---
apps/files_encryption/lib/keymanager.php | 2 +-
apps/files_encryption/tests/keymanager.php | 30 +++++++++++++++++++++++++++++-
2 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/apps/files_encryption/lib/keymanager.php b/apps/files_encryption/lib/keymanager.php
index 07ac1a7..98986d1 100755
--- a/apps/files_encryption/lib/keymanager.php
+++ b/apps/files_encryption/lib/keymanager.php
@@ -516,7 +516,7 @@ class Keymanager {
* @param string|boolean $path
* @param string $basePath
*/
- public static function keySetPreparation(\OC\Files\View $view, $path, $basePath, $userId) {
+ protected static function keySetPreparation(\OC\Files\View $view, $path, $basePath, $userId) {
$targetPath = ltrim($path, '/');
diff --git a/apps/files_encryption/tests/keymanager.php b/apps/files_encryption/tests/keymanager.php
index 2bd2ddc..0c02544 100644
--- a/apps/files_encryption/tests/keymanager.php
+++ b/apps/files_encryption/tests/keymanager.php
@@ -239,11 +239,30 @@ class Test_Encryption_Keymanager extends \PHPUnit_Framework_TestCase {
\OC_FileProxy::$enabled = true;
// cleanup
- $this->view->unlink('/admin/files/folder1');
+ $this->view->deleteAll('/admin/files/folder1');
// change encryption proxy to previous state
\OC_FileProxy::$enabled = $proxyStatus;
}
+
+ function testKeySetPreperation() {
+ $basePath = '/'.Test_Encryption_Keymanager::TEST_USER.'/files';
+ $path = '/folder1/subfolder/subsubfolder';
+
+ $this->assertFalse($this->view->is_dir($basePath . '/testKeySetPreperation'));
+
+ $result = TestProtectedKeymanagerMethods::testKeySetPreperation($this->view, $path, $basePath);
+
+ // return path without leading slash
+ $this->assertSame('folder1/subfolder/subsubfolder', $result);
+
+ // check if directory structure was created
+ $this->assertTrue($this->view->is_dir($basePath . '/folder1/subfolder/subsubfolder'));
+
+ // cleanup
+ $this->view->deleteAll($basePath . '/folder1');
+
+ }
}
/**
@@ -257,4 +276,13 @@ class TestProtectedKeymanagerMethods extends \OCA\Encryption\Keymanager {
public static function testGetFilenameFromShareKey($sharekey) {
return self::getFilenameFromShareKey($sharekey);
}
+
+ /**
+ * @param \OC\Files\View $view relative to data/
+ * @param string $path
+ * @param string $basePath
+ */
+ public static function testKeySetPreperation($view, $path, $basePath) {
+ return self::keySetPreparation($view, $path, $basePath, '');
+ }
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list