@ -28,6 +28,7 @@ use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserSession;
use OCP\ServerVersion;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
use Test\TestCase;
@ -143,7 +144,7 @@ class AppManagerTest extends TestCase {
);
}
#[\PHPUnit\Framework\Attributes\ DataProvider('dataGetAppIcon')]
#[DataProvider('dataGetAppIcon')]
public function testGetAppIcon($callback, ?bool $dark, ?string $expected): void {
$this->urlGenerator->expects($this->atLeastOnce())
->method('imagePath')
@ -314,7 +315,7 @@ class AppManagerTest extends TestCase {
/**
* @param array $appInfo
*/
#[\PHPUnit\Framework\Attributes\ DataProvider('dataEnableAppForGroupsAllowedTypes')]
#[DataProvider('dataEnableAppForGroupsAllowedTypes')]
public function testEnableAppForGroupsAllowedTypes(array $appInfo): void {
$group1 = $this->createMock(IGroup::class);
$group1->method('getGID')
@ -375,7 +376,7 @@ class AppManagerTest extends TestCase {
* @param string $type
*
*/
#[\PHPUnit\Framework\Attributes\ DataProvider('dataEnableAppForGroupsForbiddenTypes')]
#[DataProvider('dataEnableAppForGroupsForbiddenTypes')]
public function testEnableAppForGroupsForbiddenTypes($type): void {
$this->expectException(\Exception::class);
$this->expectExceptionMessage('test can\'t be enabled for groups.');
@ -781,7 +782,7 @@ class AppManagerTest extends TestCase {
];
}
#[\PHPUnit\Framework\Attributes\ DataProvider('isBackendRequiredDataProvider')]
#[DataProvider('isBackendRequiredDataProvider')]
public function testIsBackendRequired(
string $backend,
array $appBackends,
@ -896,4 +897,25 @@ class AppManagerTest extends TestCase {
$manager->getAppVersion('unknown'),
);
}
public static function dataCleanAppId(): array {
return [
['simple', 'simple'],
['UPPERCASEa', 'a'],
['MixEdCaSe', 'ixdae'],
['007startwithdigit', 'startwithdigit'],
['0-numb3rs-4ll0w3d-1n-m1ddle-0', 'numb3rs-4ll0w3d-1n-m1ddle-0'],
['hyphen-and_underscore_allowed', 'hyphen-and_underscore_allowed'],
['_but-not-at-the-end_', 'but-not-at-the-end'],
['-but-not-at-the-end-', 'but-not-at-the-end'],
['--_but-not-at-the-end___', 'but-not-at-the-end'],
[' also remove all spaces', 'alsoremoveallspaces'],
['a«"«»()@+-/*=%\{}…~|& œ—< >[]^±_− ÷× ≠‰A', 'a-_'],
];
}
#[DataProvider('dataCleanAppId')]
public function testCleanAppId(string $inputString, string $appid): void {
$this->assertEquals($appid, $this->manager->cleanAppId($inputString));
}
}