ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ILIAS\MetaData\Elements\ElementTest Class Reference
+ Inheritance diagram for ILIAS\MetaData\Elements\ElementTest:
+ Collaboration diagram for ILIAS\MetaData\Elements\ElementTest:

Public Member Functions

 testSubAndSuperElements ()
 
 testGetData ()
 
 testIsScaffold ()
 
 testGetMarkerAndIsMarked ()
 
 testMarkerTrail ()
 
 testMarkTwice ()
 
 testMarkWithScaffolds ()
 
 testAddScaffolds ()
 
 testAddScaffoldByName ()
 
 testAddScaffoldsWithSubElementsException ()
 
 testAddScaffoldByNameWithSubElementsException ()
 

Protected Member Functions

 getDefinition (string $name)
 
 getElement (int|NoID $id, Element ... $elements)
 
 getElementWithName (int|NoID $id, string $name, Element ... $elements)
 

Detailed Description

Definition at line 35 of file ElementTest.php.

Member Function Documentation

◆ getDefinition()

ILIAS\MetaData\Elements\ElementTest::getDefinition ( string  $name)
protected

Definition at line 37 of file ElementTest.php.

References ILIAS\__construct().

Referenced by ILIAS\MetaData\Elements\ElementTest\getElement(), ILIAS\MetaData\Elements\ElementTest\getElementWithName(), and ILIAS\MetaData\Elements\ElementTest\testGetData().

37  : DefinitionInterface
38  {
39  return new class ($name) extends NullDefinition {
40  public function __construct(protected string $name)
41  {
42  }
43 
44  public function name(): string
45  {
46  return $this->name;
47  }
48  };
49  }
__construct()
Constructor setup ILIAS global object public.
Definition: class.ilias.php:62
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getElement()

◆ getElementWithName()

ILIAS\MetaData\Elements\ElementTest::getElementWithName ( int|NoID  $id,
string  $name,
Element ...  $elements 
)
protected

Definition at line 63 of file ElementTest.php.

References ILIAS\MetaData\Elements\ElementTest\getDefinition().

Referenced by ILIAS\MetaData\Elements\ElementTest\testAddScaffoldByName(), and ILIAS\MetaData\Elements\ElementTest\testAddScaffolds().

