ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilBuddySystemStateFactoryTest Class Reference
+ Inheritance diagram for ilBuddySystemStateFactoryTest:
+ Collaboration diagram for ilBuddySystemStateFactoryTest:

Public Member Functions

 testInitialStateEqualsUnlinkedRelation ()
 
 testStatesCanBeReceivedAsOptionMap ()
 
 testRelationsCanBeFilteredByState ()
 

Protected Member Functions

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

Private Attributes

ilBuddySystemRelationStateFactory $stateFactory
 

Detailed Description

Definition at line 21 of file ilBuddySystemStateFactoryTest.php.

Member Function Documentation

◆ setUp()

ilBuddySystemStateFactoryTest::setUp ( )
protected

Definition at line 25 of file ilBuddySystemStateFactoryTest.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 function (string $keyword): string {
31  return $keyword;
32  });
33 
36  }
$lng
+ Here is the call graph for this function:

◆ testInitialStateEqualsUnlinkedRelation()

ilBuddySystemStateFactoryTest::testInitialStateEqualsUnlinkedRelation ( )

Definition at line 38 of file ilBuddySystemStateFactoryTest.php.

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

◆ testRelationsCanBeFilteredByState()

ilBuddySystemStateFactoryTest::testRelationsCanBeFilteredByState ( )

Definition at line 64 of file ilBuddySystemStateFactoryTest.php.

References ILIAS\LTI\ToolProvider\$key.

64  : void
65  {
66  $validStates = $this->stateFactory->getValidStates();
67  $this->assertThat(count($validStates), $this->greaterThan(0));
68 
69  foreach ($this->stateFactory->getValidStates() as $state) {
70  $tableFilterStateMapper = $this->stateFactory->getTableFilterStateMapper($state);
71 
72  $otions = $tableFilterStateMapper->optionsForState();
73  $this->assertThat(count($otions), $this->greaterThan(0));
74 
75  array_walk($otions, function (string $value, string $key) use ($tableFilterStateMapper, $state): void {
76  if ($state instanceof ilBuddySystemRequestedRelationState) {
77  if ($key === get_class($state) . '_a') {
78  $relation = $this->getMockBuilder(ilBuddySystemRelation::class)->disableOriginalConstructor()->getMock();
79  $relation->method('isOwnedByActor')->willReturn(false);
80 
81  $this->assertFalse($tableFilterStateMapper->filterMatchesRelation($key, $relation));
82 
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);
89 
90  $this->assertFalse($tableFilterStateMapper->filterMatchesRelation($key, $relation));
91 
92  $relation = $this->getMockBuilder(ilBuddySystemRelation::class)->disableOriginalConstructor()->getMock();
93  $relation->method('isOwnedByActor')->willReturn(false);
94  }
95  } else {
96  $relation = $this->getMockBuilder(ilBuddySystemRelation::class)->disableOriginalConstructor()->getMock();
97  $this->assertTrue($tableFilterStateMapper->filterMatchesRelation($key, $relation));
98  }
99  });
100  }
101  }
string $key
Consumer key/client ID value.
Definition: System.php:193

◆ testStatesCanBeReceivedAsOptionMap()

ilBuddySystemStateFactoryTest::testStatesCanBeReceivedAsOptionMap ( )

Definition at line 46 of file ilBuddySystemStateFactoryTest.php.

References ILIAS\LTI\ToolProvider\$key.

46  : void
47  {
48  $validStates = $this->stateFactory->getValidStates();
49  $this->assertThat(count($validStates), $this->greaterThan(0));
50 
51  foreach ($this->stateFactory->getValidStates() as $state) {
52  $tableFilterStateMapper = $this->stateFactory->getTableFilterStateMapper($state);
53 
54  $otions = $tableFilterStateMapper->optionsForState();
55  $this->assertThat(count($otions), $this->greaterThan(0));
56 
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');
60  });
61  }
62  }
string $key
Consumer key/client ID value.
Definition: System.php:193

Field Documentation

◆ $stateFactory

ilBuddySystemRelationStateFactory ilBuddySystemStateFactoryTest::$stateFactory
private

Definition at line 23 of file ilBuddySystemStateFactoryTest.php.


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