ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilBuddySystemRelationTest.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2015 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once 'Services/Contact/BuddySystem/test/ilBuddySystemBaseTest.php';
5 
12 {
13  const RELATION_OWNER_ID = -1;
14  const RELATION_BUDDY_ID = -2;
15 
19  protected $buddylist;
20 
24  public function setUp()
25  {
26  }
27 
32  {
33  $state_mock = $this->getMockBuilder('ilBuddySystemRelationState')->getMock();
34  $relation = new ilBuddySystemRelation($state_mock);
35  $this->assertNull($relation->getPriorState());
36  }
37 
42  {
43  $state_mock = $this->getMockBuilder('ilBuddySystemRelationState')->getMock();
44  $further_state_mock = $this->getMockBuilder('ilBuddySystemRelationState')->getMock();
45  $finish_state_mock = $this->getMockBuilder('ilBuddySystemRelationState')->getMock();
46  $state_mock->expects($this->any())->method('link');
47 
48  $relation = new ilBuddySystemRelation($state_mock);
49  $relation->setState($further_state_mock);
50  $this->assertEquals($state_mock, $relation->getPriorState());
51  $relation->setState($finish_state_mock);
52  $this->assertEquals($state_mock, $relation->getPriorState());
53  }
54 
59  {
60  $state_mock = $this->getMockBuilder('ilBuddySystemRelationState')->getMock();
61  $relation = new ilBuddySystemRelation($state_mock);
62 
63  $relation->setUserId(1);
64  $this->assertEquals(1, $relation->getUserId());
65 
66  $relation->setBuddyUserId(2);
67  $this->assertEquals(2, $relation->getBuddyUserId());
68 
69  $ts = time();
70  $relation->setTimestamp($ts);
71  $this->assertEquals($ts, $relation->getTimestamp());
72  }
73 
78  {
79  $this->assertException(ilBuddySystemRelationStateException::class);
80  $state_mock = $this->getMockBuilder('ilBuddySystemUnlinkedRelationState')->getMock();
81  $expected_relation = new ilBuddySystemRelation($state_mock);
82 
83  $expected_relation->setUserId(self::RELATION_OWNER_ID);
84  $expected_relation->setBuddyUserId(self::RELATION_OWNER_ID);
85 
86  $expected_relation->request();
87  }
88 
93  {
94  $this->assertException(ilBuddySystemRelationStateException::class);
95  $state_mock = $this->getMockBuilder('ilBuddySystemLinkedRelationState')->getMock();
96  $expected_relation = new ilBuddySystemRelation($state_mock);
97  $expected_relation->setUserId(self::RELATION_OWNER_ID);
98  $expected_relation->setBuddyUserId(self::RELATION_OWNER_ID);
99 
100  $expected_relation->unlink();
101  }
102 
107  {
108  $this->assertException(ilBuddySystemRelationStateException::class);
109  $state_mock = $this->getMockBuilder('ilBuddySystemRequestedRelationState')->getMock();
110  $expected_relation = new ilBuddySystemRelation($state_mock);
111  $expected_relation->setUserId(self::RELATION_OWNER_ID);
112  $expected_relation->setBuddyUserId(self::RELATION_OWNER_ID);
113 
114  $expected_relation->link();
115  }
116 
121  {
122  $this->assertException(ilBuddySystemRelationStateException::class);
123  $state_mock = $this->getMockBuilder('ilBuddySystemRequestedRelationState')->getMock();
124  $expected_relation = new ilBuddySystemRelation($state_mock);
125  $expected_relation->setUserId(self::RELATION_OWNER_ID);
126  $expected_relation->setBuddyUserId(self::RELATION_OWNER_ID);
127 
128  $expected_relation->ignore();
129  }
130 }
testUsersAreNotAbleToRequestThemselves()
ilBuddySystemRelationStateException
assertException($exception_class)
testUsersAreNotAbleToUnlinkThemselves()
ilBuddySystemRelationStateException
testUsersAreNotAbleToLinkThemselves()
ilBuddySystemRelationStateException
Class ilBuddySystemRelationTest.
testUsersAreNotAbleToIgnoreThemselves()
ilBuddySystemRelationStateException
Class ilBuddySystemRelation.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.