aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2025-01-24 13:14:19 +0100
committerFerdinand Thiessen <opensource@fthiessen.de>2025-01-29 08:37:33 +0100
commita82a097e6ad329b624012d6122667a9baaa06115 (patch)
tree1b82e70695cc243f79883bfc5e1d69a18dda50bd /tests
parentef015a99d20d90d5e52038634e7cb44cefcce621 (diff)
downloadnextcloud-server-a82a097e6ad329b624012d6122667a9baaa06115.tar.gz
nextcloud-server-a82a097e6ad329b624012d6122667a9baaa06115.zip
fix(TemplateLayout): `core` is not an app but the server itselfbackport/50398/stable30
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/App/AppManagerTest.php27
-rw-r--r--tests/lib/AppTest.php46
2 files changed, 27 insertions, 46 deletions
diff --git a/tests/lib/App/AppManagerTest.php b/tests/lib/App/AppManagerTest.php
index 7546679dc9e..b715ef5a828 100644
--- a/tests/lib/App/AppManagerTest.php
+++ b/tests/lib/App/AppManagerTest.php
@@ -25,7 +25,6 @@ use OCP\IGroupManager;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserSession;
-use OCP\ServerVersion;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
use Test\TestCase;
@@ -101,8 +100,6 @@ class AppManagerTest extends TestCase {
protected IURLGenerator&MockObject $urlGenerator;
- protected ServerVersion&MockObject $serverVersion;
-
/** @var IAppManager */
protected $manager;
@@ -118,7 +115,6 @@ class AppManagerTest extends TestCase {
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
$this->logger = $this->createMock(LoggerInterface::class);
$this->urlGenerator = $this->createMock(IURLGenerator::class);
- $this->serverVersion = $this->createMock(ServerVersion::class);
$this->overwriteService(AppConfig::class, $this->appConfig);
$this->overwriteService(IURLGenerator::class, $this->urlGenerator);
@@ -140,7 +136,6 @@ class AppManagerTest extends TestCase {
$this->cacheFactory,
$this->eventDispatcher,
$this->logger,
- $this->serverVersion,
);
}
@@ -291,7 +286,6 @@ class AppManagerTest extends TestCase {
$this->cacheFactory,
$this->eventDispatcher,
$this->logger,
- $this->serverVersion,
])
->onlyMethods([
'getAppPath',
@@ -345,7 +339,6 @@ class AppManagerTest extends TestCase {
$this->cacheFactory,
$this->eventDispatcher,
$this->logger,
- $this->serverVersion,
])
->onlyMethods([
'getAppPath',
@@ -407,7 +400,6 @@ class AppManagerTest extends TestCase {
$this->cacheFactory,
$this->eventDispatcher,
$this->logger,
- $this->serverVersion,
])
->onlyMethods([
'getAppPath',
@@ -610,7 +602,6 @@ class AppManagerTest extends TestCase {
$this->cacheFactory,
$this->eventDispatcher,
$this->logger,
- $this->serverVersion,
])
->onlyMethods(['getAppInfo'])
->getMock();
@@ -669,7 +660,6 @@ class AppManagerTest extends TestCase {
$this->cacheFactory,
$this->eventDispatcher,
$this->logger,
- $this->serverVersion,
])
->onlyMethods(['getAppInfo'])
->getMock();
@@ -961,7 +951,6 @@ class AppManagerTest extends TestCase {
$this->cacheFactory,
$this->eventDispatcher,
$this->logger,
- $this->serverVersion,
])
->onlyMethods([
'getAppInfo',
@@ -973,10 +962,6 @@ class AppManagerTest extends TestCase {
->with('myapp')
->willReturn(['version' => '99.99.99-rc.99']);
- $this->serverVersion
- ->expects(self::never())
- ->method('getVersionString');
-
$this->assertEquals(
'99.99.99-rc.99',
$manager->getAppVersion('myapp'),
@@ -992,7 +977,6 @@ class AppManagerTest extends TestCase {
$this->cacheFactory,
$this->eventDispatcher,
$this->logger,
- $this->serverVersion,
])
->onlyMethods([
'getAppInfo',
@@ -1002,10 +986,8 @@ class AppManagerTest extends TestCase {
$manager->expects(self::never())
->method('getAppInfo');
- $this->serverVersion
- ->expects(self::once())
- ->method('getVersionString')
- ->willReturn('1.2.3-beta.4');
+ $util = new \OC_Util();
+ self::invokePrivate($util, 'versionCache', [['OC_VersionString' => '1.2.3-beta.4']]);
$this->assertEquals(
'1.2.3-beta.4',
@@ -1022,7 +1004,6 @@ class AppManagerTest extends TestCase {
$this->cacheFactory,
$this->eventDispatcher,
$this->logger,
- $this->serverVersion,
])
->onlyMethods([
'getAppInfo',
@@ -1034,10 +1015,6 @@ class AppManagerTest extends TestCase {
->with('unknown')
->willReturn(null);
- $this->serverVersion
- ->expects(self::never())
- ->method('getVersionString');
-
$this->assertEquals(
'0',
$manager->getAppVersion('unknown'),
diff --git a/tests/lib/AppTest.php b/tests/lib/AppTest.php
index 4fe88e09e6a..e04bfaee45e 100644
--- a/tests/lib/AppTest.php
+++ b/tests/lib/AppTest.php
@@ -12,7 +12,12 @@ use OC\App\InfoParser;
use OC\AppConfig;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IAppConfig;
-use OCP\IURLGenerator;
+use OCP\ICacheFactory;
+use OCP\IConfig;
+use OCP\IDBConnection;
+use OCP\IGroupManager;
+use OCP\IUserManager;
+use OCP\IUserSession;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
@@ -457,12 +462,12 @@ class AppTest extends \Test\TestCase {
*
* @dataProvider appConfigValuesProvider
*/
- public function testEnabledApps($user, $expectedApps, $forceAll) {
- $userManager = \OC::$server->getUserManager();
- $groupManager = \OC::$server->getGroupManager();
- $user1 = $userManager->createUser(self::TEST_USER1, self::TEST_USER1);
- $user2 = $userManager->createUser(self::TEST_USER2, self::TEST_USER2);
- $user3 = $userManager->createUser(self::TEST_USER3, self::TEST_USER3);
+ public function testEnabledApps($user, $expectedApps, $forceAll): void {
+ $userManager = \OCP\Server::get(IUserManager::class);
+ $groupManager = \OCP\Server::get(IGroupManager::class);
+ $user1 = $userManager->createUser(self::TEST_USER1, 'NotAnEasyPassword123456+');
+ $user2 = $userManager->createUser(self::TEST_USER2, 'NotAnEasyPassword123456_');
+ $user3 = $userManager->createUser(self::TEST_USER3, 'NotAnEasyPassword123456?');
$group1 = $groupManager->createGroup(self::TEST_GROUP1);
$group1->addUser($user1);
@@ -506,9 +511,9 @@ class AppTest extends \Test\TestCase {
* Test isEnabledApps() with cache, not re-reading the list of
* enabled apps more than once when a user is set.
*/
- public function testEnabledAppsCache() {
- $userManager = \OC::$server->getUserManager();
- $user1 = $userManager->createUser(self::TEST_USER1, self::TEST_USER1);
+ public function testEnabledAppsCache(): void {
+ $userManager = \OCP\Server::get(IUserManager::class);
+ $user1 = $userManager->createUser(self::TEST_USER1, 'NotAnEasyPassword123456+');
\OC_User::setUserId(self::TEST_USER1);
@@ -539,8 +544,8 @@ class AppTest extends \Test\TestCase {
private function setupAppConfigMock() {
/** @var AppConfig|MockObject */
$appConfig = $this->getMockBuilder(AppConfig::class)
- ->setMethods(['getValues'])
- ->setConstructorArgs([\OC::$server->getDatabaseConnection()])
+ ->onlyMethods(['getValues'])
+ ->setConstructorArgs([\OCP\Server::get(IDBConnection::class)])
->disableOriginalConstructor()
->getMock();
@@ -556,13 +561,12 @@ class AppTest extends \Test\TestCase {
private function registerAppConfig(AppConfig $appConfig) {
$this->overwriteService(AppConfig::class, $appConfig);
$this->overwriteService(AppManager::class, new AppManager(
- \OC::$server->getUserSession(),
- \OC::$server->getConfig(),
- \OC::$server->getGroupManager(),
- \OC::$server->getMemCacheFactory(),
- \OC::$server->get(IEventDispatcher::class),
- \OC::$server->get(LoggerInterface::class),
- \OC::$server->get(IURLGenerator::class),
+ \OCP\Server::get(IUserSession::class),
+ \OCP\Server::get(IConfig::class),
+ \OCP\Server::get(IGroupManager::class),
+ \OCP\Server::get(ICacheFactory::class),
+ \OCP\Server::get(IEventDispatcher::class),
+ \OCP\Server::get(LoggerInterface::class),
));
}
@@ -621,14 +625,14 @@ class AppTest extends \Test\TestCase {
public function testParseAppInfoL10N() {
$parser = new InfoParser();
- $data = $parser->parse(\OC::$SERVERROOT. "/tests/data/app/description-multi-lang.xml");
+ $data = $parser->parse(\OC::$SERVERROOT . '/tests/data/app/description-multi-lang.xml');
$this->assertEquals('English', \OC_App::parseAppInfo($data, 'en')['description']);
$this->assertEquals('German', \OC_App::parseAppInfo($data, 'de')['description']);
}
public function testParseAppInfoL10NSingleLanguage() {
$parser = new InfoParser();
- $data = $parser->parse(\OC::$SERVERROOT. "/tests/data/app/description-single-lang.xml");
+ $data = $parser->parse(\OC::$SERVERROOT . '/tests/data/app/description-single-lang.xml');
$this->assertEquals('English', \OC_App::parseAppInfo($data, 'en')['description']);
}
}