fix fs cache test user setup

Signed-off-by: Robin Appelman <robin@icewind.nl>
pull/30942/head
Robin Appelman 2022-02-01 13:53:22 +07:00
parent 1ab58eff0f
commit 2673775f6e
No known key found for this signature in database
GPG Key ID: 42B69D8A64526EFB
2 changed files with 11 additions and 13 deletions

@ -368,6 +368,8 @@ class Filesystem {
} elseif ($user instanceof IUser) {
$userObject = $user;
$user = $userObject->getUID();
} else {
$userObject = null;
}
if ($userObject === null || $user === false || $user === '') {

@ -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, [], '/');