Browse Source

test: Fix non-static data providers

Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/52851/head
Joas Schilling 6 months ago
parent
commit
3e7db013c1
No known key found for this signature in database GPG Key ID: F72FA5B49FFA96B0
  1. 23
      tests/lib/Accounts/AccountManagerTest.php
  2. 2
      tests/lib/Accounts/AccountPropertyTest.php
  3. 12
      tests/lib/Accounts/HooksTest.php
  4. 6
      tests/lib/Activity/ManagerTest.php
  5. 2
      tests/lib/AllConfigTest.php
  6. 28
      tests/lib/AppConfigTest.php
  7. 6
      tests/lib/AppTest.php
  8. 2
      tests/lib/Avatar/AvatarManagerTest.php
  9. 2
      tests/lib/Avatar/UserAvatarTest.php
  10. 2
      tests/lib/BackgroundJob/JobListTest.php
  11. 4
      tests/lib/Collaboration/Collaborators/MailPluginTest.php
  12. 6
      tests/lib/Collaboration/Collaborators/RemotePluginTest.php
  13. 4
      tests/lib/Collaboration/Collaborators/SearchResultTest.php
  14. 2
      tests/lib/Collaboration/Collaborators/SearchTest.php
  15. 6
      tests/lib/Collaboration/Collaborators/UserPluginTest.php
  16. 6
      tests/lib/Comments/CommentTest.php
  17. 2
      tests/lib/ContactsManagerTest.php
  18. 2
      tests/lib/DB/ConnectionFactoryTest.php
  19. 2
      tests/lib/DB/Exception/DbalExceptionTest.php
  20. 2
      tests/lib/DB/MigrationsTest.php
  21. 2
      tests/lib/DB/MigratorTest.php
  22. 56
      tests/lib/DateTimeFormatterTest.php
  23. 7
      tests/lib/EmojiHelperTest.php
  24. 12
      tests/lib/ErrorHandlerTest.php
  25. 8
      tests/lib/Federation/CloudIdManagerTest.php
  26. 2
      tests/lib/Federation/CloudIdTest.php
  27. 8
      tests/lib/Files/FilenameValidatorTest.php
  28. 8
      tests/lib/Files/FilesystemTest.php
  29. 8
      tests/lib/Files/PathVerificationTest.php
  30. 5
      tests/lib/Files/Utils/ScannerTest.php
  31. 8
      tests/lib/ImageTest.php
  32. 2
      tests/lib/InfoXmlTest.php
  33. 2
      tests/lib/InitialStateServiceTest.php
  34. 2
      tests/lib/InstallerTest.php
  35. 13
      tests/lib/L10N/L10nTest.php
  36. 2
      tests/lib/L10N/LanguageIteratorTest.php
  37. 2
      tests/lib/LargeFileHelperGetFileSizeTest.php
  38. 4
      tests/lib/Log/PsrLoggerAdapterTest.php
  39. 4
      tests/lib/LoggerTest.php
  40. 4
      tests/lib/Memcache/FactoryTest.php
  41. 4
      tests/lib/NaturalSortTest.php
  42. 12
      tests/lib/NavigationManagerTest.php
  43. 4
      tests/lib/Net/HostnameClassifierTest.php
  44. 4
      tests/lib/Net/IpAddressClassifierTest.php
  45. 5
      tests/lib/OCS/ApiHelperTest.php
  46. 4
      tests/lib/OCS/DiscoveryServiceTest.php
  47. 2
      tests/lib/Preview/GeneratorTest.php
  48. 2
      tests/lib/Preview/SVGTest.php
  49. 2
      tests/lib/Repair/ClearGeneratedAvatarCacheTest.php
  50. 2
      tests/lib/Repair/RepairInvalidSharesTest.php
  51. 4
      tests/lib/RichObjectStrings/DefinitionsTest.php
  52. 2
      tests/lib/ServerTest.php
  53. 4
      tests/lib/Share/HelperTest.php
  54. 4
      tests/lib/Share/ShareTest.php
  55. 2
      tests/lib/Support/Subscription/RegistryTest.php
  56. 16
      tests/lib/SystemTag/SystemTagManagerTest.php
  57. 14
      tests/lib/UrlGeneratorTest.php

23
tests/lib/Accounts/AccountManagerTest.php