67  : Element {
68  return new Element(
69  $id,
70  $this->getDefinition($name),
71  new NullData(),
72  ...$elements
73  );
74  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testAddScaffoldByName()

ILIAS\MetaData\Elements\ElementTest::testAddScaffoldByName ( )

Definition at line 207 of file ElementTest.php.

References ILIAS\MetaData\Elements\ElementTest\getElement(), and ILIAS\MetaData\Elements\ElementTest\getElementWithName().

207  : void
208  {
209  $second = $this->getElementWithName(6, 'second');
210  $third = $this->getElementWithName(17, 'third');
211  $el = $this->getElement(13, $second, $third);
212 
213  $el->addScaffoldToSubElements(new MockScaffoldProvider(), 'second');
214 
215  $subs = $el->getSubElements();
216  $this->assertSame($second, $subs->current());
217  $subs->next();
218  $this->assertTrue($subs->current()->isScaffold());
219  $this->assertSame('second', $subs->current()->getDefinition()->name());
220  $subs->next();
221  $this->assertSame($third, $subs->current());
222  $subs->next();
223  $this->assertNull($subs->current());
224  }
getElementWithName(int|NoID $id, string $name, Element ... $elements)
Definition: ElementTest.php:63
getElement(int|NoID $id, Element ... $elements)
Definition: ElementTest.php:51
+ Here is the call graph for this function:

◆ testAddScaffoldByNameWithSubElementsException()

ILIAS\MetaData\Elements\ElementTest::testAddScaffoldByNameWithSubElementsException ( )

Definition at line 234 of file ElementTest.php.

References ILIAS\MetaData\Elements\ElementTest\getElement().

234  : void
235  {
236  $el = $this->getElement(37);
237 
238  $this->expectException(\ilMDElementsException::class);
239  $el->addScaffoldToSubElements(new MockBrokenScaffoldProvider(), 'with sub');
240  }
getElement(int|NoID $id, Element ... $elements)
Definition: ElementTest.php:51
+ Here is the call graph for this function:

◆ testAddScaffolds()

ILIAS\MetaData\Elements\ElementTest::testAddScaffolds ( )

Definition at line 185 of file ElementTest.php.

References ILIAS\MetaData\Elements\ElementTest\getElement(), and ILIAS\MetaData\Elements\ElementTest\getElementWithName().

185  : void
186  {
187  $second = $this->getElementWithName(6, 'second');
188  $el = $this->getElement(13, $second);
189 
190  $el->addScaffoldsToSubElements(new MockScaffoldProvider());
191 
192  $subs = $el->getSubElements();
193  $this->assertTrue($subs->current()->isScaffold());
194  $this->assertSame('first', $subs->current()->getDefinition()->name());
195  $subs->next();
196  $this->assertSame($second, $subs->current());
197  $subs->next();
198  $this->assertTrue($subs->current()->isScaffold());
199  $this->assertSame('second', $subs->current()->getDefinition()->name());
200  $subs->next();
201  $this->assertTrue($subs->current()->isScaffold());
202  $this->assertSame('third', $subs->current()->getDefinition()->name());
203  $subs->next();
204  $this->assertNull($subs->current());
205  }
getElementWithName(int|NoID $id, string $name, Element ... $elements)
Definition: ElementTest.php:63
getElement(int|NoID $id, Element ... $elements)
Definition: ElementTest.php:51
+ Here is the call graph for this function:

◆ testAddScaffoldsWithSubElementsException()

ILIAS\MetaData\Elements\ElementTest::testAddScaffoldsWithSubElementsException ( )

Definition at line 226 of file ElementTest.php.

References ILIAS\MetaData\Elements\ElementTest\getElement().

226  : void
227  {
228  $el = $this->getElement(37);
229 
230  $this->expectException(\ilMDElementsException::class);
231  $el->addScaffoldsToSubElements(new MockBrokenScaffoldProvider());
232  }
getElement(int|NoID $id, Element ... $elements)
Definition: ElementTest.php:51
+ Here is the call graph for this function:

◆ testGetData()

ILIAS\MetaData\Elements\ElementTest::testGetData ( )

Definition at line 94 of file ElementTest.php.

References $data, and ILIAS\MetaData\Elements\ElementTest\getDefinition().

94  : void
95  {
96  $data = new NullData();
97  $el = new Element(
98  7,
99  $this->getDefinition('name'),
100  $data
101  );
102 
103  $this->assertSame($data, $el->getData());
104  }
+ Here is the call graph for this function:

◆ testGetMarkerAndIsMarked()

ILIAS\MetaData\Elements\ElementTest::testGetMarkerAndIsMarked ( )

Definition at line 115 of file ElementTest.php.

References ILIAS\MetaData\Elements\ElementTest\getElement().

115  : void
116  {
117  $mark_me = $this->getElement(13);
118  $stay_away = $this->getElement(7);
119  $mark_me->mark(new MockMarkerFactory(), Action::NEUTRAL);
120 
121  $this->assertTrue($mark_me->isMarked());
122  $this->assertInstanceOf(MarkerInterface::class, $mark_me->getMarker());
123  $this->assertFalse($stay_away->isMarked());
124  $this->assertNull($stay_away->getMarker());
125  }
getElement(int|NoID $id, Element ... $elements)
Definition: ElementTest.php:51
+ Here is the call graph for this function:

◆ testIsScaffold()

ILIAS\MetaData\Elements\ElementTest::testIsScaffold ( )

Definition at line 106 of file ElementTest.php.

References ILIAS\MetaData\Elements\ElementTest\getElement().

106  : void
107  {
108  $scaffold = $this->getElement(NoID::SCAFFOLD);
109  $not_scaffold = $this->getElement(5);
110 
111  $this->assertTrue($scaffold->isScaffold());
112  $this->assertFalse($not_scaffold->isScaffold());
113  }
getElement(int|NoID $id, Element ... $elements)
Definition: ElementTest.php:51
+ Here is the call graph for this function:

◆ testMarkerTrail()

ILIAS\MetaData\Elements\ElementTest::testMarkerTrail ( )

Definition at line 127 of file ElementTest.php.

References ILIAS\MetaData\Elements\ElementTest\getElement().

127  : void
128  {
129  $el111 = $this->getElement(111);
130  $el11 = $this->getElement(11, $el111);
131  $el12 = $this->getElement(12);
132  $el1 = $this->getElement(1, $el11, $el12);
133  $el2 = $this->getElement(2);
134  $root = $this->getElement(NoID::ROOT, $el1, $el2);
135 
136  $el11->mark(new MockMarkerFactory(), Action::CREATE_OR_UPDATE);
137 
138  $this->assertTrue($el11->isMarked());
139  $this->assertSame(Action::CREATE_OR_UPDATE, $el11->getMarker()->action());
140  $this->assertTrue($el1->isMarked());
141  $this->assertSame(Action::NEUTRAL, $el1->getMarker()->action());
142  $this->assertTrue($root->isMarked());
143  $this->assertSame(Action::NEUTRAL, $root->getMarker()->action());
144 
145  $this->assertFalse($el111->isMarked());
146  $this->assertFalse($el12->isMarked());
147  $this->assertFalse($el2->isMarked());
148  }
getElement(int|NoID $id, Element ... $elements)
Definition: ElementTest.php:51
+ Here is the call graph for this function:

◆ testMarkTwice()

ILIAS\MetaData\Elements\ElementTest::testMarkTwice ( )

Definition at line 150 of file ElementTest.php.

References ILIAS\MetaData\Elements\Markers\DELETE, and ILIAS\MetaData\Elements\ElementTest\getElement().

150  : void
151  {
152  $marker_factory = new MockMarkerFactory();
153  $sub = $this->getElement(11);
154  $el = $this->getElement(1, $sub);
155 
156  $el->mark($marker_factory, Action::CREATE_OR_UPDATE);
157  $this->assertSame(Action::CREATE_OR_UPDATE, $el->getMarker()->action());
158 
159  $sub->mark($marker_factory, Action::DELETE);
160  $this->assertSame(Action::DELETE, $sub->getMarker()->action());
161  $this->assertSame(Action::CREATE_OR_UPDATE, $el->getMarker()->action());
162 
163  $el->mark($marker_factory, Action::DELETE);
164  $this->assertSame(Action::DELETE, $el->getMarker()->action());
165  }
getElement(int|NoID $id, Element ... $elements)
Definition: ElementTest.php:51
+ Here is the call graph for this function:

◆ testMarkWithScaffolds()

ILIAS\MetaData\Elements\ElementTest::testMarkWithScaffolds ( )

Definition at line 167 of file ElementTest.php.

References ILIAS\MetaData\Elements\Markers\DELETE, and ILIAS\MetaData\Elements\ElementTest\getElement().

167  : void
168  {
169  $marker_factory = new MockMarkerFactory();
170  $sub = $this->getElement(NoID::SCAFFOLD);
171  $el = $this->getElement(NoID::SCAFFOLD, $sub);
172 
173  $sub->mark($marker_factory, Action::CREATE_OR_UPDATE);
174  $this->assertSame(Action::CREATE_OR_UPDATE, $sub->getMarker()->action());
175  $this->assertSame(Action::CREATE_OR_UPDATE, $el->getMarker()->action());
176 
177  $sub = $this->getElement(NoID::SCAFFOLD);
178  $el = $this->getElement(NoID::SCAFFOLD, $sub);
179 
180  $sub->mark($marker_factory, Action::DELETE);
181  $this->assertSame(Action::DELETE, $sub->getMarker()->action());
182  $this->assertSame(Action::NEUTRAL, $el->getMarker()->action());
183  }
getElement(int|NoID $id, Element ... $elements)
Definition: ElementTest.php:51
+ Here is the call graph for this function:

◆ testSubAndSuperElements()

ILIAS\MetaData\Elements\ElementTest::testSubAndSuperElements ( )

Definition at line 76 of file ElementTest.php.

References ILIAS\MetaData\Elements\ElementTest\getElement().

76  : void
77  {
78  $el11 = $this->getElement(11);
79  $el1 = $this->getElement(1, $el11);
80  $el2 = $this->getElement(2);
81  $root = $this->getElement(NoID::ROOT, $el1, $el2);
82 
83  $subs = $root->getSubElements();
84  $this->assertSame($el1, $subs->current());
85  $subs->next();
86  $this->assertSame($el2, $subs->current());
87  $subs->next();
88  $this->assertNull($subs->current());
89 
90  $this->assertSame($root, $el1->getSuperElement());
91  $this->assertSame($el11, $el1->getSubElements()->current());
92  }
getElement(int|NoID $id, Element ... $elements)
Definition: ElementTest.php:51
+ Here is the call graph for this function:

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