ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilBuddyListTest Class Reference

Class ilBuddyListTest. More...

+ Inheritance diagram for ilBuddyListTest:
+ Collaboration diagram for ilBuddyListTest:

Public Member Functions

 setUp ()
 
 testInstanceCanBeCreatedByGlobalUserObject ()
 
 testInstanceCannotBeCreatedByAnonymousGlobalUserObject ()
 ilBuddySystemException More...
 
 testInstanceByBeCreatedBySingletonMethod ()
 
 testListIsInitiallyEmpty ()
 
 testRepositoryIsEnquiredToFetchRelationsWhenRequestedExplicitly ()
 
 testRepositoryIsEnquiredOnlyOnceToFetchRelationsWhenCalledImplicitly ()
 
 testRelationRequestCannotBeApprovedByTheRelationOwner ()
 ilBuddySystemException More...
 
 testRelationRequestCanBeApprovedByTheRelationTarget ()
 
 testRelationRequestCannotBeIgnoredByTheRelationOwner ()
 ilBuddySystemException More...
 
 testRelationRequestCanBeIgnoredByTheRelationTarget ()
 
 testRelationCannotBeRequestedForAnonymous ()
 ilBuddySystemException More...
 
 testRelationCannotBeRequestedForUnknownUserAccounts ()
 ilBuddySystemException More...
 
 testRepositoryIsEnquiredWhenBuddyListShouldBeDestroyed ()
 
 testUnlinkedRelationIsReturnedWhenRelationWasRequestedForAUknownBuddyId ()
 
 testValuesCanBeFetchedByGettersWhenSetBySetters ()
 
 testDifferentRelationStatesCanBeRetrieved ()
 
 testExceptionIsThrownWhenNonNumericOwnerIdIsPassed ()
 InvalidArgumentException More...
 
 testExceptionIsThrownWhenRelationIsRequestedForANonNumericUserId ()
 InvalidArgumentException More...
 
 testAlreadyGivenStateExceptionIsThrownWhenALinkedRelationShouldBeMarkedAsLinked ()
 ilBuddySystemRelationStateAlreadyGivenException More...
 
 testAlreadyGivenStateExceptionIsThrownWhenAnIgnoredRelationShouldBeMarkedAsIgnored ()
 ilBuddySystemRelationStateAlreadyGivenException More...
 
 testAlreadyGivenStateExceptionIsThrownWhenAnUnlinkedRelationShouldBeMarkedAsUnlinked ()
 ilBuddySystemRelationStateAlreadyGivenException More...
 
 testAlreadyGivenStateExceptionIsThrownWhenARequestedRelationShouldBeMarkedAsRequested ()
 ilBuddySystemRelationStateAlreadyGivenException More...
 
 testStateTransitionExceptionIsThrownWhenALinkedRelationShouldBeMarkedAsIgnored ()
 ilBuddySystemRelationStateTransitionException More...
 

Data Fields

const BUDDY_LIST_OWNER_ID = -1
 
const BUDDY_LIST_BUDDY_ID = -2
 

Protected Attributes

 $buddylist
 

Private Member Functions

 setPriorRelationState (ilBuddySystemRelation $relation, ilBuddySystemRelationState $state)
 

Detailed Description

Class ilBuddyListTest.

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

Definition at line 9 of file ilBuddyListTest.php.

Member Function Documentation

◆ setPriorRelationState()

ilBuddyListTest::setPriorRelationState ( ilBuddySystemRelation  $relation,
ilBuddySystemRelationState  $state 
)
finalprivate

Definition at line 451 of file ilBuddyListTest.php.

Referenced by testAlreadyGivenStateExceptionIsThrownWhenALinkedRelationShouldBeMarkedAsLinked(), testAlreadyGivenStateExceptionIsThrownWhenAnIgnoredRelationShouldBeMarkedAsIgnored(), testAlreadyGivenStateExceptionIsThrownWhenAnUnlinkedRelationShouldBeMarkedAsUnlinked(), testAlreadyGivenStateExceptionIsThrownWhenARequestedRelationShouldBeMarkedAsRequested(), and testStateTransitionExceptionIsThrownWhenALinkedRelationShouldBeMarkedAsIgnored().

452  {
453  $object = new ReflectionObject($relation);
454  $property = $object->getProperty('prior_state');
455  $property->setAccessible(true);
456 
457  $property->setValue($relation, $state);
458  }
+ Here is the caller graph for this function:

◆ setUp()

