[!!!][TASK] Extract testing framework for TYPO3
[Packages/TYPO3.CMS.git] / typo3 / sysext / beuser / Tests / Unit / Domain / Model / BackendUserTest.php
1 <?php
2 namespace TYPO3\CMS\Beuser\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 BackendUserTest extends \TYPO3\CMS\Components\TestingFramework\Core\UnitTestCase
21 {
22 /**
23 * @var \TYPO3\CMS\Beuser\Domain\Model\BackendUser
24 */
25 protected $subject;
26
27 protected function setUp()
28 {
29 $this->subject = new \TYPO3\CMS\Beuser\Domain\Model\BackendUser();
30 }
31
32 /**
33 * @test
34 */
35 public function getUidReturnsInitialValueForInt()
36 {
37 $this->assertTrue($this->subject->getUid() === null, 'Not uid set after initialization.');
38 }
39
40 /**
41 * @test
42 */
43 public function getUserNameReturnsInitialValueForString()
44 {
45 $this->assertTrue($this->subject->getUserName() === '', 'Username not empty');
46 }
47
48 /**
49 * @test
50 */
51 public function setUserNameForStringSetsUserName()
52 {
53 $newUserName = 'DonJuan';
54 $this->subject->setUserName($newUserName);
55 $this->assertSame($this->subject->getUserName(), $newUserName);
56 }
57
58 /**
59 * @test
60 */
61 public function getRealNameReturnInitialValueForString()
62 {
63 $this->assertTrue($this->subject->getRealName() === '', 'Real name not empty');
64 }
65
66 /**
67 * @test
68 */
69 public function setRealNameForStringSetsName()
70 {
71 $realName = 'Conceived at T3CON2018';
72 $this->subject->setRealName($realName);
73 $this->assertSame($this->subject->getRealName(), $realName);
74 }
75
76 /**
77 * @test
78 */
79 public function getAdminReturnInitialValueForBoolean()
80 {
81 $this->assertTrue($this->subject->getIsAdministrator() === false, 'Admin status is correct.');
82 }
83
84 /**
85 * @test
86 */
87 public function setAdminToTrueSetsAdmin()
88 {
89 $this->subject->setIsAdministrator(true);
90 $this->assertTrue($this->subject->getIsAdministrator(), 'Admin status is not true, after setting to true.');
91 }
92
93 /**
94 * @test
95 */
96 public function setAdminToFalseSetsAdmin()
97 {
98 $this->subject->setIsAdministrator(false);
99 $this->assertFalse($this->subject->getIsAdministrator(), 'Admin status is not false, after setting to false.');
100 }
101 }