[TASK] Shorten the extend class in all unit tests
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Unit / Domain / Model / FrontendUserTest.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 use TYPO3\CMS\Extbase\Domain\Model\FileReference;
17 use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
18 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
19
20 /**
21 * Test case
22 */
23 class FrontendUserTest extends UnitTestCase
24 {
25 /**
26 * @var \TYPO3\CMS\Extbase\Domain\Model\FrontendUser
27 */
28 protected $subject;
29
30 protected function setUp()
31 {
32 $this->subject = new \TYPO3\CMS\Extbase\Domain\Model\FrontendUser();
33 }
34
35 /**
36 * @test
37 */
38 public function getUsernameInitiallyReturnsEmptyString()
39 {
40 $this->assertSame('', $this->subject->getUsername());
41 }
42
43 /**
44 * @test
45 */
46 public function setUsernameSetsUsername()
47 {
48 $username = 'don.juan';
49 $this->subject->setUsername($username);
50 $this->assertSame($username, $this->subject->getUsername());
51 }
52
53 /**
54 * @test
55 */
56 public function getPasswordInitiallyReturnsEmptyString()
57 {
58 $this->assertSame('', $this->subject->getPassword());
59 }
60
61 /**
62 * @test
63 */
64 public function setPasswordSetsPassword()
65 {
66 $password = 'f00Bar';
67 $this->subject->setPassword($password);
68 $this->assertSame($password, $this->subject->getPassword());
69 }
70
71 /**
72 * @test
73 */
74 public function setUsergroupSetsUsergroup()
75 {
76 $usergroup = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
77 $usergroup->attach(new \TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup('foo'));
78 $this->subject->setUsergroup($usergroup);
79 $this->assertSame($usergroup, $this->subject->getUsergroup());
80 }
81
82 /**
83 * @test
84 */
85 public function addUsergroupAddsUserGroup()
86 {
87 $usergroup = new \TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup('foo');
88 $this->assertEquals(count($this->subject->getUsergroup()), 0);
89 $this->subject->addUsergroup($usergroup);
90 $this->assertEquals(count($this->subject->getUsergroup()), 1);
91 }
92
93 /**
94 * @test
95 */
96 public function removeUsergroupRemovesUsergroup()
97 {
98 $usergroup = new \TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup('foo');
99 $this->subject->addUsergroup($usergroup);
100 $this->assertEquals(count($this->subject->getUsergroup()), 1);
101 $this->subject->removeUsergroup($usergroup);
102 $this->assertEquals(count($this->subject->getUsergroup()), 0);
103 }
104
105 /**
106 * @test
107 */
108 public function getNameInitiallyReturnsEmptyString()
109 {
110 $this->assertSame('', $this->subject->getName());
111 }
112
113 /**
114 * @test
115 */
116 public function setNameSetsName()
117 {
118 $name = 'don juan';
119 $this->subject->setName($name);
120 $this->assertSame($name, $this->subject->getName());
121 }
122
123 /**
124 * @test
125 */
126 public function getFirstNameInitiallyReturnsEmptyString()
127 {
128 $this->assertSame('', $this->subject->getFirstName());
129 }
130
131 /**
132 * @test
133 */
134 public function setFirstNameSetsFirstName()
135 {
136 $firstName = 'don';
137 $this->subject->setFirstName($firstName);
138 $this->assertSame($firstName, $this->subject->getFirstName());
139 }
140
141 /**
142 * @test
143 */
144 public function getMiddleNameInitiallyReturnsEmptyString()
145 {
146 $this->assertSame('', $this->subject->getMiddleName());
147 }
148
149 /**
150 * @test
151 */
152 public function setMiddleNameSetsMiddleName()
153 {
154 $middleName = 'miguel';
155 $this->subject->setMiddleName($middleName);
156 $this->assertSame($middleName, $this->subject->getMiddleName());
157 }
158
159 /**
160 * @test
161 */
162 public function getLastNameInitiallyReturnsEmptyString()
163 {
164 $this->assertSame('', $this->subject->getLastName());
165 }
166
167 /**
168 * @test
169 */
170 public function setLastNameSetsLastName()
171 {
172 $lastName = 'juan';
173 $this->subject->setLastName($lastName);
174 $this->assertSame($lastName, $this->subject->getLastName());
175 }
176
177 /**
178 * @test
179 */
180 public function getAddressInitiallyReturnsEmptyString()
181 {
182 $this->assertSame('', $this->subject->getAddress());
183 }
184
185 /**
186 * @test
187 */
188 public function setAddressSetsAddress()
189 {
190 $address = 'foobar 42, foo';
191 $this->subject->setAddress($address);
192 $this->assertSame($address, $this->subject->getAddress());
193 }
194
195 /**
196 * @test
197 */
198 public function getTelephoneInitiallyReturnsEmptyString()
199 {
200 $this->assertSame('', $this->subject->getTelephone());
201 }
202
203 /**
204 * @test
205 */
206 public function setTelephoneSetsTelephone()
207 {
208 $telephone = '42';
209 $this->subject->setTelephone($telephone);
210 $this->assertSame($telephone, $this->subject->getTelephone());
211 }
212
213 /**
214 * @test
215 */
216 public function getFaxInitiallyReturnsEmptyString()
217 {
218 $this->assertSame('', $this->subject->getFax());
219 }
220
221 /**
222 * @test
223 */
224 public function setFaxSetsFax()
225 {
226 $fax = '42';
227 $this->subject->setFax($fax);
228 $this->assertSame($fax, $this->subject->getFax());
229 }
230
231 /**
232 * @test
233 */
234 public function getEmailInitiallyReturnsEmptyString()
235 {
236 $this->assertSame('', $this->subject->getEmail());
237 }
238
239 /**
240 * @test
241 */
242 public function setEmailSetsEmail()
243 {
244 $email = 'don.juan@example.com';
245 $this->subject->setEmail($email);
246 $this->assertSame($email, $this->subject->getEmail());
247 }
248
249 /**
250 * @test
251 */
252 public function getLockToDomainInitiallyReturnsEmptyString()
253 {
254 $this->assertSame('', $this->subject->getLockToDomain());
255 }
256
257 /**
258 * @test
259 */
260 public function setLockToDomainSetsLockToDomain()
261 {
262 $lockToDomain = 'foo.bar';
263 $this->subject->setLockToDomain($lockToDomain);
264 $this->assertSame($lockToDomain, $this->subject->getLockToDomain());
265 }
266
267 /**
268 * @test
269 */
270 public function getTitleInitiallyReturnsEmptyString()
271 {
272 $this->assertSame('', $this->subject->getTitle());
273 }
274
275 /**
276 * @test
277 */
278 public function setTitleSetsTitle()
279 {
280 $title = 'foobar';
281 $this->subject->setTitle($title);
282 $this->assertSame($title, $this->subject->getTitle());
283 }
284
285 /**
286 * @test
287 */
288 public function getZipInitiallyReturnsEmptyString()
289 {
290 $this->assertSame('', $this->subject->getZip());
291 }
292
293 /**
294 * @test
295 */
296 public function setZipSetsZip()
297 {
298 $zip = '42';
299 $this->subject->setZip($zip);
300 $this->assertSame($zip, $this->subject->getZip());
301 }
302
303 /**
304 * @test
305 */
306 public function getCityInitiallyReturnsEmptyString()
307 {
308 $this->assertSame('', $this->subject->getCity());
309 }
310
311 /**
312 * @test
313 */
314 public function setCitySetsCity()
315 {
316 $city = 'foo';
317 $this->subject->setCity($city);
318 $this->assertSame($city, $this->subject->getCity());
319 }
320
321 /**
322 * @test
323 */
324 public function getCountryInitiallyReturnsEmptyString()
325 {
326 $this->assertSame('', $this->subject->getCountry());
327 }
328
329 /**
330 * @test
331 */
332 public function setCountrySetsCountry()
333 {
334 $country = 'foo';
335 $this->subject->setCountry($country);
336 $this->assertSame($country, $this->subject->getCountry());
337 }
338
339 /**
340 * @test
341 */
342 public function getWwwInitiallyReturnsEmptyString()
343 {
344 $this->assertSame('', $this->subject->getWww());
345 }
346
347 /**
348 * @test
349 */
350 public function setWwwSetsWww()
351 {
352 $www = 'foo.bar';
353 $this->subject->setWww($www);
354 $this->assertSame($www, $this->subject->getWww());
355 }
356
357 /**
358 * @test
359 */
360 public function getCompanyInitiallyReturnsEmptyString()
361 {
362 $this->assertSame('', $this->subject->getCompany());
363 }
364
365 /**
366 * @test
367 */
368 public function setCompanySetsCompany()
369 {
370 $company = 'foo bar';
371 $this->subject->setCompany($company);
372 $this->assertSame($company, $this->subject->getCompany());
373 }
374
375 /**
376 * @test
377 */
378 public function getImageInitiallyReturnsEmptyString()
379 {
380 $this->assertSame(null, $this->subject->getImage());
381 }
382
383 /**
384 * @test
385 */
386 public function setImageSetsImage()
387 {
388 $images = new ObjectStorage();
389 $reference = new FileReference();
390 $reference->setPid(123);
391 $images->attach($reference);
392
393 $this->subject->setImage($images);
394 $this->assertSame($images, $this->subject->getImage());
395 }
396
397 /**
398 * @test
399 */
400 public function getLastloginInitiallyReturnsNull()
401 {
402 $this->assertNull($this->subject->getLastlogin());
403 }
404
405 /**
406 * @test
407 */
408 public function setLastloginSetsLastlogin()
409 {
410 $date = new \DateTime();
411 $this->subject->setLastlogin($date);
412 $this->assertSame($date, $this->subject->getLastlogin());
413 }
414 }