aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-12-04 14:01:23 +0100
committerVincent Petry <pvince81@owncloud.com>2014-12-10 16:11:27 +0100
commit5101bc54faea28d1210eb24f72abd76944c83af6 (patch)
treebe047fe997d3d72eb8c5ee994dc9e9da31e53164
parent3898fbc0d2d65785b8b132645c5bf99077d16818 (diff)
downloadnextcloud-server-5101bc54faea28d1210eb24f72abd76944c83af6.tar.gz
nextcloud-server-5101bc54faea28d1210eb24f72abd76944c83af6.zip
Add login/logout to TestCase base class
-rw-r--r--tests/lib/testcase.php21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/lib/testcase.php b/tests/lib/testcase.php
index 27c28329535..1ea3aa13547 100644
--- a/tests/lib/testcase.php
+++ b/tests/lib/testcase.php
@@ -148,4 +148,25 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase {
\OC_FileProxy::$enabled = true;
\OC_FileProxy::clearProxies();
}
+
+ /**
+ * Login and setup FS as a given user,
+ * sets the given user as the current user.
+ *
+ * @param string $user user id
+ */
+ static protected function loginAsUser($user) {
+ self::logout();
+ \OC\Files\Filesystem::tearDown();
+ \OC_User::setUserId($user);
+ \OC_Util::setupFS($user);
+ }
+
+ /**
+ * Logout the current user and tear down the filesystem.
+ */
+ static protected function logout() {
+ \OC_Util::tearDownFS();
+ \OC_User::setUserId('');
+ }
}