ilBuddyListTest::setUp ( )

Definition at line 22 of file ilBuddyListTest.php.

References $GLOBALS.

23  {
24  $GLOBALS['ilAppEventHandler'] = $this->getMockBuilder('ilAppEventHandler')->disableOriginalConstructor()->setMethods(array('raise'))->getMock();
25  }
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276

◆ testAlreadyGivenStateExceptionIsThrownWhenALinkedRelationShouldBeMarkedAsLinked()

ilBuddyListTest::testAlreadyGivenStateExceptionIsThrownWhenALinkedRelationShouldBeMarkedAsLinked ( )

ilBuddySystemRelationStateAlreadyGivenException

Definition at line 463 of file ilBuddyListTest.php.

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

464  {
465  $buddylist = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
466  $buddylist->reset();
467 
468  $state = new ilBuddySystemLinkedRelationState();
469 
470  $relation = new ilBuddySystemRelation($state);
471  $relation->setUserId(self::BUDDY_LIST_OWNER_ID);
472  $relation->setBuddyUserId(self::BUDDY_LIST_BUDDY_ID);
473 
474  $this->setPriorRelationState($relation, $state);
475 
476  $buddylist->link($relation);
477  }
static getInstanceByUserId($usr_id)
Class ilBuddySystemRelation.
setPriorRelationState(ilBuddySystemRelation $relation, ilBuddySystemRelationState $state)
+ Here is the call graph for this function:

◆ testAlreadyGivenStateExceptionIsThrownWhenAnIgnoredRelationShouldBeMarkedAsIgnored()

ilBuddyListTest::testAlreadyGivenStateExceptionIsThrownWhenAnIgnoredRelationShouldBeMarkedAsIgnored ( )

ilBuddySystemRelationStateAlreadyGivenException

Definition at line 482 of file ilBuddyListTest.php.

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

483  {
484  $buddylist = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
485  $buddylist->reset();
486 
488 
489  $relation = new ilBuddySystemRelation($state);
490  $relation->setUserId(self::BUDDY_LIST_BUDDY_ID);
491  $relation->setBuddyUserId(self::BUDDY_LIST_OWNER_ID);
492 
493  $this->setPriorRelationState($relation, $state);
494 
495  $buddylist->ignore($relation);
496  }
static getInstanceByUserId($usr_id)
Class ilBuddySystemRelation.
setPriorRelationState(ilBuddySystemRelation $relation, ilBuddySystemRelationState $state)
+ Here is the call graph for this function:

◆ testAlreadyGivenStateExceptionIsThrownWhenAnUnlinkedRelationShouldBeMarkedAsUnlinked()

ilBuddyListTest::testAlreadyGivenStateExceptionIsThrownWhenAnUnlinkedRelationShouldBeMarkedAsUnlinked ( )

ilBuddySystemRelationStateAlreadyGivenException

Definition at line 501 of file ilBuddyListTest.php.

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

502  {
503  $buddylist = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
504  $buddylist->reset();
505 
506  $state = new ilBuddySystemUnlinkedRelationState();
507 
508  $relation = new ilBuddySystemRelation($state);
509  $relation->setUserId(self::BUDDY_LIST_OWNER_ID);
510  $relation->setBuddyUserId(self::BUDDY_LIST_BUDDY_ID);
511 
512  $this->setPriorRelationState($relation, $state);
513 
514  $buddylist->unlink($relation);
515  }
Class ilBuddySystemUnlinkedRelationState.
static getInstanceByUserId($usr_id)
Class ilBuddySystemRelation.
setPriorRelationState(ilBuddySystemRelation $relation, ilBuddySystemRelationState $state)
+ Here is the call graph for this function:

◆ testAlreadyGivenStateExceptionIsThrownWhenARequestedRelationShouldBeMarkedAsRequested()

ilBuddyListTest::testAlreadyGivenStateExceptionIsThrownWhenARequestedRelationShouldBeMarkedAsRequested ( )

ilBuddySystemRelationStateAlreadyGivenException

Definition at line 520 of file ilBuddyListTest.php.

References $buddylist, $GLOBALS, ilBuddyList\getInstanceByUserId(), and setPriorRelationState().

