ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilBuddySystemRelationTestCase.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 private const int RELATION_OWNER_ID = -1;
24
26 {
27 $stateMock = $this->getMockBuilder(ilBuddySystemRelationState::class)->getMock();
29 $stateMock,
30 self::RELATION_OWNER_ID,
31 self::RELATION_OWNER_ID,
32 false,
33 time()
34 );
35 $this->assertNull($relation->getPriorState());
36 }
37
39 {
40 $stateMock = $this->getMockBuilder(ilBuddySystemRelationState::class)->getMock();
41 $furtherStateMock = $this->getMockBuilder(ilBuddySystemRelationState::class)->getMock();
42 $finishStateMock = $this->getMockBuilder(ilBuddySystemRelationState::class)->getMock();
43 $stateMock->method('link');
44
46 $stateMock,
47 self::RELATION_OWNER_ID,
48 self::RELATION_OWNER_ID,
49 false,
50 time()
51 );
52 $relation->setState($furtherStateMock);
53 $this->assertEquals($stateMock, $relation->getPriorState());
54 $relation->setState($finishStateMock);
55 $this->assertEquals($stateMock, $relation->getPriorState());
56 }
57
59 {
60 $stateMock = $this->getMockBuilder(ilBuddySystemRelationState::class)->getMock();
61 $ts = time();
63 $stateMock,
64 self::RELATION_OWNER_ID,
65 self::RELATION_OWNER_ID,
66 false,
67 time()
68 );
69
70 $relation = $relation->withUsrId(1);
71 $this->assertSame(1, $relation->getUsrId());
72
73 $relation = $relation->withBuddyUsrId(2);
74 $this->assertSame(2, $relation->getBuddyUsrId());
75
76 $relation = $relation->withTimestamp($ts + 1);
77 $this->assertSame($ts + 1, $relation->getTimestamp());
78
79 $relation = $relation->withIsOwnedByActor(true);
80 $this->assertTrue($relation->isOwnedByActor());
81 }
82
84 {
85 $this->expectException(ilBuddySystemRelationStateException::class);
86 $stateMock = $this->getMockBuilder(ilBuddySystemUnlinkedRelationState::class)->getMock();
87 $expectedRelation = new ilBuddySystemRelation(
88 $stateMock,
89 self::RELATION_OWNER_ID,
90 self::RELATION_OWNER_ID,
91 false,
92 time()
93 );
94
95 $expectedRelation = $expectedRelation->withUsrId(self::RELATION_OWNER_ID);
96 $expectedRelation = $expectedRelation->withBuddyUsrId(self::RELATION_OWNER_ID);
97
98 $expectedRelation->request();
99 }
100
102 {
103 $this->expectException(ilBuddySystemRelationStateException::class);
104 $stateMock = $this->getMockBuilder(ilBuddySystemLinkedRelationState::class)->getMock();
105 $expectedRelation = new ilBuddySystemRelation(
106 $stateMock,
107 self::RELATION_OWNER_ID,
108 self::RELATION_OWNER_ID,
109 false,
110 time()
111 );
112 $expectedRelation = $expectedRelation->withUsrId(self::RELATION_OWNER_ID);
113 $expectedRelation = $expectedRelation->withBuddyUsrId(self::RELATION_OWNER_ID);
114
115 $expectedRelation->unlink();
116 }
117
119 {
120 $this->expectException(ilBuddySystemRelationStateException::class);
121 $stateMock = $this->getMockBuilder(ilBuddySystemRequestedRelationState::class)->getMock();
122 $expectedRelation = new ilBuddySystemRelation(
123 $stateMock,
124 self::RELATION_OWNER_ID,
125 self::RELATION_OWNER_ID,
126 false,
127 time()
128 );
129 $expectedRelation = $expectedRelation->withUsrId(self::RELATION_OWNER_ID);
130 $expectedRelation = $expectedRelation->withBuddyUsrId(self::RELATION_OWNER_ID);
131
132 $expectedRelation->link();
133 }
134
136 {
137 $this->expectException(ilBuddySystemRelationStateException::class);
138 $stateMock = $this->getMockBuilder(ilBuddySystemRequestedRelationState::class)->getMock();
139 $expectedRelation = new ilBuddySystemRelation(
140 $stateMock,
141 self::RELATION_OWNER_ID,
142 self::RELATION_OWNER_ID,
143 false,
144 time()
145 );
146 $expectedRelation = $expectedRelation->withUsrId(self::RELATION_OWNER_ID);
147 $expectedRelation = $expectedRelation->withBuddyUsrId(self::RELATION_OWNER_ID);
148
149 $expectedRelation->ignore();
150 }
151}
$relation
Class ilBuddySystemRelation.