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());
78 $this->
user->setUsername($username);
79 $this->assertSame($expected, $this->
user->getUsername());
84 $username =
'username';
89 'username' => $username,
93 $this->ilChatroomMock->method(
'getRoomId')->willReturn(99);
95 $this->assertSame($username, $this->
user->getUsername());
112 $this->ilUserMock->expects($this->once())->method(
'getPublicName')->willReturn($username);
113 $this->ilChatroomMock->method(
'getRoomId')->willReturn($roomId);
115 $this->assertSame($username, $this->
user->getUsername());
120 $this->ilChatroomMock->method(
'getSetting')->willReturn(
'#_anonymous');
122 $firstName = $this->
user->buildAnonymousName();
123 $secondName = $this->
user->buildAnonymousName();
125 $this->assertNotEquals($firstName, $secondName);
130 $username =
'username';
131 $this->ilUserMock->expects($this->once())->method(
'getLogin')->willReturn($username);
133 $this->assertSame($username, $this->
user->buildLogin());
138 $fullname =
'John Doe';
139 $this->ilUserMock->expects($this->once())->method(
'getPublicName')->willReturn($fullname);
141 $this->assertSame($fullname, $this->
user->buildFullname());
148 $this->ilUserMock->expects($this->once())->method(
'getFirstname')->willReturn($firstname);
149 $this->ilUserMock->expects($this->once())->method(
'getLastname')->willReturn($lastname);
151 $this->assertSame(
'J. Doe', $this->
user->buildShortname());
156 $this->ilUserMock->method(
'isAnonymous')->willReturn(
true);
157 $this->ilChatroomMock->method(
'getSetting')->willReturn(
'#_anonymous');
159 $first = $this->
user->getChatNameSuggestions();
160 $second = $this->
user->getChatNameSuggestions();
162 $this->assertNotEquals($first, $second);
167 $this->ilUserMock->method(
'isAnonymous')->willReturn(
false);
168 $this->ilUserMock->expects($this->once())->method(
'getFirstname')->willReturn(
'John');
169 $this->ilUserMock->expects($this->once())->method(
'getLastname')->willReturn(
'Doe');
170 $this->ilUserMock->expects($this->once())->method(
'getPublicName')->willReturn(
'John Doe');
171 $this->ilUserMock->expects($this->once())->method(
'getLogin')->willReturn(
'jdoe');
172 $this->ilChatroomMock->method(
'getSetting')->willReturn(
'#_anonymous');
174 $suggestions = $this->
user->getChatNameSuggestions();
176 $this->assertSame(
'John Doe', $suggestions[
'fullname']);
177 $this->assertSame(
'J. Doe', $suggestions[
'shortname']);
178 $this->assertSame(
'jdoe', $suggestions[
'login']);
184 [
'username',
'username'],
185 [
'>username<',
'>username<'],
193 $this->ilUserMock = $this->getMockBuilder(ilObjUser::class)->disableOriginalConstructor()->onlyMethods(
194 [
'getId',
'isAnonymous',
'getLogin',
'getPublicName',
'getFirstname',
'getLastname']
196 $this->ilChatroomMock = $this->getMockBuilder(ilChatroom::class)->disableOriginalConstructor()->onlyMethods(
197 [
'getRoomId',
'getSetting']
testSetUsername(string $username, string $expected)
usernameDataProvider
testGetUsernameFromIlObjUser()
Class ilChatroomUserTest.
testGetUserIdRandomGeneratedIfAnonymous()
testGetUserIdIfNotAnonymous()
testGetChatNameSuggestionsIfAnonymous()
Class ilChatroomAbstractTest.
testGetUsernameFromSession()
testGetChatNameSuggestionsIfNotAnonymous()
testGetUserIdFromSessionIfAnonymous()
static set(string $a_var, $a_val)
Set a value.
static usernameDataProvider()