521  {
522  $buddylist = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
523  $buddylist->reset();
524 
526 
527  $relation = new ilBuddySystemRelation($state);
528  $relation->setUserId(self::BUDDY_LIST_BUDDY_ID);
529  $relation->setBuddyUserId(self::BUDDY_LIST_OWNER_ID);
530 
531  $this->setPriorRelationState($relation, $state);
532 
533  $db = $this->getMockBuilder('ilDBInterface')->getMock();
534  $db->expects($this->any())->method('fetchAssoc')->will($this->returnValue(array(
535  'login' => 'phpunit'
536  )));
537  $GLOBALS['ilDB'] = $db;
538 
539  $buddylist->request($relation);
540  }
static getInstanceByUserId($usr_id)
Class ilBuddySystemRelation.
setPriorRelationState(ilBuddySystemRelation $relation, ilBuddySystemRelationState $state)
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
+ Here is the call graph for this function:

◆ testDifferentRelationStatesCanBeRetrieved()

ilBuddyListTest::testDifferentRelationStatesCanBeRetrieved ( )

Definition at line 372 of file ilBuddyListTest.php.

References $buddylist, and ilBuddyList\getInstanceByUserId().

373  {
374  $buddylist = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
375  $buddylist->reset();
376 
377  $relations = array();
378 
380  $relation->setUserId(self::BUDDY_LIST_OWNER_ID);
381  $relation->setBuddyUserId(self::BUDDY_LIST_BUDDY_ID);
382  $relations[self::BUDDY_LIST_BUDDY_ID] = $relation;
383 
385  $relation->setUserId(self::BUDDY_LIST_BUDDY_ID + 1);
386  $relation->setBuddyUserId(self::BUDDY_LIST_OWNER_ID);
387  $relations[self::BUDDY_LIST_BUDDY_ID + 1] = $relation;
388 
390  $relation->setUserId(self::BUDDY_LIST_BUDDY_ID + 2);
391  $relation->setBuddyUserId(self::BUDDY_LIST_OWNER_ID);
392  $relations[self::BUDDY_LIST_BUDDY_ID + 2] = $relation;
393 
395  $relation->setUserId(self::BUDDY_LIST_BUDDY_ID + 3);
396  $relation->setBuddyUserId(self::BUDDY_LIST_OWNER_ID);
397  $relations[self::BUDDY_LIST_BUDDY_ID + 3] = $relation;
398 
400  $relation->setUserId(self::BUDDY_LIST_OWNER_ID);
401  $relation->setBuddyUserId(self::BUDDY_LIST_BUDDY_ID + 4);
402  $relations[self::BUDDY_LIST_BUDDY_ID + 4] = $relation;
403 
405  $relation->setUserId(self::BUDDY_LIST_BUDDY_ID + 5);
406  $relation->setBuddyUserId(self::BUDDY_LIST_OWNER_ID);
407  $relations[self::BUDDY_LIST_BUDDY_ID + 5] = $relation;
408 
410  $relation->setUserId(self::BUDDY_LIST_OWNER_ID);
411  $relation->setBuddyUserId(self::BUDDY_LIST_BUDDY_ID + 6);
412  $relations[self::BUDDY_LIST_BUDDY_ID + 6] = $relation;
413 
415  $relation->setUserId(self::BUDDY_LIST_OWNER_ID);
416  $relation->setBuddyUserId(self::BUDDY_LIST_BUDDY_ID + 7);
417  $relations[self::BUDDY_LIST_BUDDY_ID + 7] = $relation;
418 
419  $repo = $this->getMockBuilder('ilBuddySystemRelationRepository')->disableOriginalConstructor()->getMock();
420  $repo->expects($this->any())->method('getAll')->willReturn($relations);
421  $buddylist->setRepository($repo);
422 
423  $this->assertCount(3, $buddylist->getLinkedRelations());
424  $this->assertCount(1, $buddylist->getRequestRelationsForOwner());
425  $this->assertCount(1, $buddylist->getRequestRelationsByOwner());
426  $this->assertCount(1, $buddylist->getIgnoredRelationsForOwner());
427  $this->assertCount(2, $buddylist->getIgnoredRelationsByOwner());
428  $this->assertEquals(array_keys($relations), $buddylist->getRelationUserIds());
429  }
static getInstanceByUserId($usr_id)
Class ilBuddySystemRelation.
+ Here is the call graph for this function:

◆ testExceptionIsThrownWhenNonNumericOwnerIdIsPassed()

ilBuddyListTest::testExceptionIsThrownWhenNonNumericOwnerIdIsPassed ( )

InvalidArgumentException

Definition at line 434 of file ilBuddyListTest.php.

References $buddylist, and ilBuddyList\getInstanceByUserId().

