ILIAS  trunk Revision v11.0_alpha-1811-gd2d5443e411
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilBuddyListTestCase Class Reference
+ Inheritance diagram for ilBuddyListTestCase:
+ Collaboration diagram for ilBuddyListTestCase:

Public Member Functions

 testInstanceCanBeCreatedByGlobalUserObject ()
 
 testInstanceCannotBeCreatedByAnonymousGlobalUserObject ()
 
 testInstanceByBeCreatedBySingletonMethod ()
 
 testListIsInitiallyEmpty ()
 
 testRepositoryIsEnquiredToFetchRelationsWhenRequestedExplicitly ()
 
 testRepositoryIsEnquiredOnlyOnceToFetchRelationsWhenCalledImplicitly ()
 
 testRelationRequestCannotBeApprovedByTheRelationOwner ()
 
 testRelationRequestCanBeApprovedByTheRelationTarget ()
 
 testRelationRequestCannotBeIgnoredByTheRelationOwner ()
 
 testRelationRequestCanBeIgnoredByTheRelationTarget ()
 
 testRelationCannotBeRequestedForAnonymous ()
 
 testRelationCannotBeRequestedForUnknownUserAccounts ()
 
 testRepositoryIsEnquiredWhenBuddyListShouldBeDestroyed ()
 
 testUnlinkedRelationIsReturnedWhenRelationWasRequestedForAnUnknownBuddyId ()
 
 testValuesCanBeFetchedByGettersWhenSetBySetters ()
 
 testDifferentRelationStatesCanBeRetrieved ()
 
 testAlreadyGivenStateExceptionIsThrownWhenALinkedRelationShouldBeMarkedAsLinked ()
 
 testAlreadyGivenStateExceptionIsThrownWhenAnIgnoredRelationShouldBeMarkedAsIgnored ()
 
 testAlreadyGivenStateExceptionIsThrownWhenAnUnlinkedRelationShouldBeMarkedAsUnlinked ()
 
 testAlreadyGivenStateExceptionIsThrownWhenARequestedRelationShouldBeMarkedAsRequested ()
 
 testStateTransitionExceptionIsThrownWhenALinkedRelationShouldBeMarkedAsIgnored ()
 

Protected Member Functions

 setUp ()
 
- Protected Member Functions inherited from ilBuddySystemBaseTestCase
 setUp ()
 
 tearDown ()
 
 setGlobalVariable (string $name, mixed $value)
 

Private Member Functions

 setPriorRelationState (ilBuddySystemRelation $relation, ilBuddySystemRelationState $state)
 

Private Attributes

const BUDDY_LIST_OWNER_ID = -1
 
const BUDDY_LIST_BUDDY_ID = -2
 

Detailed Description

Definition at line 21 of file ilBuddyListTestCase.php.

Member Function Documentation

◆ setPriorRelationState()

ilBuddyListTestCase::setPriorRelationState ( ilBuddySystemRelation  $relation,
ilBuddySystemRelationState  $state 
)
private

◆ setUp()

ilBuddyListTestCase::setUp ( )
protected

Definition at line 26 of file ilBuddyListTestCase.php.

References ilBuddySystemBaseTestCase\setGlobalVariable().

26  : void
27  {
28  parent::setUp();
29 
30  $this->setGlobalVariable(
31  'ilAppEventHandler',
32  $this->getMockBuilder(ilAppEventHandler::class)->disableOriginalConstructor()->onlyMethods(['raise'])->getMock()
33  );
34  $this->setGlobalVariable('ilDB', $this->createMock(ilDBInterface::class));
35  $this->setGlobalVariable(
36  'lng',
37  $this->getMockBuilder(ilLanguage::class)
38  ->disableOriginalConstructor()
39  ->onlyMethods(['txt', 'loadLanguageModule'])
40  ->getMock()
41  );
42  }
setGlobalVariable(string $name, mixed $value)
+ Here is the call graph for this function:

◆ testAlreadyGivenStateExceptionIsThrownWhenALinkedRelationShouldBeMarkedAsLinked()

ilBuddyListTestCase::testAlreadyGivenStateExceptionIsThrownWhenALinkedRelationShouldBeMarkedAsLinked ( )

Definition at line 519 of file ilBuddyListTestCase.php.

References $relation, ilBuddyList\getInstanceByUserId(), and setPriorRelationState().

519  : void
520  {
521  $this->expectException(ilBuddySystemRelationStateAlreadyGivenException::class);
522 
523  $buddyList = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
524  $buddyList->reset();
525 
526  $state = new ilBuddySystemLinkedRelationState();
527 
529  $state,
530  self::BUDDY_LIST_OWNER_ID,
531  self::BUDDY_LIST_BUDDY_ID,
532  false,
533  time()
534  );
535 
536  $this->setPriorRelationState($relation, $state);
537 
538  $buddyList->link($relation);
539  }
$relation
setPriorRelationState(ilBuddySystemRelation $relation, ilBuddySystemRelationState $state)
static getInstanceByUserId(int $usrId)
+ Here is the call graph for this function:

◆ testAlreadyGivenStateExceptionIsThrownWhenAnIgnoredRelationShouldBeMarkedAsIgnored()

ilBuddyListTestCase::testAlreadyGivenStateExceptionIsThrownWhenAnIgnoredRelationShouldBeMarkedAsIgnored ( )

Definition at line 541 of file ilBuddyListTestCase.php.

References $relation, ilBuddyList\getInstanceByUserId(), and setPriorRelationState().

541  : void
542  {
543  $this->expectException(ilBuddySystemRelationStateAlreadyGivenException::class);
544 
545  $buddyList = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
546  $buddyList->reset();
547 
549 
551  $state,
552  self::BUDDY_LIST_BUDDY_ID,
553  self::BUDDY_LIST_OWNER_ID,
554  false,
555  time()
556  );
557 
558  $this->setPriorRelationState($relation, $state);
559 
560  $buddyList->ignore($relation);
561  }
$relation
setPriorRelationState(ilBuddySystemRelation $relation, ilBuddySystemRelationState $state)
static getInstanceByUserId(int $usrId)
+ Here is the call graph for this function:

◆ testAlreadyGivenStateExceptionIsThrownWhenAnUnlinkedRelationShouldBeMarkedAsUnlinked()

ilBuddyListTestCase::testAlreadyGivenStateExceptionIsThrownWhenAnUnlinkedRelationShouldBeMarkedAsUnlinked ( )

Definition at line 563 of file ilBuddyListTestCase.php.

References $relation, ilBuddyList\getInstanceByUserId(), and setPriorRelationState().

563  : void
564  {
565  $this->expectException(ilBuddySystemRelationStateAlreadyGivenException::class);
566 
567  $buddyList = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
568  $buddyList->reset();
569 
570  $state = new ilBuddySystemUnlinkedRelationState();
571 
573  $state,
574  self::BUDDY_LIST_OWNER_ID,
575  self::BUDDY_LIST_BUDDY_ID,
576  false,
577  time()
578  );
579 
580  $this->setPriorRelationState($relation, $state);
581 
582  $buddyList->unlink($relation);
583  }
$relation
Class ilBuddySystemUnlinkedRelationState.
setPriorRelationState(ilBuddySystemRelation $relation, ilBuddySystemRelationState $state)
static getInstanceByUserId(int $usrId)
+ Here is the call graph for this function:

◆ testAlreadyGivenStateExceptionIsThrownWhenARequestedRelationShouldBeMarkedAsRequested()

ilBuddyListTestCase::testAlreadyGivenStateExceptionIsThrownWhenARequestedRelationShouldBeMarkedAsRequested ( )

Definition at line 585 of file ilBuddyListTestCase.php.

References $relation, ilBuddyList\getInstanceByUserId(), ilBuddySystemBaseTestCase\setGlobalVariable(), and setPriorRelationState().

585  : void
586  {
587  $this->expectException(ilBuddySystemRelationStateAlreadyGivenException::class);
588 
589  $buddyList = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
590  $buddyList->reset();
591 
593 
595  $state,
596  self::BUDDY_LIST_BUDDY_ID,
597  self::BUDDY_LIST_OWNER_ID,
598  false,
599  time()
600  );
601 
602  $this->setPriorRelationState($relation, $state);
603 
604  $db = $this->createMock(ilDBInterface::class);
605  $db->method('fetchAssoc')->willReturn([
606  'login' => 'phpunit'
607  ]);
608  $this->setGlobalVariable('ilDB', $db);
609 
610  $buddyList->request($relation);
611  }
$relation
setPriorRelationState(ilBuddySystemRelation $relation, ilBuddySystemRelationState $state)
static getInstanceByUserId(int $usrId)
setGlobalVariable(string $name, mixed $value)
+ Here is the call graph for this function:

◆ testDifferentRelationStatesCanBeRetrieved()

ilBuddyListTestCase::testDifferentRelationStatesCanBeRetrieved ( )

Definition at line 418 of file ilBuddyListTestCase.php.

References $relation, and ilBuddyList\getInstanceByUserId().

418  : void
419  {
420  $buddyList = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
421  $buddyList->reset();
422 
423  $relations = [];
424 
427  self::BUDDY_LIST_OWNER_ID,
428  self::BUDDY_LIST_BUDDY_ID,
429  false,
430  time()
431  );
432  $relations[self::BUDDY_LIST_BUDDY_ID] = $relation;
433 
436  self::BUDDY_LIST_BUDDY_ID + 1,
437  self::BUDDY_LIST_OWNER_ID,
438  false,
439  time()
440  );
441  $relations[self::BUDDY_LIST_BUDDY_ID + 1] = $relation;
442 
445  self::BUDDY_LIST_BUDDY_ID + 2,
446  self::BUDDY_LIST_OWNER_ID,
447  false,
448  time()
449  );
450  $relations[self::BUDDY_LIST_BUDDY_ID + 2] = $relation;
451 
454  self::BUDDY_LIST_BUDDY_ID + 3,
455  self::BUDDY_LIST_OWNER_ID,
456  false,
457  time()
458  );
459  $relations[self::BUDDY_LIST_BUDDY_ID + 3] = $relation;
460 
463  self::BUDDY_LIST_OWNER_ID,
464  self::BUDDY_LIST_BUDDY_ID + 4,
465  false,
466  time()
467  );
468  $relations[self::BUDDY_LIST_BUDDY_ID + 4] = $relation;
469 
472  self::BUDDY_LIST_BUDDY_ID + 5,
473  self::BUDDY_LIST_OWNER_ID,
474  false,
475  time()
476  );
477  $relations[self::BUDDY_LIST_BUDDY_ID + 5] = $relation;
478 
481  self::BUDDY_LIST_OWNER_ID,
482  self::BUDDY_LIST_BUDDY_ID + 6,
483  false,
484  time()
485  );
486  $relations[self::BUDDY_LIST_BUDDY_ID + 6] = $relation;
487 
490  self::BUDDY_LIST_OWNER_ID,
491  self::BUDDY_LIST_BUDDY_ID + 7,
492  false,
493  time()
494  );
495  $relations[self::BUDDY_LIST_BUDDY_ID + 7] = $relation;
496 
497  $repo = $this->getMockBuilder(ilBuddySystemRelationRepository::class)->disableOriginalConstructor()->getMock();
498  $repo->method('getAll')->willReturn($relations);
499  $buddyList->setRepository($repo);
500 
501  $this->assertCount(3, $buddyList->getLinkedRelations());
502  $this->assertCount(1, $buddyList->getRequestRelationsForOwner());
503  $this->assertCount(1, $buddyList->getRequestRelationsByOwner());
504  $this->assertCount(1, $buddyList->getIgnoredRelationsForOwner());
505  $this->assertCount(2, $buddyList->getIgnoredRelationsByOwner());
506  $this->assertEquals(array_keys($relations), $buddyList->getRelationUserIds());
507  }
$relation
static getInstanceByUserId(int $usrId)
+ Here is the call graph for this function:

◆ testInstanceByBeCreatedBySingletonMethod()

ilBuddyListTestCase::testInstanceByBeCreatedBySingletonMethod ( )

Definition at line 64 of file ilBuddyListTestCase.php.

References ilBuddyList\getInstanceByUserId().

64  : void
65  {
66  $relations = [
67  4711 => new ilBuddySystemRelation(
69  self::BUDDY_LIST_BUDDY_ID,
70  self::BUDDY_LIST_OWNER_ID,
71  false,
72  time()
73  ),
74  4712 => new ilBuddySystemRelation(
76  self::BUDDY_LIST_BUDDY_ID,
77  self::BUDDY_LIST_OWNER_ID,
78  false,
79  time()
80  )
81  ];
82 
83  $buddyList = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
84  $buddyList->setRelations(new ilBuddySystemRelationCollection($relations));
85  $otherBuddylist = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
86  $otherBuddylist->setRelations(new ilBuddySystemRelationCollection());
87 
88  $this->assertEquals($buddyList, $otherBuddylist);
89  }
Class ilBuddySystemUnlinkedRelationState.
static getInstanceByUserId(int $usrId)
Class ilBuddySystemRelationCollection A collection which contains all entries of a buddy list...
+ Here is the call graph for this function:

◆ testInstanceCanBeCreatedByGlobalUserObject()

ilBuddyListTestCase::testInstanceCanBeCreatedByGlobalUserObject ( )

Definition at line 44 of file ilBuddyListTestCase.php.

References ilBuddyList\getInstanceByGlobalUser(), and ilBuddySystemBaseTestCase\setGlobalVariable().

44  : void
45  {
46  $user = $this->getMockBuilder(ilObjUser::class)->disableOriginalConstructor()->onlyMethods(['getId'])->getMock();
47  $user->expects($this->once())->method('getId')->willReturn(self::BUDDY_LIST_OWNER_ID);
48  $this->setGlobalVariable('ilUser', $user);
49 
51  }
setGlobalVariable(string $name, mixed $value)
static getInstanceByGlobalUser(?ilObjUser $user=null)
+ Here is the call graph for this function:

◆ testInstanceCannotBeCreatedByAnonymousGlobalUserObject()

ilBuddyListTestCase::testInstanceCannotBeCreatedByAnonymousGlobalUserObject ( )

Definition at line 53 of file ilBuddyListTestCase.php.

References ANONYMOUS_USER_ID, ilBuddyList\getInstanceByGlobalUser(), and ilBuddySystemBaseTestCase\setGlobalVariable().

53  : void
54  {
55  $this->expectException(ilBuddySystemException::class);
56 
57  $user = $this->getMockBuilder(ilObjUser::class)->disableOriginalConstructor()->onlyMethods(['getId'])->getMock();
58  $user->expects($this->once())->method('getId')->willReturn(ANONYMOUS_USER_ID);
59  $this->setGlobalVariable('ilUser', $user);
60 
62  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
setGlobalVariable(string $name, mixed $value)
static getInstanceByGlobalUser(?ilObjUser $user=null)
+ Here is the call graph for this function:

◆ testListIsInitiallyEmpty()

ilBuddyListTestCase::testListIsInitiallyEmpty ( )

Definition at line 91 of file ilBuddyListTestCase.php.

References ilBuddyList\getInstanceByUserId().

91  : void
92  {
93  $repo = $this->getMockBuilder(ilBuddySystemRelationRepository::class)->disableOriginalConstructor()->getMock();
94  $repo->expects($this->once())->method('getAll')->willReturn([]);
95 
96  $buddyList = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
97  $buddyList->reset();
98  $buddyList->setRepository($repo);
99 
100  $this->assertEmpty($buddyList->getRelations());
101  }
static getInstanceByUserId(int $usrId)
+ Here is the call graph for this function:

◆ testRelationCannotBeRequestedForAnonymous()

ilBuddyListTestCase::testRelationCannotBeRequestedForAnonymous ( )

Definition at line 318 of file ilBuddyListTestCase.php.

References ANONYMOUS_USER_ID, and ilBuddyList\getInstanceByUserId().

318  : void
319  {
320  $this->expectException(ilBuddySystemException::class);
321 
322  $expectedRelation = new ilBuddySystemRelation(
324  self::BUDDY_LIST_OWNER_ID,
326  false,
327  time()
328  );
329 
330  $repo = $this->getMockBuilder(ilBuddySystemRelationRepository::class)->disableOriginalConstructor()->getMock();
331  $repo->expects($this->never())->method('getAll')->willReturn([]);
332  $repo->expects($this->never())->method('save');
333 
334  $buddyList = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
335  $buddyList->reset();
336  $buddyList->setRepository($repo);
337  $buddyList->request($expectedRelation);
338  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
Class ilBuddySystemUnlinkedRelationState.
static getInstanceByUserId(int $usrId)
+ Here is the call graph for this function:

◆ testRelationCannotBeRequestedForUnknownUserAccounts()

ilBuddyListTestCase::testRelationCannotBeRequestedForUnknownUserAccounts ( )

Definition at line 340 of file ilBuddyListTestCase.php.

References ilBuddyList\getInstanceByUserId(), null, and ilBuddySystemBaseTestCase\setGlobalVariable().

340  : void
341  {
342  $this->expectException(ilBuddySystemException::class);
343 
344  $expectedRelation = new ilBuddySystemRelation(
346  self::BUDDY_LIST_BUDDY_ID,
347  self::BUDDY_LIST_OWNER_ID,
348  false,
349  time()
350  );
351  $expectedRelation = $expectedRelation->withUsrId(self::BUDDY_LIST_OWNER_ID);
352  $expectedRelation = $expectedRelation->withBuddyUsrId(-3);
353 
354  $db = $this->createMock(ilDBInterface::class);
355  $db->expects($this->once())->method('queryF');
356  $db->expects($this->once())->method('fetchAssoc')->willReturn(null);
357  $this->setGlobalVariable('ilDB', $db);
358 
359  $repo = $this->getMockBuilder(ilBuddySystemRelationRepository::class)->disableOriginalConstructor()->getMock();
360  $repo->expects($this->never())->method('getAll')->willReturn([]);
361  $repo->expects($this->never())->method('save');
362 
363  $buddyList = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
364  $buddyList->reset();
365  $buddyList->setRepository($repo);
366  $buddyList->request($expectedRelation);
367 
368  $this->assertEquals(new ilBuddySystemRequestedRelationState(), $expectedRelation->getState());
369  }
Class ilBuddySystemUnlinkedRelationState.
static getInstanceByUserId(int $usrId)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setGlobalVariable(string $name, mixed $value)
+ Here is the call graph for this function:

◆ testRelationRequestCanBeApprovedByTheRelationTarget()

ilBuddyListTestCase::testRelationRequestCanBeApprovedByTheRelationTarget ( )

Definition at line 206 of file ilBuddyListTestCase.php.

References ilBuddyList\getInstanceByUserId(), and ilBuddySystemBaseTestCase\setGlobalVariable().

206  : void
207  {
208  $expectedRelation = new ilBuddySystemRelation(
210  self::BUDDY_LIST_OWNER_ID,
211  self::BUDDY_LIST_BUDDY_ID,
212  false,
213  time()
214  );
215 
216  $relations = [
217  $expectedRelation->getBuddyUsrId() => $expectedRelation
218  ];
219 
220  $db = $this->createMock(ilDBInterface::class);
221  $db->method('queryF');
222  $db->method('fetchAssoc')->willReturn([
223  'login' => 'phpunit'
224  ]);
225  $this->setGlobalVariable('ilDB', $db);
226 
227  $repo = $this->getMockBuilder(ilBuddySystemRelationRepository::class)->disableOriginalConstructor()->getMock();
228  $repo->method('getAll')->willReturn($relations);
229  $repo->method('save')->with($expectedRelation);
230 
231  $buddyList = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
232  $buddyList->reset();
233  $buddyList->setRepository($repo);
234  $buddyList->request($expectedRelation);
235 
236  $other_buddylist = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_BUDDY_ID);
237  $other_buddylist->reset();
238  $other_buddylist->setRepository($repo);
239  $other_buddylist->link($expectedRelation);
240 
241  $this->assertEquals(new ilBuddySystemLinkedRelationState(), $expectedRelation->getState());
242  }
Class ilBuddySystemUnlinkedRelationState.
static getInstanceByUserId(int $usrId)
setGlobalVariable(string $name, mixed $value)
+ Here is the call graph for this function:

◆ testRelationRequestCanBeIgnoredByTheRelationTarget()

ilBuddyListTestCase::testRelationRequestCanBeIgnoredByTheRelationTarget ( )

Definition at line 280 of file ilBuddyListTestCase.php.

References ilBuddyList\getInstanceByUserId(), and ilBuddySystemBaseTestCase\setGlobalVariable().

280  : void
281  {
282  $expectedRelation = new ilBuddySystemRelation(
284  self::BUDDY_LIST_OWNER_ID,
285  self::BUDDY_LIST_BUDDY_ID,
286  false,
287  time()
288  );
289 
290  $relations = [
291  $expectedRelation->getBuddyUsrId() => $expectedRelation
292  ];
293 
294  $db = $this->createMock(ilDBInterface::class);
295  $db->method('queryF');
296  $db->method('fetchAssoc')->willReturn([
297  'login' => 'phpunit'
298  ]);
299  $this->setGlobalVariable('ilDB', $db);
300 
301  $repo = $this->getMockBuilder(ilBuddySystemRelationRepository::class)->disableOriginalConstructor()->getMock();
302  $repo->method('getAll')->willReturn($relations);
303  $repo->method('save')->with($expectedRelation);
304 
305  $buddyList = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
306  $buddyList->reset();
307  $buddyList->setRepository($repo);
308  $buddyList->request($expectedRelation);
309 
310  $other_buddylist = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_BUDDY_ID);
311  $other_buddylist->reset();
312  $other_buddylist->setRepository($repo);
313  $other_buddylist->ignore($expectedRelation);
314 
315  $this->assertEquals(new ilBuddySystemIgnoredRequestRelationState(), $expectedRelation->getState());
316  }
Class ilBuddySystemUnlinkedRelationState.
static getInstanceByUserId(int $usrId)
setGlobalVariable(string $name, mixed $value)
+ Here is the call graph for this function:

◆ testRelationRequestCannotBeApprovedByTheRelationOwner()

ilBuddyListTestCase::testRelationRequestCannotBeApprovedByTheRelationOwner ( )

Definition at line 170 of file ilBuddyListTestCase.php.

References $relation, ilBuddyList\getInstanceByUserId(), and ilBuddySystemBaseTestCase\setGlobalVariable().

170  : void
171  {
172  $this->expectException(ilBuddySystemException::class);
173 
174  $expectedRelation = new ilBuddySystemRelation(
176  self::BUDDY_LIST_OWNER_ID,
177  self::BUDDY_LIST_BUDDY_ID,
178  false,
179  time()
180  );
181 
182  $relations = [
183  $expectedRelation->getBuddyUsrId() => $expectedRelation
184  ];
185 
186  $db = $this->createMock(ilDBInterface::class);
187  $db->expects($this->once())->method('queryF');
188  $db->expects($this->once())->method('fetchAssoc')->willReturn([
189  'login' => 'phpunit'
190  ]);
191  $this->setGlobalVariable('ilDB', $db);
192 
193  $repo = $this->getMockBuilder(ilBuddySystemRelationRepository::class)->disableOriginalConstructor()->getMock();
194  $repo->expects($this->once())->method('getAll')->willReturn($relations);
195  $repo->expects($this->once())->method('save')->with($expectedRelation);
196 
197  $buddyList = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
198  $buddyList->reset();
199  $buddyList->setRepository($repo);
200 
201  $relation = $buddyList->getRelationByUserId($expectedRelation->getBuddyUsrId());
202  $buddyList->request($relation);
203  $buddyList->link($relation);
204  }
$relation
Class ilBuddySystemUnlinkedRelationState.
static getInstanceByUserId(int $usrId)
setGlobalVariable(string $name, mixed $value)
+ Here is the call graph for this function:

◆ testRelationRequestCannotBeIgnoredByTheRelationOwner()

ilBuddyListTestCase::testRelationRequestCannotBeIgnoredByTheRelationOwner ( )

Definition at line 244 of file ilBuddyListTestCase.php.

References $relation, ilBuddyList\getInstanceByUserId(), and ilBuddySystemBaseTestCase\setGlobalVariable().

244  : void
245  {
246  $this->expectException(ilBuddySystemException::class);
247 
248  $expectedRelation = new ilBuddySystemRelation(
250  self::BUDDY_LIST_OWNER_ID,
251  self::BUDDY_LIST_BUDDY_ID,
252  false,
253  time()
254  );
255 
256  $relations = [
257  $expectedRelation->getBuddyUsrId() => $expectedRelation
258  ];
259 
260  $db = $this->createMock(ilDBInterface::class);
261  $db->expects($this->once())->method('queryF');
262  $db->expects($this->once())->method('fetchAssoc')->willReturn([
263  'login' => 'phpunit'
264  ]);
265  $this->setGlobalVariable('ilDB', $db);
266 
267  $repo = $this->getMockBuilder(ilBuddySystemRelationRepository::class)->disableOriginalConstructor()->getMock();
268  $repo->expects($this->once())->method('getAll')->willReturn($relations);
269  $repo->expects($this->once())->method('save')->with($expectedRelation);
270 
271  $buddyList = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
272  $buddyList->reset();
273  $buddyList->setRepository($repo);
274 
275  $relation = $buddyList->getRelationByUserId($expectedRelation->getBuddyUsrId());
276  $buddyList->request($relation);
277  $buddyList->ignore($relation);
278  }
$relation
Class ilBuddySystemUnlinkedRelationState.
static getInstanceByUserId(int $usrId)
setGlobalVariable(string $name, mixed $value)
+ Here is the call graph for this function:

