diff options
author | Joas Schilling <coding@schilljs.com> | 2023-11-20 11:18:47 +0100 |
---|---|---|
committer | backportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com> | 2023-11-20 16:15:39 +0000 |
commit | 5d12f1231975ab7249ad554f0d0a3c8d2eb67b13 (patch) | |
tree | 71f2adf932bdc31571532c1c6bea702bb5c0d1d7 /tests/lib | |
parent | 5b16df8dd1f12858c97a42c1a3e85e49382395e5 (diff) | |
download | nextcloud-server-5d12f1231975ab7249ad554f0d0a3c8d2eb67b13.tar.gz nextcloud-server-5d12f1231975ab7249ad554f0d0a3c8d2eb67b13.zip |
fix: Fix linkToOCSRouteAbsolute() without index.php and subfolder
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests/lib')
-rw-r--r-- | tests/lib/UrlGeneratorTest.php | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/tests/lib/UrlGeneratorTest.php b/tests/lib/UrlGeneratorTest.php index b95cb115217..740f02e3e7d 100644 --- a/tests/lib/UrlGeneratorTest.php +++ b/tests/lib/UrlGeneratorTest.php @@ -192,26 +192,34 @@ class UrlGeneratorTest extends \Test\TestCase { /** * @dataProvider provideOCSRoutes */ - public function testLinkToOCSRouteAbsolute(string $route, string $expected) { + public function testLinkToOCSRouteAbsolute(string $route, bool $ignoreFrontController, string $expected): void { $this->mockBaseUrl(); \OC::$WEBROOT = '/nextcloud'; $this->router->expects($this->once()) ->method('generate') - ->willReturnCallback(function ($routeName, $parameters) { + ->willReturnCallback(function (string $routeName, array $parameters) use ($ignoreFrontController) { if ($routeName === 'ocs.core.OCS.getCapabilities') { - return '/index.php/ocsapp/cloud/capabilities'; + if (!$ignoreFrontController) { + return '/nextcloud/index.php/ocsapp/cloud/capabilities'; + } + return '/nextcloud/ocsapp/cloud/capabilities'; } elseif ($routeName === 'ocs.core.WhatsNew.dismiss') { - return '/index.php/ocsapp/core/whatsnew'; + if (!$ignoreFrontController) { + return '/nextcloud/index.php/ocsapp/core/whatsnew'; + } + return '/nextcloud/ocsapp/core/whatsnew'; } }); $result = $this->urlGenerator->linkToOCSRouteAbsolute($route); $this->assertEquals($expected, $result); } - public function provideOCSRoutes() { + public function provideOCSRoutes(): array { return [ - ['core.OCS.getCapabilities', 'http://localhost/nextcloud/ocs/v2.php/cloud/capabilities'], - ['core.WhatsNew.dismiss', 'http://localhost/nextcloud/ocs/v2.php/core/whatsnew'], + ['core.OCS.getCapabilities', false, 'http://localhost/nextcloud/ocs/v2.php/cloud/capabilities'], + ['core.OCS.getCapabilities', true, 'http://localhost/nextcloud/ocs/v2.php/cloud/capabilities'], + ['core.WhatsNew.dismiss', false, 'http://localhost/nextcloud/ocs/v2.php/core/whatsnew'], + ['core.WhatsNew.dismiss', true, 'http://localhost/nextcloud/ocs/v2.php/core/whatsnew'], ]; } |