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