mirror of
https://github.com/nextcloud/server.git
synced 2026-04-15 22:11:17 -04:00
Fix UtilTest::testDefaultApps()
Oh wow... This definitly was no best practice... 😒
Signed-off-by: Daniel Rudolf <github.com@daniel-rudolf.de>
This commit is contained in:
parent
a43de10d1e
commit
e16bf707aa
2 changed files with 4 additions and 16 deletions
|
|
@ -1089,6 +1089,7 @@ class OC_Util {
|
|||
* @suppress PhanDeprecatedFunction
|
||||
*/
|
||||
public static function getDefaultPageUrl() {
|
||||
/** @var IURLGenerator $urlGenerator */
|
||||
$urlGenerator = \OC::$server->get(IURLGenerator::class);
|
||||
return $urlGenerator->linkToDefaultPageUrl();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -187,15 +187,16 @@ class UtilTest extends \Test\TestCase {
|
|||
->willReturnCallback(function ($appId) use ($enabledApps) {
|
||||
return in_array($appId, $enabledApps);
|
||||
});
|
||||
Dummy_OC_Util::$appManager = $appManager;
|
||||
$this->overwriteService(IAppManager::class, $appManager);
|
||||
|
||||
// need to set a user id to make sure enabled apps are read from cache
|
||||
\OC_User::setUserId($this->getUniqueID());
|
||||
\OC::$server->getConfig()->setSystemValue('defaultapp', $defaultAppConfig);
|
||||
$this->assertEquals('http://localhost/' . $expectedPath, Dummy_OC_Util::getDefaultPageUrl());
|
||||
$this->assertEquals('http://localhost/' . $expectedPath, OC_Util::getDefaultPageUrl());
|
||||
|
||||
// restore old state
|
||||
\OC::$WEBROOT = $oldWebRoot;
|
||||
$this->restoreService(IAppManager::class);
|
||||
\OC::$server->getConfig()->setSystemValue('defaultapp', $oldDefaultApps);
|
||||
\OC_User::setUserId(null);
|
||||
}
|
||||
|
|
@ -360,17 +361,3 @@ class UtilTest extends \Test\TestCase {
|
|||
], \OC_Util::$styles);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dummy OC Util class to make it possible to override the app manager
|
||||
*/
|
||||
class Dummy_OC_Util extends OC_Util {
|
||||
/**
|
||||
* @var \OCP\App\IAppManager
|
||||
*/
|
||||
public static $appManager;
|
||||
|
||||
protected static function getAppManager() {
|
||||
return self::$appManager;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue