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