‪TYPO3CMS  11.5
GroupResolverTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
22 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
23 
24 class ‪GroupResolverTest extends FunctionalTestCase
25 {
26  public function ‪setUp(): void
27  {
28  parent::setUp();
29  $this->importCSVDataSet(__DIR__ . '/Fixtures/be_users.csv');
30  $this->importCSVDataSet(__DIR__ . '/Fixtures/be_groups.csv');
31  }
32 
34  {
35  return [
36  'invalid group' => [
37  [238],
38  [],
39  ],
40  'direct group with multiple users' => [
41  [1],
42  [2, 3],
43  ],
44  'direct group with one users' => [
45  [4],
46  [3],
47  ],
48  'direct and indirect subgroup with one users' => [
49  [2],
50  [3],
51  ],
52  'subgroup with no direct reference' => [
53  [5],
54  [3],
55  ],
56  'subgroup and direct with no direct reference' => [
57  [5, 2, 3],
58  [3],
59  ],
60  'no group given' => [
61  [],
62  [],
63  ],
64  ];
65  }
66 
73  public function ‪findAllUsersOfGroupsHandlesRecursiveCalls(array $groupIds, array $expectedUsers): void
74  {
75  $subject = GeneralUtility::makeInstance(GroupResolver::class);
76  $users = $subject->findAllUsersInGroups($groupIds, 'be_groups', 'be_users');
77  self::assertEquals($expectedUsers, array_map('intval', array_column($users, 'uid')));
78  }
79 }
‪TYPO3\CMS\Core\Tests\Functional\Authentication\GroupResolverTest\findAllUsersOfGroupsHandlesRecursiveCalls
‪findAllUsersOfGroupsHandlesRecursiveCalls(array $groupIds, array $expectedUsers)
Definition: GroupResolverTest.php:73
‪TYPO3\CMS\Core\Tests\Functional\Authentication\GroupResolverTest\setUp
‪setUp()
Definition: GroupResolverTest.php:26
‪TYPO3\CMS\Core\Tests\Functional\Authentication\GroupResolverTest\findAllUsersOfGroupsHandlesRecursiveCallsDataProvider
‪findAllUsersOfGroupsHandlesRecursiveCallsDataProvider()
Definition: GroupResolverTest.php:33
‪TYPO3\CMS\Core\Tests\Functional\Authentication
Definition: AbstractUserAuthenticationTest.php:18
‪TYPO3\CMS\Core\Authentication\GroupResolver
Definition: GroupResolver.php:36
‪TYPO3\CMS\Core\Tests\Functional\Authentication\GroupResolverTest
Definition: GroupResolverTest.php:25
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50