aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/Traits
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/Traits')
-rw-r--r--tests/lib/Traits/EncryptionTrait.php22
-rw-r--r--tests/lib/Traits/MountProviderTrait.php8
-rw-r--r--tests/lib/Traits/UserTrait.php14
3 files changed, 25 insertions, 19 deletions
diff --git a/tests/lib/Traits/EncryptionTrait.php b/tests/lib/Traits/EncryptionTrait.php
index e435a286685..fa0aa1541c3 100644
--- a/tests/lib/Traits/EncryptionTrait.php
+++ b/tests/lib/Traits/EncryptionTrait.php
@@ -11,10 +11,14 @@ use OC\Encryption\EncryptionWrapper;
use OC\Files\SetupManager;
use OC\Memcache\ArrayCache;
use OCA\Encryption\AppInfo\Application;
+use OCA\Encryption\Crypto\Encryption;
use OCA\Encryption\KeyManager;
use OCA\Encryption\Users\Setup;
use OCP\Encryption\IManager;
+use OCP\IConfig;
use OCP\IUserManager;
+use OCP\IUserSession;
+use OCP\Server;
use Psr\Log\LoggerInterface;
/**
@@ -51,7 +55,7 @@ trait EncryptionTrait {
\OC_Util::tearDownFS();
\OC_User::setUserId('');
// needed for fully logout
- \OC::$server->getUserSession()->setUser(null);
+ Server::get(IUserSession::class)->setUser(null);
$this->setupManager->tearDown();
@@ -81,32 +85,32 @@ trait EncryptionTrait {
protected function postLogin() {
$encryptionWrapper = new EncryptionWrapper(
new ArrayCache(),
- \OC::$server->getEncryptionManager(),
- \OC::$server->get(LoggerInterface::class)
+ Server::get(\OCP\Encryption\IManager::class),
+ Server::get(LoggerInterface::class)
);
$this->registerStorageWrapper('oc_encryption', [$encryptionWrapper, 'wrapStorage']);
}
protected function setUpEncryptionTrait() {
- $isReady = \OC::$server->getEncryptionManager()->isReady();
+ $isReady = Server::get(\OCP\Encryption\IManager::class)->isReady();
if (!$isReady) {
$this->markTestSkipped('Encryption not ready');
}
- $this->userManager = \OC::$server->get(IUserManager::class);
- $this->setupManager = \OC::$server->get(SetupManager::class);
+ $this->userManager = Server::get(IUserManager::class);
+ $this->setupManager = Server::get(SetupManager::class);
\OC_App::loadApp('encryption');
$this->encryptionApp = new Application([], $isReady);
- $this->config = \OC::$server->getConfig();
+ $this->config = Server::get(IConfig::class);
$this->encryptionWasEnabled = $this->config->getAppValue('core', 'encryption_enabled', 'no');
$this->originalEncryptionModule = $this->config->getAppValue('core', 'default_encryption_module');
- $this->config->setAppValue('core', 'default_encryption_module', \OCA\Encryption\Crypto\Encryption::ID);
+ $this->config->setAppValue('core', 'default_encryption_module', Encryption::ID);
$this->config->setAppValue('core', 'encryption_enabled', 'yes');
- $this->assertTrue(\OC::$server->getEncryptionManager()->isEnabled());
+ $this->assertTrue(Server::get(\OCP\Encryption\IManager::class)->isEnabled());
}
protected function tearDownEncryptionTrait() {
diff --git a/tests/lib/Traits/MountProviderTrait.php b/tests/lib/Traits/MountProviderTrait.php
index 3bb92f48e20..479e702e2f1 100644
--- a/tests/lib/Traits/MountProviderTrait.php
+++ b/tests/lib/Traits/MountProviderTrait.php
@@ -9,7 +9,9 @@ namespace Test\Traits;
use OC\Files\Mount\MountPoint;
use OC\Files\Storage\StorageFactory;
+use OCP\Files\Config\IMountProviderCollection;
use OCP\IUser;
+use OCP\Server;
/**
* Allow setting mounts for users
@@ -49,7 +51,7 @@ trait MountProviderTrait {
$this->mountProvider = $this->getMockBuilder('\OCP\Files\Config\IMountProvider')->getMock();
$this->mountProvider->expects($this->any())
->method('getMountsForUser')
- ->will($this->returnCallback(function (IUser $user) {
+ ->willReturnCallback(function (IUser $user) {
if (isset($this->mounts[$user->getUID()])) {
return array_map(function ($config) {
return new MountPoint($config['storage'], $config['mountPoint'], $config['arguments'], $this->storageFactory);
@@ -57,7 +59,7 @@ trait MountProviderTrait {
} else {
return [];
}
- }));
- \OCP\Server::get(\OCP\Files\Config\IMountProviderCollection::class)->registerProvider($this->mountProvider);
+ });
+ Server::get(IMountProviderCollection::class)->registerProvider($this->mountProvider);
}
}
diff --git a/tests/lib/Traits/UserTrait.php b/tests/lib/Traits/UserTrait.php
index 05fb0caa8ca..137ca986911 100644
--- a/tests/lib/Traits/UserTrait.php
+++ b/tests/lib/Traits/UserTrait.php
@@ -10,14 +10,14 @@ namespace Test\Traits;
use OC\User\User;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IUser;
+use OCP\IUserManager;
use OCP\Server;
class DummyUser extends User {
- private string $uid;
-
- public function __construct(string $uid) {
- $this->uid = $uid;
- parent::__construct($uid, null, Server::get(IEventDispatcher::class));
+ public function __construct(
+ private string $uid,
+ ) {
+ parent::__construct($this->uid, null, Server::get(IEventDispatcher::class));
}
public function getUID(): string {
@@ -41,10 +41,10 @@ trait UserTrait {
protected function setUpUserTrait() {
$this->userBackend = new \Test\Util\User\Dummy();
- \OC::$server->getUserManager()->registerBackend($this->userBackend);
+ Server::get(IUserManager::class)->registerBackend($this->userBackend);
}
protected function tearDownUserTrait() {
- \OC::$server->getUserManager()->removeBackend($this->userBackend);
+ Server::get(IUserManager::class)->removeBackend($this->userBackend);
}
}