diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2024-09-03 15:18:16 +0200 |
---|---|---|
committer | Côme Chilliet <91878298+come-nc@users.noreply.github.com> | 2024-09-09 10:46:29 +0200 |
commit | 359bbce3afa1e00c1e62a9f3e2349994d4ac8f49 (patch) | |
tree | 27f2bd9ddf852696aef870bfb4b9a96bf1ee6310 /tests/lib/OCS/ApiHelperTest.php | |
parent | e184784f86f6f3c176a29a2aeec2588d357ebf08 (diff) | |
download | nextcloud-server-359bbce3afa1e00c1e62a9f3e2349994d4ac8f49.tar.gz nextcloud-server-359bbce3afa1e00c1e62a9f3e2349994d4ac8f49.zip |
chore: Adapt tests to OC_API refactoring
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'tests/lib/OCS/ApiHelperTest.php')
-rw-r--r-- | tests/lib/OCS/ApiHelperTest.php | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/lib/OCS/ApiHelperTest.php b/tests/lib/OCS/ApiHelperTest.php new file mode 100644 index 00000000000..fdbc1f4c538 --- /dev/null +++ b/tests/lib/OCS/ApiHelperTest.php @@ -0,0 +1,54 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2016 ownCloud, Inc. + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace Test\OCS; + +use OC\OCS\ApiHelper; +use OCP\IRequest; + +class ApiHelperTest extends \Test\TestCase { + /** + * @return array + */ + public function versionDataScriptNameProvider(): array { + return [ + // Valid script name + [ + '/master/ocs/v2.php', true, + ], + + // Invalid script names + [ + '/master/ocs/v2.php/someInvalidPathName', false, + ], + [ + '/master/ocs/v1.php', false, + ], + [ + '', false, + ], + ]; + } + + /** + * @dataProvider versionDataScriptNameProvider + */ + public function testIsV2(string $scriptName, bool $expected): void { + $request = $this->getMockBuilder(IRequest::class) + ->disableOriginalConstructor() + ->getMock(); + $request + ->expects($this->once()) + ->method('getScriptName') + ->willReturn($scriptName); + + $this->assertEquals($expected, $this->invokePrivate(new ApiHelper, 'isV2', [$request])); + } +} |