[CLEANUP] Adjust code to coding guidelines
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Unit / Domain / Model / FrontendUserGroupTest.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Tests\Unit\Domain\Model;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2012 Markus Günther <mail@markus-guenther.de>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 * This script is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * This copyright notice MUST APPEAR in all copies of the script!
27 ***************************************************************/
28 /**
29 * Testcase for \TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup.
30 *
31 * @author Markus Günther <mail@markus-guenther.de>
32 * @api
33 */
34 class FrontendUserGroupTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
35
36 /**
37 * @var \TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup
38 */
39 protected $fixture = NULL;
40
41 public function setUp() {
42 $this->fixture = new \TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup();
43 }
44
45 public function tearDown() {
46 unset($this->fixture);
47 }
48
49 /**
50 * @test
51 */
52 public function getTitleInitiallyReturnsEmptyString() {
53 $this->fixture = new \TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup();
54 $this->assertSame('', $this->fixture->getTitle());
55 }
56
57 /**
58 * @test
59 */
60 public function getTitleInitiallyReturnsGivenTitleFromConstruct() {
61 $title = 'foo bar';
62 $this->fixture = new \TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup($title);
63 $this->assertSame($title, $this->fixture->getTitle());
64 }
65
66 /**
67 * @test
68 */
69 public function setTitleSetsTitle() {
70 $title = 'foo bar';
71 $this->fixture->setTitle($title);
72 $this->assertSame($title, $this->fixture->getTitle());
73 }
74
75 /**
76 * @test
77 */
78 public function getLockToDomainInitiallyReturnsEmptyString() {
79 $this->assertSame('', $this->fixture->getLockToDomain());
80 }
81
82 /**
83 * @test
84 */
85 public function setLockToDomainSetsLockToDomain() {
86 $lockToDomain = 'foo.bar';
87 $this->fixture->setLockToDomain($lockToDomain);
88 $this->assertSame($lockToDomain, $this->fixture->getLockToDomain());
89 }
90
91 /**
92 * @test
93 */
94 public function getDescriptionInitiallyReturnsEmptyString() {
95 $this->assertSame('', $this->fixture->getDescription());
96 }
97
98 /**
99 * @test
100 */
101 public function setDescriptionSetsDescription() {
102 $description = 'foo bar';
103 $this->fixture->setDescription($description);
104 $this->assertSame($description, $this->fixture->getDescription());
105 }
106
107 /**
108 * @test
109 */
110 public function addSubgroupAddsSubgroup() {
111 $group1 = new \TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup('foo');
112 $this->assertEquals(count($this->fixture->getSubgroup()), 0);
113 $this->fixture->addSubgroup($group1);
114 $this->assertEquals(count($this->fixture->getSubgroup()), 1);
115 }
116
117 /**
118 * @test
119 */
120 public function removeSubgroupRemovesSubgroup() {
121 $group1 = new \TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup('foo');
122 $group2 = new \TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup('bar');
123 $this->fixture->addSubgroup($group1);
124 $this->fixture->addSubgroup($group2);
125 $this->assertEquals(count($this->fixture->getSubgroup()), 2);
126 $this->fixture->removeSubgroup($group1);
127 $this->assertEquals(count($this->fixture->getSubgroup()), 1);
128 $this->fixture->removeSubgroup($group2);
129 $this->assertEquals(count($this->fixture->getSubgroup()), 0);
130 }
131
132 /**
133 * @test
134 */
135 public function setSubgroupSetsSubgroups() {
136 $subgroup = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
137 $group = new \TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup('foo');
138 $subgroup->attach($group);
139 $this->fixture->setSubgroup($subgroup);
140 $this->assertSame($subgroup, $this->fixture->getSubgroup());
141 }
142 }
143
144 ?>