435  {
436  $buddylist = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
437  $buddylist->reset();
438  $buddylist->setOwnerId("phpunit");
439  }
static getInstanceByUserId($usr_id)
+ Here is the call graph for this function:

◆ testExceptionIsThrownWhenRelationIsRequestedForANonNumericUserId()

ilBuddyListTest::testExceptionIsThrownWhenRelationIsRequestedForANonNumericUserId ( )

InvalidArgumentException

Definition at line 444 of file ilBuddyListTest.php.

References $buddylist, and ilBuddyList\getInstanceByUserId().

445  {
446  $buddylist = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
447  $buddylist->reset();
448  $buddylist->getRelationByUserId("phpunit");
449  }
static getInstanceByUserId($usr_id)
+ Here is the call graph for this function:

◆ testInstanceByBeCreatedBySingletonMethod()

ilBuddyListTest::testInstanceByBeCreatedBySingletonMethod ( )

Definition at line 54 of file ilBuddyListTest.php.

References $buddylist, and ilBuddyList\getInstanceByUserId().

55  {
56  $relations = array(
59  );
60 
61  $buddylist = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
62  $buddylist->setRelations(new ilBuddySystemRelationCollection($relations));
63  $other_buddylist = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
64  $other_buddylist->setRelations(new ilBuddySystemRelationCollection());
65 
66  $this->assertEquals($buddylist, $other_buddylist);
67  }
Class ilBuddySystemUnlinkedRelationState.
Class ilBuddySystemRelationCollection A collection which contains all entries of a buddy list...
static getInstanceByUserId($usr_id)
Class ilBuddySystemRelation.
+ Here is the call graph for this function:

◆ testInstanceCanBeCreatedByGlobalUserObject()

ilBuddyListTest::testInstanceCanBeCreatedByGlobalUserObject ( )

Definition at line 30 of file ilBuddyListTest.php.

References $GLOBALS.

31  {
32  $user = $this->getMockBuilder('ilObjUser')->disableOriginalConstructor()->setMethods(array('getId'))->getMock();
33  $user->expects($this->once())->method('getId')->will($this->returnValue(self::BUDDY_LIST_OWNER_ID));
34  $GLOBALS['ilUser'] = $user;
35 
36  ilBuddyList::getInstanceByGlobalUser();
37  }
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276

◆ testInstanceCannotBeCreatedByAnonymousGlobalUserObject()

ilBuddyListTest::testInstanceCannotBeCreatedByAnonymousGlobalUserObject ( )

ilBuddySystemException

Definition at line 42 of file ilBuddyListTest.php.

References $GLOBALS.

43  {
44  $user = $this->getMockBuilder('ilObjUser')->disableOriginalConstructor()->setMethods(array('getId'))->getMock();
45  $user->expects($this->once())->method('getId')->will($this->returnValue(ANONYMOUS_USER_ID));
46  $GLOBALS['ilUser'] = $user;
47 
48  ilBuddyList::getInstanceByGlobalUser();
49  }
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276

◆ testListIsInitiallyEmpty()

ilBuddyListTest::testListIsInitiallyEmpty ( )

Definition at line 72 of file ilBuddyListTest.php.

References $buddylist, and ilBuddyList\getInstanceByUserId().

73  {
74  $repo = $this->getMockBuilder('ilBuddySystemRelationRepository')->disableOriginalConstructor()->getMock();
75  $repo->expects($this->exactly(1))->method('getAll')->willReturn(array());
76 
77  $buddylist = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
78  $buddylist->reset();
79  $buddylist->setRepository($repo);
80 
81  $this->assertEmpty($buddylist->getRelations());
82  }
static getInstanceByUserId($usr_id)
+ Here is the call graph for this function:

◆ testRelationCannotBeRequestedForAnonymous()

ilBuddyListTest::testRelationCannotBeRequestedForAnonymous ( )

ilBuddySystemException

Definition at line 279 of file ilBuddyListTest.php.

References $buddylist, and ilBuddyList\getInstanceByUserId().

