diff options
Diffstat (limited to 'tests/lib/Collaboration/Collaborators')
7 files changed, 60 insertions, 73 deletions
diff --git a/tests/lib/Collaboration/Collaborators/GroupPluginTest.php b/tests/lib/Collaboration/Collaborators/GroupPluginTest.php index 8fe71234906..a4ecd598562 100644 --- a/tests/lib/Collaboration/Collaborators/GroupPluginTest.php +++ b/tests/lib/Collaboration/Collaborators/GroupPluginTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later @@ -417,7 +418,6 @@ class GroupPluginTest extends TestCase { } /** - * @dataProvider dataGetGroups * * @param string $searchTerm * @param bool $shareWithGroupOnly @@ -430,6 +430,7 @@ class GroupPluginTest extends TestCase { * @param bool $reachedEnd * @param bool|IGroup $singleGroup */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataGetGroups')] public function testSearch( string $searchTerm, bool $shareWithGroupOnly, diff --git a/tests/lib/Collaboration/Collaborators/LookupPluginTest.php b/tests/lib/Collaboration/Collaborators/LookupPluginTest.php index 7ff01831e18..ac9b196ea1e 100644 --- a/tests/lib/Collaboration/Collaborators/LookupPluginTest.php +++ b/tests/lib/Collaboration/Collaborators/LookupPluginTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later @@ -76,13 +77,10 @@ class LookupPluginTest extends TestCase { ->willReturn('yes'); $this->config->expects($this->exactly(2)) ->method('getSystemValueBool') - ->withConsecutive( - ['gs.enabled', false], - ['has_internet_connection', true], - )->willReturnOnConsecutiveCalls( - true, - true, - ); + ->willReturnMap([ + ['gs.enabled', false, true], + ['has_internet_connection', true, true], + ]); $this->config->expects($this->once()) ->method('getSystemValueString') @@ -105,13 +103,10 @@ class LookupPluginTest extends TestCase { ->willReturn('yes'); $this->config->expects($this->exactly(2)) ->method('getSystemValueBool') - ->withConsecutive( - ['gs.enabled', false], - ['has_internet_connection', true], - )->willReturnOnConsecutiveCalls( - false, - false, - ); + ->willReturnMap([ + ['gs.enabled', false, false], + ['has_internet_connection', true, false], + ]); $this->clientService->expects($this->never()) ->method('newClient'); @@ -123,9 +118,9 @@ class LookupPluginTest extends TestCase { } /** - * @dataProvider searchDataProvider * @param array $searchParams */ + #[\PHPUnit\Framework\Attributes\DataProvider('searchDataProvider')] public function testSearch(array $searchParams): void { $type = new SearchResultType('lookup'); @@ -141,13 +136,10 @@ class LookupPluginTest extends TestCase { ->willReturn('yes'); $this->config->expects($this->exactly(2)) ->method('getSystemValueBool') - ->withConsecutive( - ['gs.enabled', false], - ['has_internet_connection', true], - )->willReturnOnConsecutiveCalls( - true, - true, - ); + ->willReturnMap([ + ['gs.enabled', false, true], + ['has_internet_connection', true, true], + ]); $this->config->expects($this->once()) ->method('getSystemValueString') @@ -184,11 +176,11 @@ class LookupPluginTest extends TestCase { /** - * @dataProvider dataSearchEnableDisableLookupServer * @param array $searchParams * @param bool $GSEnabled * @param bool $LookupEnabled */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataSearchEnableDisableLookupServer')] public function testSearchEnableDisableLookupServer(array $searchParams, $GSEnabled, $LookupEnabled): void { $type = new SearchResultType('lookup'); @@ -206,13 +198,10 @@ class LookupPluginTest extends TestCase { $this->config->expects($this->exactly(2)) ->method('getSystemValueBool') - ->withConsecutive( - ['gs.enabled', false], - ['has_internet_connection', true], - )->willReturnOnConsecutiveCalls( - $GSEnabled, - true, - ); + ->willReturnMap([ + ['gs.enabled', false, $GSEnabled], + ['has_internet_connection', true, true], + ]); $this->config->expects($this->once()) ->method('getSystemValueString') ->with('lookup_server', 'https://lookup.nextcloud.com') @@ -239,13 +228,10 @@ class LookupPluginTest extends TestCase { $searchResult->expects($this->never())->method('addResultSet'); $this->config->expects($this->exactly(2)) ->method('getSystemValueBool') - ->withConsecutive( - ['gs.enabled', false], - ['has_internet_connection', true], - )->willReturnOnConsecutiveCalls( - $GSEnabled, - true, - ); + ->willReturnMap([ + ['gs.enabled', false, $GSEnabled], + ['has_internet_connection', true, true], + ]); } $moreResults = $this->plugin->search( $searchParams['search'], @@ -276,7 +262,7 @@ class LookupPluginTest extends TestCase { $this->assertFalse($this->plugin->search('irr', 10, 0, $searchResult)); } - public function dataSearchEnableDisableLookupServer() { + public static function dataSearchEnableDisableLookupServer(): array { $fedIDs = [ 'foo@enceladus.moon', 'foobar@enceladus.moon', @@ -449,7 +435,7 @@ class LookupPluginTest extends TestCase { ]; } - public function searchDataProvider() { + public static function searchDataProvider(): array { $fedIDs = [ 'foo@enceladus.moon', 'foobar@enceladus.moon', diff --git a/tests/lib/Collaboration/Collaborators/MailPluginTest.php b/tests/lib/Collaboration/Collaborators/MailPluginTest.php index 02b1034240f..b38b961a512 100644 --- a/tests/lib/Collaboration/Collaborators/MailPluginTest.php +++ b/tests/lib/Collaboration/Collaborators/MailPluginTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later @@ -63,11 +64,11 @@ class MailPluginTest extends TestCase { $this->userSession = $this->createMock(IUserSession::class); $this->mailer = $this->createMock(IMailer::class); $this->cloudIdManager = new CloudIdManager( + $this->createMock(ICacheFactory::class), + $this->createMock(IEventDispatcher::class), $this->contactsManager, $this->createMock(IURLGenerator::class), $this->createMock(IUserManager::class), - $this->createMock(ICacheFactory::class), - $this->createMock(IEventDispatcher::class) ); $this->searchResult = new SearchResult(); @@ -86,7 +87,6 @@ class MailPluginTest extends TestCase { } /** - * @dataProvider dataGetEmail * * @param string $searchTerm * @param array $contacts @@ -94,6 +94,7 @@ class MailPluginTest extends TestCase { * @param array $expected * @param bool $reachedEnd */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataGetEmail')] public function testSearch($searchTerm, $contacts, $shareeEnumeration, $expected, $exactIdMatch, $reachedEnd, $validEmail): void { $this->config->expects($this->any()) ->method('getAppValue') @@ -134,7 +135,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], @@ -568,7 +569,6 @@ class MailPluginTest extends TestCase { } /** - * @dataProvider dataGetEmailGroupsOnly * * @param string $searchTerm * @param array $contacts @@ -577,6 +577,7 @@ class MailPluginTest extends TestCase { * @param bool $reachedEnd * @param array groups */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataGetEmailGroupsOnly')] public function testSearchGroupsOnly($searchTerm, $contacts, $expected, $exactIdMatch, $reachedEnd, $userToGroupMapping, $validEmail): void { $this->config->expects($this->any()) ->method('getAppValue') @@ -593,7 +594,7 @@ class MailPluginTest extends TestCase { $this->instantiatePlugin(); - /** @var \OCP\IUser | \PHPUnit\Framework\MockObject\MockObject */ + /** @var IUser|\PHPUnit\Framework\MockObject\MockObject */ $currentUser = $this->createMock('\OCP\IUser'); $currentUser->expects($this->any()) @@ -618,7 +619,7 @@ class MailPluginTest extends TestCase { $this->groupManager->expects($this->any()) ->method('getUserGroupIds') - ->willReturnCallback(function (\OCP\IUser $user) use ($userToGroupMapping) { + ->willReturnCallback(function (IUser $user) use ($userToGroupMapping) { return $userToGroupMapping[$user->getUID()]; }); @@ -636,7 +637,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..a9a5e05dfe4 100644 --- a/tests/lib/Collaboration/Collaborators/RemotePluginTest.php +++ b/tests/lib/Collaboration/Collaborators/RemotePluginTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later @@ -48,11 +49,11 @@ class RemotePluginTest extends TestCase { $this->config = $this->createMock(IConfig::class); $this->contactsManager = $this->createMock(IManager::class); $this->cloudIdManager = new CloudIdManager( + $this->createMock(ICacheFactory::class), + $this->createMock(IEventDispatcher::class), $this->contactsManager, $this->createMock(IURLGenerator::class), $this->createMock(IUserManager::class), - $this->createMock(ICacheFactory::class), - $this->createMock(IEventDispatcher::class) ); $this->searchResult = new SearchResult(); } @@ -70,7 +71,6 @@ class RemotePluginTest extends TestCase { } /** - * @dataProvider dataGetRemote * * @param string $searchTerm * @param array $contacts @@ -79,6 +79,7 @@ class RemotePluginTest extends TestCase { * @param bool $exactIdMatch * @param bool $reachedEnd */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataGetRemote')] public function testSearch($searchTerm, array $contacts, $shareeEnumeration, array $expected, $exactIdMatch, $reachedEnd): void { $this->config->expects($this->any()) ->method('getAppValue') @@ -111,12 +112,12 @@ class RemotePluginTest extends TestCase { } /** - * @dataProvider dataTestSplitUserRemote * * @param string $remote * @param string $expectedUser * @param string $expectedUrl */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestSplitUserRemote')] public function testSplitUserRemote($remote, $expectedUser, $expectedUrl): void { $this->instantiatePlugin(); @@ -130,10 +131,9 @@ class RemotePluginTest extends TestCase { } /** - * @dataProvider dataTestSplitUserRemoteError - * * @param string $id */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataTestSplitUserRemoteError')] public function testSplitUserRemoteError($id): void { $this->expectException(\Exception::class); @@ -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..687901c47a6 100644 --- a/tests/lib/Collaboration/Collaborators/SearchResultTest.php +++ b/tests/lib/Collaboration/Collaborators/SearchResultTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later @@ -27,7 +28,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' => []]], @@ -37,10 +38,10 @@ class SearchResultTest extends TestCase { } /** - * @dataProvider dataAddResultSet * @param array $toAdd * @param array $expected */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataAddResultSet')] public function testAddResultSet(array $toAdd, array $expected): void { $result = new SearchResult(); @@ -51,7 +52,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], @@ -66,12 +67,12 @@ class SearchResultTest extends TestCase { } /** - * @dataProvider dataHasResult * @param array $toAdd * @param string $type * @param string $id * @param bool $expected */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataHasResult')] public function testHasResult(array $toAdd, $type, $id, $expected): void { $result = new SearchResult(); diff --git a/tests/lib/Collaboration/Collaborators/SearchTest.php b/tests/lib/Collaboration/Collaborators/SearchTest.php index 3e43d6331b2..ade995ea526 100644 --- a/tests/lib/Collaboration/Collaborators/SearchTest.php +++ b/tests/lib/Collaboration/Collaborators/SearchTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later @@ -29,9 +30,7 @@ class SearchTest extends TestCase { $this->search = new Search($this->container); } - /** - * @dataProvider dataSearchSharees - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataSearchSharees')] public function testSearch( string $searchTerm, array $shareTypes, @@ -115,7 +114,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..cb4949fb86d 100644 --- a/tests/lib/Collaboration/Collaborators/UserPluginTest.php +++ b/tests/lib/Collaboration/Collaborators/UserPluginTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later @@ -124,7 +125,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], @@ -417,7 +418,6 @@ class UserPluginTest extends TestCase { } /** - * @dataProvider dataGetUsers * * @param string $searchTerm * @param bool $shareWithGroupOnly @@ -430,6 +430,7 @@ class UserPluginTest extends TestCase { * @param bool|IUser $singleUser * @param array $users */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataGetUsers')] public function testSearch( $searchTerm, $shareWithGroupOnly, @@ -508,7 +509,7 @@ class UserPluginTest extends TestCase { $this->assertSame($reachedEnd, $moreResults); } - public function takeOutCurrentUserProvider() { + public static function takeOutCurrentUserProvider(): array { $inputUsers = [ 'alice' => 'Alice', 'bob' => 'Bob', @@ -534,11 +535,11 @@ class UserPluginTest extends TestCase { } /** - * @dataProvider takeOutCurrentUserProvider * @param array $users * @param array $expectedUIDs * @param $currentUserId */ + #[\PHPUnit\Framework\Attributes\DataProvider('takeOutCurrentUserProvider')] public function testTakeOutCurrentUser(array $users, array $expectedUIDs, $currentUserId): void { $this->instantiatePlugin(); @@ -555,7 +556,7 @@ class UserPluginTest extends TestCase { $this->assertSame($expectedUIDs, array_keys($users)); } - public function dataSearchEnumeration() { + public static function dataSearchEnumeration(): array { return [ [ 'test', @@ -716,9 +717,7 @@ class UserPluginTest extends TestCase { ]; } - /** - * @dataProvider dataSearchEnumeration - */ + #[\PHPUnit\Framework\Attributes\DataProvider('dataSearchEnumeration')] public function testSearchEnumerationLimit($search, $userGroups, $matchingUsers, $result, $mockedSettings): void { $this->mockConfig($mockedSettings); |