diff options
author | Joas Schilling <coding@schilljs.com> | 2025-05-13 10:10:13 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2025-05-15 08:25:01 +0200 |
commit | 3e7db013c18777ee68cf3a6135d82727d5db8dd4 (patch) | |
tree | ade3641e667feea5d78891161b0425144ea59d1c | |
parent | 9621e451ba24c287b4bab73d4376a6655f59cd7f (diff) | |
download | nextcloud-server-3e7db013c18777ee68cf3a6135d82727d5db8dd4.tar.gz nextcloud-server-3e7db013c18777ee68cf3a6135d82727d5db8dd4.zip |
test: Fix non-static data providers
Signed-off-by: Joas Schilling <coding@schilljs.com>
57 files changed, 181 insertions, 186 deletions
diff --git a/tests/lib/Accounts/AccountManagerTest.php b/tests/lib/Accounts/AccountManagerTest.php index fab3aaf5fdd..05c7efd08fb 100644 --- a/tests/lib/Accounts/AccountManagerTest.php +++ b/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 [ [ [], diff --git a/tests/lib/Accounts/AccountPropertyTest.php b/tests/lib/Accounts/AccountPropertyTest.php index ae5a6a0f5e7..68e1da41557 100644 --- a/tests/lib/Accounts/AccountPropertyTest.php +++ b/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], diff --git a/tests/lib/Accounts/HooksTest.php b/tests/lib/Accounts/HooksTest.php index 75772089f43..73cef2e2c65 100644 --- a/tests/lib/Accounts/HooksTest.php +++ b/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'] diff --git a/tests/lib/Activity/ManagerTest.php b/tests/lib/Activity/ManagerTest.php index 61eeee82c43..f42a38eab53 100644 --- a/tests/lib/Activity/ManagerTest.php +++ b/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'], diff --git a/tests/lib/AllConfigTest.php b/tests/lib/AllConfigTest.php index e892e441ecf..b4137c07ac5 100644 --- a/tests/lib/AllConfigTest.php +++ b/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], diff --git a/tests/lib/AppConfigTest.php b/tests/lib/AppConfigTest.php index 518d7909d70..6cbc683afde 100644 --- a/tests/lib/AppConfigTest.php +++ b/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], diff --git a/tests/lib/AppTest.php b/tests/lib/AppTest.php index 3e4d762a0a4..b817d968910 100644 --- a/tests/lib/AppTest.php +++ b/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 "], diff --git a/tests/lib/Avatar/AvatarManagerTest.php b/tests/lib/Avatar/AvatarManagerTest.php index 25e8e1563f5..5fac90e0f34 100644 --- a/tests/lib/Avatar/AvatarManagerTest.php +++ b/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], diff --git a/tests/lib/Avatar/UserAvatarTest.php b/tests/lib/Avatar/UserAvatarTest.php index 0e2bfe6872f..633a0fda368 100644 --- a/tests/lib/Avatar/UserAvatarTest.php +++ b/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'], diff --git a/tests/lib/BackgroundJob/JobListTest.php b/tests/lib/BackgroundJob/JobListTest.php index bf21639d3aa..64279c11a35 100644 --- a/tests/lib/BackgroundJob/JobListTest.php +++ b/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], diff --git a/tests/lib/Collaboration/Collaborators/MailPluginTest.php b/tests/lib/Collaboration/Collaborators/MailPluginTest.php index 02b1034240f..5112795ec7c 100644 --- a/tests/lib/Collaboration/Collaborators/MailPluginTest.php +++ b/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 [ diff --git a/tests/lib/Collaboration/Collaborators/RemotePluginTest.php b/tests/lib/Collaboration/Collaborators/RemotePluginTest.php index 14894aa2df6..aa7e4c8afd5 100644 --- a/tests/lib/Collaboration/Collaborators/RemotePluginTest.php +++ b/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@'], diff --git a/tests/lib/Collaboration/Collaborators/SearchResultTest.php b/tests/lib/Collaboration/Collaborators/SearchResultTest.php index 6641a2caed1..7a0afe87e4b 100644 --- a/tests/lib/Collaboration/Collaborators/SearchResultTest.php +++ b/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], diff --git a/tests/lib/Collaboration/Collaborators/SearchTest.php b/tests/lib/Collaboration/Collaborators/SearchTest.php index 3e43d6331b2..146befe966e 100644 --- a/tests/lib/Collaboration/Collaborators/SearchTest.php +++ b/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 [ diff --git a/tests/lib/Collaboration/Collaborators/UserPluginTest.php b/tests/lib/Collaboration/Collaborators/UserPluginTest.php index 453f16c6686..3b342b7938b 100644 --- a/tests/lib/Collaboration/Collaborators/UserPluginTest.php +++ b/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', diff --git a/tests/lib/Comments/CommentTest.php b/tests/lib/Comments/CommentTest.php index 3cfc897b28e..988ffbe0e0b 100644 --- a/tests/lib/Comments/CommentTest.php +++ b/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!', diff --git a/tests/lib/ContactsManagerTest.php b/tests/lib/ContactsManagerTest.php index 7586b063883..6fea6b39e92 100644 --- a/tests/lib/ContactsManagerTest.php +++ b/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 => '',], diff --git a/tests/lib/DB/ConnectionFactoryTest.php b/tests/lib/DB/ConnectionFactoryTest.php index 23bde34a8fb..31dd8037964 100644 --- a/tests/lib/DB/ConnectionFactoryTest.php +++ b/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']], diff --git a/tests/lib/DB/Exception/DbalExceptionTest.php b/tests/lib/DB/Exception/DbalExceptionTest.php index 470beff9080..c37e65aea0e 100644 --- a/tests/lib/DB/Exception/DbalExceptionTest.php +++ b/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], diff --git a/tests/lib/DB/MigrationsTest.php b/tests/lib/DB/MigrationsTest.php index 57ffb91e37e..f5379b30be9 100644 --- a/tests/lib/DB/MigrationsTest.php +++ b/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'], diff --git a/tests/lib/DB/MigratorTest.php b/tests/lib/DB/MigratorTest.php index c6afe5a053a..46724afee86 100644 --- a/tests/lib/DB/MigratorTest.php +++ b/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], diff --git a/tests/lib/DateTimeFormatterTest.php b/tests/lib/DateTimeFormatterTest.php index 924cac9d399..7b542ee422f 100644 --- a/tests/lib/DateTimeFormatterTest.php +++ b/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"], diff --git a/tests/lib/EmojiHelperTest.php b/tests/lib/EmojiHelperTest.php index 9ad56b32472..517d8655e53 100644 --- a/tests/lib/EmojiHelperTest.php +++ b/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], diff --git a/tests/lib/ErrorHandlerTest.php b/tests/lib/ErrorHandlerTest.php index a2003cfbd93..00cf8e4c8db 100644 --- a/tests/lib/ErrorHandlerTest.php +++ b/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(); } /** diff --git a/tests/lib/Federation/CloudIdManagerTest.php b/tests/lib/Federation/CloudIdManagerTest.php index 7019cd202db..0bd0659b2f2 100644 --- a/tests/lib/Federation/CloudIdManagerTest.php +++ b/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'], diff --git a/tests/lib/Federation/CloudIdTest.php b/tests/lib/Federation/CloudIdTest.php index ca949d163c7..ec3cc15d6ff 100644 --- a/tests/lib/Federation/CloudIdTest.php +++ b/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'], diff --git a/tests/lib/Files/FilenameValidatorTest.php b/tests/lib/Files/FilenameValidatorTest.php index c5361e2c648..db7874b0bd5 100644 --- a/tests/lib/Files/FilenameValidatorTest.php +++ b/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 diff --git a/tests/lib/Files/FilesystemTest.php b/tests/lib/Files/FilesystemTest.php index a920dc662da..4a3543474a1 100644 --- a/tests/lib/Files/FilesystemTest.php +++ b/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], diff --git a/tests/lib/Files/PathVerificationTest.php b/tests/lib/Files/PathVerificationTest.php index fcbe0a6957f..d6dff445c0f 100644 --- a/tests/lib/Files/PathVerificationTest.php +++ b/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'], diff --git a/tests/lib/Files/Utils/ScannerTest.php b/tests/lib/Files/Utils/ScannerTest.php index f66bb72e865..51089e5560c 100644 --- a/tests/lib/Files/Utils/ScannerTest.php +++ b/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 [ [ '../', diff --git a/tests/lib/ImageTest.php b/tests/lib/ImageTest.php index 5de5435335a..494f616ac9c 100644 --- a/tests/lib/ImageTest.php +++ b/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'], diff --git a/tests/lib/InfoXmlTest.php b/tests/lib/InfoXmlTest.php index e579a4b4efd..ffc367d4471 100644 --- a/tests/lib/InfoXmlTest.php +++ b/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'], diff --git a/tests/lib/InitialStateServiceTest.php b/tests/lib/InitialStateServiceTest.php index f58d54cb26b..5e0f7c7b55e 100644 --- a/tests/lib/InitialStateServiceTest.php +++ b/tests/lib/InitialStateServiceTest.php @@ -36,7 +36,7 @@ class InitialStateServiceTest extends TestCase { ); } - public function staticData(): array { + public static function staticData(): array { return [ ['string'], [23], diff --git a/tests/lib/InstallerTest.php b/tests/lib/InstallerTest.php index d27ca6e2159..9e77cb6a4fc 100644 --- a/tests/lib/InstallerTest.php +++ b/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 [ diff --git a/tests/lib/L10N/L10nTest.php b/tests/lib/L10N/L10nTest.php index 32b81cf06a7..a95a1241f4b 100644 --- a/tests/lib/L10N/L10nTest.php +++ b/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'], diff --git a/tests/lib/L10N/LanguageIteratorTest.php b/tests/lib/L10N/LanguageIteratorTest.php index 79998c36354..e328941e35d 100644 --- a/tests/lib/L10N/LanguageIteratorTest.php +++ b/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']], diff --git a/tests/lib/LargeFileHelperGetFileSizeTest.php b/tests/lib/LargeFileHelperGetFileSizeTest.php index 247886fee6a..7f6604bdb35 100644 --- a/tests/lib/LargeFileHelperGetFileSizeTest.php +++ b/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 [ diff --git a/tests/lib/Log/PsrLoggerAdapterTest.php b/tests/lib/Log/PsrLoggerAdapterTest.php index cc9ddea378a..9a159ba537d 100644 --- a/tests/lib/Log/PsrLoggerAdapterTest.php +++ b/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'], diff --git a/tests/lib/LoggerTest.php b/tests/lib/LoggerTest.php index c7c60e892aa..5c8345b392b 100644 --- a/tests/lib/LoggerTest.php +++ b/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'], diff --git a/tests/lib/Memcache/FactoryTest.php b/tests/lib/Memcache/FactoryTest.php index fa0d80c5153..cbf908e0cc6 100644 --- a/tests/lib/Memcache/FactoryTest.php +++ b/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 diff --git a/tests/lib/NaturalSortTest.php b/tests/lib/NaturalSortTest.php index 3a07c5ceb66..833e2f5e3be 100644 --- a/tests/lib/NaturalSortTest.php +++ b/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 [ diff --git a/tests/lib/NavigationManagerTest.php b/tests/lib/NavigationManagerTest.php index 48cfa972f2b..986d2183a14 100644 --- a/tests/lib/NavigationManagerTest.php +++ b/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', diff --git a/tests/lib/Net/HostnameClassifierTest.php b/tests/lib/Net/HostnameClassifierTest.php index 766246ed8ad..5d80da01e46 100644 --- a/tests/lib/Net/HostnameClassifierTest.php +++ b/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'], diff --git a/tests/lib/Net/IpAddressClassifierTest.php b/tests/lib/Net/IpAddressClassifierTest.php index 803be00f740..be0b7e52fe0 100644 --- a/tests/lib/Net/IpAddressClassifierTest.php +++ b/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'], diff --git a/tests/lib/OCS/ApiHelperTest.php b/tests/lib/OCS/ApiHelperTest.php index fdbc1f4c538..93de6b22af7 100644 --- a/tests/lib/OCS/ApiHelperTest.php +++ b/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 [ diff --git a/tests/lib/OCS/DiscoveryServiceTest.php b/tests/lib/OCS/DiscoveryServiceTest.php index 3db3163e11d..2fce12ee3c0 100644 --- a/tests/lib/OCS/DiscoveryServiceTest.php +++ b/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']], diff --git a/tests/lib/Preview/GeneratorTest.php b/tests/lib/Preview/GeneratorTest.php index 607127a6495..84ffe6662c7 100644 --- a/tests/lib/Preview/GeneratorTest.php +++ b/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], diff --git a/tests/lib/Preview/SVGTest.php b/tests/lib/Preview/SVGTest.php index 6a0e93e5f79..14730bc8034 100644 --- a/tests/lib/Preview/SVGTest.php +++ b/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'], diff --git a/tests/lib/Repair/ClearGeneratedAvatarCacheTest.php b/tests/lib/Repair/ClearGeneratedAvatarCacheTest.php index 810fa1fe4e8..88fc24b40ad 100644 --- a/tests/lib/Repair/ClearGeneratedAvatarCacheTest.php +++ b/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], diff --git a/tests/lib/Repair/RepairInvalidSharesTest.php b/tests/lib/Repair/RepairInvalidSharesTest.php index dfcdce3801a..7c49d74e2ef 100644 --- a/tests/lib/Repair/RepairInvalidSharesTest.php +++ b/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 [ diff --git a/tests/lib/RichObjectStrings/DefinitionsTest.php b/tests/lib/RichObjectStrings/DefinitionsTest.php index 9299a556972..cc964aff50f 100644 --- a/tests/lib/RichObjectStrings/DefinitionsTest.php +++ b/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'); diff --git a/tests/lib/ServerTest.php b/tests/lib/ServerTest.php index eb9b1dab9f5..371bc572b15 100644 --- a/tests/lib/ServerTest.php +++ b/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'], diff --git a/tests/lib/Share/HelperTest.php b/tests/lib/Share/HelperTest.php index c923bb0480a..c56350358eb 100644 --- a/tests/lib/Share/HelperTest.php +++ b/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], diff --git a/tests/lib/Share/ShareTest.php b/tests/lib/Share/ShareTest.php index 60891e10ca2..944d0738eb1 100644 --- a/tests/lib/Share/ShareTest.php +++ b/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 [ diff --git a/tests/lib/Support/Subscription/RegistryTest.php b/tests/lib/Support/Subscription/RegistryTest.php index b3a0f8e603e..08a216294d6 100644 --- a/tests/lib/Support/Subscription/RegistryTest.php +++ b/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], diff --git a/tests/lib/SystemTag/SystemTagManagerTest.php b/tests/lib/SystemTag/SystemTagManagerTest.php index 94103c52cb1..4627ebbf546 100644 --- a/tests/lib/SystemTag/SystemTagManagerTest.php +++ b/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], diff --git a/tests/lib/UrlGeneratorTest.php b/tests/lib/UrlGeneratorTest.php index ed7b797d809..7006c3948f6 100644 --- a/tests/lib/UrlGeneratorTest.php +++ b/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'], |