280  {
281  $expected_relation = new ilBuddySystemRelation(new ilBuddySystemUnlinkedRelationState());
282  $expected_relation->setUserId(self::BUDDY_LIST_OWNER_ID);
283  $expected_relation->setBuddyUserId(ANONYMOUS_USER_ID);
284 
285  $repo = $this->getMockBuilder('ilBuddySystemRelationRepository')->disableOriginalConstructor()->getMock();
286  $repo->expects($this->never())->method('getAll')->willReturn(array());
287  $repo->expects($this->never())->method('save');
288 
289  $buddylist = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
290  $buddylist->reset();
291  $buddylist->setRepository($repo);
292  $buddylist->request($expected_relation);
293  }
Class ilBuddySystemUnlinkedRelationState.
static getInstanceByUserId($usr_id)
Class ilBuddySystemRelation.
+ Here is the call graph for this function:

◆ testRelationCannotBeRequestedForUnknownUserAccounts()

ilBuddyListTest::testRelationCannotBeRequestedForUnknownUserAccounts ( )

ilBuddySystemException

Definition at line 298 of file ilBuddyListTest.php.

References $buddylist, $GLOBALS, and ilBuddyList\getInstanceByUserId().

299  {
300  $expected_relation = new ilBuddySystemRelation(new ilBuddySystemUnlinkedRelationState());
301  $expected_relation->setUserId(self::BUDDY_LIST_OWNER_ID);
302  $expected_relation->setBuddyUserId(-3);
303 
304  $db = $this->getMockBuilder('ilDBMySQL')->disableOriginalConstructor()->setMethods(array('queryF', 'fetchAssoc'))->getMock();
305  $db->expects($this->once())->method('queryF');
306  $db->expects($this->once())->method('fetchAssoc')->will($this->returnValue(null));
307  $GLOBALS['ilDB'] = $db;
308 
309  $repo = $this->getMockBuilder('ilBuddySystemRelationRepository')->disableOriginalConstructor()->getMock();
310  $repo->expects($this->never())->method('getAll')->willReturn(array());
311  $repo->expects($this->never())->method('save');
312 
313  $buddylist = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
314  $buddylist->reset();
315  $buddylist->setRepository($repo);
316  $buddylist->request($expected_relation);
317  }
Class ilBuddySystemUnlinkedRelationState.
static getInstanceByUserId($usr_id)
Class ilBuddySystemRelation.
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
+ Here is the call graph for this function:

◆ testRelationRequestCanBeApprovedByTheRelationTarget()

ilBuddyListTest::testRelationRequestCanBeApprovedByTheRelationTarget ( )

Definition at line 176 of file ilBuddyListTest.php.

References $buddylist, and ilBuddyList\getInstanceByUserId().

177  {
178  $expected_relation = new ilBuddySystemRelation(new ilBuddySystemUnlinkedRelationState());
179  $expected_relation->setUserId(self::BUDDY_LIST_OWNER_ID);
180  $expected_relation->setBuddyUserId(self::BUDDY_LIST_BUDDY_ID);
181 
182  $relations = array(
183  $expected_relation->getBuddyUserId() => $expected_relation
184  );
185 
186  $db = $this->getMockBuilder('ilDBInterface')->getMock();
187  $db->expects($this->any())->method('queryF');
188  $db->expects($this->any())->method('fetchAssoc')->will($this->returnValue(array(
189  'login' => 'phpunit'
190  )));
191  $this->setGlobalVariable('ilDB', $db);
192 
193  $repo = $this->getMockBuilder('ilBuddySystemRelationRepository')->disableOriginalConstructor()->getMock();
194  $repo->expects($this->any())->method('getAll')->willReturn($relations);
195  $repo->expects($this->any())->method('save')->with($expected_relation);
196 
197  $buddylist = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
198  $buddylist->reset();
199  $buddylist->setRepository($repo);
200  $buddylist->request($expected_relation);
201 
202  $other_buddylist = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_BUDDY_ID);
203  $other_buddylist->reset();
204  $other_buddylist->setRepository($repo);
205  $other_buddylist->link($expected_relation);
206  }
Class ilBuddySystemUnlinkedRelationState.
static getInstanceByUserId($usr_id)
Class ilBuddySystemRelation.
+ Here is the call graph for this function:

◆ testRelationRequestCanBeIgnoredByTheRelationTarget()

ilBuddyListTest::testRelationRequestCanBeIgnoredByTheRelationTarget ( )

Definition at line 244 of file ilBuddyListTest.php.

References $buddylist, $GLOBALS, and ilBuddyList\getInstanceByUserId().

