ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
10{
13
17 protected $buddylist;
18
22 public function setUp()
23 {
24 }
25
30 {
31 $state_mock = $this->getMock('ilBuddySystemRelationState');
32 $relation = new ilBuddySystemRelation($state_mock);
33 $this->assertNull($relation->getPriorState());
34 }
35
40 {
41 $state_mock = $this->getMock('ilBuddySystemRelationState');
42 $further_state_mock = $this->getMock('ilBuddySystemRelationState');
43 $finish_state_mock = $this->getMock('ilBuddySystemRelationState');
44 $state_mock->expects($this->any())->method('link');
45
46 $relation = new ilBuddySystemRelation($state_mock);
47 $relation->setState($further_state_mock);
48 $this->assertEquals($state_mock, $relation->getPriorState());
49 $relation->setState($finish_state_mock);
50 $this->assertEquals($state_mock, $relation->getPriorState());
51 }
52
57 {
58 $state_mock = $this->getMock('ilBuddySystemRelationState');
59 $relation = new ilBuddySystemRelation($state_mock);
60
61 $relation->setUserId(1);
62 $this->assertEquals(1, $relation->getUserId());
63
64 $relation->setBuddyUserId(2);
65 $this->assertEquals(2, $relation->getBuddyUserId());
66
67 $ts = time();
68 $relation->setTimestamp($ts);
69 $this->assertEquals($ts, $relation->getTimestamp());
70 }
71
76 {
77 $state_mock = $this->getMock('ilBuddySystemUnlinkedRelationState');
78 $expected_relation = new ilBuddySystemRelation($state_mock);
79
80 $expected_relation->setUserId(self::RELATION_OWNER_ID);
81 $expected_relation->setBuddyUserId(self::RELATION_OWNER_ID);
82
83 $expected_relation->request();
84 }
85
90 {
91 $state_mock = $this->getMock('ilBuddySystemLinkedRelationState');
92 $expected_relation = new ilBuddySystemRelation($state_mock);
93 $expected_relation->setUserId(self::RELATION_OWNER_ID);
94 $expected_relation->setBuddyUserId(self::RELATION_OWNER_ID);
95
96 $expected_relation->unlink();
97 }
98
103 {
104 $state_mock = $this->getMock('ilBuddySystemRequestedRelationState');
105 $expected_relation = new ilBuddySystemRelation($state_mock);
106 $expected_relation->setUserId(self::RELATION_OWNER_ID);
107 $expected_relation->setBuddyUserId(self::RELATION_OWNER_ID);
108
109 $expected_relation->link();
110 }
111
116 {
117 $state_mock = $this->getMock('ilBuddySystemRequestedRelationState');
118 $expected_relation = new ilBuddySystemRelation($state_mock);
119 $expected_relation->setUserId(self::RELATION_OWNER_ID);
120 $expected_relation->setBuddyUserId(self::RELATION_OWNER_ID);
121
122 $expected_relation->ignore();
123 }
124}
Class ilBuddySystemRelationTest.
testUsersAreNotAbleToUnlinkThemselves()
@expectedException ilBuddySystemRelationStateException
testUsersAreNotAbleToRequestThemselves()
@expectedException ilBuddySystemRelationStateException
testUsersAreNotAbleToLinkThemselves()
@expectedException ilBuddySystemRelationStateException
testUsersAreNotAbleToIgnoreThemselves()
@expectedException ilBuddySystemRelationStateException
Class ilBuddySystemRelation.