‪TYPO3CMS  9.5
BackendUserAuthenticationTest.php
Go to the documentation of this file.
1 <?php
2 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 
18 use Psr\Log\NullLogger;
20 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
21 
25 class ‪BackendUserAuthenticationTest extends UnitTestCase
26 {
30  public function ‪getTSConfigDataProvider(): array
31  {
32  $completeConfiguration = [
33  'value' => 'oneValue',
34  'value.' => ['oneProperty' => 'oneValue'],
35  'permissions.' => [
36  'file.' => [
37  'default.' => ['readAction' => '1'],
38  '1.' => ['writeAction' => '1'],
39  '0.' => ['readAction' => '0'],
40  ],
41  ]
42  ];
43 
44  return [
45  'single level string' => [
46  $completeConfiguration,
47  'permissions',
48  [
49  'value' => null,
50  'properties' =>
51  [
52  'file.' => [
53  'default.' => ['readAction' => '1'],
54  '1.' => ['writeAction' => '1'],
55  '0.' => ['readAction' => '0'],
56  ],
57  ],
58  ],
59  ],
60  'two levels string' => [
61  $completeConfiguration,
62  'permissions.file',
63  [
64  'value' => null,
65  'properties' =>
66  [
67  'default.' => ['readAction' => '1'],
68  '1.' => ['writeAction' => '1'],
69  '0.' => ['readAction' => '0'],
70  ],
71  ],
72  ],
73  'three levels string' => [
74  $completeConfiguration,
75  'permissions.file.default',
76  [
77  'value' => null,
78  'properties' =>
79  ['readAction' => '1'],
80  ],
81  ],
82  'three levels string with integer property' => [
83  $completeConfiguration,
84  'permissions.file.1',
85  [
86  'value' => null,
87  'properties' => ['writeAction' => '1'],
88  ],
89  ],
90  'three levels string with integer zero property' => [
91  $completeConfiguration,
92  'permissions.file.0',
93  [
94  'value' => null,
95  'properties' => ['readAction' => '0'],
96  ],
97  ],
98  'four levels string with integer zero property, value, no properties' => [
99  $completeConfiguration,
100  'permissions.file.0.readAction',
101  [
102  'value' => '0',
103  'properties' => null,
104  ],
105  ],
106  'four levels string with integer property, value, no properties' => [
107  $completeConfiguration,
108  'permissions.file.1.writeAction',
109  [
110  'value' => '1',
111  'properties' => null,
112  ],
113  ],
114  'one level, not existent string' => [
115  $completeConfiguration,
116  'foo',
117  [
118  'value' => null,
119  'properties' => null,
120  ],
121  ],
122  'two level, not existent string' => [
123  $completeConfiguration,
124  'foo.bar',
125  [
126  'value' => null,
127  'properties' => null,
128  ],
129  ],
130  'two level, where second level does not exist' => [
131  $completeConfiguration,
132  'permissions.bar',
133  [
134  'value' => null,
135  'properties' => null,
136  ],
137  ],
138  'three level, where third level does not exist' => [
139  $completeConfiguration,
140  'permissions.file.foo',
141  [
142  'value' => null,
143  'properties' => null,
144  ],
145  ],
146  'three level, where second and third level does not exist' => [
147  $completeConfiguration,
148  'permissions.foo.bar',
149  [
150  'value' => null,
151  'properties' => null,
152  ],
153  ],
154  'value and properties' => [
155  $completeConfiguration,
156  'value',
157  [
158  'value' => 'oneValue',
159  'properties' => ['oneProperty' => 'oneValue'],
160  ],
161  ],
162  ];
163  }
164 
172  public function ‪getTSConfigReturnsCorrectArrayForGivenObjectString(array $completeConfiguration, $objectString, array $expectedConfiguration): void
173  {
175  $subject = $this->getAccessibleMock(BackendUserAuthentication::class, ['dummy'], [], '', false);
176  $subject->setLogger(new NullLogger());
177  $subject->_set('userTS', $completeConfiguration);
178 
179  $actualConfiguration = $subject->getTSConfig($objectString);
180  $this->assertSame($expectedConfiguration, $actualConfiguration);
181  }
182 }
‪TYPO3\CMS\Core\Tests\UnitDeprecated\Authentication\BackendUserAuthenticationTest
Definition: BackendUserAuthenticationTest.php:26
‪TYPO3\CMS\Core\Tests\UnitDeprecated\Authentication
Definition: BackendUserAuthenticationTest.php:3
‪TYPO3\CMS\Core\Tests\UnitDeprecated\Authentication\BackendUserAuthenticationTest\getTSConfigReturnsCorrectArrayForGivenObjectString
‪getTSConfigReturnsCorrectArrayForGivenObjectString(array $completeConfiguration, $objectString, array $expectedConfiguration)
Definition: BackendUserAuthenticationTest.php:172
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:45
‪TYPO3\CMS\Core\Tests\UnitDeprecated\Authentication\BackendUserAuthenticationTest\getTSConfigDataProvider
‪array getTSConfigDataProvider()
Definition: BackendUserAuthenticationTest.php:30