ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
4require_once 'Services/Contact/BuddySystem/test/ilBuddySystemBaseTest.php';
5
12{
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}
An exception for terminatinating execution or to throw for unit testing.
assertException($exception_class)
Class ilBuddySystemRelationTest.
testUsersAreNotAbleToUnlinkThemselves()
@expectedException ilBuddySystemRelationStateException
testUsersAreNotAbleToRequestThemselves()
@expectedException ilBuddySystemRelationStateException
testUsersAreNotAbleToLinkThemselves()
@expectedException ilBuddySystemRelationStateException
testUsersAreNotAbleToIgnoreThemselves()
@expectedException ilBuddySystemRelationStateException
Class ilBuddySystemRelation.