19 declare(strict_types=1);
25 protected function setUp(): void
29 $lng = $this->getMockBuilder(ilLanguage::class)->disableOriginalConstructor()->getMock();
30 $lng->method(
'txt')->willReturnCallback(
static function (
string $keyword):
string {
40 $this->assertInstanceOf(
41 ilBuddySystemUnlinkedRelationState::class,
42 $this->stateFactory->getInitialState()
48 $validStates = $this->stateFactory->getValidStates();
49 $this->assertThat(count($validStates), $this->greaterThan(0));
51 foreach ($this->stateFactory->getValidStates() as $state) {
52 $tableFilterStateMapper = $this->stateFactory->getTableFilterStateMapper($state);
54 $otions = $tableFilterStateMapper->optionsForState();
55 $this->assertThat(count($otions), $this->greaterThan(0));
57 array_walk($otions,
function (
string $value,
string $key):
void {
58 $this->assertNotEmpty($value,
'Option value for table filter must not be empty');
59 $this->assertNotEmpty($key,
'Option key for table filter must not be empty');
66 $validStates = $this->stateFactory->getValidStates();
67 $this->assertThat(count($validStates), $this->greaterThan(0));
69 foreach ($this->stateFactory->getValidStates() as $state) {
70 $tableFilterStateMapper = $this->stateFactory->getTableFilterStateMapper($state);
72 $otions = $tableFilterStateMapper->optionsForState();
73 $this->assertThat(count($otions), $this->greaterThan(0));
75 array_walk($otions,
function (
string $value,
string $key) use ($tableFilterStateMapper, $state):
void {
77 if ($key === get_class($state) .
'_a') {
78 $relation = $this->getMockBuilder(ilBuddySystemRelation::class)->disableOriginalConstructor()->getMock();
79 $relation->method(
'isOwnedByActor')->willReturn(
false);
81 $this->assertFalse($tableFilterStateMapper->filterMatchesRelation($key, $relation));
83 $relation = $this->getMockBuilder(ilBuddySystemRelation::class)->disableOriginalConstructor()->getMock();
84 $relation->method(
'isOwnedByActor')->willReturn(
true);
85 $this->assertTrue($tableFilterStateMapper->filterMatchesRelation($key, $relation));
86 } elseif ($key === get_class($state) .
'_p') {
87 $relation = $this->getMockBuilder(ilBuddySystemRelation::class)->disableOriginalConstructor()->getMock();
88 $relation->method(
'isOwnedByActor')->willReturn(
true);
90 $this->assertFalse($tableFilterStateMapper->filterMatchesRelation($key, $relation));
92 $relation = $this->getMockBuilder(ilBuddySystemRelation::class)->disableOriginalConstructor()->getMock();
93 $relation->method(
'isOwnedByActor')->willReturn(
false);
96 $relation = $this->getMockBuilder(ilBuddySystemRelation::class)->disableOriginalConstructor()->getMock();
97 $this->assertTrue($tableFilterStateMapper->filterMatchesRelation($key, $relation));
static getInstance(?ilLanguage $lng=null)
Class ilBuddySystemRelationStateFactory.
testRelationsCanBeFilteredByState()
testStatesCanBeReceivedAsOptionMap()
testInitialStateEqualsUnlinkedRelation()
ilBuddySystemRelationStateFactory $stateFactory
Class ilBuddySystemRequestedRelationState.