-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37472 from nextcloud/backport/37435/stable25
[stable25] Add label for logo link
- Loading branch information
Showing
7 changed files
with
96 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,6 @@ | |
use OCP\IConfig; | ||
use OCP\IRequest; | ||
use OCP\IURLGenerator; | ||
use OCP\IUser; | ||
use OCP\IUserSession; | ||
|
||
/** | ||
|
@@ -217,21 +216,16 @@ public function provideOCSRoutes() { | |
]; | ||
} | ||
|
||
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() { | ||
|
@@ -247,7 +241,7 @@ public function testLinkToDefaultPageUrlWithRedirectUrlRedirectBypassWithoutFron | |
putenv('front_controller_active=false'); | ||
|
||
$_REQUEST['redirect_url'] = '[email protected]: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() { | ||
|
@@ -256,70 +250,16 @@ public function testLinkToDefaultPageUrlWithRedirectUrlRedirectBypassWithFrontCo | |
putenv('front_controller_active=true'); | ||
|
||
$_REQUEST['redirect_url'] = '[email protected]: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'] = '[email protected]: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 { | ||
|