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-23 20:29:08 +0300
committerRobin Appelman <robin@icewind.nl>2022-03-04 18:29:59 +0300
commit1c468129afa2b2ec4a370a879f8eaffd22768baf (patch)
tree1c096e8c0a62371965104684e1f1bf2ef55eb2d4 /tests/lib/Traits
parent5c0fe934988960ece3ac71d5a1dfc8df405413aa (diff)
adjust tests to new fs setup
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'tests/lib/Traits')
-rw-r--r--tests/lib/Traits/EncryptionTrait.php21
-rw-r--r--tests/lib/Traits/UserTrait.php18
2 files changed, 33 insertions, 6 deletions
diff --git a/tests/lib/Traits/EncryptionTrait.php b/tests/lib/Traits/EncryptionTrait.php
index 6b74f7ca8ee..9cb64c12d00 100644
--- a/tests/lib/Traits/EncryptionTrait.php
+++ b/tests/lib/Traits/EncryptionTrait.php
@@ -9,12 +9,13 @@
namespace Test\Traits;
use OC\Encryption\EncryptionWrapper;
-use OC\Files\Filesystem;
+use OC\Files\SetupManager;
use OC\Memcache\ArrayCache;
use OCA\Encryption\AppInfo\Application;
use OCA\Encryption\KeyManager;
use OCA\Encryption\Users\Setup;
use OCP\Encryption\IManager;
+use OCP\IUserManager;
/**
* Enables encryption
@@ -31,6 +32,11 @@ trait EncryptionTrait {
private $originalEncryptionModule;
+ /** @var IUserManager */
+ private $userManager;
+ /** @var SetupManager */
+ private $setupManager;
+
/**
* @var \OCP\IConfig
*/
@@ -47,18 +53,20 @@ trait EncryptionTrait {
// needed for fully logout
\OC::$server->getUserSession()->setUser(null);
- Filesystem::tearDown();
+ $this->setupManager->tearDown();
+
\OC_User::setUserId($user);
$this->postLogin();
\OC_Util::setupFS($user);
- if (\OC::$server->getUserManager()->userExists($user)) {
+ if ($this->userManager->userExists($user)) {
\OC::$server->getUserFolder($user);
}
}
protected function setupForUser($name, $password) {
- \OC_Util::tearDownFS();
- \OC_Util::setupFS($name);
+ $this->setupManager->tearDown();
+ $this->setupManager->setupForUser($this->userManager->get($name));
+
$container = $this->encryptionApp->getContainer();
/** @var KeyManager $keyManager */
$keyManager = $container->query(KeyManager::class);
@@ -86,6 +94,9 @@ trait EncryptionTrait {
$this->markTestSkipped('Encryption not ready');
}
+ $this->userManager = \OC::$server->get(IUserManager::class);
+ $this->setupManager = \OC::$server->get(SetupManager::class);
+
\OC_App::loadApp('encryption');
$this->encryptionApp = new Application([], $isReady);
diff --git a/tests/lib/Traits/UserTrait.php b/tests/lib/Traits/UserTrait.php
index 229087a5200..3f7cfe419db 100644
--- a/tests/lib/Traits/UserTrait.php
+++ b/tests/lib/Traits/UserTrait.php
@@ -8,6 +8,21 @@
namespace Test\Traits;
+use OC\User\User;
+use OCP\IUser;
+
+class DummyUser extends User {
+ private string $uid;
+
+ public function __construct(string $uid) {
+ $this->uid = $uid;
+ }
+
+ public function getUID(): string {
+ return $this->uid;
+ }
+}
+
/**
* Allow creating users in a temporary backend
*/
@@ -17,8 +32,9 @@ trait UserTrait {
*/
protected $userBackend;
- protected function createUser($name, $password) {
+ protected function createUser($name, $password): IUser {
$this->userBackend->createUser($name, $password);
+ return new DummyUser($name);
}
protected function setUpUserTrait() {