5655f73891077226a55531b45c26790352376623
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Unit / Domain / Model / BackendUserTest.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Tests\Unit\Domain\Model;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2012 Felix Kopp <felix-source@phorax.com>
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\BackendUser.
30 *
31 * @author Felix Kopp <felix-source@phorax.com>
32 * @author Oliver Klee <typo3-coding@oliverklee.de>
33 * @api
34 */
35 class BackendUserTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
36
37 /**
38 * @var \TYPO3\CMS\Extbase\Domain\Model\BackendUser
39 */
40 protected $fixture = NULL;
41
42 public function setUp() {
43 $this->fixture = new \TYPO3\CMS\Extbase\Domain\Model\BackendUser();
44 }
45
46 public function tearDown() {
47 unset($this->fixture);
48 }
49
50 /**
51 * @test
52 */
53 public function getUserNameInitiallyReturnsEmptyString() {
54 $this->assertSame('', $this->fixture->getUserName());
55 }
56
57 /**
58 * @test
59 */
60 public function setUserNameSetsUserName() {
61 $userName = 'don.juan';
62 $this->fixture->setUserName($userName);
63 $this->assertSame($userName, $this->fixture->getUserName());
64 }
65
66 /**
67 * @test
68 */
69 public function getIsAdministratorInitiallyReturnsFalse() {
70 $this->assertFalse($this->fixture->getIsAdministrator());
71 }
72
73 /**
74 * @test
75 */
76 public function setIsAdministratorCanSetIsAdministratorToTrue() {
77 $this->fixture->setIsAdministrator(TRUE);
78 $this->assertTrue($this->fixture->getIsAdministrator());
79 }
80
81 /**
82 * @test
83 */
84 public function getIsDisabledInitiallyReturnsFalse() {
85 $this->assertFalse($this->fixture->getIsDisabled());
86 }
87
88 /**
89 * @test
90 */
91 public function setIsDisabledCanSetIsDisabledToTrue() {
92 $this->fixture->setIsDisabled(TRUE);
93 $this->assertTrue($this->fixture->getIsDisabled());
94 }
95
96 /**
97 * @test
98 */
99 public function getStartDateAndTimeInitiallyReturnsNull() {
100 $this->assertNull($this->fixture->getStartDateAndTime());
101 }
102
103 /**
104 * @test
105 */
106 public function setStartDateAndTimeSetsStartDateAndTime() {
107 $date = new \DateTime();
108 $this->fixture->setStartDateAndTime($date);
109 $this->assertSame($date, $this->fixture->getStartDateAndTime());
110 }
111
112 /**
113 * @test
114 */
115 public function getEndDateAndTimeInitiallyReturnsNull() {
116 $this->assertNull($this->fixture->getEndDateAndTime());
117 }
118
119 /**
120 * @test
121 */
122 public function setEndDateAndTimeSetsEndDateAndTime() {
123 $date = new \DateTime();
124 $this->fixture->setEndDateAndTime($date);
125 $this->assertSame($date, $this->fixture->getEndDateAndTime());
126 }
127
128 /**
129 * @test
130 */
131 public function isActivatedInitiallyReturnsTrue() {
132 $this->assertTrue($this->fixture->isActivated());
133 }
134
135 /**
136 * @test
137 */
138 public function isActivatedForDisabledReturnsFalse() {
139 $this->fixture->setIsDisabled(TRUE);
140 $this->assertFalse($this->fixture->isActivated());
141 }
142
143 /**
144 * @test
145 */
146 public function isActivatedForStartDateAndTimeInFutureReturnsFalse() {
147 $tomorrow = new \DateTime('tomorrow');
148 $this->fixture->setStartDateAndTime($tomorrow);
149 $this->assertFalse($this->fixture->isActivated());
150 }
151
152 /**
153 * @test
154 */
155 public function isActivatedForStartDateAndTimeInPastReturnsTrue() {
156 $yesterday = new \DateTime('yesterday');
157 $this->fixture->setStartDateAndTime($yesterday);
158 $this->assertTrue($this->fixture->isActivated());
159 }
160
161 /**
162 * @test
163 */
164 public function isActivatedForEndDateAndTimeInFutureReturnsTrue() {
165 $tomorrow = new \DateTime('tomorrow');
166 $this->fixture->setEndDateAndTime($tomorrow);
167 $this->assertTrue($this->fixture->isActivated());
168 }
169
170 /**
171 * @test
172 */
173 public function isActivatedForEndDateAndTimeInPastReturnsFalse() {
174 $yesterday = new \DateTime('yesterday');
175 $this->fixture->setEndDateAndTime($yesterday);
176 $this->assertFalse($this->fixture->isActivated());
177 }
178
179 /**
180 * @test
181 */
182 public function isActivatedForStartDateAndTimeInPastEndDateAndTimeInFutureReturnsTrue() {
183 $yesterday = new \DateTime('yesterday');
184 $this->fixture->setStartDateAndTime($yesterday);
185 $tomorrow = new \DateTime('tomorrow');
186 $this->fixture->setEndDateAndTime($tomorrow);
187 $this->assertTrue($this->fixture->isActivated());
188 }
189
190 /**
191 * @test
192 */
193 public function isActivatedForStartDateAndTimeInPastEndDateAndTimeInPastReturnsFalse() {
194 $yesterday = new \DateTime('yesterday');
195 $this->fixture->setStartDateAndTime($yesterday);
196 $this->fixture->setEndDateAndTime($yesterday);
197 $this->assertFalse($this->fixture->isActivated());
198 }
199
200 /**
201 * @test
202 */
203 public function isActivatedForStartDateAndTimeInFutureEndDateAndTimeInFutureReturnsFalse() {
204 $tomorrow = new \DateTime('tomorrow');
205 $this->fixture->setStartDateAndTime($tomorrow);
206 $this->fixture->setEndDateAndTime($tomorrow);
207 $this->assertFalse($this->fixture->isActivated());
208 }
209
210 /**
211 * @test
212 */
213 public function getEmailInitiallyReturnsEmptyString() {
214 $this->assertSame('', $this->fixture->getEmail());
215 }
216
217 /**
218 * @test
219 */
220 public function setEmailSetsEmail() {
221 $email = 'don.juan@example.com';
222 $this->fixture->setEmail($email);
223 $this->assertSame($email, $this->fixture->getEmail());
224 }
225
226 /**
227 * @test
228 */
229 public function getRealNameInitiallyReturnsEmptyString() {
230 $this->assertSame('', $this->fixture->getRealName());
231 }
232
233 /**
234 * @test
235 */
236 public function setRealNameSetsRealName() {
237 $realName = 'Don Juan';
238 $this->fixture->setRealName($realName);
239 $this->assertSame($realName, $this->fixture->getRealName());
240 }
241
242 /**
243 * @test
244 */
245 public function getIpLockIsDisabledInitiallyReturnsFalse() {
246 $this->assertFalse($this->fixture->getIpLockIsDisabled());
247 }
248
249 /**
250 * @test
251 */
252 public function setIpLockIsDisabledCanSetIpLockIsDisabledToTrue() {
253 $this->fixture->setIpLockIsDisabled(TRUE);
254 $this->assertTrue($this->fixture->getIpLockIsDisabled());
255 }
256
257 /**
258 * @test
259 */
260 public function getLastLoginDateAndTimeInitiallyReturnsNull() {
261 $this->assertNull($this->fixture->getLastLoginDateAndTime());
262 }
263
264 /**
265 * @test
266 */
267 public function setLastLoginDateAndTimeSetsLastLoginDateAndTime() {
268 $date = new \DateTime();
269 $this->fixture->setLastLoginDateAndTime($date);
270 $this->assertSame($date, $this->fixture->getLastLoginDateAndTime());
271 }
272
273 /**
274 * @test
275 */
276 public function getFileMountsInitiallyReturnsEmpty() {
277 $this->assertSame(0, $this->fixture->getFileMounts()->count());
278 }
279
280 /**
281 * @test
282 */
283 public function setFileMountsSetsFileMounts() {
284 $fileMounts = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
285 $this->fixture->setFileMounts($fileMounts);
286
287 $this->assertSame(
288 $fileMounts,
289 $this->fixture->getFileMounts()
290 );
291 }
292
293 /**
294 * @test
295 */
296 public function addFileMountAddsFileMount() {
297 $fileMount = new \TYPO3\CMS\Extbase\Domain\Model\FileMount();
298
299 $this->fixture->addFileMount($fileMount);
300 $this->assertTrue($this->fixture->getFileMounts()->contains($fileMount));
301 }
302
303 /**
304 * @test
305 */
306 public function removeFileMountRemovesFileMount() {
307 $fileMount = new \TYPO3\CMS\Extbase\Domain\Model\FileMount();
308
309 $this->fixture->addFileMount($fileMount);
310 $this->fixture->removeFileMount($fileMount);
311 $this->assertFalse($this->fixture->getFileMounts()->contains($fileMount));
312 }
313
314 /**
315 * @test
316 */
317 public function removeAllFileMountsRemovesAllFileMounts() {
318 $fileMount = new \TYPO3\CMS\Extbase\Domain\Model\FileMount();
319 $fileMount2 = new \TYPO3\CMS\Extbase\Domain\Model\FileMount();
320
321 $this->fixture->addFileMount($fileMount);
322 $this->fixture->addFileMount($fileMount2);
323 $this->fixture->removeAllFileMounts();
324
325 $this->assertFalse($this->fixture->getFileMounts()->contains($fileMount));
326 $this->assertFalse($this->fixture->getFileMounts()->contains($fileMount2));
327 }
328 }
329
330 ?>