19 declare(strict_types=1);
37 $this->ilUserMock->expects($this->once())->method(
'getId')->willReturn($userId);
38 $this->ilUserMock->expects($this->once())->method(
'isAnonymous')->willReturn(
false);
40 $this->assertSame($userId, $this->
user->getUserId());
48 $this->ilUserMock->expects($this->once())->method(
'getId')->willReturn($userId);
49 $this->ilUserMock->expects($this->once())->method(
'isAnonymous')->willReturn(
true);
51 $this->ilChatroomMock->method(
'getRoomId')->willReturn($roomId);
60 $this->assertSame($userId, $this->
user->getUserId());
65 $this->ilUserMock->expects($this->once())->method(
'getId')->willReturn(0);
66 $this->ilUserMock->expects($this->once())->method(
'isAnonymous')->willReturn(
true);
68 $this->ilChatroomMock->method(
'getRoomId')->willReturn(99);
70 $this->assertNotNull($this->
user->getUserId());
80 $this->
user->setUsername($username);
81 $this->assertSame($expected, $this->
user->getUsername());
86 $username =
'username';
91 'username' => $username,
95 $this->ilChatroomMock->method(
'getRoomId')->willReturn(99);
97 $this->assertSame($username, $this->
user->getUsername());
114 $this->ilUserMock->expects($this->once())->method(
'getLogin')->willReturn($username);
115 $this->ilChatroomMock->method(
'getRoomId')->willReturn($roomId);
117 $this->assertSame($username, $this->
user->getUsername());
122 $this->ilChatroomMock->method(
'getSetting')->willReturn(
'#_anonymous');
124 $firstName = $this->
user->buildAnonymousName();
125 $secondName = $this->
user->buildAnonymousName();
127 $this->assertNotEquals($firstName, $secondName);
132 $username =
'username';
133 $this->ilUserMock->expects($this->once())->method(
'getLogin')->willReturn($username);
135 $this->assertSame($username, $this->
user->buildLogin());
140 $fullname =
'John Doe';
141 $this->ilUserMock->expects($this->once())->method(
'getPublicName')->willReturn($fullname);
143 $this->assertSame($fullname, $this->
user->buildFullname());
150 $this->ilUserMock->expects($this->once())->method(
'getFirstname')->willReturn($firstname);
151 $this->ilUserMock->expects($this->once())->method(
'getLastname')->willReturn($lastname);
153 $this->assertSame(
'J. Doe', $this->
user->buildShortname());
158 $this->ilUserMock->method(
'isAnonymous')->willReturn(
true);
159 $this->ilChatroomMock->method(
'getSetting')->willReturn(
'#_anonymous');
161 $first = $this->
user->getChatNameSuggestions();
162 $second = $this->
user->getChatNameSuggestions();
164 $this->assertNotEquals($first, $second);
169 $this->ilUserMock->method(
'isAnonymous')->willReturn(
false);
170 $this->ilUserMock->expects($this->once())->method(
'getFirstname')->willReturn(
'John');
171 $this->ilUserMock->expects($this->once())->method(
'getLastname')->willReturn(
'Doe');
172 $this->ilUserMock->expects($this->once())->method(
'getPublicName')->willReturn(
'John Doe');
173 $this->ilUserMock->expects($this->once())->method(
'getLogin')->willReturn(
'jdoe');
174 $this->ilChatroomMock->method(
'getSetting')->willReturn(
'#_anonymous');
176 $suggestions = $this->
user->getChatNameSuggestions();
178 $this->assertSame(
'John Doe', $suggestions[
'fullname']);
179 $this->assertSame(
'J. Doe', $suggestions[
'shortname']);
180 $this->assertSame(
'jdoe', $suggestions[
'login']);
189 [
'username',
'username'],
190 [
'>username<',
'>username<'],
198 $this->ilUserMock = $this->getMockBuilder(ilObjUser::class)->disableOriginalConstructor()->onlyMethods(
199 [
'getId',
'isAnonymous',
'getLogin',
'getPublicName',
'getFirstname',
'getLastname']
201 $this->ilChatroomMock = $this->getMockBuilder(ilChatroom::class)->disableOriginalConstructor()->onlyMethods(
202 [
'getRoomId',
'getSetting']
testSetUsername(string $username, string $expected)
usernameDataProvider
Class ilChatroomAbstractTest.
testGetUsernameFromIlObjUser()
Class ilChatroomUserTest.
testGetUserIdRandomGeneratedIfAnonymous()
testGetUserIdIfNotAnonymous()
testGetChatNameSuggestionsIfAnonymous()
testGetUsernameFromSession()
testGetChatNameSuggestionsIfNotAnonymous()
testGetUserIdFromSessionIfAnonymous()
static set(string $a_var, $a_val)
Set a value.