245  {
246  $expected_relation = new ilBuddySystemRelation(new ilBuddySystemUnlinkedRelationState());
247  $expected_relation->setUserId(self::BUDDY_LIST_OWNER_ID);
248  $expected_relation->setBuddyUserId(self::BUDDY_LIST_BUDDY_ID);
249 
250  $relations = array(
251  $expected_relation->getBuddyUserId() => $expected_relation
252  );
253 
254  $db = $this->getMockBuilder('ilDBMySQL')->disableOriginalConstructor()->setMethods(array('queryF', 'fetchAssoc'))->getMock();
255  $db->expects($this->any())->method('queryF');
256  $db->expects($this->any())->method('fetchAssoc')->will($this->returnValue(array(
257  'login' => 'phpunit'
258  )));
259  $GLOBALS['ilDB'] = $db;
260 
261  $repo = $this->getMockBuilder('ilBuddySystemRelationRepository')->disableOriginalConstructor()->getMock();
262  $repo->expects($this->any())->method('getAll')->willReturn($relations);
263  $repo->expects($this->any())->method('save')->with($expected_relation);
264 
265  $buddylist = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
266  $buddylist->reset();
267  $buddylist->setRepository($repo);
268  $buddylist->request($expected_relation);
269 
270  $other_buddylist = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_BUDDY_ID);
271  $other_buddylist->reset();
272  $other_buddylist->setRepository($repo);
273  $other_buddylist->ignore($expected_relation);
274  }
Class ilBuddySystemUnlinkedRelationState.
static getInstanceByUserId($usr_id)
Class ilBuddySystemRelation.
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
+ Here is the call graph for this function:

◆ testRelationRequestCannotBeApprovedByTheRelationOwner()

ilBuddyListTest::testRelationRequestCannotBeApprovedByTheRelationOwner ( )

ilBuddySystemException

Definition at line 142 of file ilBuddyListTest.php.

References $buddylist, and ilBuddyList\getInstanceByUserId().

143  {
144  $this->assertException(ilBuddySystemException::class);
145  $expected_relation = new ilBuddySystemRelation(new ilBuddySystemUnlinkedRelationState());
146  $expected_relation->setUserId(self::BUDDY_LIST_OWNER_ID);
147  $expected_relation->setBuddyUserId(self::BUDDY_LIST_BUDDY_ID);
148 
149  $relations = array(
150  $expected_relation->getBuddyUserId() => $expected_relation
151  );
152 
153  $db = $this->getMockBuilder('ilDBInterface')->getMock();
154  $db->expects($this->once())->method('queryF');
155  $db->expects($this->once())->method('fetchAssoc')->will($this->returnValue(array(
156  'login' => 'phpunit'
157  )));
158  $this->setGlobalVariable('ilDB', $db);
159 
160  $repo = $this->getMockBuilder('ilBuddySystemRelationRepository')->disableOriginalConstructor()->getMock();
161  $repo->expects($this->once())->method('getAll')->willReturn($relations);
162  $repo->expects($this->exactly(1))->method('save')->with($expected_relation);
163 
164  $buddylist = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
165  $buddylist->reset();
166  $buddylist->setRepository($repo);
167 
168  $relation = $buddylist->getRelationByUserId($expected_relation->getBuddyUserId());
169  $buddylist->request($relation);
170  $buddylist->link($relation);
171  }
Class ilBuddySystemUnlinkedRelationState.
static getInstanceByUserId($usr_id)
Class ilBuddySystemRelation.
+ Here is the call graph for this function:

◆ testRelationRequestCannotBeIgnoredByTheRelationOwner()

ilBuddyListTest::testRelationRequestCannotBeIgnoredByTheRelationOwner ( )

ilBuddySystemException

Definition at line 211 of file ilBuddyListTest.php.

References $buddylist, $GLOBALS, and ilBuddyList\getInstanceByUserId().

212  {
213  $expected_relation = new ilBuddySystemRelation(new ilBuddySystemUnlinkedRelationState());
214  $expected_relation->setUserId(self::BUDDY_LIST_OWNER_ID);
215  $expected_relation->setBuddyUserId(self::BUDDY_LIST_BUDDY_ID);
216 
217  $relations = array(
218  $expected_relation->getBuddyUserId() => $expected_relation
219  );
220 
221  $db = $this->getMockBuilder('ilDBMySQL')->disableOriginalConstructor()->setMethods(array('queryF', 'fetchAssoc'))->getMock();
222  $db->expects($this->once())->method('queryF');
223  $db->expects($this->once())->method('fetchAssoc')->will($this->returnValue(array(
224  'login' => 'phpunit'
225  )));
226  $GLOBALS['ilDB'] = $db;
227 
228  $repo = $this->getMockBuilder('ilBuddySystemRelationRepository')->disableOriginalConstructor()->getMock();
229  $repo->expects($this->once())->method('getAll')->willReturn($relations);
230  $repo->expects($this->exactly(1))->method('save')->with($expected_relation);
231 
232  $buddylist = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
233  $buddylist->reset();
234  $buddylist->setRepository($repo);
235 
236  $relation = $buddylist->getRelationByUserId($expected_relation->getBuddyUserId());
237  $buddylist->request($relation);
238  $buddylist->ignore($relation);
239  }
Class ilBuddySystemUnlinkedRelationState.
static getInstanceByUserId($usr_id)
Class ilBuddySystemRelation.
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
+ Here is the call graph for this function:

◆ testRepositoryIsEnquiredOnlyOnceToFetchRelationsWhenCalledImplicitly()

ilBuddyListTest::testRepositoryIsEnquiredOnlyOnceToFetchRelationsWhenCalledImplicitly ( )

Definition at line 108 of file ilBuddyListTest.php.

References $buddylist, $GLOBALS, and ilBuddyList\getInstanceByUserId().

109  {
110  $expected_relation = new ilBuddySystemRelation(new ilBuddySystemUnlinkedRelationState());
111  $expected_relation->setUserId(self::BUDDY_LIST_OWNER_ID);
112  $expected_relation->setBuddyUserId(self::BUDDY_LIST_BUDDY_ID);
113 
114  $relations = array(
115  $expected_relation->getBuddyUserId() => $expected_relation
116  );
117 
118  $db = $this->getMockBuilder('ilDBMySQL')->disableOriginalConstructor()->setMethods(array('queryF', 'fetchAssoc'))->getMock();
119  $db->expects($this->exactly(2))->method('queryF');
120  $db->expects($this->exactly(2))->method('fetchAssoc')->will($this->returnValue(array(
121  'login' => 'phpunit'
122  )));
123  $GLOBALS['ilDB'] = $db;
124 
125  $repo = $this->getMockBuilder('ilBuddySystemRelationRepository')->disableOriginalConstructor()->getMock();
126  $repo->expects($this->once())->method('getAll')->willReturn($relations);
127  $repo->expects($this->exactly(3))->method('save')->with($expected_relation);
128 
129  $buddylist = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
130  $buddylist->reset();
131  $buddylist->setRepository($repo);
132 
133  $relation = $buddylist->getRelationByUserId($expected_relation->getBuddyUserId());
134  $buddylist->request($relation);
135  $buddylist->unlink($relation);
136  $buddylist->request($relation);
137  }
Class ilBuddySystemUnlinkedRelationState.
static getInstanceByUserId($usr_id)
Class ilBuddySystemRelation.
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
+ Here is the call graph for this function:

◆ testRepositoryIsEnquiredToFetchRelationsWhenRequestedExplicitly()

ilBuddyListTest::testRepositoryIsEnquiredToFetchRelationsWhenRequestedExplicitly ( )

Definition at line 87 of file ilBuddyListTest.php.

References $buddylist, and ilBuddyList\getInstanceByUserId().

88  {
89  $relations = array(
92  );
93 
94  $repo = $this->getMockBuilder('ilBuddySystemRelationRepository')->disableOriginalConstructor()->getMock();
95  $repo->expects($this->exactly(1))->method('getAll')->willReturn($relations);
96 
97  $buddylist = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
98  $buddylist->reset();
99  $buddylist->setRepository($repo);
100  $this->assertEquals(new ilBuddySystemRelationCollection($relations), $buddylist->getRelations());
101  $this->assertEquals(new ilBuddySystemRelationCollection($relations), $buddylist->getRelations());
102  $this->assertEquals(new ilBuddySystemRelationCollection($relations), $buddylist->getRelations());
103  }
Class ilBuddySystemUnlinkedRelationState.
Class ilBuddySystemRelationCollection A collection which contains all entries of a buddy list...
static getInstanceByUserId($usr_id)
Class ilBuddySystemRelation.
+ Here is the call graph for this function:

◆ testRepositoryIsEnquiredWhenBuddyListShouldBeDestroyed()

ilBuddyListTest::testRepositoryIsEnquiredWhenBuddyListShouldBeDestroyed ( )

Definition at line 322 of file ilBuddyListTest.php.

References $buddylist, and ilBuddyList\getInstanceByUserId().

323  {
324  $repo = $this->getMockBuilder('ilBuddySystemRelationRepository')->disableOriginalConstructor()->getMock();
325  $repo->expects($this->once())->method('destroy');
326 
327  $buddylist = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
328  $buddylist->reset();
329  $buddylist->setRepository($repo);
330  $buddylist->destroy();
331  }
static getInstanceByUserId($usr_id)
+ Here is the call graph for this function:

◆ testStateTransitionExceptionIsThrownWhenALinkedRelationShouldBeMarkedAsIgnored()

ilBuddyListTest::testStateTransitionExceptionIsThrownWhenALinkedRelationShouldBeMarkedAsIgnored ( )

ilBuddySystemRelationStateTransitionException

Definition at line 545 of file ilBuddyListTest.php.

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

546  {
547  $this->assertException(ilBuddySystemRelationStateTransitionException::class);
548  $buddylist = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
549  $buddylist->reset();
550 
551  $state = new ilBuddySystemLinkedRelationState();
552 
553  $relation = new ilBuddySystemRelation($state);
554  $relation->setUserId(self::BUDDY_LIST_OWNER_ID);
555  $relation->setBuddyUserId(self::BUDDY_LIST_BUDDY_ID);
556 
557  $this->setPriorRelationState($relation, $state);
558 
559  $buddylist->ignore($relation);
560  }
static getInstanceByUserId($usr_id)
Class ilBuddySystemRelation.
setPriorRelationState(ilBuddySystemRelation $relation, ilBuddySystemRelationState $state)
+ Here is the call graph for this function:

◆ testUnlinkedRelationIsReturnedWhenRelationWasRequestedForAUknownBuddyId()

ilBuddyListTest::testUnlinkedRelationIsReturnedWhenRelationWasRequestedForAUknownBuddyId ( )

Definition at line 336 of file ilBuddyListTest.php.

References $buddylist, and ilBuddyList\getInstanceByUserId().

337  {
338  $repo = $this->getMockBuilder('ilBuddySystemRelationRepository')->disableOriginalConstructor()->getMock();
339  $repo->expects($this->once())->method('getAll')->willReturn(array());
340 
341  $buddylist = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
342  $buddylist->reset();
343  $buddylist->setRepository($repo);
344  $this->assertInstanceOf('ilBuddySystemUnlinkedRelationState', $buddylist->getRelationByUserId(-3)->getState());
345  }
static getInstanceByUserId($usr_id)
+ Here is the call graph for this function:

◆ testValuesCanBeFetchedByGettersWhenSetBySetters()

ilBuddyListTest::testValuesCanBeFetchedByGettersWhenSetBySetters ( )

Definition at line 350 of file ilBuddyListTest.php.

References $buddylist, and ilBuddyList\getInstanceByUserId().

351  {
352  $buddylist = ilBuddyList::getInstanceByUserId(self::BUDDY_LIST_OWNER_ID);
353  $buddylist->reset();
354  $buddylist->setOwnerId(self::BUDDY_LIST_BUDDY_ID);
355  $this->assertEquals(self::BUDDY_LIST_BUDDY_ID, $buddylist->getOwnerId());
356 
357  $repo = $this->getMockBuilder('ilBuddySystemRelationRepository')->disableOriginalConstructor()->getMock();
358  $repo->expects($this->never())->method('getAll')->willReturn(array());
359  $buddylist->setRepository($repo);
360  $this->assertEquals($repo, $buddylist->getRepository());
361 
362  $relations = array(
363  self::BUDDY_LIST_BUDDY_ID => new ilBuddySystemRelation(new ilBuddySystemUnlinkedRelationState())
364  );
365  $buddylist->setRelations(new ilBuddySystemRelationCollection($relations));
366  $this->assertEquals(new ilBuddySystemRelationCollection($relations), $buddylist->getRelations());
367  }
Class ilBuddySystemUnlinkedRelationState.
Class ilBuddySystemRelationCollection A collection which contains all entries of a buddy list...
static getInstanceByUserId($usr_id)
Class ilBuddySystemRelation.
+ Here is the call graph for this function:

Field Documentation

◆ $buddylist

◆ BUDDY_LIST_BUDDY_ID

const ilBuddyListTest::BUDDY_LIST_BUDDY_ID = -2

Definition at line 12 of file ilBuddyListTest.php.

◆ BUDDY_LIST_OWNER_ID

const ilBuddyListTest::BUDDY_LIST_OWNER_ID = -1

Definition at line 11 of file ilBuddyListTest.php.


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