ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilBuddySystemStateFactoryTestCase Class Reference
+ Inheritance diagram for ilBuddySystemStateFactoryTestCase:
+ Collaboration diagram for ilBuddySystemStateFactoryTestCase:

Public Member Functions

 testInitialStateEqualsUnlinkedRelation ()
 
 testStatesCanBeReceivedAsOptionMap ()
 
 testRelationsCanBeFilteredByState ()
 

Protected Member Functions

 setUp ()
 
- Protected Member Functions inherited from ilBuddySystemBaseTestCase
 setUp ()
 
 tearDown ()
 
 setGlobalVariable (string $name, mixed $value)
 

Private Attributes

ilBuddySystemRelationStateFactory $stateFactory
 

Detailed Description

Definition at line 21 of file ilBuddySystemStateFactoryTestCase.php.

Member Function Documentation

◆ setUp()

ilBuddySystemStateFactoryTestCase::setUp ( )
protected

Definition at line 25 of file ilBuddySystemStateFactoryTestCase.php.

References $lng, and ilBuddySystemRelationStateFactory\getInstance().

25  : void
26  {
27  parent::setUp();
28 
29  $lng = $this->getMockBuilder(ilLanguage::class)->disableOriginalConstructor()->getMock();
30  $lng->method('txt')->willReturnCallback(static fn(string $keyword): string => $keyword);
31 
34  }
global $lng
Definition: privfeed.php:31
+ Here is the call graph for this function:

◆ testInitialStateEqualsUnlinkedRelation()

ilBuddySystemStateFactoryTestCase::testInitialStateEqualsUnlinkedRelation ( )

Definition at line 36 of file ilBuddySystemStateFactoryTestCase.php.

36  : void
37  {
38  $this->assertInstanceOf(
39  ilBuddySystemUnlinkedRelationState::class,
40  $this->stateFactory->getInitialState()
41  );
42  }

◆ testRelationsCanBeFilteredByState()

ilBuddySystemStateFactoryTestCase::testRelationsCanBeFilteredByState ( )

Definition at line 62 of file ilBuddySystemStateFactoryTestCase.php.

References $relation.

62  : void
63  {
64  $validStates = $this->stateFactory->getValidStates();
65  $this->assertThat(count($validStates), $this->greaterThan(0));
66 
67  foreach ($this->stateFactory->getValidStates() as $state) {
68  $tableFilterStateMapper = $this->stateFactory->getTableFilterStateMapper($state);
69 
70  $otions = $tableFilterStateMapper->optionsForState();
71  $this->assertThat(count($otions), $this->greaterThan(0));
72 
73  array_walk($otions, function (string $value, string $key) use ($tableFilterStateMapper, $state): void {
74  if ($state instanceof ilBuddySystemRequestedRelationState) {
75  if ($key === $state::class . '_a') {
76  $relation = $this->getMockBuilder(ilBuddySystemRelation::class)->disableOriginalConstructor()->getMock();
77  $relation->method('isOwnedByActor')->willReturn(false);
78 
79  $this->assertFalse($tableFilterStateMapper->filterMatchesRelation($key, $relation));
80 
81  $relation = $this->getMockBuilder(ilBuddySystemRelation::class)->disableOriginalConstructor()->getMock();
82  $relation->method('isOwnedByActor')->willReturn(true);
83  $this->assertTrue($tableFilterStateMapper->filterMatchesRelation($key, $relation));
84  } elseif ($key === $state::class . '_p') {
85  $relation = $this->getMockBuilder(ilBuddySystemRelation::class)->disableOriginalConstructor()->getMock();
86  $relation->method('isOwnedByActor')->willReturn(true);
87 
88  $this->assertFalse($tableFilterStateMapper->filterMatchesRelation($key, $relation));
89 
90  $relation = $this->getMockBuilder(ilBuddySystemRelation::class)->disableOriginalConstructor()->getMock();
91  $relation->method('isOwnedByActor')->willReturn(false);
92  }
93  } else {
94  $relation = $this->getMockBuilder(ilBuddySystemRelation::class)->disableOriginalConstructor()->getMock();
95  $this->assertTrue($tableFilterStateMapper->filterMatchesRelation($key, $relation));
96  }
97  });
98  }
99  }
$relation

◆ testStatesCanBeReceivedAsOptionMap()

ilBuddySystemStateFactoryTestCase::testStatesCanBeReceivedAsOptionMap ( )

Definition at line 44 of file ilBuddySystemStateFactoryTestCase.php.

44  : void
45  {
46  $validStates = $this->stateFactory->getValidStates();
47  $this->assertThat(count($validStates), $this->greaterThan(0));
48 
49  foreach ($this->stateFactory->getValidStates() as $state) {
50  $tableFilterStateMapper = $this->stateFactory->getTableFilterStateMapper($state);
51 
52  $otions = $tableFilterStateMapper->optionsForState();
53  $this->assertThat(count($otions), $this->greaterThan(0));
54 
55  array_walk($otions, function (string $value, string $key): void {
56  $this->assertNotEmpty($value, 'Option value for table filter must not be empty');
57  $this->assertNotEmpty($key, 'Option key for table filter must not be empty');
58  });
59  }
60  }

Field Documentation

◆ $stateFactory

ilBuddySystemRelationStateFactory ilBuddySystemStateFactoryTestCase::$stateFactory
private

Definition at line 23 of file ilBuddySystemStateFactoryTestCase.php.


The documentation for this class was generated from the following file: