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