◆ testRepositoryIsEnquiredOnlyOnceToFetchRelationsWhenCalledImplicitly()

ilBuddyListTestCase::testRepositoryIsEnquiredOnlyOnceToFetchRelationsWhenCalledImplicitly ( )

Definition at line 133 of file ilBuddyListTestCase.php.

References $relation, ilBuddyList\getInstanceByUserId(), and ilBuddySystemBaseTestCase\setGlobalVariable().

133  : void
134  {
135  $expectedRelation = new ilBuddySystemRelation(
137  self::BUDDY_LIST_BUDDY_ID,
138  self::BUDDY_LIST_OWNER_ID,
139  false,
140  time()
141  );
142  $expectedRelation = $expectedRelation->withUsrId(self::BUDDY_LIST_OWNER_ID);
143  $expectedRelation = $expectedRelation->withBuddyUsrId(self::BUDDY_LIST_BUDDY_ID);
144 
145  $relations = [
146  $expectedRelation->getBuddyUsrId() => $expectedRelation
147  ];
148 
149  $db = $this->createMock(ilDBInterface::class);
150  $db->expects($this->exactly(2))->method('queryF');
151  $db->expects($this->exactly(2))->method('fetchAssoc')->willReturn([
152  'login' => 'phpunit'
153  ]);
154  $this->setGlobalVariable('ilDB', $db);
155 
156  $repo = $this->getMockBuilder(ilBuddySystemRelationRepository::class)->disableOriginalConstructor()->getMock();
157  $repo->expects($this->once())->method('getAll')->willReturn($relations);
158  $repo->expects($this->exactly(3))->method('save')->with($expectedRelation);
159 
160  $buddyList = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
161  $buddyList->reset();
162  $buddyList->setRepository($repo);
163 
164  $relation = $buddyList->getRelationByUserId($expectedRelation->getBuddyUsrId());
165  $buddyList->request($relation);
166  $buddyList->unlink($relation);
167  $buddyList->request($relation);
168  }
$relation
Class ilBuddySystemUnlinkedRelationState.
static getInstanceByUserId(int $usrId)
setGlobalVariable(string $name, mixed $value)
+ Here is the call graph for this function:

◆ testRepositoryIsEnquiredToFetchRelationsWhenRequestedExplicitly()

ilBuddyListTestCase::testRepositoryIsEnquiredToFetchRelationsWhenRequestedExplicitly ( )

Definition at line 103 of file ilBuddyListTestCase.php.

References ilBuddyList\getInstanceByUserId().

103  : void
104  {
105  $relations = [
106  4711 => new ilBuddySystemRelation(
108  self::BUDDY_LIST_BUDDY_ID,
109  self::BUDDY_LIST_OWNER_ID,
110  false,
111  time()
112  ),
113  4712 => new ilBuddySystemRelation(
115  self::BUDDY_LIST_BUDDY_ID,
116  self::BUDDY_LIST_OWNER_ID,
117  false,
118  time()
119  )
120  ];
121 
122  $repo = $this->getMockBuilder(ilBuddySystemRelationRepository::class)->disableOriginalConstructor()->getMock();
123  $repo->expects($this->once())->method('getAll')->willReturn($relations);
124 
125  $buddyList = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
126  $buddyList->reset();
127  $buddyList->setRepository($repo);
128  $this->assertEquals(new ilBuddySystemRelationCollection($relations), $buddyList->getRelations());
129  $this->assertEquals(new ilBuddySystemRelationCollection($relations), $buddyList->getRelations());
130  $this->assertEquals(new ilBuddySystemRelationCollection($relations), $buddyList->getRelations());
131  }
Class ilBuddySystemUnlinkedRelationState.
static getInstanceByUserId(int $usrId)
Class ilBuddySystemRelationCollection A collection which contains all entries of a buddy list...
+ Here is the call graph for this function:

◆ testRepositoryIsEnquiredWhenBuddyListShouldBeDestroyed()

ilBuddyListTestCase::testRepositoryIsEnquiredWhenBuddyListShouldBeDestroyed ( )

Definition at line 371 of file ilBuddyListTestCase.php.

References ilBuddyList\getInstanceByUserId().

