diff options
author | Robin Appelman <robin@icewind.nl> | 2025-06-30 16:56:59 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2025-07-01 22:45:52 +0200 |
commit | aa15f9d16d5b46d04763c7deedb129990e819364 (patch) | |
tree | 758e0aebcac34a545f9a21806120a9fcb96f4cb6 /apps/user_ldap | |
parent | 1620a0c0510a42b1da0a66488838f1ce3ba1210d (diff) | |
download | nextcloud-server-rector-phpunit10.tar.gz nextcloud-server-rector-phpunit10.zip |
chore: run rectorrector-phpunit10
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps/user_ldap')
-rw-r--r-- | apps/user_ldap/tests/AccessTest.php | 22 | ||||
-rw-r--r-- | apps/user_ldap/tests/ConfigurationTest.php | 12 | ||||
-rw-r--r-- | apps/user_ldap/tests/ConnectionTest.php | 3 | ||||
-rw-r--r-- | apps/user_ldap/tests/Group_LDAPTest.php | 27 | ||||
-rw-r--r-- | apps/user_ldap/tests/Jobs/CleanUpTest.php | 2 | ||||
-rw-r--r-- | apps/user_ldap/tests/Jobs/SyncTest.php | 20 | ||||
-rw-r--r-- | apps/user_ldap/tests/LDAPTest.php | 4 | ||||
-rw-r--r-- | apps/user_ldap/tests/Migration/UUIDFixInsertTest.php | 8 | ||||
-rw-r--r-- | apps/user_ldap/tests/Service/BirthdateParserServiceTest.php | 4 | ||||
-rw-r--r-- | apps/user_ldap/tests/User/ManagerTest.php | 8 | ||||
-rw-r--r-- | apps/user_ldap/tests/User/OfflineUserTest.php | 4 | ||||
-rw-r--r-- | apps/user_ldap/tests/User/UserTest.php | 12 | ||||
-rw-r--r-- | apps/user_ldap/tests/User_LDAPTest.php | 8 |
13 files changed, 36 insertions, 98 deletions
diff --git a/apps/user_ldap/tests/AccessTest.php b/apps/user_ldap/tests/AccessTest.php index eafaeb76403..54be29d0f86 100644 --- a/apps/user_ldap/tests/AccessTest.php +++ b/apps/user_ldap/tests/AccessTest.php @@ -132,10 +132,10 @@ class AccessTest extends TestCase { } /** - * @dataProvider convertSID2StrSuccessData * @param array $sidArray * @param $sidExpected */ + #[\PHPUnit\Framework\Attributes\DataProvider('convertSID2StrSuccessData')] public function testConvertSID2StrSuccess(array $sidArray, $sidExpected): void { $sidBinary = implode('', $sidArray); $this->assertSame($sidExpected, $this->access->convertSID2Str($sidBinary)); @@ -219,9 +219,7 @@ class AccessTest extends TestCase { ]; } - /** - * @dataProvider dnInputDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dnInputDataProvider')] public function testStringResemblesDN(string $input, array|bool $interResult, bool $expectedResult): void { [$lw, $con, $um, $helper] = $this->getConnectorAndLdapMock(); /** @var IConfig&MockObject $config */ @@ -240,9 +238,7 @@ class AccessTest extends TestCase { $this->assertSame($expectedResult, $access->stringResemblesDN($input)); } - /** - * @dataProvider dnInputDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dnInputDataProvider')] public function testStringResemblesDNLDAPmod(string $input, array|bool $interResult, bool $expectedResult): void { [, $con, $um, $helper] = $this->getConnectorAndLdapMock(); /** @var IConfig&MockObject $config */ @@ -414,9 +410,7 @@ class AccessTest extends TestCase { ]; } - /** - * @dataProvider dNAttributeProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dNAttributeProvider')] public function testSanitizeDN(string $attribute): void { [$lw, $con, $um, $helper] = $this->getConnectorAndLdapMock(); /** @var IConfig&MockObject $config */ @@ -698,9 +692,7 @@ class AccessTest extends TestCase { ]; } - /** - * @dataProvider intUsernameProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('intUsernameProvider')] public function testSanitizeUsername(string $name, ?string $expected): void { if ($expected === null) { $this->expectException(\InvalidArgumentException::class); @@ -709,9 +701,7 @@ class AccessTest extends TestCase { $this->assertSame($expected, $sanitizedName); } - /** - * @dataProvider groupIDCandidateProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('groupIDCandidateProvider')] public function testSanitizeGroupIDCandidate(string $name, string $expected): void { $sanitizedName = $this->access->sanitizeGroupIDCandidate($name); $this->assertSame($expected, $sanitizedName); diff --git a/apps/user_ldap/tests/ConfigurationTest.php b/apps/user_ldap/tests/ConfigurationTest.php index dd6bd020f7b..db92598fcfd 100644 --- a/apps/user_ldap/tests/ConfigurationTest.php +++ b/apps/user_ldap/tests/ConfigurationTest.php @@ -86,9 +86,7 @@ class ConfigurationTest extends \Test\TestCase { ]; } - /** - * @dataProvider configurationDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('configurationDataProvider')] public function testSetValue(string $key, string|array $input, string|array $expected): void { $this->configuration->setConfiguration([$key => $input]); $this->assertSame($this->configuration->$key, $expected); @@ -105,17 +103,13 @@ class ConfigurationTest extends \Test\TestCase { ]; } - /** - * @dataProvider avatarRuleValueProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('avatarRuleValueProvider')] public function testGetAvatarAttributes(string $setting, array $expected): void { $this->configuration->setConfiguration(['ldapUserAvatarRule' => $setting]); $this->assertSame($expected, $this->configuration->getAvatarAttributes()); } - /** - * @dataProvider avatarRuleValueProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('avatarRuleValueProvider')] public function testResolveRule(string $setting, array $expected): void { $this->configuration->setConfiguration(['ldapUserAvatarRule' => $setting]); // so far the only thing that can get resolved :) diff --git a/apps/user_ldap/tests/ConnectionTest.php b/apps/user_ldap/tests/ConnectionTest.php index 601611fcc2f..7116e15898f 100644 --- a/apps/user_ldap/tests/ConnectionTest.php +++ b/apps/user_ldap/tests/ConnectionTest.php @@ -101,8 +101,7 @@ class ConnectionTest extends \Test\TestCase { // Not called often enough? Then, the fallback to the backup server is broken. $this->connection->expects($this->exactly(2)) ->method('getFromCache') - ->with('overrideMainServer') - ->will($this->onConsecutiveCalls(false, false, true, true)); + ->with('overrideMainServer')->willReturnOnConsecutiveCalls(false, false, true, true); $this->connection->expects($this->once()) ->method('writeToCache') diff --git a/apps/user_ldap/tests/Group_LDAPTest.php b/apps/user_ldap/tests/Group_LDAPTest.php index d2634548f4f..10182111768 100644 --- a/apps/user_ldap/tests/Group_LDAPTest.php +++ b/apps/user_ldap/tests/Group_LDAPTest.php @@ -475,9 +475,7 @@ class Group_LDAPTest extends TestCase { ]; } - /** - * @dataProvider groupWithMembersProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('groupWithMembersProvider')] public function testInGroupMember(string $gid, string $groupDn, array $memberDNs): void { $uid = 'someUser'; $userDn = $memberDNs[0]; @@ -516,9 +514,7 @@ class Group_LDAPTest extends TestCase { $this->assertTrue($this->groupBackend->inGroup($uid, $gid)); } - /** - * @dataProvider groupWithMembersProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('groupWithMembersProvider')] public function testInGroupMemberNot(string $gid, string $groupDn, array $memberDNs): void { $uid = 'unelatedUser'; $userDn = 'uid=unrelatedUser,ou=unrelatedTeam,ou=unrelatedDepartment,dc=someDomain,dc=someTld'; @@ -557,9 +553,7 @@ class Group_LDAPTest extends TestCase { $this->assertFalse($this->groupBackend->inGroup($uid, $gid)); } - /** - * @dataProvider groupWithMembersProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('groupWithMembersProvider')] public function testInGroupMemberUid(string $gid, string $groupDn, array $memberDNs): void { $memberUids = []; $userRecords = []; @@ -767,8 +761,7 @@ class Group_LDAPTest extends TestCase { ->method('username2dn') ->willReturn($dn); $this->access->expects($this->exactly(5)) - ->method('readAttribute') - ->will($this->onConsecutiveCalls($expectedGroups, [], [], [], [])); + ->method('readAttribute')->willReturnOnConsecutiveCalls($expectedGroups, [], [], [], []); $this->access->expects($this->any()) ->method('dn2groupname') ->willReturnArgument(0); @@ -947,9 +940,7 @@ class Group_LDAPTest extends TestCase { ]; } - /** - * @dataProvider nestedGroupsProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('nestedGroupsProvider')] public function testGetGroupsByMember(bool $nestedGroups): void { $groupFilter = '(&(objectclass=nextcloudGroup)(nextcloudEnabled=TRUE))'; $this->access->connection->expects($this->any()) @@ -1321,9 +1312,7 @@ class Group_LDAPTest extends TestCase { ]; } - /** - * @dataProvider groupMemberProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('groupMemberProvider')] public function testGroupMembers(array $expectedResult, array $groupsInfo): void { $this->access->expects($this->any()) ->method('readAttribute') @@ -1362,9 +1351,7 @@ class Group_LDAPTest extends TestCase { ]; } - /** - * @dataProvider displayNameProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('displayNameProvider')] public function testGetDisplayName(string $expected, bool|array $ldapResult): void { $gid = 'graphic_novelists'; diff --git a/apps/user_ldap/tests/Jobs/CleanUpTest.php b/apps/user_ldap/tests/Jobs/CleanUpTest.php index cefc9cc86b5..5a1e563a1e8 100644 --- a/apps/user_ldap/tests/Jobs/CleanUpTest.php +++ b/apps/user_ldap/tests/Jobs/CleanUpTest.php @@ -61,7 +61,7 @@ class CleanUpTest extends TestCase { public function test_runNotAllowedByBrokenHelper(): void { $this->mocks['helper']->expects($this->once()) ->method('haveDisabledConfigurations') - ->will($this->throwException(new Exception())); + ->willThrowException(new Exception()); $this->mocks['ocConfig']->expects($this->never()) ->method('getSystemValue'); diff --git a/apps/user_ldap/tests/Jobs/SyncTest.php b/apps/user_ldap/tests/Jobs/SyncTest.php index 20489ea0901..f6ecf984ab0 100644 --- a/apps/user_ldap/tests/Jobs/SyncTest.php +++ b/apps/user_ldap/tests/Jobs/SyncTest.php @@ -102,9 +102,7 @@ class SyncTest extends TestCase { ]; } - /** - * @dataProvider intervalDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('intervalDataProvider')] public function testUpdateInterval(int $userCount, int $pagingSize1, int $pagingSize2): void { $this->config->expects($this->once()) ->method('setAppValue') @@ -145,9 +143,7 @@ class SyncTest extends TestCase { ]; } - /** - * @dataProvider moreResultsProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('moreResultsProvider')] public function testMoreResults($pagingSize, $results, $expected): void { $connection = $this->getMockBuilder(Connection::class) ->setConstructorArgs([ @@ -204,9 +200,7 @@ class SyncTest extends TestCase { ]; } - /** - * @dataProvider cycleDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('cycleDataProvider')] public function testDetermineNextCycle(?array $cycleData, array $prefixes, ?array $expectedCycle): void { $this->helper->expects($this->any()) ->method('getServerConfigurationPrefixes') @@ -220,7 +214,7 @@ class SyncTest extends TestCase { ]; $this->config->expects($this->exactly(2)) ->method('setAppValue') - ->willReturnCallback(function () use (&$calls) { + ->willReturnCallback(function () use (&$calls): void { $expected = array_shift($calls); $this->assertEquals($expected, func_get_args()); }); @@ -284,9 +278,7 @@ class SyncTest extends TestCase { ]; } - /** - * @dataProvider runDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('runDataProvider')] public function testRun(array $runData): void { $this->config->expects($this->any()) ->method('getAppValue') @@ -322,7 +314,7 @@ class SyncTest extends TestCase { ]; $this->config->expects($this->exactly(3)) ->method('setAppValue') - ->willReturnCallback(function () use (&$calls) { + ->willReturnCallback(function () use (&$calls): void { $expected = array_shift($calls); $this->assertEquals($expected, func_get_args()); }); diff --git a/apps/user_ldap/tests/LDAPTest.php b/apps/user_ldap/tests/LDAPTest.php index 936a1a27d3d..6da592ad6a1 100644 --- a/apps/user_ldap/tests/LDAPTest.php +++ b/apps/user_ldap/tests/LDAPTest.php @@ -33,9 +33,7 @@ class LDAPTest extends TestCase { ]; } - /** - * @dataProvider errorProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('errorProvider')] public function testSearchWithErrorHandler(string $errorMessage, bool $passThrough): void { $wasErrorHandlerCalled = false; $errorHandler = function ($number, $message, $file, $line) use (&$wasErrorHandlerCalled): void { diff --git a/apps/user_ldap/tests/Migration/UUIDFixInsertTest.php b/apps/user_ldap/tests/Migration/UUIDFixInsertTest.php index 0fc601c7d2e..6215ffcb6a1 100644 --- a/apps/user_ldap/tests/Migration/UUIDFixInsertTest.php +++ b/apps/user_ldap/tests/Migration/UUIDFixInsertTest.php @@ -86,9 +86,7 @@ class UUIDFixInsertTest extends TestCase { ]; } - /** - * @dataProvider recordProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('recordProvider')] public function testRun(array $userBatches, array $groupBatches): void { $this->config->expects($this->once()) ->method('getAppValue') @@ -116,9 +114,7 @@ class UUIDFixInsertTest extends TestCase { $this->job->run($out); } - /** - * @dataProvider recordProviderTooLongAndNone - */ + #[\PHPUnit\Framework\Attributes\DataProvider('recordProviderTooLongAndNone')] public function testRunWithManyAndNone(array $userBatches, array $groupBatches): void { $this->config->expects($this->once()) ->method('getAppValue') diff --git a/apps/user_ldap/tests/Service/BirthdateParserServiceTest.php b/apps/user_ldap/tests/Service/BirthdateParserServiceTest.php index 85d6a6ba5f7..061118f10c1 100644 --- a/apps/user_ldap/tests/Service/BirthdateParserServiceTest.php +++ b/apps/user_ldap/tests/Service/BirthdateParserServiceTest.php @@ -35,9 +35,7 @@ class BirthdateParserServiceTest extends TestCase { ]; } - /** - * @dataProvider parseBirthdateDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('parseBirthdateDataProvider')] public function testParseBirthdate( string $value, ?DateTimeImmutable $expected, diff --git a/apps/user_ldap/tests/User/ManagerTest.php b/apps/user_ldap/tests/User/ManagerTest.php index 3f8b3aa174f..bf9d1f5746f 100644 --- a/apps/user_ldap/tests/User/ManagerTest.php +++ b/apps/user_ldap/tests/User/ManagerTest.php @@ -85,9 +85,7 @@ class ManagerTest extends \Test\TestCase { ]; } - /** - * @dataProvider dnProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dnProvider')] public function testGetByDNExisting(string $inputDN): void { $uid = '563418fc-423b-1033-8d1c-ad5f418ee02e'; @@ -184,9 +182,7 @@ class ManagerTest extends \Test\TestCase { ]; } - /** - * @dataProvider attributeRequestProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('attributeRequestProvider')] public function testGetAttributes($minimal): void { $this->connection->setConfiguration([ 'ldapEmailAttribute' => 'MAIL', diff --git a/apps/user_ldap/tests/User/OfflineUserTest.php b/apps/user_ldap/tests/User/OfflineUserTest.php index 5ef89303111..223e63421ad 100644 --- a/apps/user_ldap/tests/User/OfflineUserTest.php +++ b/apps/user_ldap/tests/User/OfflineUserTest.php @@ -47,9 +47,7 @@ class OfflineUserTest extends TestCase { ]; } - /** - * @dataProvider shareOwnerProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('shareOwnerProvider')] public function testHasActiveShares(array $existingShareTypes, bool $expected): void { $shareMock = $this->createMock(IShare::class); diff --git a/apps/user_ldap/tests/User/UserTest.php b/apps/user_ldap/tests/User/UserTest.php index d9075af1569..00edd8b3f9b 100644 --- a/apps/user_ldap/tests/User/UserTest.php +++ b/apps/user_ldap/tests/User/UserTest.php @@ -780,9 +780,7 @@ class UserTest extends \Test\TestCase { ]; } - /** - * @dataProvider extStorageHomeDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('extStorageHomeDataProvider')] public function testUpdateExtStorageHome(string $expected, ?string $valueFromLDAP = null, bool $isSet = true): void { if ($valueFromLDAP === null) { $this->connection->expects($this->once()) @@ -936,9 +934,7 @@ class UserTest extends \Test\TestCase { ]; } - /** - * @dataProvider emptyHomeFolderAttributeValueProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('emptyHomeFolderAttributeValueProvider')] public function testGetHomePathNotConfigured(string $attributeValue): void { $this->connection->expects($this->any()) ->method('__get') @@ -1012,9 +1008,7 @@ class UserTest extends \Test\TestCase { ]; } - /** - * @dataProvider displayNameProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('displayNameProvider')] public function testComposeAndStoreDisplayName(string $part1, string $part2, string $expected, bool $expectTriggerChange): void { $this->config->expects($this->once()) ->method('setUserValue'); diff --git a/apps/user_ldap/tests/User_LDAPTest.php b/apps/user_ldap/tests/User_LDAPTest.php index 5be01d5e414..f8900c3cca4 100644 --- a/apps/user_ldap/tests/User_LDAPTest.php +++ b/apps/user_ldap/tests/User_LDAPTest.php @@ -1325,9 +1325,7 @@ class User_LDAPTest extends TestCase { ]; } - /** - * @dataProvider avatarDataProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('avatarDataProvider')] public function testCanChangeAvatar(string|bool $imageData, bool $expected): void { $isValidImage = str_starts_with((string)$imageData, 'valid'); @@ -1452,9 +1450,7 @@ class User_LDAPTest extends TestCase { ]; } - /** - * @dataProvider actionProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('actionProvider')] public function testImplementsAction(string $configurable, string|int $value, int $actionCode, bool $expected): void { $this->pluginManager->expects($this->once()) ->method('getImplementedActions') |