[!!!][TASK] Remove leftover unzipping core functionality
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Unit / Domain / Model / BackendUserGroupTest.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Tests\Unit\Domain\Model;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 /**
18 * Test case
19 */
20 class BackendUserGroupTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
21 {
22 /**
23 * @var \TYPO3\CMS\Extbase\Domain\Model\BackendUserGroup
24 */
25 protected $subject = null;
26
27 protected function setUp()
28 {
29 $this->subject = new \TYPO3\CMS\Extbase\Domain\Model\BackendUserGroup();
30 }
31
32 /**
33 * @test
34 */
35 public function getTitleInitiallyReturnsEmptyString()
36 {
37 $this->assertSame('', $this->subject->getTitle());
38 }
39
40 /**
41 * @test
42 */
43 public function setTitleSetsTitle()
44 {
45 $title = 'foo bar';
46 $this->subject->setTitle($title);
47 $this->assertSame($title, $this->subject->getTitle());
48 }
49
50 /**
51 * @test
52 */
53 public function getDescriptionInitiallyReturnsEmptyString()
54 {
55 $this->assertSame('', $this->subject->getDescription());
56 }
57
58 /**
59 * @test
60 */
61 public function setDescriptionSetsDescription()
62 {
63 $description = 'foo bar';
64 $this->subject->setDescription($description);
65 $this->assertSame($description, $this->subject->getDescription());
66 }
67
68 /**
69 * @test
70 */
71 public function setSubGroupsSetsSubgroups()
72 {
73 $subGroups = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
74 $this->subject->setSubGroups($subGroups);
75 $this->assertSame($subGroups, $this->subject->getSubGroups());
76 }
77
78 /**
79 * @test
80 */
81 public function anSubGroupCanBeRemoved()
82 {
83 $group1 = new \TYPO3\CMS\Extbase\Domain\Model\BackendUserGroup();
84 $group1->setTitle('foo');
85 $group2 = new \TYPO3\CMS\Extbase\Domain\Model\BackendUserGroup();
86 $group2->setTitle('bar');
87 $this->subject->addSubGroup($group1);
88 $this->subject->addSubGroup($group2);
89 $this->assertEquals(count($this->subject->getSubGroups()), 2);
90 $this->subject->removeSubGroup($group1);
91 $this->assertEquals(count($this->subject->getSubGroups()), 1);
92 $this->subject->removeSubGroup($group2);
93 $this->assertEquals(count($this->subject->getSubGroups()), 0);
94 }
95
96 /**
97 * @test
98 */
99 public function allSubGroupsCanBeRemoved()
100 {
101 $group1 = new \TYPO3\CMS\Extbase\Domain\Model\BackendUserGroup();
102 $group1->setTitle('foo');
103 $group2 = new \TYPO3\CMS\Extbase\Domain\Model\BackendUserGroup();
104 $group2->setTitle('bar');
105 $this->subject->addSubGroup($group1);
106 $this->subject->addSubGroup($group2);
107 $this->subject->removeAllSubGroups();
108 $this->assertEquals(count($this->subject->getSubGroups()), 0);
109 }
110
111 /**
112 * @test
113 */
114 public function getModulesInitiallyReturnsEmptyString()
115 {
116 $this->assertSame('', $this->subject->getModules());
117 }
118
119 /**
120 * @test
121 */
122 public function setModulesSetsModules()
123 {
124 $modules = 'foo,bar';
125 $this->subject->setModules($modules);
126 $this->assertSame($modules, $this->subject->getModules());
127 }
128
129 /**
130 * @test
131 */
132 public function getTablesListeningInitiallyReturnsEmptyString()
133 {
134 $this->assertSame('', $this->subject->getTablesListening());
135 }
136
137 /**
138 * @test
139 */
140 public function setTablesListeningSetsTablesListening()
141 {
142 $tablesListening = 'foo,bar';
143 $this->subject->setTablesListening($tablesListening);
144 $this->assertSame($tablesListening, $this->subject->getTablesListening());
145 }
146
147 /**
148 * @test
149 */
150 public function getTablesModifyInitiallyReturnsEmptyString()
151 {
152 $this->assertSame('', $this->subject->getTablesModify());
153 }
154
155 /**
156 * @test
157 */
158 public function getPageTypesInitiallyReturnsEmptyString()
159 {
160 $this->assertSame('', $this->subject->getPageTypes());
161 }
162
163 /**
164 * @test
165 */
166 public function setPageTypesSetsPageTypes()
167 {
168 $pageTypes = 'foo,bar';
169 $this->subject->setPageTypes($pageTypes);
170 $this->assertSame($pageTypes, $this->subject->getPageTypes());
171 }
172
173 /**
174 * @test
175 */
176 public function setTablesModifySetsTablesModify()
177 {
178 $tablesModify = 'foo,bar';
179 $this->subject->setTablesModify($tablesModify);
180 $this->assertSame($tablesModify, $this->subject->getTablesModify());
181 }
182
183 /**
184 * @test
185 */
186 public function getAllowedExcludeFieldsInitiallyReturnsEmptyString()
187 {
188 $this->assertSame('', $this->subject->getAllowedExcludeFields());
189 }
190
191 /**
192 * @test
193 */
194 public function setAllowedExcludeFieldsSetsAllowedExcludeFields()
195 {
196 $allowedExcludeFields = 'foo,bar';
197 $this->subject->setAllowedExcludeFields($allowedExcludeFields);
198 $this->assertSame($allowedExcludeFields, $this->subject->getAllowedExcludeFields());
199 }
200
201 /**
202 * @test
203 */
204 public function getExplicitlyAllowAndDenyInitiallyReturnsEmptyString()
205 {
206 $this->assertSame('', $this->subject->getExplicitlyAllowAndDeny());
207 }
208
209 /**
210 * @test
211 */
212 public function setExplicitlyAllowAndDenySetsExplicitlyAllowAndDeny()
213 {
214 $explicitlyAllowAndDeny = 'foo,bar';
215 $this->subject->setExplicitlyAllowAndDeny($explicitlyAllowAndDeny);
216 $this->assertSame($explicitlyAllowAndDeny, $this->subject->getExplicitlyAllowAndDeny());
217 }
218
219 /**
220 * @test
221 */
222 public function getAllowedLanguagesInitiallyReturnsEmptyString()
223 {
224 $this->assertSame('', $this->subject->getAllowedLanguages());
225 }
226
227 /**
228 * @test
229 */
230 public function setAllowedLanguagesSetsAllowedLanguages()
231 {
232 $allowedLanguages = '1,0';
233 $this->subject->setAllowedLanguages($allowedLanguages);
234 $this->assertSame($allowedLanguages, $this->subject->getAllowedLanguages());
235 }
236
237 /**
238 * @test
239 */
240 public function getWorkspacePermissionInitiallyReturnsFalse()
241 {
242 $this->assertFalse($this->subject->getWorkspacePermission());
243 }
244
245 /**
246 * @test
247 */
248 public function setWorkspacePermissionSetsWorkspacePermission()
249 {
250 $this->subject->setWorkspacePermissions(true);
251 $this->assertTrue($this->subject->getWorkspacePermission());
252 }
253
254 /**
255 * @test
256 */
257 public function getDatabaseMountsInitiallyReturnsEmptyString()
258 {
259 $this->assertSame('', $this->subject->getDatabaseMounts());
260 }
261
262 /**
263 * @test
264 */
265 public function setDatabaseMountsSetsDatabaseMounts()
266 {
267 $mounts = '1,42';
268 $this->subject->setDatabaseMounts($mounts);
269 $this->assertSame($mounts, $this->subject->getDatabaseMounts());
270 }
271
272 /**
273 * @test
274 */
275 public function getFileOperationPermissionsInitiallyReturnsZero()
276 {
277 $this->assertSame(0, $this->subject->getFileOperationPermissions());
278 }
279
280 /**
281 * @test
282 */
283 public function setFileOperationPermissionsSetsFileOperationPermissions()
284 {
285 $permission = 7;
286 $this->subject->setFileOperationPermissions($permission);
287 $this->assertSame($permission, $this->subject->getFileOperationPermissions());
288 }
289
290 /**
291 * @test
292 */
293 public function getIsFileOperationAllowedReturnsFalse()
294 {
295 $this->subject->setFileOperationPermissions(0);
296 $this->assertFalse($this->subject->isFileOperationAllowed());
297 $this->subject->setFileOperationPermissions(2);
298 $this->assertFalse($this->subject->isFileOperationAllowed());
299 $this->subject->setFileOperationPermissions(6);
300 $this->assertFalse($this->subject->isFileOperationAllowed());
301 }
302
303 /**
304 * @test
305 */
306 public function getIsFileOperationAllowedReturnsTrue()
307 {
308 $this->subject->setFileOperationPermissions(1);
309 $this->assertTrue($this->subject->isFileOperationAllowed());
310 $this->subject->setFileOperationPermissions(3);
311 $this->assertTrue($this->subject->isFileOperationAllowed());
312 }
313
314 /**
315 * @test
316 */
317 public function setFileOperationAllowedSetsFileOperationAllowed()
318 {
319 $this->subject->setFileOperationPermissions(0);
320 $this->subject->setFileOperationAllowed(true);
321 $this->assertTrue($this->subject->isFileOperationAllowed());
322 }
323
324 /**
325 * @test
326 */
327 public function getIsDirectoryRemoveRecursivelyAllowedReturnsFalse()
328 {
329 $this->subject->setFileOperationPermissions(1);
330 $this->assertFalse($this->subject->isDirectoryRemoveRecursivelyAllowed());
331 $this->subject->setFileOperationPermissions(15);
332 $this->assertFalse($this->subject->isDirectoryRemoveRecursivelyAllowed());
333 $this->subject->setFileOperationPermissions(7);
334 $this->assertFalse($this->subject->isDirectoryRemoveRecursivelyAllowed());
335 }
336
337 /**
338 * @test
339 */
340 public function getIsDirectoryRemoveRecursivelyAllowedReturnsTrue()
341 {
342 $this->subject->setFileOperationPermissions(16);
343 $this->assertTrue($this->subject->isDirectoryRemoveRecursivelyAllowed());
344 $this->subject->setFileOperationPermissions(31);
345 $this->assertTrue($this->subject->isDirectoryRemoveRecursivelyAllowed());
346 }
347
348 /**
349 * @test
350 */
351 public function setDirectoryRemoveRecursivelyAllowedSetsDirectoryRemoveRecursivelyAllowed()
352 {
353 $this->subject->setFileOperationPermissions(0);
354 $this->subject->setDirectoryRemoveRecursivelyAllowed(true);
355 $this->assertTrue($this->subject->isDirectoryRemoveRecursivelyAllowed());
356 }
357
358 /**
359 * @test
360 */
361 public function getIsDirectoryCopyAllowedReturnsFalse()
362 {
363 $this->subject->setFileOperationPermissions(0);
364 $this->assertFalse($this->subject->isDirectoryCopyAllowed());
365 $this->subject->setFileOperationPermissions(7);
366 $this->assertFalse($this->subject->isDirectoryCopyAllowed());
367 $this->subject->setFileOperationPermissions(23);
368 $this->assertFalse($this->subject->isDirectoryCopyAllowed());
369 }
370
371 /**
372 * @test
373 */
374 public function getIsDirectoryCopyAllowedReturnsTrue()
375 {
376 $this->subject->setFileOperationPermissions(8);
377 $this->assertTrue($this->subject->isDirectoryCopyAllowed());
378 $this->subject->setFileOperationPermissions(15);
379 $this->assertTrue($this->subject->isDirectoryCopyAllowed());
380 }
381
382 /**
383 * @test
384 */
385 public function setDirectoryCopyAllowedSetsDirectoryCopyAllowed()
386 {
387 $this->subject->setFileOperationPermissions(0);
388 $this->subject->setDirectoryCopyAllowed(true);
389 $this->assertTrue($this->subject->isDirectoryCopyAllowed());
390 }
391
392 /**
393 * @test
394 */
395 public function getIsDirectoryOperationAllowedReturnsFalse()
396 {
397 $this->subject->setFileOperationPermissions(0);
398 $this->assertFalse($this->subject->isDirectoryOperationAllowed());
399 $this->subject->setFileOperationPermissions(3);
400 $this->assertFalse($this->subject->isDirectoryOperationAllowed());
401 $this->subject->setFileOperationPermissions(11);
402 $this->assertFalse($this->subject->isDirectoryOperationAllowed());
403 }
404
405 /**
406 * @test
407 */
408 public function getIsDirectoryOperationAllowedReturnsTrue()
409 {
410 $this->subject->setFileOperationPermissions(4);
411 $this->assertTrue($this->subject->isDirectoryOperationAllowed());
412 $this->subject->setFileOperationPermissions(7);
413 $this->assertTrue($this->subject->isDirectoryOperationAllowed());
414 }
415
416 /**
417 * @test
418 */
419 public function setDirectoryOperationAllowedSetsDirectoryOperationAllowed()
420 {
421 $this->subject->setFileOperationPermissions(0);
422 $this->subject->setDirectoryoperationAllowed(true);
423 $this->assertTrue($this->subject->isDirectoryOperationAllowed());
424 }
425
426 /**
427 * @test
428 */
429 public function getLockToDomainInitiallyReturnsEmptyString()
430 {
431 $this->assertSame('', $this->subject->getLockToDomain());
432 }
433
434 /**
435 * @test
436 */
437 public function setLockToDomainSetsLockToDomain()
438 {
439 $lockToDomain = 'foo.bar';
440 $this->subject->setLockToDomain($lockToDomain);
441 $this->assertSame($lockToDomain, $this->subject->getLockToDomain());
442 }
443
444 /**
445 * @test
446 */
447 public function getHideInListInitiallyReturnsFalse()
448 {
449 $this->assertFalse($this->subject->getHideInList());
450 }
451
452 /**
453 * @test
454 */
455 public function setHideInListSetsHideInList()
456 {
457 $this->subject->setHideInList(true);
458 $this->assertTrue($this->subject->getHideInList());
459 }
460
461 /**
462 * @test
463 */
464 public function getTsConfigInitiallyReturnsEmptyString()
465 {
466 $this->assertSame('', $this->subject->getTsConfig());
467 }
468
469 /**
470 * @test
471 */
472 public function setTsConfigSetsTsConfig()
473 {
474 $tsConfig = 'foo bar';
475 $this->subject->setTsConfig($tsConfig);
476 $this->assertSame($tsConfig, $this->subject->getTsConfig());
477 }
478 }