summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorChristopher Ng <chrng8@gmail.com>2023-03-29 13:36:45 -0700
committerChristopher Ng <chrng8@gmail.com>2023-03-29 13:36:45 -0700
commit4f8e916585889b99247d967d51325ac0c840ec59 (patch)
tree67e9b24aa50f033cf88d52f53b648bb2bd30aab4 /tests
parentfc371facd202d7ede86f1adb37fc78a8c478deff (diff)
downloadnextcloud-server-4f8e916585889b99247d967d51325ac0c840ec59.tar.gz
nextcloud-server-4f8e916585889b99247d967d51325ac0c840ec59.zip
Add label for logo link
Signed-off-by: Christopher Ng <chrng8@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/App/AppManagerTest.php43
-rw-r--r--tests/lib/UrlGeneratorTest.php80
2 files changed, 53 insertions, 70 deletions
diff --git a/tests/lib/App/AppManagerTest.php b/tests/lib/App/AppManagerTest.php
index bf9592ac6a6..3518ada3314 100644
--- a/tests/lib/App/AppManagerTest.php
+++ b/tests/lib/App/AppManagerTest.php
@@ -617,4 +617,47 @@ class AppManagerTest extends TestCase {
$this->assertEquals([], $this->manager->getAppRestriction('test2'));
$this->assertEquals(['foo'], $this->manager->getAppRestriction('test3'));
}
+
+ public function provideDefaultApps(): array {
+ return [
+ // none specified, default to files
+ [
+ '',
+ 'files',
+ ],
+ // unexisting or inaccessible app specified, default to files
+ [
+ 'unexist',
+ 'files',
+ ],
+ // non-standard app
+ [
+ 'settings',
+ 'settings',
+ ],
+ // non-standard app with fallback
+ [
+ 'unexist,settings',
+ 'settings',
+ ],
+ ];
+ }
+
+ /**
+ * @dataProvider provideDefaultApps
+ */
+ public function testGetDefaultAppForUser($defaultApps, $expectedApp) {
+ $user = $this->newUser('user1');
+
+ $this->userSession->expects($this->once())
+ ->method('getUser')
+ ->willReturn($user);
+
+ $this->config->expects($this->once())
+ ->method('getSystemValueString')
+ ->with('defaultapp', $this->anything())
+ ->willReturn($defaultApps);
+
+ $this->assertEquals($expectedApp, $this->manager->getDefaultAppForUser());
+ }
}
diff --git a/tests/lib/UrlGeneratorTest.php b/tests/lib/UrlGeneratorTest.php
index 420b2fe4eb9..523616b4532 100644
--- a/tests/lib/UrlGeneratorTest.php
+++ b/tests/lib/UrlGeneratorTest.php
@@ -13,7 +13,6 @@ use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IRequest;
use OCP\IURLGenerator;
-use OCP\IUser;
use OCP\IUserSession;
/**
@@ -216,21 +215,16 @@ class UrlGeneratorTest extends \Test\TestCase {
];
}
- private function mockLinkToDefaultPageUrl(string $defaultAppConfig = '', bool $ignoreFrontControllerConfig = false) {
- $this->config->expects($this->exactly(2))
- ->method('getSystemValue')
- ->withConsecutive(
- ['defaultapp', $this->anything()],
- ['htaccess.IgnoreFrontController', $this->anything()],
- )
- ->will($this->onConsecutiveCalls(
- $defaultAppConfig,
- $ignoreFrontControllerConfig
- ));
+ private function mockLinkToDefaultPageUrl(bool $ignoreFrontControllerConfig = false) {
$this->config->expects($this->once())
->method('getAppValue')
->with('core', 'defaultpage')
->willReturn('');
+
+ $this->config->expects($this->once())
+ ->method('getSystemValue')
+ ->with('htaccess.IgnoreFrontController', $this->anything())
+ ->willReturn($ignoreFrontControllerConfig);
}
public function testLinkToDefaultPageUrlWithRedirectUrlWithoutFrontController() {
@@ -246,7 +240,7 @@ class UrlGeneratorTest extends \Test\TestCase {
putenv('front_controller_active=false');
$_REQUEST['redirect_url'] = 'myRedirectUrl.com@foo.com:a';
- $this->assertSame('http://localhost' . \OC::$WEBROOT . '/index.php/apps/files/', $this->urlGenerator->linkToDefaultPageUrl());
+ $this->assertSame('http://localhost' . \OC::$WEBROOT . '/index.php/apps/dashboard/', $this->urlGenerator->linkToDefaultPageUrl());
}
public function testLinkToDefaultPageUrlWithRedirectUrlRedirectBypassWithFrontController() {
@@ -255,70 +249,16 @@ class UrlGeneratorTest extends \Test\TestCase {
putenv('front_controller_active=true');
$_REQUEST['redirect_url'] = 'myRedirectUrl.com@foo.com:a';
- $this->assertSame('http://localhost' . \OC::$WEBROOT . '/apps/files/', $this->urlGenerator->linkToDefaultPageUrl());
+ $this->assertSame('http://localhost' . \OC::$WEBROOT . '/apps/dashboard/', $this->urlGenerator->linkToDefaultPageUrl());
}
public function testLinkToDefaultPageUrlWithRedirectUrlWithIgnoreFrontController() {
$this->mockBaseUrl();
- $this->mockLinkToDefaultPageUrl('', true);
+ $this->mockLinkToDefaultPageUrl(true);
putenv('front_controller_active=false');
$_REQUEST['redirect_url'] = 'myRedirectUrl.com@foo.com:a';
- $this->assertSame('http://localhost' . \OC::$WEBROOT . '/apps/files/', $this->urlGenerator->linkToDefaultPageUrl());
- }
-
- /**
- * @dataProvider provideDefaultApps
- */
- public function testLinkToDefaultPageUrlWithDefaultApps($defaultAppConfig, $expectedPath) {
- $userId = $this->getUniqueID();
-
- /** @var \PHPUnit\Framework\MockObject\MockObject|IUser $userMock */
- $userMock = $this->createMock(IUser::class);
- $userMock->expects($this->once())
- ->method('getUID')
- ->willReturn($userId);
-
- $this->mockBaseUrl();
- $this->mockLinkToDefaultPageUrl($defaultAppConfig);
-
- $this->config->expects($this->once())
- ->method('getUserValue')
- ->with($userId, 'core', 'defaultapp')
- ->willReturn('');
- $this->userSession->expects($this->once())
- ->method('isLoggedIn')
- ->willReturn(true);
- $this->userSession->expects($this->once())
- ->method('getUser')
- ->willReturn($userMock);
-
- $this->assertEquals('http://localhost' . \OC::$WEBROOT . $expectedPath, $this->urlGenerator->linkToDefaultPageUrl());
- }
-
- public function provideDefaultApps(): array {
- return [
- // none specified, default to files
- [
- '',
- '/index.php/apps/files/',
- ],
- // unexisting or inaccessible app specified, default to files
- [
- 'unexist',
- '/index.php/apps/files/',
- ],
- // non-standard app
- [
- 'settings',
- '/index.php/apps/settings/',
- ],
- // non-standard app with fallback
- [
- 'unexist,settings',
- '/index.php/apps/settings/',
- ],
- ];
+ $this->assertSame('http://localhost' . \OC::$WEBROOT . '/apps/dashboard/', $this->urlGenerator->linkToDefaultPageUrl());
}
public function imagePathProvider(): array {