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')) {
28 include_once(
"./Services/PHPUnit/classes/class.ilUnitUtil.php");
29 ilUnitUtil::performInitialisation();
31 chdir(dirname(__FILE__));
35 require_once
'./Modules/Chatroom/classes/class.ilChatroomUser.php';
37 $this->ilUserMock = $this->getMockBuilder(
'ilObjUser')->disableOriginalConstructor()->setMethods(
38 array(
'getId',
'isAnonymous',
'getLogin',
'getPublicName',
'getFirstname',
'getLastname')
40 $this->ilChatroomMock = $this->getMockBuilder(
'ilChatroom')->disableOriginalConstructor()->setMethods(
41 array(
'getRoomId',
'getSetting')
Create styles array
The data for the language used.
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
◆ testBuildAnonymousName()
ilChatroomUserTest::testBuildAnonymousName |
( |
| ) |
|
Definition at line 129 of file class.ilChatroomUserTest.php.
References user().
131 $this->ilChatroomMock->expects($this->any())->method(
'getSetting')->will($this->returnValue(
'#_anonymous'));
133 $firstName = $this->
user->buildAnonymousName();
134 $secondName = $this->
user->buildAnonymousName();
136 $this->assertNotEquals($firstName, $secondName);
◆ testBuildFullname()
ilChatroomUserTest::testBuildFullname |
( |
| ) |
|
Definition at line 147 of file class.ilChatroomUserTest.php.
References user().
149 $fullname =
'John Doe';
150 $this->ilUserMock->expects($this->once())->method(
'getPublicName')->will($this->returnValue($fullname));
152 $this->assertEquals($fullname, $this->
user->buildFullname());
◆ testBuildLogin()
ilChatroomUserTest::testBuildLogin |
( |
| ) |
|
Definition at line 139 of file class.ilChatroomUserTest.php.
References user().
141 $username =
'username';
142 $this->ilUserMock->expects($this->once())->method(
'getLogin')->will($this->returnValue($username));
144 $this->assertEquals($username, $this->
user->buildLogin());
◆ testBuildShortname()
ilChatroomUserTest::testBuildShortname |
( |
| ) |
|
Definition at line 155 of file class.ilChatroomUserTest.php.
References user().
159 $this->ilUserMock->expects($this->once())->method(
'getFirstname')->will($this->returnValue($firstname));
160 $this->ilUserMock->expects($this->once())->method(
'getLastname')->will($this->returnValue($lastname));
162 $this->assertEquals(
'J. Doe', $this->
user->buildShortname());
◆ testConstructor()
ilChatroomUserTest::testConstructor |
( |
| ) |
|
◆ testGetChatNameSuggestionsIfAnonymous()
ilChatroomUserTest::testGetChatNameSuggestionsIfAnonymous |
( |
| ) |
|
Definition at line 165 of file class.ilChatroomUserTest.php.
References user().
167 $this->ilUserMock->expects($this->any())->method(
'isAnonymous')->will($this->returnValue(
true));
168 $this->ilChatroomMock->expects($this->any())->method(
'getSetting')->will($this->returnValue(
'#_anonymous'));
170 $first = $this->
user->getChatNameSuggestions();
171 $second = $this->
user->getChatNameSuggestions();
173 $this->assertNotEquals($first, $second);
◆ testGetChatNameSuggestionsIfNotAnonymous()
ilChatroomUserTest::testGetChatNameSuggestionsIfNotAnonymous |
( |
| ) |
|
Definition at line 176 of file class.ilChatroomUserTest.php.
References user().
178 $this->ilUserMock->expects($this->any())->method(
'isAnonymous')->will($this->returnValue(
false));
179 $this->ilUserMock->expects($this->once())->method(
'getFirstname')->will($this->returnValue(
'John'));
180 $this->ilUserMock->expects($this->once())->method(
'getLastname')->will($this->returnValue(
'Doe'));
181 $this->ilUserMock->expects($this->once())->method(
'getPublicName')->will($this->returnValue(
'John Doe'));
182 $this->ilUserMock->expects($this->once())->method(
'getLogin')->will($this->returnValue(
'jdoe'));
183 $this->ilChatroomMock->expects($this->any())->method(
'getSetting')->will($this->returnValue(
'#_anonymous'));
185 $suggestions = $this->
user->getChatNameSuggestions();
187 $this->assertEquals(
'John Doe', $suggestions[
'fullname']);
188 $this->assertEquals(
'J. Doe', $suggestions[
'shortname']);
189 $this->assertEquals(
'jdoe', $suggestions[
'login']);
◆ testGetUserIdFromSessionIfAnonymous()
ilChatroomUserTest::testGetUserIdFromSessionIfAnonymous |
( |
| ) |
|
Definition at line 62 of file class.ilChatroomUserTest.php.
References $_SESSION, array, and user().
67 $this->ilUserMock->expects($this->once())->method(
'getId')->will($this->returnValue($userId));
68 $this->ilUserMock->expects($this->once())->method(
'isAnonymous')->will($this->returnValue(
true));
70 $this->ilChatroomMock->expects($this->any())->method(
'getRoomId')->will($this->returnValue($roomId));
78 $this->assertEquals($userId, $this->
user->getUserId());
Create styles array
The data for the language used.
◆ testGetUserIdIfNotAnonymous()
ilChatroomUserTest::testGetUserIdIfNotAnonymous |
( |
| ) |
|
Definition at line 52 of file class.ilChatroomUserTest.php.
References user().
56 $this->ilUserMock->expects($this->once())->method(
'getId')->will($this->returnValue($userId));
57 $this->ilUserMock->expects($this->once())->method(
'isAnonymous')->will($this->returnValue(
false));
59 $this->assertEquals($userId, $this->
user->getUserId());
◆ testGetUserIdRandomGeneratedIfAnonymous()
ilChatroomUserTest::testGetUserIdRandomGeneratedIfAnonymous |
( |
| ) |
|
Definition at line 81 of file class.ilChatroomUserTest.php.
References user().
83 $this->ilUserMock->expects($this->once())->method(
'getId')->will($this->returnValue(null));
84 $this->ilUserMock->expects($this->once())->method(
'isAnonymous')->will($this->returnValue(
true));
86 $this->ilChatroomMock->expects($this->any())->method(
'getRoomId')->will($this->returnValue(99));
88 $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 117 of file class.ilChatroomUserTest.php.
References $_SESSION, and user().
121 $_SESSION[
'chat'][$roomId][
'username'] =
'';
123 $this->ilUserMock->expects($this->once())->method(
'getLogin')->will($this->returnValue($username));
124 $this->ilChatroomMock->expects($this->any())->method(
'getRoomId')->will($this->returnValue($roomId));
126 $this->assertEquals($username, $this->
user->getUsername());
◆ testGetUsernameFromSession()
ilChatroomUserTest::testGetUsernameFromSession |
( |
| ) |
|
Definition at line 102 of file class.ilChatroomUserTest.php.
References $_SESSION, and user().
104 $username =
'username';
106 $_SESSION[
'chat'][$roomId][
'username'] = $username;
108 $this->ilChatroomMock->expects($this->any())->method(
'getRoomId')->will($this->returnValue(99));
110 $this->assertEquals($username, $this->
user->getUsername());
◆ testSetUsername()
ilChatroomUserTest::testSetUsername |
( |
|
$username, |
|
|
|
$expected |
|
) |
| |
usernameDataProvider
- Parameters
-
string | $username | |
string | $expected | |
Definition at line 96 of file class.ilChatroomUserTest.php.
References user().
98 $this->
user->setUsername($username);
99 $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: