[FEATURE] Backend usergroup model and repository
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Unit / Domain / Model / BackendUserGroupTest.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2012 Markus Günther <mail@markus-guenther>
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 /**
28 * Testcase for Tx_Extbase_Domain_Model_BackendUserGroup.
29 *
30 * @author Markus Günther <mail@markus-guenther>
31 *
32 * @package Extbase
33 * @subpackage Domain\Model
34 *
35 * @scope prototype
36 * @entity
37 * @api
38 */
39 class Tx_Extbase_Tests_Unit_Domain_Model_BackendUserGroupTest extends Tx_Extbase_Tests_Unit_BaseTestCase {
40
41 /**
42 * @var Tx_Extbase_Domain_Model_BackendUserGroup
43 */
44 protected $fixture = NULL;
45
46 public function setUp() {
47 $this->fixture = new Tx_Extbase_Domain_Model_BackendUserGroup();
48 }
49
50 public function tearDown() {
51 unset($this->fixture);
52 }
53
54 /**
55 * @test
56 */
57 public function getTitleInitiallyReturnsEmptyString() {
58 $this->assertSame(
59 '',
60 $this->fixture->getTitle()
61 );
62 }
63
64 /**
65 * @test
66 */
67 public function setTitleSetsTitle() {
68 $title = 'foo bar';
69 $this->fixture->setTitle($title);
70
71 $this->assertSame(
72 $title,
73 $this->fixture->getTitle()
74 );
75 }
76
77 /**
78 * @test
79 */
80 public function getDescriptionInitiallyReturnsEmptyString() {
81 $this->assertSame(
82 '',
83 $this->fixture->getDescription()
84 );
85 }
86
87 /**
88 * @test
89 */
90 public function setDescriptionSetsDescription() {
91 $description = 'foo bar';
92 $this->fixture->setDescription($description);
93
94 $this->assertSame(
95 $description,
96 $this->fixture->getDescription()
97 );
98 }
99
100 /**
101 * @test
102 */
103 public function setSubGroupsSetsSubgroups() {
104 $subGroups = new Tx_Extbase_Persistence_ObjectStorage();
105 $this->fixture->setSubGroups($subGroups);
106
107 $this->assertSame(
108 $subGroups,
109 $this->fixture->getSubGroups()
110 );
111 }
112
113 /**
114 * @test
115 */
116 public function anSubGroupCanBeRemoved() {
117 $group1 = new Tx_Extbase_Domain_Model_BackendUserGroup;
118 $group1->setTitle('foo');
119 $group2 = new Tx_Extbase_Domain_Model_BackendUserGroup;
120 $group2->setTitle('bar');
121
122 $this->fixture->addSubGroup($group1);
123 $this->fixture->addSubGroup($group2);
124 $this->assertEquals(count($this->fixture->getSubGroups()), 2);
125 $this->fixture->removeSubGroup($group1);
126 $this->assertEquals(count($this->fixture->getSubGroups()), 1);
127 $this->fixture->removeSubGroup($group2);
128 $this->assertEquals(count($this->fixture->getSubGroups()), 0);
129 }
130
131 /**
132 * @test
133 */
134 public function allSubGroupsCanBeRemoved() {
135 $group1 = new Tx_Extbase_Domain_Model_BackendUserGroup;
136 $group1->setTitle('foo');
137 $group2 = new Tx_Extbase_Domain_Model_BackendUserGroup;
138 $group2->setTitle('bar');
139
140 $this->fixture->addSubGroup($group1);
141 $this->fixture->addSubGroup($group2);
142 $this->fixture->removeAllSubGroups();
143
144 $this->assertEquals(count($this->fixture->getSubGroups()), 0);
145 }
146
147 /**
148 * @test
149 */
150 public function getModulesInitiallyReturnsEmptyString() {
151 $this->assertSame(
152 '',
153 $this->fixture->getModules()
154 );
155 }
156
157 /**
158 * @test
159 */
160 public function setModulesSetsModules() {
161 $modules = 'foo,bar';
162 $this->fixture->setModules($modules);
163
164 $this->assertSame(
165 $modules,
166 $this->fixture->getModules()
167 );
168 }
169
170 /**
171 * @test
172 */
173 public function getTablesListeningInitiallyReturnsEmptyString() {
174 $this->assertSame(
175 '',
176 $this->fixture->getTablesListening()
177 );
178 }
179
180 /**
181 * @test
182 */
183 public function setTablesListeningSetsTablesListening() {
184 $tablesListening = 'foo,bar';
185 $this->fixture->setTablesListening($tablesListening);
186
187 $this->assertSame(
188 $tablesListening,
189 $this->fixture->getTablesListening()
190 );
191 }
192
193 /**
194 * @test
195 */
196 public function getTablesModifyInitiallyReturnsEmptyString() {
197 $this->assertSame(
198 '',
199 $this->fixture->getTablesModify()
200 );
201 }
202
203 /**
204 * @test
205 */
206 public function getPageTypesInitiallyReturnsEmptyString() {
207 $this->assertSame(
208 '',
209 $this->fixture->getPageTypes()
210 );
211 }
212
213 /**
214 * @test
215 */
216 public function setPageTypesSetsPageTypes() {
217 $pageTypes = 'foo,bar';
218 $this->fixture->setPageTypes($pageTypes);
219
220 $this->assertSame(
221 $pageTypes,
222 $this->fixture->getPageTypes()
223 );
224 }
225
226 /**
227 * @test
228 */
229 public function setTablesModifySetsTablesModify() {
230 $tablesModify = 'foo,bar';
231 $this->fixture->setTablesModify($tablesModify);
232
233 $this->assertSame(
234 $tablesModify,
235 $this->fixture->getTablesModify()
236 );
237 }
238
239 /**
240 * @test
241 */
242 public function getAllowedExcludeFieldsInitiallyReturnsEmptyString() {
243 $this->assertSame(
244 '',
245 $this->fixture->getAllowedExcludeFields()
246 );
247 }
248
249 /**
250 * @test
251 */
252 public function setAllowedExcludeFieldsSetsAllowedExcludeFields() {
253 $allowedExcludeFields = 'foo,bar';
254 $this->fixture->setAllowedExcludeFields($allowedExcludeFields);
255
256 $this->assertSame(
257 $allowedExcludeFields,
258 $this->fixture->getAllowedExcludeFields()
259 );
260 }
261
262 /**
263 * @test
264 */
265 public function getExplicitlyAllowAndDenyInitiallyReturnsEmptyString() {
266 $this->assertSame(
267 '',
268 $this->fixture->getExplicitlyAllowAndDeny()
269 );
270 }
271
272 /**
273 * @test
274 */
275 public function setExplicitlyAllowAndDenySetsExplicitlyAllowAndDeny() {
276 $explicitlyAllowAndDeny = 'foo,bar';
277 $this->fixture->setExplicitlyAllowAndDeny($explicitlyAllowAndDeny);
278
279 $this->assertSame(
280 $explicitlyAllowAndDeny,
281 $this->fixture->getExplicitlyAllowAndDeny()
282 );
283 }
284
285 /**
286 * @test
287 */
288 public function getAllowedLanguagesInitiallyReturnsEmptyString() {
289 $this->assertSame(
290 '',
291 $this->fixture->getAllowedLanguages()
292 );
293 }
294
295 /**
296 * @test
297 */
298 public function setAllowedLanguagesSetsAllowedLanguages() {
299 $allowedLanguages = '1,0';
300 $this->fixture->setAllowedLanguages($allowedLanguages);
301
302 $this->assertSame(
303 $allowedLanguages,
304 $this->fixture->getAllowedLanguages()
305 );
306 }
307
308 /**
309 * @test
310 */
311 public function getWorkspacePermissionInitiallyReturnsFalse() {
312 $this->assertFalse(
313 $this->fixture->getWorkspacePermission()
314 );
315 }
316
317 /**
318 * @test
319 */
320 public function setWorkspacePermissionSetsWorkspacePermission() {
321 $this->fixture->setWorkspacePermissions(TRUE);
322
323 $this->assertTrue(
324 $this->fixture->getWorkspacePermission()
325 );
326 }
327
328 /**
329 * @test
330 */
331 public function getDatabaseMountsInitiallyReturnsEmptyString() {
332 $this->assertSame(
333 '',
334 $this->fixture->getDatabaseMounts()
335 );
336 }
337
338 /**
339 * @test
340 */
341 public function setDatabaseMountsSetsDatabaseMounts() {
342 $mounts = '1,42';
343 $this->fixture->setDatabaseMounts($mounts);
344
345 $this->assertSame(
346 $mounts,
347 $this->fixture->getDatabaseMounts()
348 );
349 }
350
351 /**
352 * @test
353 */
354 public function getFileOperationPermissionsInitiallyReturnsZero() {
355 $this->assertSame(
356 0,
357 $this->fixture->getFileOperationPermissions()
358 );
359 }
360
361 /**
362 * @test
363 */
364 public function setFileOperationPermissionsSetsFileOperationPermissions() {
365 $permission = 7;
366 $this->fixture->setFileOperationPermissions($permission);
367
368 $this->assertSame(
369 $permission,
370 $this->fixture->getFileOperationPermissions()
371 );
372 }
373
374 /**
375 * @test
376 */
377 public function getIsFileOperationAllowedReturnsFalse() {
378 $this->fixture->setFileOperationPermissions(0);
379 $this->assertFalse(
380 $this->fixture->isFileOperationAllowed()
381 );
382
383 $this->fixture->setFileOperationPermissions(2);
384 $this->assertFalse(
385 $this->fixture->isFileOperationAllowed()
386 );
387
388 $this->fixture->setFileOperationPermissions(6);
389 $this->assertFalse(
390 $this->fixture->isFileOperationAllowed()
391 );
392 }
393
394 /**
395 * @test
396 */
397 public function getIsFileOperationAllowedReturnsTrue() {
398 $this->fixture->setFileOperationPermissions(1);
399 $this->assertTrue(
400 $this->fixture->isFileOperationAllowed()
401 );
402
403 $this->fixture->setFileOperationPermissions(3);
404 $this->assertTrue(
405 $this->fixture->isFileOperationAllowed()
406 );
407 }
408
409 /**
410 * @test
411 */
412 public function setFileOperationAllowedSetsFileOperationAllowed() {
413 $this->fixture->setFileOperationPermissions(0);
414 $this->fixture->setFileOperationAllowed(TRUE);
415
416 $this->assertTrue(
417 $this->fixture->isFileOperationAllowed()
418 );
419 }
420
421 /**
422 * @test
423 */
424 public function getIsFileUnzipAllowedReturnsFalse() {
425 $this->fixture->setFileOperationPermissions(0);
426 $this->assertFalse(
427 $this->fixture->isFileUnzipAllowed()
428 );
429
430 $this->fixture->setFileOperationPermissions(1);
431 $this->assertFalse(
432 $this->fixture->isFileUnzipAllowed()
433 );
434
435 $this->fixture->setFileOperationPermissions(5);
436 $this->assertFalse(
437 $this->fixture->isFileUnzipAllowed()
438 );
439 }
440
441 /**
442 * @test
443 */
444 public function getIsFileUnzipAllowedReturnsTrue() {
445 $this->fixture->setFileOperationPermissions(2);
446 $this->assertTrue(
447 $this->fixture->isFileUnzipAllowed()
448 );
449
450 $this->fixture->setFileOperationPermissions(3);
451 $this->assertTrue(
452 $this->fixture->isFileUnzipAllowed()
453 );
454 }
455
456 /**
457 * @test
458 */
459 public function setFileUnzipAllowedSetsFileUnzipAllowed() {
460 $this->fixture->setFileOperationPermissions(0);
461 $this->fixture->setFileUnzipAllowed(TRUE);
462
463 $this->assertTrue(
464 $this->fixture->isFileUnzipAllowed()
465 );
466 }
467
468 /**
469 * @test
470 */
471 public function getIsDirectoryRemoveRecursivelyAllowedReturnsFalse() {
472 $this->fixture->setFileOperationPermissions(1);
473 $this->assertFalse(
474 $this->fixture->isDirectoryRemoveRecursivelyAllowed()
475 );
476
477 $this->fixture->setFileOperationPermissions(15);
478 $this->assertFalse(
479 $this->fixture->isDirectoryRemoveRecursivelyAllowed()
480 );
481
482 $this->fixture->setFileOperationPermissions(7);
483 $this->assertFalse(
484 $this->fixture->isDirectoryRemoveRecursivelyAllowed()
485 );
486 }
487
488 /**
489 * @test
490 */
491 public function getIsDirectoryRemoveRecursivelyAllowedReturnsTrue() {
492 $this->fixture->setFileOperationPermissions(16);
493 $this->assertTrue(
494 $this->fixture->isDirectoryRemoveRecursivelyAllowed()
495 );
496
497 $this->fixture->setFileOperationPermissions(31);
498 $this->assertTrue(
499 $this->fixture->isDirectoryRemoveRecursivelyAllowed()
500 );
501 }
502
503 /**
504 * @test
505 */
506 public function setDirectoryRemoveRecursivelyAllowedSetsDirectoryRemoveRecursivelyAllowed() {
507 $this->fixture->setFileOperationPermissions(0);
508 $this->fixture->setDirectoryRemoveRecursivelyAllowed(TRUE);
509
510 $this->assertTrue(
511 $this->fixture->isDirectoryRemoveRecursivelyAllowed()
512 );
513 }
514
515 /**
516 * @test
517 */
518 public function getIsDirectoryCopyAllowedReturnsFalse() {
519 $this->fixture->setFileOperationPermissions(0);
520 $this->assertFalse(
521 $this->fixture->isDirectoryCopyAllowed()
522 );
523
524 $this->fixture->setFileOperationPermissions(7);
525 $this->assertFalse(
526 $this->fixture->isDirectoryCopyAllowed()
527 );
528
529 $this->fixture->setFileOperationPermissions(23);
530 $this->assertFalse(
531 $this->fixture->isDirectoryCopyAllowed()
532 );
533 }
534
535 /**
536 * @test
537 */
538 public function getIsDirectoryCopyAllowedReturnsTrue() {
539 $this->fixture->setFileOperationPermissions(8);
540 $this->assertTrue(
541 $this->fixture->isDirectoryCopyAllowed()
542 );
543
544 $this->fixture->setFileOperationPermissions(15);
545 $this->assertTrue(
546 $this->fixture->isDirectoryCopyAllowed()
547 );
548 }
549
550 /**
551 * @test
552 */
553 public function setDirectoryCopyAllowedSetsDirectoryCopyAllowed() {
554 $this->fixture->setFileOperationPermissions(0);
555 $this->fixture->setDirectoryCopyAllowed(TRUE);
556
557 $this->assertTrue(
558 $this->fixture->isDirectoryCopyAllowed()
559 );
560 }
561
562 /**
563 * @test
564 */
565 public function getIsDirectoryOperationAllowedReturnsFalse() {
566 $this->fixture->setFileOperationPermissions(0);
567 $this->assertFalse(
568 $this->fixture->isDirectoryOperationAllowed()
569 );
570
571 $this->fixture->setFileOperationPermissions(3);
572 $this->assertFalse(
573 $this->fixture->isDirectoryOperationAllowed()
574 );
575
576 $this->fixture->setFileOperationPermissions(11);
577 $this->assertFalse(
578 $this->fixture->isDirectoryOperationAllowed()
579 );
580 }
581
582 /**
583 * @test
584 */
585 public function getIsDirectoryOperationAllowedReturnsTrue() {
586 $this->fixture->setFileOperationPermissions(4);
587 $this->assertTrue(
588 $this->fixture->isDirectoryOperationAllowed()
589 );
590
591 $this->fixture->setFileOperationPermissions(7);
592 $this->assertTrue(
593 $this->fixture->isDirectoryOperationAllowed()
594 );
595 }
596
597 /**
598 * @test
599 */
600 public function setDirectoryOperationAllowedSetsDirectoryOperationAllowed() {
601 $this->fixture->setFileOperationPermissions(0);
602 $this->fixture->setDirectoryoperationAllowed(TRUE);
603
604 $this->assertTrue(
605 $this->fixture->isDirectoryOperationAllowed()
606 );
607 }
608
609 /**
610 * @test
611 */
612 public function getLockToDomainInitiallyReturnsEmptyString() {
613 $this->assertSame(
614 '',
615 $this->fixture->getLockToDomain()
616 );
617 }
618
619 /**
620 * @test
621 */
622 public function setLockToDomainSetsLockToDomain() {
623 $lockToDomain = 'foo.bar';
624 $this->fixture->setLockToDomain($lockToDomain);
625
626 $this->assertSame(
627 $lockToDomain,
628 $this->fixture->getLockToDomain()
629 );
630 }
631
632 /**
633 * @test
634 */
635 public function getHideInListInitiallyReturnsFalse() {
636 $this->assertFalse(
637 $this->fixture->getHideInList()
638 );
639 }
640
641 /**
642 * @test
643 */
644 public function setHideInListSetsHideInList() {
645 $this->fixture->setHideInList(TRUE);
646
647 $this->assertTrue(
648 $this->fixture->getHideInList()
649 );
650 }
651
652 /**
653 * @test
654 */
655 public function getTsConfigInitiallyReturnsEmptyString() {
656 $this->assertSame(
657 '',
658 $this->fixture->getTsConfig()
659 );
660 }
661
662 /**
663 * @test
664 */
665 public function setTsConfigSetsTsConfig() {
666 $tsConfig = 'foo bar';
667 $this->fixture->setTsConfig($tsConfig);
668
669 $this->assertSame(
670 $tsConfig,
671 $this->fixture->getTsConfig()
672 );
673 }
674 }
675 ?>