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