19 declare(strict_types=1);
    27         $user = $this->getMockBuilder(ilObjUser::class)->onlyMethods([
'getId'])->disableOriginalConstructor()->getMock();
    28         $user->method(
'getId')->willReturn(1);
    29         $db = $this->createMock(ilDBInterface::class);
    30         $resultMock = $this->createMock(ilDBStatement::class);
    32         $consecutive = [
'FROM osc_activity', 
'FROM osc_messages'];
    33         $db->expects($this->exactly(2))
    36                 $this->callback(
function ($value) use (&$consecutive) {
    37                     $this->assertStringContainsString(array_shift($consecutive), $value);
    40                 $this->isType(
'array'),
    41                 $this->isType(
'array')
    43             ->willReturn($resultMock);
    45         $db->expects($this->once())
    47             ->with($this->stringContains(
'FROM osc_conversation'))
    48             ->willReturn($resultMock);
    50         $db->expects($this->exactly(10))->method(
'fetchAssoc')->with($resultMock)->willReturnOnConsecutiveCalls(
    51             [
'conversation_id' => 
'1'],
    52             [
'conversation_id' => 
'2'],
    54             [
'conversation_id' => 
'1'],
    55             [
'conversation_id' => 
'3'],
    57             [
'participants' => json_encode([[
'id' => 1], [
'id' => 2], [
'id' => 3]], JSON_THROW_ON_ERROR)],
    58             [
'participants' => json_encode([[
'id' => 1], [
'id' => 4]], JSON_THROW_ON_ERROR)],
    59             [
'participants' => json_encode([[
'id' => 1], [
'id' => 6]], JSON_THROW_ON_ERROR)],
    63         $repository = 
new class ($db, $user) extends 
Subscriber {
    64             public function getDataByUserIds(array $usrIds): array
    67                 foreach ($usrIds as $usrId) {
    69                         'public_name' => 
'User ' . $usrId,
    70                         'profile_image' => 
'Image ' . $usrId
    78         $profile_data = $repository->getInitialUserProfileData();
    79         $this->assertCount(5, $profile_data);
 
testSubscribersCanBeRetrieved()
 
Class ilOnScreenChatBaseTest.