19 declare(strict_types=1);
32 $stateMock = $this->getMockBuilder(ilBuddySystemRelationState::class)->getMock();
35 self::RELATION_OWNER_ID,
36 self::RELATION_OWNER_ID,
40 $this->assertNull($relation->getPriorState());
45 $stateMock = $this->getMockBuilder(ilBuddySystemRelationState::class)->getMock();
46 $furtherStateMock = $this->getMockBuilder(ilBuddySystemRelationState::class)->getMock();
47 $finishStateMock = $this->getMockBuilder(ilBuddySystemRelationState::class)->getMock();
48 $stateMock->method(
'link');
52 self::RELATION_OWNER_ID,
53 self::RELATION_OWNER_ID,
57 $relation->setState($furtherStateMock);
58 $this->assertEquals($stateMock, $relation->getPriorState());
59 $relation->setState($finishStateMock);
60 $this->assertEquals($stateMock, $relation->getPriorState());
65 $stateMock = $this->getMockBuilder(ilBuddySystemRelationState::class)->getMock();
69 self::RELATION_OWNER_ID,
70 self::RELATION_OWNER_ID,
75 $relation = $relation->withUsrId(1);
76 $this->assertSame(1, $relation->getUsrId());
78 $relation = $relation->withBuddyUsrId(2);
79 $this->assertSame(2, $relation->getBuddyUsrId());
81 $relation = $relation->withTimestamp($ts + 1);
82 $this->assertSame($ts + 1, $relation->getTimestamp());
84 $relation = $relation->withIsOwnedByActor(
true);
85 $this->assertTrue($relation->isOwnedByActor());
90 $this->expectException(ilBuddySystemRelationStateException::class);
91 $stateMock = $this->getMockBuilder(ilBuddySystemUnlinkedRelationState::class)->getMock();
94 self::RELATION_OWNER_ID,
95 self::RELATION_OWNER_ID,
100 $expectedRelation = $expectedRelation->withUsrId(self::RELATION_OWNER_ID);
101 $expectedRelation = $expectedRelation->withBuddyUsrId(self::RELATION_OWNER_ID);
103 $expectedRelation->request();
108 $this->expectException(ilBuddySystemRelationStateException::class);
109 $stateMock = $this->getMockBuilder(ilBuddySystemLinkedRelationState::class)->getMock();
112 self::RELATION_OWNER_ID,
113 self::RELATION_OWNER_ID,
117 $expectedRelation = $expectedRelation->withUsrId(self::RELATION_OWNER_ID);
118 $expectedRelation = $expectedRelation->withBuddyUsrId(self::RELATION_OWNER_ID);
120 $expectedRelation->unlink();
125 $this->expectException(ilBuddySystemRelationStateException::class);
126 $stateMock = $this->getMockBuilder(ilBuddySystemRequestedRelationState::class)->getMock();
129 self::RELATION_OWNER_ID,
130 self::RELATION_OWNER_ID,
134 $expectedRelation = $expectedRelation->withUsrId(self::RELATION_OWNER_ID);
135 $expectedRelation = $expectedRelation->withBuddyUsrId(self::RELATION_OWNER_ID);
137 $expectedRelation->link();
142 $this->expectException(ilBuddySystemRelationStateException::class);
143 $stateMock = $this->getMockBuilder(ilBuddySystemRequestedRelationState::class)->getMock();
146 self::RELATION_OWNER_ID,
147 self::RELATION_OWNER_ID,
151 $expectedRelation = $expectedRelation->withUsrId(self::RELATION_OWNER_ID);
152 $expectedRelation = $expectedRelation->withBuddyUsrId(self::RELATION_OWNER_ID);
154 $expectedRelation->ignore();
testUsersAreNotAbleToRequestThemselves()
testValuesCanBeFetchedByGettersWhenSetBySetters()
testUsersAreNotAbleToUnlinkThemselves()
testUsersAreNotAbleToLinkThemselves()
testPriorStateIsEmptyAfterInstanceWasCreated()
Class ilBuddySystemRelationTest.
testPriorStateCanBeRetrievedAfterSubsequentTransitions()
testUsersAreNotAbleToIgnoreThemselves()