Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2022-02-01 15:53:22 +0300
committerRobin Appelman (Rebase PR Action) <robin@icewind.nl>2022-03-21 16:55:08 +0300
commitcb3dc01163b82daf2b9d2e293112ab3135ca6163 (patch)
treef7493fc05df99e77d82012e6be50ec645d4f3ff7
parent1cfb740d680fa502d7b23cb97f5b37b56f939f15 (diff)
fix fs cache test user setup
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r--lib/private/Files/Filesystem.php2
-rw-r--r--tests/lib/Cache/FileCacheTest.php22
2 files changed, 11 insertions, 13 deletions
diff --git a/lib/private/Files/Filesystem.php b/lib/private/Files/Filesystem.php
index 0064e61ea2b..ea113d86940 100644
--- a/lib/private/Files/Filesystem.php
+++ b/lib/private/Files/Filesystem.php
@@ -368,6 +368,8 @@ class Filesystem {
} elseif ($user instanceof IUser) {
$userObject = $user;
$user = $userObject->getUID();
+ } else {
+ $userObject = null;
}
if ($userObject === null || $user === false || $user === '') {
diff --git a/tests/lib/Cache/FileCacheTest.php b/tests/lib/Cache/FileCacheTest.php
index 5791e28eb0c..a800fd005d9 100644
--- a/tests/lib/Cache/FileCacheTest.php
+++ b/tests/lib/Cache/FileCacheTest.php
@@ -23,6 +23,7 @@
namespace Test\Cache;
use OC\Files\Storage\Local;
+use Test\Traits\UserTrait;
/**
* Class FileCacheTest
@@ -32,6 +33,8 @@ use OC\Files\Storage\Local;
* @package Test\Cache
*/
class FileCacheTest extends TestCache {
+ use UserTrait;
+
/**
* @var string
* */
@@ -56,6 +59,12 @@ class FileCacheTest extends TestCache {
protected function setUp(): void {
parent::setUp();
+ //login
+ $this->createUser('test', 'test');
+
+ $this->user = \OC_User::getUser();
+ \OC_User::setUserId('test');
+
//clear all proxies and hooks so we can do clean testing
\OC_Hook::clear('OC_Filesystem');
@@ -69,15 +78,6 @@ class FileCacheTest extends TestCache {
$this->datadir = $config->getSystemValue('cachedirectory', \OC::$SERVERROOT.'/data/cache');
$config->setSystemValue('cachedirectory', $datadir);
- \OC_User::clearBackends();
- \OC_User::useBackend(new \Test\Util\User\Dummy());
-
- //login
- \OC::$server->getUserManager()->createUser('test', 'test');
-
- $this->user = \OC_User::getUser();
- \OC_User::setUserId('test');
-
//set up the users dir
$this->rootView = new \OC\Files\View('');
$this->rootView->mkdir('/test');
@@ -101,10 +101,6 @@ class FileCacheTest extends TestCache {
$this->instance = null;
}
- //tear down the users dir aswell
- $user = \OC::$server->getUserManager()->get('test');
- $user->delete();
-
// Restore the original mount point
\OC\Files\Filesystem::clearMounts();
\OC\Files\Filesystem::mount($this->storage, [], '/');