|
28 | 28 | use OCP\IUser; |
29 | 29 | use OCP\IUserSession; |
30 | 30 | use OCP\ServerVersion; |
| 31 | +use PHPUnit\Framework\Attributes\DataProvider; |
31 | 32 | use PHPUnit\Framework\MockObject\MockObject; |
32 | 33 | use Psr\Log\LoggerInterface; |
33 | 34 | use Test\TestCase; |
@@ -143,7 +144,7 @@ protected function setUp(): void { |
143 | 144 | ); |
144 | 145 | } |
145 | 146 |
|
146 | | - #[\PHPUnit\Framework\Attributes\DataProvider('dataGetAppIcon')] |
| 147 | + #[DataProvider('dataGetAppIcon')] |
147 | 148 | public function testGetAppIcon($callback, ?bool $dark, ?string $expected): void { |
148 | 149 | $this->urlGenerator->expects($this->atLeastOnce()) |
149 | 150 | ->method('imagePath') |
@@ -314,7 +315,7 @@ public static function dataEnableAppForGroupsAllowedTypes(): array { |
314 | 315 | /** |
315 | 316 | * @param array $appInfo |
316 | 317 | */ |
317 | | - #[\PHPUnit\Framework\Attributes\DataProvider('dataEnableAppForGroupsAllowedTypes')] |
| 318 | + #[DataProvider('dataEnableAppForGroupsAllowedTypes')] |
318 | 319 | public function testEnableAppForGroupsAllowedTypes(array $appInfo): void { |
319 | 320 | $group1 = $this->createMock(IGroup::class); |
320 | 321 | $group1->method('getGID') |
@@ -375,7 +376,7 @@ public static function dataEnableAppForGroupsForbiddenTypes(): array { |
375 | 376 | * @param string $type |
376 | 377 | * |
377 | 378 | */ |
378 | | - #[\PHPUnit\Framework\Attributes\DataProvider('dataEnableAppForGroupsForbiddenTypes')] |
| 379 | + #[DataProvider('dataEnableAppForGroupsForbiddenTypes')] |
379 | 380 | public function testEnableAppForGroupsForbiddenTypes($type): void { |
380 | 381 | $this->expectException(\Exception::class); |
381 | 382 | $this->expectExceptionMessage('test can\'t be enabled for groups.'); |
@@ -781,7 +782,7 @@ public static function isBackendRequiredDataProvider(): array { |
781 | 782 | ]; |
782 | 783 | } |
783 | 784 |
|
784 | | - #[\PHPUnit\Framework\Attributes\DataProvider('isBackendRequiredDataProvider')] |
| 785 | + #[DataProvider('isBackendRequiredDataProvider')] |
785 | 786 | public function testIsBackendRequired( |
786 | 787 | string $backend, |
787 | 788 | array $appBackends, |
@@ -896,4 +897,25 @@ public function testGetAppVersionUnknown() { |
896 | 897 | $manager->getAppVersion('unknown'), |
897 | 898 | ); |
898 | 899 | } |
| 900 | + |
| 901 | + public static function dataCleanAppId(): array { |
| 902 | + return [ |
| 903 | + ['simple', 'simple'], |
| 904 | + ['UPPERCASEa', 'a'], |
| 905 | + ['MixEdCaSe', 'ixdae'], |
| 906 | + ['007startwithdigit', 'startwithdigit'], |
| 907 | + ['0-numb3rs-4ll0w3d-1n-m1ddle-0', 'numb3rs-4ll0w3d-1n-m1ddle-0'], |
| 908 | + ['hyphen-and_underscore_allowed', 'hyphen-and_underscore_allowed'], |
| 909 | + ['_but-not-at-the-end_', 'but-not-at-the-end'], |
| 910 | + ['-but-not-at-the-end-', 'but-not-at-the-end'], |
| 911 | + ['--_but-not-at-the-end___', 'but-not-at-the-end'], |
| 912 | + [' also remove all spaces', 'alsoremoveallspaces'], |
| 913 | + ['a«"«»()@+-/*=%\{}…~|&œ—<>[]^±_−÷×≠‰A', 'a-_'], |
| 914 | + ]; |
| 915 | + } |
| 916 | + |
| 917 | + #[DataProvider('dataCleanAppId')] |
| 918 | + public function testCleanAppId(string $inputString, string $appid): void { |
| 919 | + $this->assertEquals($appid, $this->manager->cleanAppId($inputString)); |
| 920 | + } |
899 | 921 | } |
0 commit comments