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 $db->expects($this->exactly(2))
35 [$this->stringContains(
'FROM osc_activity'), $this->isType(
'array'), $this->isType(
'array')],
36 [$this->stringContains(
'FROM osc_messages'), $this->isType(
'array'), $this->isType(
'array')]
38 ->willReturn($resultMock);
40 $db->expects($this->once())
42 ->with($this->stringContains(
'FROM osc_conversation'))
43 ->willReturn($resultMock);
45 $db->expects($this->exactly(10))->method(
'fetchAssoc')->with($resultMock)->willReturnOnConsecutiveCalls(
46 [
'conversation_id' =>
'1'],
47 [
'conversation_id' =>
'2'],
49 [
'conversation_id' =>
'1'],
50 [
'conversation_id' =>
'3'],
52 [
'participants' => json_encode([[
'id' => 1], [
'id' => 2], [
'id' => 3]], JSON_THROW_ON_ERROR)],
53 [
'participants' => json_encode([[
'id' => 1], [
'id' => 4]], JSON_THROW_ON_ERROR)],
54 [
'participants' => json_encode([[
'id' => 1], [
'id' => 6]], JSON_THROW_ON_ERROR)],
58 $repository =
new class ($db, $user) extends
Subscriber {
59 public function getDataByUserIds(array $usrIds): array
62 foreach ($usrIds as $usrId) {
64 'public_name' =>
'User ' . $usrId,
65 'profile_image' =>
'Image ' . $usrId
73 $profile_data = $repository->getInitialUserProfileData();
74 $this->assertCount(5, $profile_data);
Class ilOnScreenChatBaseTest.
testSubscribersCanBeRetrieved()