@ -499,7 +499,7 @@ class AccountManagerTest extends TestCase {
$this->invokePrivate($accountManager, 'updateUser', [$user, $newData, $oldData]);
}
public function dataTrueFalse(): array {
public static function dataTrueFalse(): array {
return [
#$newData | $oldData | $insertNew | $updateExisting
[['myProperty' => ['value' => 'newData']], ['myProperty' => ['value' => 'oldData']], false, true],
@ -896,7 +896,7 @@ class AccountManagerTest extends TestCase {
}
}
public function searchDataProvider(): array {
public static function searchDataProvider(): array {
return [
[ #0 Search for an existing name
IAccountManager::PROPERTY_DISPLAYNAME,
@ -948,21 +948,22 @@ class AccountManagerTest extends TestCase {
];
}
public function dataCheckEmailVerification(): array {
public static function dataCheckEmailVerification(): array {
return [
[$this->makeUser('steve', 'Steve Smith', 'steve@steve.steve'), null],
[$this->makeUser('emma', 'Emma Morales', 'emma@emma.com'), 'emma@morales.com'],
[$this->makeUser('sarah@web.org', 'Sarah Foster', 'sarah@web.org'), null],
[$this->makeUser('cole@web.org', 'Cole Harrison', 'cole@web.org'), 'cole@example.com'],
[$this->makeUser('8d29e358-cf69-4849-bbf9-28076c0b908b', 'Alice McPherson', 'alice@example.com'), 'alice@mcpherson.com'],
[$this->makeUser('11da2744-3f4d-4c17-8c13-4c057a379237', 'James Loranger', 'james@example.com'), ''],
[['steve', 'Steve Smith', 'steve@steve.steve'], null],
[['emma', 'Emma Morales', 'emma@emma.com'], 'emma@morales.com'],
[['sarah@web.org', 'Sarah Foster', 'sarah@web.org'], null],
[['cole@web.org', 'Cole Harrison', 'cole@web.org'], 'cole@example.com'],
[['8d29e358-cf69-4849-bbf9-28076c0b908b', 'Alice McPherson', 'alice@example.com'], 'alice@mcpherson.com'],
[['11da2744-3f4d-4c17-8c13-4c057a379237', 'James Loranger', 'james@example.com'], ''],
];
}
/**
* @dataProvider dataCheckEmailVerification
*/
public function testCheckEmailVerification(IUser $user, ?string $newEmail): void {
public function testCheckEmailVerification(array $userData, ?string $newEmail): void {
$user = $this->makeUser(...$userData);
// Once because of getAccount, once because of getUser
$this->config->expects($this->exactly(2))->method('getSystemValue')->with('account_manager.default_property_scope', [])->willReturn([]);
$account = $this->accountManager->getAccount($user);
@ -988,7 +989,7 @@ class AccountManagerTest extends TestCase {
$this->invokePrivate($this->accountManager, 'checkEmailVerification', [$account, $oldData]);
}
public function dataSetDefaultPropertyScopes(): array {
public static function dataSetDefaultPropertyScopes(): array {
return [
[
[],

2
tests/lib/Accounts/AccountPropertyTest.php

@ -56,7 +56,7 @@ class AccountPropertyTest extends TestCase {
$this->assertEquals(IAccountManager::SCOPE_LOCAL, $actualReturn->getScope());
}
public function scopesProvider() {
public static function scopesProvider(): array {
return [
// current values
[IAccountManager::SCOPE_PRIVATE, IAccountManager::SCOPE_PRIVATE],

12
tests/lib/Accounts/HooksTest.php

@ -96,14 +96,14 @@ class HooksTest extends TestCase {
}
}
$params['user'] = $this->createMock(IUser::class);
$this->hooks->changeUserHook($params['user'], $params['feature'], $params['value']);
}
public function dataTestChangeUserHook() {
$user = $this->createMock(IUser::class);
public static function dataTestChangeUserHook(): array {
return [
[
['user' => $user, 'feature' => '', 'value' => ''],
['feature' => '', 'value' => ''],
[
IAccountManager::PROPERTY_EMAIL => ['value' => ''],
IAccountManager::PROPERTY_DISPLAYNAME => ['value' => '']
@ -111,7 +111,7 @@ class HooksTest extends TestCase {
false, false, true
],
[
['user' => $user, 'feature' => 'foo', 'value' => 'bar'],
['feature' => 'foo', 'value' => 'bar'],
[
IAccountManager::PROPERTY_EMAIL => ['value' => 'oldMail@example.com'],
IAccountManager::PROPERTY_DISPLAYNAME => ['value' => 'oldDisplayName']
@ -119,7 +119,7 @@ class HooksTest extends TestCase {
false, false, false
],
[
['user' => $user, 'feature' => 'eMailAddress', 'value' => 'newMail@example.com'],
['feature' => 'eMailAddress', 'value' => 'newMail@example.com'],
[
IAccountManager::PROPERTY_EMAIL => ['value' => 'oldMail@example.com'],
IAccountManager::PROPERTY_DISPLAYNAME => ['value' => 'oldDisplayName']
@ -127,7 +127,7 @@ class HooksTest extends TestCase {
true, false, false
],
[
['user' => $user, 'feature' => 'displayName', 'value' => 'newDisplayName'],
['feature' => 'displayName', 'value' => 'newDisplayName'],
[
IAccountManager::PROPERTY_EMAIL => ['value' => 'oldMail@example.com'],
IAccountManager::PROPERTY_DISPLAYNAME => ['value' => 'oldDisplayName']

6
tests/lib/Activity/ManagerTest.php

@ -74,7 +74,7 @@ class ManagerTest extends TestCase {
self::invokePrivate($this->activityManager, 'getConsumers');
}
public function getUserFromTokenThrowInvalidTokenData() {
public static function getUserFromTokenThrowInvalidTokenData(): array {
return [
[null, []],
['', []],
@ -98,7 +98,7 @@ class ManagerTest extends TestCase {
self::invokePrivate($this->activityManager, 'getUserFromToken');
}
public function getUserFromTokenData() {
public static function getUserFromTokenData(): array {
return [
[null, '123456789012345678901234567890', 'user1'],
['user2', null, 'user2'],
@ -190,7 +190,7 @@ class ManagerTest extends TestCase {
$this->activityManager->publish($event);
}
public function dataPublish() {
public static function dataPublish(): array {
return [
[null, ''],
['test_author', 'test_author'],

2
tests/lib/AllConfigTest.php

@ -125,7 +125,7 @@ class AllConfigTest extends \Test\TestCase {
$config->deleteUserValue('userPreCond', 'appPreCond', 'keyPreCond');
}
public function dataSetUserValueUnexpectedValue() {
public static function dataSetUserValueUnexpectedValue(): array {
return [
[true],
[false],

28
tests/lib/AppConfigTest.php

@ -32,10 +32,10 @@ class AppConfigTest extends TestCase {
private array $originalConfig;
/**
* @var array<string, array<array<string, string, int, bool, bool>>>
* @var array<string, array<string, array<string, string, int, bool, bool>>>
* [appId => [configKey, configValue, valueType, lazy, sensitive]]
*/
private array $baseStruct =
private static array $baseStruct =
[
'testapp' => [
'enabled' => ['enabled', 'true'],
@ -114,14 +114,14 @@ class AppConfigTest extends TestCase {
]
);
foreach ($this->baseStruct as $appId => $appData) {
foreach (self::$baseStruct as $appId => $appData) {
foreach ($appData as $key => $row) {
$value = $row[1];
$type = $row[2] ?? IAppConfig::VALUE_MIXED;
if (($row[4] ?? false) === true) {
$type |= IAppConfig::VALUE_SENSITIVE;
$value = self::invokePrivate(AppConfig::class, 'ENCRYPTION_PREFIX') . $this->crypto->encrypt($value);
$this->baseStruct[$appId][$key]['encrypted'] = $value;
self::$baseStruct[$appId][$key]['encrypted'] = $value;
}
$sql->setParameters(
@ -197,7 +197,7 @@ class AppConfigTest extends TestCase {
$this->assertSame(true, $status['fastLoaded'], $msg);
$this->assertSame(false, $status['lazyLoaded'], $msg);
$apps = array_values(array_diff(array_keys($this->baseStruct), ['only-lazy']));
$apps = array_values(array_diff(array_keys(self::$baseStruct), ['only-lazy']));
$this->assertEqualsCanonicalizing($apps, array_keys($status['fastCache']), $msg);
$this->assertSame([], array_keys($status['lazyCache']), $msg);
}
@ -208,7 +208,7 @@ class AppConfigTest extends TestCase {
public function testGetApps(): void {
$config = $this->generateAppConfig(false);
$this->assertEqualsCanonicalizing(array_keys($this->baseStruct), $config->getApps());
$this->assertEqualsCanonicalizing(array_keys(self::$baseStruct), $config->getApps());
}
/**
@ -217,9 +217,9 @@ class AppConfigTest extends TestCase {
* @return array<string, string[]> ['appId' => ['key1', 'key2', ]]
* @see testGetKeys
*/
public function providerGetAppKeys(): array {
public static function providerGetAppKeys(): array {
$appKeys = [];
foreach ($this->baseStruct as $appId => $appData) {
foreach (self::$baseStruct as $appId => $appData) {
$keys = [];
foreach ($appData as $row) {
$keys[] = $row[0];
@ -238,9 +238,9 @@ class AppConfigTest extends TestCase {
* @see testIsLazy
* @see testGetKeys
*/
public function providerGetKeys(): array {
public static function providerGetKeys(): array {
$appKeys = [];
foreach ($this->baseStruct as $appId => $appData) {
foreach (self::$baseStruct as $appId => $appData) {
foreach ($appData as $row) {
$appKeys[] = [
(string)$appId, $row[0], $row[1], $row[2] ?? IAppConfig::VALUE_MIXED, $row[3] ?? false,
@ -283,7 +283,7 @@ class AppConfigTest extends TestCase {
public function testHasKeyOnNonExistentKeyReturnsFalse(): void {
$config = $this->generateAppConfig();
$this->assertEquals(false, $config->hasKey(array_keys($this->baseStruct)[0], 'inexistant-key'));
$this->assertEquals(false, $config->hasKey(array_keys(self::$baseStruct)[0], 'inexistant-key'));
}
public function testHasKeyOnUnknownAppReturnsFalse(): void {
@ -319,7 +319,7 @@ class AppConfigTest extends TestCase {
public function testIsSensitiveOnNonExistentKeyThrowsException(): void {
$config = $this->generateAppConfig();
$this->expectException(AppConfigUnknownKeyException::class);
$config->isSensitive(array_keys($this->baseStruct)[0], 'inexistant-key');
$config->isSensitive(array_keys(self::$baseStruct)[0], 'inexistant-key');
}
public function testIsSensitiveOnUnknownAppThrowsException(): void {
@ -362,7 +362,7 @@ class AppConfigTest extends TestCase {
public function testIsLazyOnNonExistentKeyThrowsException(): void {
$config = $this->generateAppConfig();
$this->expectException(AppConfigUnknownKeyException::class);
$config->isLazy(array_keys($this->baseStruct)[0], 'inexistant-key');
$config->isLazy(array_keys(self::$baseStruct)[0], 'inexistant-key');
}
public function testIsLazyOnUnknownAppThrowsException(): void {
@ -530,7 +530,7 @@ class AppConfigTest extends TestCase {
*
* @see testGetValueMixed
*/
public function providerGetValueMixed(): array {
public static function providerGetValueMixed(): array {
return [
// key, value, type
['mixed', 'mix', IAppConfig::VALUE_MIXED],

6
tests/lib/AppTest.php

@ -34,7 +34,7 @@ class AppTest extends \Test\TestCase {
public const TEST_GROUP1 = 'group1';
public const TEST_GROUP2 = 'group2';
public function appVersionsProvider() {
public static function appVersionsProvider(): array {
return [
// exact match
[
@ -335,7 +335,7 @@ class AppTest extends \Test\TestCase {
/**
* Providers for the app config values
*/
public function appConfigValuesProvider() {
public static function appConfigValuesProvider(): array {
return [
// logged in user1
[
@ -591,7 +591,7 @@ class AppTest extends \Test\TestCase {
/**
* Providers for the app data values
*/
public function appDataProvider() {
public static function appDataProvider(): array {
return [
[
['description' => " \t This is a multiline \n test with \n \t \n \n some new lines "],

2
tests/lib/Avatar/AvatarManagerTest.php

@ -186,7 +186,7 @@ class AvatarManagerTest extends \Test\TestCase {
$this->assertEquals($expected, $this->avatarManager->getAvatar('vaLid-USER'));
}
public function dataGetAvatarScopes() {
public static function dataGetAvatarScopes(): array {
return [
// public access cannot see real avatar
[IAccountManager::SCOPE_PRIVATE, true, false, true],

2
tests/lib/Avatar/UserAvatarTest.php

@ -41,7 +41,7 @@ class UserAvatarTest extends \Test\TestCase {
$this->avatar = $this->getUserAvatar($this->user);
}
public function avatarTextData() {
public static function avatarTextData(): array {
return [
['', '?'],
['matchish', 'M'],

2
tests/lib/BackgroundJob/JobListTest.php

@ -73,7 +73,7 @@ class JobListTest extends TestCase {
return $jobs;
}
public function argumentProvider() {
public static function argumentProvider(): array {
return [
[null],
[false],

4
tests/lib/Collaboration/Collaborators/MailPluginTest.php

@ -134,7 +134,7 @@ class MailPluginTest extends TestCase {
$this->assertSame($reachedEnd, $moreResults);
}
public function dataGetEmail() {
public static function dataGetEmail(): array {
return [
// data set 0
['test', [], true, ['emails' => [], 'exact' => ['emails' => []]], false, false, false],
@ -636,7 +636,7 @@ class MailPluginTest extends TestCase {
$this->assertSame($reachedEnd, $moreResults);
}
public function dataGetEmailGroupsOnly() {
public static function dataGetEmailGroupsOnly(): array {
return [
// The user `User` can share with the current user
[

6
tests/lib/Collaboration/Collaborators/RemotePluginTest.php

@ -141,7 +141,7 @@ class RemotePluginTest extends TestCase {
$this->plugin->splitUserRemote($id);
}
public function dataGetRemote() {
public static function dataGetRemote() {
return [
['test', [], true, ['remotes' => [], 'exact' => ['remotes' => []]], false, true],
['test', [], false, ['remotes' => [], 'exact' => ['remotes' => []]], false, true],
@ -374,7 +374,7 @@ class RemotePluginTest extends TestCase {
];
}
public function dataTestSplitUserRemote() {
public static function dataTestSplitUserRemote(): array {
$userPrefix = ['user@name', 'username'];
$protocols = ['', 'http://', 'https://'];
$remotes = [
@ -410,7 +410,7 @@ class RemotePluginTest extends TestCase {
return $testCases;
}
public function dataTestSplitUserRemoteError() {
public static function dataTestSplitUserRemoteError(): array {
return [
// Invalid path
['user@'],

4
tests/lib/Collaboration/Collaborators/SearchResultTest.php

@ -27,7 +27,7 @@ class SearchResultTest extends TestCase {
$this->search = new Search($this->container);
}
public function dataAddResultSet() {
public static function dataAddResultSet(): array {
return [
[[], ['exact' => []]],
[['users' => ['exact' => null, 'loose' => []]], ['exact' => ['users' => []], 'users' => []]],
@ -51,7 +51,7 @@ class SearchResultTest extends TestCase {
$this->assertEquals($expected, $result->asArray());
}
public function dataHasResult() {
public static function dataHasResult(): array {
$result = ['value' => ['shareWith' => 'l1']];
return [
[[],'users', 'n1', false],

2
tests/lib/Collaboration/Collaborators/SearchTest.php

@ -115,7 +115,7 @@ class SearchTest extends TestCase {
$this->assertSame($expectedMoreResults, $moreResults);
}
public function dataSearchSharees() {
public static function dataSearchSharees(): array {
return [
// #0
[

6
tests/lib/Collaboration/Collaborators/UserPluginTest.php

@ -124,7 +124,7 @@ class UserPluginTest extends TestCase {
return $group;
}
public function dataGetUsers() {
public function dataGetUsers(): array {
return [
['test', false, true, [], [], [], [], true, false],
['test', false, false, [], [], [], [], true, false],
@ -508,7 +508,7 @@ class UserPluginTest extends TestCase {
$this->assertSame($reachedEnd, $moreResults);
}
public function takeOutCurrentUserProvider() {
public static function takeOutCurrentUserProvider(): array {
$inputUsers = [
'alice' => 'Alice',
'bob' => 'Bob',
@ -555,7 +555,7 @@ class UserPluginTest extends TestCase {
$this->assertSame($expectedUIDs, array_keys($users));
}
public function dataSearchEnumeration() {
public static function dataSearchEnumeration(): array {
return [
[
'test',

6
tests/lib/Comments/CommentTest.php

@ -81,7 +81,7 @@ class CommentTest extends TestCase {
$this->assertSame('', $comment->getId());
}
public function simpleSetterProvider() {
public static function simpleSetterProvider(): array {
return [
['Id', true],
['TopmostParentId', true],
@ -105,7 +105,7 @@ class CommentTest extends TestCase {
$comment->$setter($input);
}
public function roleSetterProvider() {
public static function roleSetterProvider(): array {
return [
['Actor', true, true],
['Actor', 'users', true],
@ -138,7 +138,7 @@ class CommentTest extends TestCase {
$comment->setMessage($msg);
}
public function mentionsProvider(): array {
public static function mentionsProvider(): array {
return [
[
'@alice @bob look look, a cook!',

2
tests/lib/ContactsManagerTest.php

@ -17,7 +17,7 @@ class ContactsManagerTest extends \Test\TestCase {
$this->cm = new \OC\ContactsManager();
}
public function searchProvider() {
public static function searchProvider(): array {
$search1 = [
0 => [
'N' => [0 => '', 1 => 'Jan', 2 => 'Jansen', 3 => '', 4 => '',],

2
tests/lib/DB/ConnectionFactoryTest.php

@ -12,7 +12,7 @@ use OCP\ICacheFactory;
use Test\TestCase;
class ConnectionFactoryTest extends TestCase {
public function splitHostFromPortAndSocketData() {
public static function splitHostFromPortAndSocketData(): array {
return [
['127.0.0.1', ['host' => '127.0.0.1']],
['db.example.org', ['host' => 'db.example.org']],

2
tests/lib/DB/Exception/DbalExceptionTest.php

@ -44,7 +44,7 @@ class DbalExceptionTest extends \Test\TestCase {
$this->assertSame($reason, $result->getReason());
}
public function dataDriverException(): array {
public static function dataDriverException(): array {
return [
[LockWaitTimeoutException::class, DbalException::REASON_LOCK_WAIT_TIMEOUT],
[ForeignKeyConstraintViolationException::class, DbalException::REASON_FOREIGN_KEY_VIOLATION],

2
tests/lib/DB/MigrationsTest.php

@ -175,7 +175,7 @@ class MigrationsTest extends \Test\TestCase {
$this->migrationService->executeStep('20170130180000');
}
public function dataGetMigration() {
public static function dataGetMigration(): array {
return [
['current', '20170130180001'],
['prev', '20170130180000'],

2
tests/lib/DB/MigratorTest.php

@ -261,7 +261,7 @@ class MigratorTest extends \Test\TestCase {
$this->assertTrue($startSchema->getTable($this->tableNameTmp)->hasForeignKey($fkName));
}
public function dataNotNullEmptyValuesFailOracle(): array {
public static function dataNotNullEmptyValuesFailOracle(): array {
return [
[ParameterType::BOOLEAN, true, Types::BOOLEAN, false],
[ParameterType::BOOLEAN, false, Types::BOOLEAN, true],

56
tests/lib/DateTimeFormatterTest.php

@ -36,23 +36,23 @@ class DateTimeFormatterTest extends TestCase {
$this->formatter = new \OC\DateTimeFormatter(new \DateTimeZone('UTC'), \OCP\Util::getL10N('lib', 'en'));
}
protected function getTimestampAgo($time, $seconds = 0, $minutes = 0, $hours = 0, $days = 0, $years = 0) {
protected static function getTimestampAgo($time, $seconds = 0, $minutes = 0, $hours = 0, $days = 0, $years = 0) {
return $time - $seconds - $minutes * 60 - $hours * 3600 - $days * 24 * 3600 - $years * 365 * 24 * 3600;
}
public function formatTimeSpanData() {
public static function formatTimeSpanData(): array {
$time = 1416916800; // Use a fixed timestamp so we don't switch days/years with the getTimestampAgo
$deL10N = \OCP\Util::getL10N('lib', 'de');
return [
['seconds ago', $time, $time],
['in a few seconds', $time + 5 , $time],
['1 minute ago', $this->getTimestampAgo($time, 30, 1), $time],
['15 minutes ago', $this->getTimestampAgo($time, 30, 15), $time],
['in 15 minutes', $time, $this->getTimestampAgo($time, 30, 15)],
['1 hour ago', $this->getTimestampAgo($time, 30, 15, 1), $time],
['3 hours ago', $this->getTimestampAgo($time, 30, 15, 3), $time],
['in 3 hours', $time, $this->getTimestampAgo($time, 30, 15, 3)],
['4 days ago', $this->getTimestampAgo($time, 30, 15, 3, 4), $time],
['1 minute ago', self::getTimestampAgo($time, 30, 1), $time],
['15 minutes ago', self::getTimestampAgo($time, 30, 15), $time],
['in 15 minutes', $time, self::getTimestampAgo($time, 30, 15)],
['1 hour ago', self::getTimestampAgo($time, 30, 15, 1), $time],
['3 hours ago', self::getTimestampAgo($time, 30, 15, 3), $time],
['in 3 hours', $time, self::getTimestampAgo($time, 30, 15, 3)],
['4 days ago', self::getTimestampAgo($time, 30, 15, 3, 4), $time],
['seconds ago', new \DateTime('Wed, 02 Oct 2013 23:59:58 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')],
['seconds ago', new \DateTime('Wed, 02 Oct 2013 23:59:00 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')],
@ -81,29 +81,29 @@ class DateTimeFormatterTest extends TestCase {
$this->assertEquals((string)$expected, (string)$this->formatter->formatTimeSpan($timestamp, $compare, $locale));
}
public function formatDateSpanData() {
public static function formatDateSpanData(): array{
$time = 1416916800; // Use a fixed timestamp so we don't switch days/years with the getTimestampAgo
$deL10N = \OCP\Util::getL10N('lib', 'de');
return [
// Normal testing
['today', $this->getTimestampAgo($time, 30, 15), $time],
['yesterday', $this->getTimestampAgo($time, 0, 0, 0, 1), $time],
['tomorrow', $time, $this->getTimestampAgo($time, 0, 0, 0, 1)],
['4 days ago', $this->getTimestampAgo($time, 0, 0, 0, 4), $time],
['in 4 days', $time, $this->getTimestampAgo($time, 0, 0, 0, 4)],
['5 months ago', $this->getTimestampAgo($time, 0, 0, 0, 155), $time],
['next month', $time, $this->getTimestampAgo($time, 0, 0, 0, 32)],
['in 5 months', $time, $this->getTimestampAgo($time, 0, 0, 0, 155)],
['2 years ago', $this->getTimestampAgo($time, 0, 0, 0, 0, 2), $time],
['next year', $time, $this->getTimestampAgo($time, 0, 0, 0, 0, 1)],
['in 2 years', $time, $this->getTimestampAgo($time, 0, 0, 0, 0, 2)],
['today', self::getTimestampAgo($time, 30, 15), $time],
['yesterday', self::getTimestampAgo($time, 0, 0, 0, 1), $time],
['tomorrow', $time, self::getTimestampAgo($time, 0, 0, 0, 1)],
['4 days ago', self::getTimestampAgo($time, 0, 0, 0, 4), $time],
['in 4 days', $time, self::getTimestampAgo($time, 0, 0, 0, 4)],
['5 months ago', self::getTimestampAgo($time, 0, 0, 0, 155), $time],
['next month', $time, self::getTimestampAgo($time, 0, 0, 0, 32)],
['in 5 months', $time, self::getTimestampAgo($time, 0, 0, 0, 155)],
['2 years ago', self::getTimestampAgo($time, 0, 0, 0, 0, 2), $time],
['next year', $time, self::getTimestampAgo($time, 0, 0, 0, 0, 1)],
['in 2 years', $time, self::getTimestampAgo($time, 0, 0, 0, 0, 2)],
// Test with compare timestamp
['today', $this->getTimestampAgo($time, 0, 0, 0, 0, 1), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)],
['yesterday', $this->getTimestampAgo($time, 30, 15, 3, 1, 1), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)],
['4 days ago', $this->getTimestampAgo($time, 30, 15, 3, 4, 1), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)],
['5 months ago', $this->getTimestampAgo($time, 30, 15, 3, 155, 1), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)],
['2 years ago', $this->getTimestampAgo($time, 30, 15, 3, 35, 3), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)],
['today', self::getTimestampAgo($time, 0, 0, 0, 0, 1), self::getTimestampAgo($time, 0, 0, 0, 0, 1)],
['yesterday', self::getTimestampAgo($time, 30, 15, 3, 1, 1), self::getTimestampAgo($time, 0, 0, 0, 0, 1)],
['4 days ago', self::getTimestampAgo($time, 30, 15, 3, 4, 1), self::getTimestampAgo($time, 0, 0, 0, 0, 1)],
['5 months ago', self::getTimestampAgo($time, 30, 15, 3, 155, 1), self::getTimestampAgo($time, 0, 0, 0, 0, 1)],
['2 years ago', self::getTimestampAgo($time, 30, 15, 3, 35, 3), self::getTimestampAgo($time, 0, 0, 0, 0, 1)],
// Test translations
[$deL10N->t('today'), new \DateTime('Wed, 02 Oct 2013 12:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000'), $deL10N],
@ -147,7 +147,7 @@ class DateTimeFormatterTest extends TestCase {
$this->assertEquals((string)$expected, (string)$this->formatter->formatDateSpan($timestamp, $compare, $locale));
}
public function formatDateData() {
public static function formatDateData(): array {
return [
[1102831200, 'December 12, 2004'],
];
@ -160,7 +160,7 @@ class DateTimeFormatterTest extends TestCase {
$this->assertEquals($expected, (string)$this->formatter->formatDate($timestamp));
}
public function formatDateTimeData() {
public static function formatDateTimeData(): array {
return [
[1350129205, null, "October 13, 2012, 11:53:25\xE2\x80\xAFAM UTC"],
[1350129205, new \DateTimeZone('Europe/Berlin'), "October 13, 2012, 1:53:25\xE2\x80\xAFPM GMT+2"],

7
tests/lib/EmojiHelperTest.php

@ -38,10 +38,7 @@ class EmojiHelperTest extends TestCase {
$this->assertEquals($expected, $this->helper->doesPlatformSupportEmoji());
}
/**
* @return array
*/
public function doesPlatformSupportEmojiDataProvider(): array {
public static function doesPlatformSupportEmojiDataProvider(): array {
return [
[true, true],
[false, false],
@ -60,7 +57,7 @@ class EmojiHelperTest extends TestCase {
$this->assertEquals($expected, $actual);
}
public function isValidSingleEmojiDataProvider(): array {
public static function isValidSingleEmojiDataProvider(): array {
return [
['📱📠', false],
['a', false],

12
tests/lib/ErrorHandlerTest.php

@ -16,10 +16,9 @@ use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
class ErrorHandlerTest extends TestCase {
/** @var MockObject */
private LoggerInterface $logger;
private LoggerInterface&MockObject $logger;
private ErrorHandler $errorHandler;
private int $errorReporting;
protected function setUp(): void {
parent::setUp();
@ -28,6 +27,13 @@ class ErrorHandlerTest extends TestCase {
$this->errorHandler = new ErrorHandler(
$this->logger
);
$this->errorReporting = error_reporting(E_ALL);
}
protected function tearDown(): void {
error_reporting($this->errorReporting);
parent::tearDown();
}
/**

8
tests/lib/Federation/CloudIdManagerTest.php

@ -56,7 +56,7 @@ class CloudIdManagerTest extends TestCase {
$this->overwriteService(ICloudIdManager::class, $this->cloudIdManager);
}
public function dataGetDisplayNameFromContact(): array {
public static function dataGetDisplayNameFromContact(): array {
return [
['test1@example.tld', 'test', 'test'],
['test2@example.tld', null, null],
@ -84,7 +84,7 @@ class CloudIdManagerTest extends TestCase {
$this->assertEquals($expected, $this->cloudIdManager->getDisplayNameFromContact($cloudId));
}
public function cloudIdProvider(): array {
public static function cloudIdProvider(): array {
return [
['test@example.com', 'test', 'example.com', 'test@example.com'],
['test@example.com/cloud', 'test', 'example.com/cloud', 'test@example.com/cloud'],
@ -122,7 +122,7 @@ class CloudIdManagerTest extends TestCase {
$this->assertEquals($displayName . '@' . $noProtocolRemote, $cloudId->getDisplayId());
}
public function invalidCloudIdProvider(): array {
public static function invalidCloudIdProvider(): array {
return [
['example.com'],
['test:foo@example.com'],
@ -142,7 +142,7 @@ class CloudIdManagerTest extends TestCase {
$this->cloudIdManager->resolveCloudId($cloudId);
}
public function getCloudIdProvider(): array {
public static function getCloudIdProvider(): array {
return [
['test', 'example.com', 'test@example.com', null, 'https://example.com', 'https://example.com'],
['test', 'http://example.com', 'test@http://example.com', 'test@example.com'],

2
tests/lib/Federation/CloudIdTest.php

@ -28,7 +28,7 @@ class CloudIdTest extends TestCase {
$this->overwriteService(ICloudIdManager::class, $this->cloudIdManager);
}
public function dataGetDisplayCloudId(): array {
public static function dataGetDisplayCloudId(): array {
return [
['test@example.com', 'test', 'example.com', 'test@example.com'],
['test@http://example.com', 'test', 'http://example.com', 'test@example.com'],

8
tests/lib/Files/FilenameValidatorTest.php

@ -122,7 +122,7 @@ class FilenameValidatorTest extends TestCase {
$this->assertEquals($exception === null, $validator->isFilenameValid($filename));
}
public function dataValidateFilename(): array {
public static function dataValidateFilename(): array {
return [
'valid name' => [
'a: b.txt', ['.htaccess'], [], [], [], null
@ -202,7 +202,7 @@ class FilenameValidatorTest extends TestCase {
$validator->validateFilename($filename);
}
public function data4ByteUnicode(): array {
public static function data4ByteUnicode(): array {
return [
['plane 1 𐪅'],
['emoji 😶‍🌫️'],
@ -218,7 +218,7 @@ class FilenameValidatorTest extends TestCase {
$validator->validateFilename($filename);
}
public function dataInvalidAsciiCharacters(): array {
public static function dataInvalidAsciiCharacters(): array {
return [
[\chr(0)],
[\chr(1)],
@ -271,7 +271,7 @@ class FilenameValidatorTest extends TestCase {
$this->assertEquals($expected, $validator->isForbidden($filename));
}
public function dataIsForbidden(): array {
public static function dataIsForbidden(): array {
return [
'valid name' => [
'a: b.txt', ['.htaccess'], false

8
tests/lib/Files/FilesystemTest.php

@ -100,7 +100,7 @@ class FilesystemTest extends \Test\TestCase {
$this->assertEquals('folder', $internalPath);
}
public function normalizePathData() {
public static function normalizePathData(): array {
return [
['/', ''],
['/', '/'],
@ -201,7 +201,7 @@ class FilesystemTest extends \Test\TestCase {
$this->assertEquals($expected, \OC\Files\Filesystem::normalizePath($path, $stripTrailingSlash));
}
public function normalizePathKeepUnicodeData() {
public static function normalizePathKeepUnicodeData(): array {
$nfdName = 'ümlaut';
$nfcName = 'ümlaut';
return [
@ -227,7 +227,7 @@ class FilesystemTest extends \Test\TestCase {
$this->assertEquals('/' . $nfdName, \OC\Files\Filesystem::normalizePath($nfdName, true, false, true));
}
public function isValidPathData() {
public static function isValidPathData(): array {
return [
['/', true],
['/path', true],
@ -260,7 +260,7 @@ class FilesystemTest extends \Test\TestCase {
$this->assertSame($expected, \OC\Files\Filesystem::isValidPath($path));
}
public function isFileBlacklistedData() {
public static function isFileBlacklistedData(): array {
return [
['/etc/foo/bar/foo.txt', false],
['\etc\foo/bar\foo.txt', false],

8
tests/lib/Files/PathVerificationTest.php

@ -49,7 +49,7 @@ class PathVerificationTest extends \Test\TestCase {
$this->view->verifyPath('', $fileName);
}
public function providesEmptyFiles() {
public static function providesEmptyFiles(): array {
return [
[''],
[' '],
@ -66,7 +66,7 @@ class PathVerificationTest extends \Test\TestCase {
$this->view->verifyPath('', $fileName);
}
public function providesDotFiles() {
public static function providesDotFiles(): array {
return [
['.'],
['..'],
@ -95,7 +95,7 @@ class PathVerificationTest extends \Test\TestCase {
$this->view->verifyPath('', $fileName);
}
public function providesAstralPlane() {
public static function providesAstralPlane(): array {
return [
// this is the monkey emoji - http://en.wikipedia.org/w/index.php?title=%F0%9F%90%B5&redirect=no
['🐵'],
@ -117,7 +117,7 @@ class PathVerificationTest extends \Test\TestCase {
$this->addToAssertionCount(1);
}
public function providesValidPosixPaths() {
public static function providesValidPosixPaths(): array {
return [
['simple'],
['simple.txt'],

5
tests/lib/Files/Utils/ScannerTest.php

@ -138,10 +138,7 @@ class ScannerTest extends \Test\TestCase {
$this->assertTrue($cache->inCache('folder/bar.txt'));
}
/**
* @return array
*/
public function invalidPathProvider() {
public static function invalidPathProvider(): array {
return [
[
'../',

8
tests/lib/ImageTest.php

@ -271,7 +271,7 @@ class ImageTest extends \Test\TestCase {
$this->assertEquals(15, $img->height());
}
public static function sampleProvider() {
public static function sampleProvider(): array {
return [
['testimage.png', [200, 100], [100, 100]],
['testimage.jpg', [840, 840], [840, 525]],
@ -294,7 +294,7 @@ class ImageTest extends \Test\TestCase {
$this->assertEquals($expected[1], $img->height());
}
public static function sampleFilenamesProvider() {
public static function sampleFilenamesProvider(): array {
return [
['testimage.png'],
['testimage.jpg'],
@ -328,7 +328,7 @@ class ImageTest extends \Test\TestCase {
);
}
public static function largeSampleProvider() {
public static function largeSampleProvider(): array {
return [
['testimage.png', [200, 100], [100, 100]],
['testimage.jpg', [840, 840], [840, 525]],
@ -351,7 +351,7 @@ class ImageTest extends \Test\TestCase {
$this->assertEquals($expected[1], $img->height());
}
public function convertDataProvider() {
public static function convertDataProvider(): array {
return [
[ 'image/gif'],
[ 'image/jpeg'],

2
tests/lib/InfoXmlTest.php

@ -23,7 +23,7 @@ class InfoXmlTest extends TestCase {
$this->appManager = Server::get(IAppManager::class);
}
public function dataApps() {
public static function dataApps(): array {
return [
['admin_audit'],
['comments'],

2
tests/lib/InitialStateServiceTest.php

@ -36,7 +36,7 @@ class InitialStateServiceTest extends TestCase {
);
}
public function staticData(): array {
public static function staticData(): array {
return [
['string'],
[23],

2
tests/lib/InstallerTest.php

@ -111,7 +111,7 @@ class InstallerTest extends TestCase {
$installer->removeApp(self::$appid);
}
public function updateArrayProvider() {
public static function updateArrayProvider(): array {
return [
// Update available
[

13
tests/lib/L10N/L10nTest.php

@ -96,7 +96,7 @@ class L10nTest extends TestCase {
$this->assertEquals('5 Dateien', (string)$l->n('%n file', '%n files', 5));
}
public function dataPlaceholders(): array {
public static function dataPlaceholders(): array {
return [
['Ordered placeholders one %s two %s', 'Placeholder one 1 two 2'],
['Reordered placeholders one %s two %s', 'Placeholder two 2 one 1'],
@ -117,7 +117,7 @@ class L10nTest extends TestCase {
$this->assertEquals($expected, $l->t($string, ['1', '2']));
}
public function localizationData() {
public static function localizationData(): array {
return [
// timestamp as string
["February 13, 2009, 11:31:30\xE2\x80\xAFPM UTC", 'en', 'en_US', 'datetime', '1234567890'],
@ -161,7 +161,7 @@ class L10nTest extends TestCase {
$this->assertSame($expectedDate, $l->l($type, $value));
}
public function firstDayData() {
public static function firstDayData(): array {
return [
[1, 'de', 'de_DE'],
[0, 'en', 'en_US'],
@ -179,7 +179,7 @@ class L10nTest extends TestCase {
$this->assertSame($expected, $l->l('firstday', 'firstday'));
}
public function jsDateData() {
public static function jsDateData(): array {
return [
['dd.MM.yy', 'de', 'de_DE'],
['M/d/yy', 'en', 'en_US'],
@ -224,10 +224,7 @@ class L10nTest extends TestCase {
);
}
/**
* @return array
*/
public function findLanguageFromLocaleData(): array {
public static function findLanguageFromLocaleData(): array {
return [
'en_US' => ['en_US', 'en'],
'en_UK' => ['en_UK', 'en'],

2
tests/lib/L10N/LanguageIteratorTest.php

@ -28,7 +28,7 @@ class LanguageIteratorTest extends TestCase {
$this->iterator = new LanguageIterator($this->user, $this->config);
}
public function languageSettingsProvider() {
public static function languageSettingsProvider(): array {
return [
// all language settings set
[ 'de_DE', 'es_CU', 'zh_TW', ['de_DE', 'de', 'es_CU', 'es', 'zh_TW', 'zh', 'en']],

2
tests/lib/LargeFileHelperGetFileSizeTest.php

@ -26,7 +26,7 @@ class LargeFileHelperGetFileSizeTest extends TestCase {
$this->helper = new \OC\LargeFileHelper();
}
public function dataFileNameProvider() {
public static function dataFileNameProvider(): array {
$path = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR;
return [

4
tests/lib/Log/PsrLoggerAdapterTest.php

@ -45,7 +45,7 @@ class PsrLoggerAdapterTest extends TestCase {
$this->assertEquals($expectedLevel, PsrLoggerAdapter::logLevelToInt($level));
}
public function dataPsrLoggingLevels(): array {
public static function dataPsrLoggingLevels(): array {
return [
[LogLevel::ALERT, ILogger::ERROR],
[LogLevel::CRITICAL, ILogger::ERROR],
@ -69,7 +69,7 @@ class PsrLoggerAdapterTest extends TestCase {
$this->loggerAdapter->log($level, 'valid message');
}
public function dataInvalidLoggingLevel(): array {
public static function dataInvalidLoggingLevel(): array {
return [
// invalid string
['this is not a level'],

4
tests/lib/LoggerTest.php

@ -72,7 +72,7 @@ class LoggerTest extends TestCase implements IWriter {
$this->assertEquals($expected, $this->getLogs());
}
public function dataMatchesCondition(): array {
public static function dataMatchesCondition(): array {
return [
[
'user0',
@ -181,7 +181,7 @@ class LoggerTest extends TestCase implements IWriter {
$this->logs[] = $level . ' ' . $textMessage;
}
public function userAndPasswordData(): array {
public static function userAndPasswordData(): array {
return [
['mySpecialUsername', 'MySuperSecretPassword'],
['my-user', '324324()#ä234'],

4
tests/lib/Memcache/FactoryTest.php

@ -56,7 +56,7 @@ class FactoryTest extends \Test\TestCase {
public const UNAVAILABLE1 = '\\Test\\Memcache\\Test_Factory_Unavailable_Cache1';
public const UNAVAILABLE2 = '\\Test\\Memcache\\Test_Factory_Unavailable_Cache2';
public function cacheAvailabilityProvider() {
public static function cacheAvailabilityProvider(): array {
return [
[
// local and distributed available
@ -86,7 +86,7 @@ class FactoryTest extends \Test\TestCase {
];
}
public function cacheUnavailableProvider() {
public static function cacheUnavailableProvider(): array {
return [
[
// local available, distributed unavailable

4
tests/lib/NaturalSortTest.php

@ -35,7 +35,7 @@ class NaturalSortTest extends \Test\TestCase {
* Must provide the same result as in core/js/tests/specs/coreSpec.js
* @return array test cases
*/
public function naturalSortDataProvider() {
public static function naturalSortDataProvider(): array {
return [
// different casing
[
@ -189,7 +189,7 @@ class NaturalSortTest extends \Test\TestCase {
* Must provide the same result as in core/js/tests/specs/coreSpec.js
* @return array test cases
*/
public function defaultCollatorDataProvider() {
public static function defaultCollatorDataProvider(): array {
return [
// different casing
[

12
tests/lib/NavigationManagerTest.php

@ -68,10 +68,10 @@ class NavigationManagerTest extends TestCase {
$this->navigationManager->clear(false);
}
public function addArrayData() {
public static function addArrayData(): array {
return [
[
'entry id' => [
'entry' => [
'id' => 'entry id',
'name' => 'link text',
'order' => 1,
@ -81,7 +81,7 @@ class NavigationManagerTest extends TestCase {
'classes' => '',
'unread' => 0
],
'entry id2' => [
'expectedEntry' => [
'id' => 'entry id',
'name' => 'link text',
'order' => 1,
@ -94,7 +94,7 @@ class NavigationManagerTest extends TestCase {
]
],
[
'entry id' => [
'entry' => [
'id' => 'entry id',
'name' => 'link text',
'order' => 1,
@ -103,7 +103,7 @@ class NavigationManagerTest extends TestCase {
'active' => true,
'unread' => 0,
],
'entry id2' => [
'expectedEntry' => [
'id' => 'entry id',
'name' => 'link text',
'order' => 1,
@ -272,7 +272,7 @@ class NavigationManagerTest extends TestCase {
$this->assertEquals($expected, $entries);
}
public function providesNavigationConfig() {
public static function providesNavigationConfig(): array {
$apps = [
'core_apps' => [
'id' => 'core_apps',

4
tests/lib/Net/HostnameClassifierTest.php

@ -21,7 +21,7 @@ class HostnameClassifierTest extends TestCase {
$this->classifier = new HostnameClassifier();
}
public function localHostnamesData():array {
public static function localHostnamesData(): array {
return [
['localhost'],
['localHost'],
@ -41,7 +41,7 @@ class HostnameClassifierTest extends TestCase {
self::assertTrue($isLocal);
}
public function publicHostnamesData(): array {
public static function publicHostnamesData(): array {
return [
['example.com'],
['example.net'],

4
tests/lib/Net/IpAddressClassifierTest.php

@ -21,7 +21,7 @@ class IpAddressClassifierTest extends TestCase {
$this->classifier = new IpAddressClassifier();
}
public function publicIpAddressData(): array {
public static function publicIpAddressData(): array {
return [
['8.8.8.8'],
['8.8.4.4'],
@ -39,7 +39,7 @@ class IpAddressClassifierTest extends TestCase {
self::assertFalse($isLocal);
}
public function localIpAddressData(): array {
public static function localIpAddressData(): array {
return [
['192.168.0.1'],
['fe80::200:5aee:feaa:20a2'],

5
tests/lib/OCS/ApiHelperTest.php

@ -14,10 +14,7 @@ use OC\OCS\ApiHelper;
use OCP\IRequest;
class ApiHelperTest extends \Test\TestCase {
/**
* @return array
*/
public function versionDataScriptNameProvider(): array {
public static function versionDataScriptNameProvider(): array {
return [
// Valid script name
[

4
tests/lib/OCS/DiscoveryServiceTest.php

@ -45,7 +45,7 @@ class DiscoveryServiceTest extends TestCase {
$this->assertSame($expected, $result);
}
public function dataTestIsSafeUrl() {
public static function dataTestIsSafeUrl(): array {
return [
['api/ocs/v1.php/foo', true],
['/api/ocs/v1.php/foo', true],
@ -69,7 +69,7 @@ class DiscoveryServiceTest extends TestCase {
$this->assertSame($expected, $result);
}
public function dataTestGetEndpoints() {
public static function dataTestGetEndpoints(): array {
return [
[['services' => ['myService' => ['endpoints' => []]]], 'myService', []],
[['services' => ['myService' => ['endpoints' => ['foo' => '/bar']]]], 'myService', ['foo' => '/bar']],

2
tests/lib/Preview/GeneratorTest.php

@ -343,7 +343,7 @@ class GeneratorTest extends \Test\TestCase {
return $image;
}
public function dataSize() {
public static function dataSize(): array {
return [
[1024, 2048, 512, 512, false, IPreview::MODE_FILL, 256, 512],
[1024, 2048, 512, 512, false, IPreview::MODE_COVER, 512, 1024],

2
tests/lib/Preview/SVGTest.php

@ -30,7 +30,7 @@ class SVGTest extends Provider {
}
}
public function dataGetThumbnailSVGHref(): array {
public static function dataGetThumbnailSVGHref(): array {
return [
['href'],
[' href'],

2
tests/lib/Repair/ClearGeneratedAvatarCacheTest.php

@ -30,7 +30,7 @@ class ClearGeneratedAvatarCacheTest extends \Test\TestCase {
$this->repair = new ClearGeneratedAvatarCache($this->config, $this->avatarManager, $this->jobList);
}
public function shouldRunDataProvider() {
public static function shouldRunDataProvider(): array {
return [
['11.0.0.0', true],
['15.0.0.3', true],

2
tests/lib/Repair/RepairInvalidSharesTest.php

@ -122,7 +122,7 @@ class RepairInvalidSharesTest extends TestCase {
$result->closeCursor();
}
public function fileSharePermissionsProvider() {
public static function fileSharePermissionsProvider(): array {
return [
// unchanged for folder
[

4
tests/lib/RichObjectStrings/DefinitionsTest.php

@ -10,7 +10,7 @@ use OCP\RichObjectStrings\Definitions;
use Test\TestCase;
class DefinitionsTest extends TestCase {
public function dataGetDefinition() {
public static function dataGetDefinition() {
$definitions = new Definitions();
$testsuite = [];
foreach ($definitions->definitions as $type => $definition) {
@ -19,7 +19,7 @@ class DefinitionsTest extends TestCase {
return $testsuite;
}
public function testGetDefinitionNotExisting(): void {
$this->expectException(\OCP\RichObjectStrings\InvalidObjectExeption::class);
$this->expectExceptionMessage('Object type is undefined');

2
tests/lib/ServerTest.php

@ -28,7 +28,7 @@ class ServerTest extends \Test\TestCase {
$this->server = new \OC\Server('', $config);
}
public function dataTestQuery() {
public static function dataTestQuery(): array {
return [
['\OCP\Activity\IManager', '\OC\Activity\Manager'],
['\OCP\IConfig', '\OC\AllConfig'],

4
tests/lib/Share/HelperTest.php

@ -12,7 +12,7 @@ namespace Test\Share;
* Class Helper
*/
class HelperTest extends \Test\TestCase {
public function expireDateProvider() {
public static function expireDateProvider(): array {
return [
// no default expire date, we take the users expire date
[['defaultExpireDateSet' => false], 2000000000, 2000010000, 2000010000],
@ -54,7 +54,7 @@ class HelperTest extends \Test\TestCase {
);
}
public function dataTestCompareServerAddresses() {
public static function dataTestCompareServerAddresses(): array {
return [
['user1', 'http://server1', 'user1', 'http://server1', true],
['user1', 'https://server1', 'user1', 'http://server1', true],

4
tests/lib/Share/ShareTest.php

@ -132,7 +132,7 @@ class ShareTest extends \Test\TestCase {
$this->assertSame($expectedResult, $result);
}
public function urls() {
public static function urls(): array {
return [
['http://owncloud.org', 'owncloud.org'],
['https://owncloud.org', 'owncloud.org'],
@ -161,7 +161,7 @@ class ShareTest extends \Test\TestCase {
}
}
public function dataProviderTestGroupItems() {
public static function dataProviderTestGroupItems(): array {
return [
// one array with one share
[

2
tests/lib/Support/Subscription/RegistryTest.php

@ -157,7 +157,7 @@ class RegistryTest extends TestCase {
$this->assertSame(false, $this->registry->delegateIsHardUserLimitReached($this->notificationManager));
}
public function dataForUserLimitCheck() {
public static function dataForUserLimitCheck(): array {
return [
// $userLimit, $userCount, $disabledUsers, $expectedResult
[35, 15, 2, false],

16
tests/lib/SystemTag/SystemTagManagerTest.php

@ -66,7 +66,7 @@ class SystemTagManagerTest extends TestCase {
$query->delete(SystemTagManager::TAG_TABLE)->execute();
}
public static function getAllTagsDataProvider() {
public static function getAllTagsDataProvider(): array {
return [
[
// no tags at all
@ -113,7 +113,7 @@ class SystemTagManagerTest extends TestCase {
}
}
public static function getAllTagsFilteredDataProvider() {
public static function getAllTagsFilteredDataProvider(): array {
return [
[
[
@ -226,7 +226,7 @@ class SystemTagManagerTest extends TestCase {
}
}
public static function oneTagMultipleFlagsProvider() {
public static function oneTagMultipleFlagsProvider(): array {
return [
['one', false, false],
['one', true, false],
@ -299,7 +299,7 @@ class SystemTagManagerTest extends TestCase {
$this->tagManager->getTagsByIds([$tag1->getId() . 'suffix']);
}
public static function updateTagProvider() {
public static function updateTagProvider(): array {
return [
[
// update name
@ -424,7 +424,7 @@ class SystemTagManagerTest extends TestCase {
], $tagIdMapping);
}
public static function visibilityCheckProvider() {
public static function visibilityCheckProvider(): array {
return [
[false, false, false, false],
[true, false, false, true],
@ -451,7 +451,7 @@ class SystemTagManagerTest extends TestCase {
$this->assertEquals($expectedResult, $this->tagManager->canUserSeeTag($tag1, $user));
}
public static function assignabilityCheckProvider() {
public static function assignabilityCheckProvider(): array {
return [
// no groups
[false, false, false, false],
@ -529,7 +529,7 @@ class SystemTagManagerTest extends TestCase {
$this->assertEquals([], $this->tagManager->getTagGroups($tag1));
}
private function allowedToCreateProvider(): array {
public static function allowedToCreateProvider(): array {
return [
[true, null, true],
[true, null, false],
@ -570,7 +570,7 @@ class SystemTagManagerTest extends TestCase {
\OC::$CLI = $oldCli;
}
private function disallowedToCreateProvider(): array {
public static function disallowedToCreateProvider(): array {
return [
[false],
[null],

14
tests/lib/UrlGeneratorTest.php

@ -107,14 +107,14 @@ class UrlGeneratorTest extends \Test\TestCase {
$this->assertEquals($expected, $result);
}
public static function provideRoutes() {
public static function provideRoutes(): array {
return [
['core.Preview.getPreview', 'http://localhost/nextcloud/index.php/core/preview.png'],
['cloud_federation_api.requesthandlercontroller.addShare', 'http://localhost/nextcloud/index.php/ocm/shares'],
];
}
public static function provideDocRootAppUrlParts() {
public static function provideDocRootAppUrlParts(): array {
return [
['files_external', 'ajax/oauth2.php', [], '/index.php/apps/files_external/ajax/oauth2.php'],
['files_external', 'ajax/oauth2.php', ['trut' => 'trat', 'dut' => 'dat'], '/index.php/apps/files_external/ajax/oauth2.php?trut=trat&dut=dat'],
@ -122,7 +122,7 @@ class UrlGeneratorTest extends \Test\TestCase {
];
}
public static function provideSubDirAppUrlParts() {
public static function provideSubDirAppUrlParts(): array {
return [
['files_external', 'ajax/oauth2.php', [], '/nextcloud/index.php/apps/files_external/ajax/oauth2.php'],
['files_external', 'ajax/oauth2.php', ['trut' => 'trat', 'dut' => 'dat'], '/nextcloud/index.php/apps/files_external/ajax/oauth2.php?trut=trat&dut=dat'],
@ -154,7 +154,7 @@ class UrlGeneratorTest extends \Test\TestCase {
$this->assertEquals($expectedResult, $result);
}
public function provideDocRootURLs() {
public static function provideDocRootURLs(): array {
return [
['index.php', 'http://localhost/index.php'],
['/index.php', 'http://localhost/index.php'],
@ -163,7 +163,7 @@ class UrlGeneratorTest extends \Test\TestCase {
];
}
public function provideSubDirURLs() {
public static function provideSubDirURLs(): array {
return [
['', 'http://localhost/nextcloud/'],
['/', 'http://localhost/nextcloud/'],
@ -213,7 +213,7 @@ class UrlGeneratorTest extends \Test\TestCase {
$this->assertEquals($expected, $result);
}
public function provideOCSRoutes(): array {
public static function provideOCSRoutes(): array {
return [
['core.OCS.getCapabilities', false, 'http://localhost/nextcloud/ocs/v2.php/cloud/capabilities'],
['core.OCS.getCapabilities', true, 'http://localhost/nextcloud/ocs/v2.php/cloud/capabilities'],
@ -268,7 +268,7 @@ class UrlGeneratorTest extends \Test\TestCase {
$this->assertSame('http://localhost' . \OC::$WEBROOT . '/apps/dashboard/', $this->urlGenerator->linkToDefaultPageUrl());
}
public function imagePathProvider(): array {
public static function imagePathProvider(): array {
return [
['core', 'favicon-mask.svg', \OC::$WEBROOT . '/core/img/favicon-mask.svg'],
['files', 'folder.svg', \OC::$WEBROOT . '/apps/files/img/folder.svg'],

Loading…
Cancel
Save