371  : void
372  {
373  $repo = $this->getMockBuilder(ilBuddySystemRelationRepository::class)->disableOriginalConstructor()->getMock();
374  $repo->expects($this->once())->method('destroy');
375 
376  $buddyList = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
377  $buddyList->reset();
378  $buddyList->setRepository($repo);
379  $buddyList->destroy();
380  }
static getInstanceByUserId(int $usrId)
+ Here is the call graph for this function:

◆ testStateTransitionExceptionIsThrownWhenALinkedRelationShouldBeMarkedAsIgnored()

ilBuddyListTestCase::testStateTransitionExceptionIsThrownWhenALinkedRelationShouldBeMarkedAsIgnored ( )

Definition at line 613 of file ilBuddyListTestCase.php.

References $relation, ilBuddyList\getInstanceByUserId(), and setPriorRelationState().

613  : void
614  {
615  $this->expectException(ilBuddySystemRelationStateTransitionException::class);
616 
617  $buddyList = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
618  $buddyList->reset();
619 
620  $state = new ilBuddySystemLinkedRelationState();
621 
623  $state,
624  self::BUDDY_LIST_OWNER_ID,
625  self::BUDDY_LIST_BUDDY_ID,
626  false,
627  time()
628  );
629 
630  $this->setPriorRelationState($relation, $state);
631 
632  $buddyList->ignore($relation);
633  }
$relation
setPriorRelationState(ilBuddySystemRelation $relation, ilBuddySystemRelationState $state)
static getInstanceByUserId(int $usrId)
+ Here is the call graph for this function:

◆ testUnlinkedRelationIsReturnedWhenRelationWasRequestedForAnUnknownBuddyId()

ilBuddyListTestCase::testUnlinkedRelationIsReturnedWhenRelationWasRequestedForAnUnknownBuddyId ( )

Definition at line 382 of file ilBuddyListTestCase.php.

References ilBuddyList\getInstanceByUserId().

382  : void
383  {
384  $repo = $this->getMockBuilder(ilBuddySystemRelationRepository::class)->disableOriginalConstructor()->getMock();
385  $repo->expects($this->once())->method('getAll')->willReturn([]);
386 
387  $buddyList = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
388  $buddyList->reset();
389  $buddyList->setRepository($repo);
390  $this->assertInstanceOf(ilBuddySystemUnlinkedRelationState::class, $buddyList->getRelationByUserId(-3)->getState());
391  }
static getInstanceByUserId(int $usrId)
+ Here is the call graph for this function:

◆ testValuesCanBeFetchedByGettersWhenSetBySetters()

ilBuddyListTestCase::testValuesCanBeFetchedByGettersWhenSetBySetters ( )

Definition at line 393 of file ilBuddyListTestCase.php.

References ilBuddyList\getInstanceByUserId().

393  : void
394  {
395  $buddyList = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
396  $buddyList->reset();
397  $buddyList->setOwnerId(self::BUDDY_LIST_BUDDY_ID);
398  $this->assertSame(self::BUDDY_LIST_BUDDY_ID, $buddyList->getOwnerId());
399 
400  $repo = $this->getMockBuilder(ilBuddySystemRelationRepository::class)->disableOriginalConstructor()->getMock();
401  $repo->expects($this->never())->method('getAll')->willReturn([]);
402  $buddyList->setRepository($repo);
403  $this->assertEquals($repo, $buddyList->getRepository());
404 
405  $relations = [
406  self::BUDDY_LIST_BUDDY_ID => new ilBuddySystemRelation(
408  self::BUDDY_LIST_BUDDY_ID,
409  self::BUDDY_LIST_OWNER_ID,
410  false,
411  time()
412  )
413  ];
414  $buddyList->setRelations(new ilBuddySystemRelationCollection($relations));
415  $this->assertEquals(new ilBuddySystemRelationCollection($relations), $buddyList->getRelations());
416  }
Class ilBuddySystemUnlinkedRelationState.
static getInstanceByUserId(int $usrId)
Class ilBuddySystemRelationCollection A collection which contains all entries of a buddy list...
+ Here is the call graph for this function:

Field Documentation

◆ BUDDY_LIST_BUDDY_ID

const ilBuddyListTestCase::BUDDY_LIST_BUDDY_ID = -2
private

Definition at line 24 of file ilBuddyListTestCase.php.

◆ BUDDY_LIST_OWNER_ID

const ilBuddyListTestCase::BUDDY_LIST_OWNER_ID = -1
private

Definition at line 23 of file ilBuddyListTestCase.php.


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