Class ilChatroomUserTest.
More...
◆ setUp()
ilChatroomUserTest::setUp |
( |
| ) |
|
|
protected |
Definition at line 25 of file class.ilChatroomUserTest.php.
References array, defined, and user().
27 if(
defined(
'ILIAS_PHPUNIT_CONTEXT'))
29 include_once(
"./Services/PHPUnit/classes/class.ilUnitUtil.php");
30 ilUnitUtil::performInitialisation();
34 chdir(dirname(__FILE__));
38 require_once
'./Modules/Chatroom/classes/class.ilChatroomUser.php';
40 $this->ilUserMock = $this->getMockBuilder(
'ilObjUser')->disableOriginalConstructor()->setMethods(
41 array(
'getId',
'isAnonymous',
'getLogin',
'getPublicName',
'getFirstname',
'getLastname')
43 $this->ilChatroomMock = $this->getMockBuilder(
'ilChatroom')->disableOriginalConstructor()->setMethods(
44 array(
'getRoomId',
'getSetting')
Create styles array
The data for the language used.
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
◆ testBuildAnonymousName()
ilChatroomUserTest::testBuildAnonymousName |
( |
| ) |
|
Definition at line 132 of file class.ilChatroomUserTest.php.
References user().
134 $this->ilChatroomMock->expects($this->any())->method(
'getSetting')->will($this->returnValue(
'#_anonymous'));
136 $firstName = $this->
user->buildAnonymousName();
137 $secondName = $this->
user->buildAnonymousName();
139 $this->assertNotEquals($firstName, $secondName);
◆ testBuildFullname()
ilChatroomUserTest::testBuildFullname |
( |
| ) |
|
Definition at line 150 of file class.ilChatroomUserTest.php.
References user().
152 $fullname =
'John Doe';
153 $this->ilUserMock->expects($this->once())->method(
'getPublicName')->will($this->returnValue($fullname));
155 $this->assertEquals($fullname, $this->
user->buildFullname());
◆ testBuildLogin()
ilChatroomUserTest::testBuildLogin |
( |
| ) |
|
Definition at line 142 of file class.ilChatroomUserTest.php.
References user().
144 $username =
'username';
145 $this->ilUserMock->expects($this->once())->method(
'getLogin')->will($this->returnValue($username));
147 $this->assertEquals($username, $this->
user->buildLogin());
◆ testBuildShortname()
ilChatroomUserTest::testBuildShortname |
( |
| ) |
|
Definition at line 158 of file class.ilChatroomUserTest.php.
References user().
162 $this->ilUserMock->expects($this->once())->method(
'getFirstname')->will($this->returnValue($firstname));
163 $this->ilUserMock->expects($this->once())->method(
'getLastname')->will($this->returnValue($lastname));
165 $this->assertEquals(
'J. Doe', $this->
user->buildShortname());
◆ testConstructor()
ilChatroomUserTest::testConstructor |
( |
| ) |
|
◆ testGetChatNameSuggestionsIfAnonymous()
ilChatroomUserTest::testGetChatNameSuggestionsIfAnonymous |
( |
| ) |
|
Definition at line 168 of file class.ilChatroomUserTest.php.
References user().
170 $this->ilUserMock->expects($this->any())->method(
'isAnonymous')->will($this->returnValue(
true));
171 $this->ilChatroomMock->expects($this->any())->method(
'getSetting')->will($this->returnValue(
'#_anonymous'));
173 $first = $this->
user->getChatNameSuggestions();
174 $second = $this->
user->getChatNameSuggestions();
176 $this->assertNotEquals($first, $second);
◆ testGetChatNameSuggestionsIfNotAnonymous()
ilChatroomUserTest::testGetChatNameSuggestionsIfNotAnonymous |
( |
| ) |
|
Definition at line 179 of file class.ilChatroomUserTest.php.
References user().
181 $this->ilUserMock->expects($this->any())->method(
'isAnonymous')->will($this->returnValue(
false));
182 $this->ilUserMock->expects($this->once())->method(
'getFirstname')->will($this->returnValue(
'John'));
183 $this->ilUserMock->expects($this->once())->method(
'getLastname')->will($this->returnValue(
'Doe'));
184 $this->ilUserMock->expects($this->once())->method(
'getPublicName')->will($this->returnValue(
'John Doe'));
185 $this->ilUserMock->expects($this->once())->method(
'getLogin')->will($this->returnValue(
'jdoe'));
186 $this->ilChatroomMock->expects($this->any())->method(
'getSetting')->will($this->returnValue(
'#_anonymous'));
188 $suggestions = $this->
user->getChatNameSuggestions();
190 $this->assertEquals(
'John Doe', $suggestions[
'fullname']);
191 $this->assertEquals(
'J. Doe', $suggestions[
'shortname']);
192 $this->assertEquals(
'jdoe', $suggestions[
'login']);
◆ testGetUserIdFromSessionIfAnonymous()
ilChatroomUserTest::testGetUserIdFromSessionIfAnonymous |
( |
| ) |
|
Definition at line 65 of file class.ilChatroomUserTest.php.
References $_SESSION, array, and user().
70 $this->ilUserMock->expects($this->once())->method(
'getId')->will($this->returnValue($userId));
71 $this->ilUserMock->expects($this->once())->method(
'isAnonymous')->will($this->returnValue(
true));
73 $this->ilChatroomMock->expects($this->any())->method(
'getRoomId')->will($this->returnValue($roomId));
81 $this->assertEquals($userId, $this->
user->getUserId());
Create styles array
The data for the language used.
◆ testGetUserIdIfNotAnonymous()
ilChatroomUserTest::testGetUserIdIfNotAnonymous |
( |
| ) |
|
Definition at line 55 of file class.ilChatroomUserTest.php.
References user().
59 $this->ilUserMock->expects($this->once())->method(
'getId')->will($this->returnValue($userId));
60 $this->ilUserMock->expects($this->once())->method(
'isAnonymous')->will($this->returnValue(
false));
62 $this->assertEquals($userId, $this->
user->getUserId());
◆ testGetUserIdRandomGeneratedIfAnonymous()
ilChatroomUserTest::testGetUserIdRandomGeneratedIfAnonymous |
( |
| ) |
|
Definition at line 84 of file class.ilChatroomUserTest.php.
References user().
86 $this->ilUserMock->expects($this->once())->method(
'getId')->will($this->returnValue(null));
87 $this->ilUserMock->expects($this->once())->method(
'isAnonymous')->will($this->returnValue(
true));
89 $this->ilChatroomMock->expects($this->any())->method(
'getRoomId')->will($this->returnValue(99));
91 $this->assertNotNull($this->
user->getUserId());
◆ testGetUsernameFromIlObjUser()
ilChatroomUserTest::testGetUsernameFromIlObjUser |
( |
| ) |
|
- Todo:
- if required session value is not set, there will be a warning.
Need to check if required value isset.
Definition at line 120 of file class.ilChatroomUserTest.php.
References $_SESSION, and user().
124 $_SESSION[
'chat'][$roomId][
'username'] =
'';
126 $this->ilUserMock->expects($this->once())->method(
'getLogin')->will($this->returnValue($username));
127 $this->ilChatroomMock->expects($this->any())->method(
'getRoomId')->will($this->returnValue($roomId));
129 $this->assertEquals($username, $this->
user->getUsername());
◆ testGetUsernameFromSession()
ilChatroomUserTest::testGetUsernameFromSession |
( |
| ) |
|
Definition at line 105 of file class.ilChatroomUserTest.php.
References $_SESSION, and user().
107 $username =
'username';
109 $_SESSION[
'chat'][$roomId][
'username'] = $username;
111 $this->ilChatroomMock->expects($this->any())->method(
'getRoomId')->will($this->returnValue(99));
113 $this->assertEquals($username, $this->
user->getUsername());
◆ testSetUsername()
ilChatroomUserTest::testSetUsername |
( |
|
$username, |
|
|
|
$expected |
|
) |
| |
usernameDataProvider
- Parameters
-
string | $username | |
string | $expected | |
Definition at line 99 of file class.ilChatroomUserTest.php.
References user().
101 $this->
user->setUsername($username);
102 $this->assertEquals($expected, $this->
user->getUsername());
◆ usernameDataProvider()
ilChatroomUserTest::usernameDataProvider |
( |
| ) |
|
◆ $ilChatroomMock
ilChatroomUserTest::$ilChatroomMock |
|
protected |
◆ $ilUserMock
ilChatroomUserTest::$ilUserMock |
|
protected |
◆ $user
ilChatroomUserTest::$user |
|
protected |
The documentation for this class was generated from the following file: