ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
SubscriberRepositoryTest Class Reference
+ Inheritance diagram for SubscriberRepositoryTest:
+ Collaboration diagram for SubscriberRepositoryTest:

Public Member Functions

 testSubscribersCanBeRetrieved ()
 

Detailed Description

Definition at line 23 of file SubscriberRepositoryTest.php.

Member Function Documentation

◆ testSubscribersCanBeRetrieved()

SubscriberRepositoryTest::testSubscribersCanBeRetrieved ( )

Definition at line 25 of file SubscriberRepositoryTest.php.

References $data.

25  : void
26  {
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);
31 
32  $db->expects($this->exactly(2))
33  ->method('queryF')
34  ->withConsecutive(
35  [$this->stringContains('FROM osc_activity'), $this->isType('array'), $this->isType('array')],
36  [$this->stringContains('FROM osc_messages'), $this->isType('array'), $this->isType('array')]
37  )
38  ->willReturn($resultMock);
39 
40  $db->expects($this->once())
41  ->method('query')
42  ->with($this->stringContains('FROM osc_conversation'))
43  ->willReturn($resultMock);
44 
45  $db->expects($this->exactly(10))->method('fetchAssoc')->with($resultMock)->willReturnOnConsecutiveCalls(
46  ['conversation_id' => '1'],
47  ['conversation_id' => '2'],
48  null,
49  ['conversation_id' => '1'],
50  ['conversation_id' => '3'],
51  null,
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)],
55  null,
56  );
57 
58  $repository = new class ($db, $user) extends Subscriber {
59  public function getDataByUserIds(array $usrIds): array
60  {
61  $data = [];
62  foreach ($usrIds as $usrId) {
63  $data[$usrId] = [
64  'public_name' => 'User ' . $usrId,
65  'profile_image' => 'Image ' . $usrId
66  ];
67  }
68 
69  return $data;
70  }
71  };
72 
73  $profile_data = $repository->getInitialUserProfileData();
74  $this->assertCount(5, $profile_data);
75  }

The documentation for this class was generated from the following file: