19declare(strict_types=1);
23use PHPUnit\Framework\TestCase;
47 public function name():
string
59 return new class ($action) extends
NullMarker {
64 $this->action = $action;
67 public function action():
Action
72 public function dataValue():
string
91 protected string $name;
98 public function name():
string
103 public function unique():
bool
108 public function dataType():
Type
115 public function type():
Type
120 public function value():
string
134 public function getScaffoldsForElement(
ElementInterface $element): \Generator
137 $sub = $this->getScaffold(
'name');
138 $with_sub = $this->getScaffold(
'with sub', $sub);
140 yield
'' => $with_sub;
144 $first = $this->getScaffold(
'first');
145 $second = $this->getScaffold(
'second');
146 $third = $this->getScaffold(
'third');
147 $fourth = $this->getScaffold(
'fourth');
155 public function getPossibleSubElementNamesForElementInOrder(
ElementInterface $element): \Generator
184 $this->getDefinition($name),
192 $el11 = $this->getElement(11);
193 $el1 = $this->getElement(1, $el11);
194 $el2 = $this->getElement(2);
195 $root = $this->getElement(NoID::ROOT, $el1, $el2);
197 $subs = $root->getSubElements();
198 $this->assertSame($el1, $subs->current());
200 $this->assertSame($el2, $subs->current());
202 $this->assertNull($subs->current());
204 $this->assertSame($root, $el1->getSuperElement());
205 $this->assertSame($el11, $el1->getSubElements()->current());
213 $this->getDefinition(
'name'),
217 $this->assertSame(
$data, $el->getData());
222 $scaffold = $this->getElement(NoID::SCAFFOLD);
223 $not_scaffold = $this->getElement(5);
225 $this->assertTrue($scaffold->isScaffold());
226 $this->assertFalse($not_scaffold->isScaffold());
231 $mark_me = $this->getElement(13);
232 $stay_away = $this->getElement(7);
233 $mark_me->mark($this->getMarkerFactory(), Action::NEUTRAL);
235 $this->assertTrue($mark_me->isMarked());
236 $this->assertInstanceOf(MarkerInterface::class, $mark_me->getMarker());
237 $this->assertFalse($stay_away->isMarked());
238 $this->assertNull($stay_away->getMarker());
243 $el111 = $this->getElement(111);
244 $el11 = $this->getElement(11, $el111);
245 $el12 = $this->getElement(12);
246 $el1 = $this->getElement(1, $el11, $el12);
247 $el2 = $this->getElement(2);
248 $root = $this->getElement(NoID::ROOT, $el1, $el2);
250 $el11->mark($this->getMarkerFactory(), Action::CREATE_OR_UPDATE);
252 $this->assertTrue($el11->isMarked());
253 $this->assertSame(Action::CREATE_OR_UPDATE, $el11->getMarker()->action());
254 $this->assertTrue($el1->isMarked());
255 $this->assertSame(Action::NEUTRAL, $el1->getMarker()->action());
256 $this->assertTrue($root->isMarked());
257 $this->assertSame(Action::NEUTRAL, $root->getMarker()->action());
259 $this->assertFalse($el111->isMarked());
260 $this->assertFalse($el12->isMarked());
261 $this->assertFalse($el2->isMarked());
266 $marker_factory = $this->getMarkerFactory();
267 $sub = $this->getElement(11);
268 $el = $this->getElement(1, $sub);
270 $el->mark($marker_factory, Action::CREATE_OR_UPDATE);
271 $this->assertSame(Action::CREATE_OR_UPDATE, $el->getMarker()->action());
275 $this->assertSame(Action::CREATE_OR_UPDATE, $el->getMarker()->action());
283 $marker_factory = $this->getMarkerFactory();
284 $sub = $this->getElement(NoID::SCAFFOLD);
285 $el = $this->getElement(NoID::SCAFFOLD, $sub);
287 $sub->mark($marker_factory, Action::CREATE_OR_UPDATE);
288 $this->assertSame(Action::CREATE_OR_UPDATE, $sub->getMarker()->action());
289 $this->assertSame(Action::CREATE_OR_UPDATE, $el->getMarker()->action());
291 $sub = $this->getElement(NoID::SCAFFOLD);
292 $el = $this->getElement(NoID::SCAFFOLD, $sub);
296 $this->assertSame(Action::NEUTRAL, $el->getMarker()->action());
301 $el111 = $this->getElement(111);
302 $el11 = $this->getElement(11, $el111);
303 $el1 = $this->getElement(1, $el11);
304 $root = $this->getElement(NoID::ROOT, $el1);
306 $el111->mark($this->getMarkerFactory(), Action::CREATE_OR_UPDATE);
309 $this->assertTrue($root->isMarked());
310 $this->assertTrue($el1->isMarked());
311 $this->assertFalse($el11->isMarked());
312 $this->assertFalse($el111->isMarked());
317 $second = $this->getElementWithName(6,
'second');
318 $fourth = $this->getElementWithName(6,
'fourth');
319 $el = $this->getElement(13, $second, $fourth);
321 $el->addScaffoldsToSubElements($this->getScaffoldProvider());
323 $subs = $el->getSubElements();
324 $this->assertTrue($subs->current()->isScaffold());
325 $this->assertSame(
'first', $subs->current()->getDefinition()->name());
327 $this->assertSame($second, $subs->current());
329 $this->assertTrue($subs->current()->isScaffold());
330 $this->assertSame(
'second', $subs->current()->getDefinition()->name());
332 $this->assertTrue($subs->current()->isScaffold());
333 $this->assertSame(
'third', $subs->current()->getDefinition()->name());
335 $this->assertSame($fourth, $subs->current());
337 $this->assertTrue($subs->current()->isScaffold());
338 $this->assertSame(
'fourth', $subs->current()->getDefinition()->name());
340 $this->assertNull($subs->current());
345 $second = $this->getElementWithName(6,
'second');
346 $third = $this->getElementWithName(17,
'third');
347 $el = $this->getElement(13, $second, $third);
349 $el->addScaffoldToSubElements($this->getScaffoldProvider(),
'second');
351 $subs = $el->getSubElements();
352 $this->assertSame($second, $subs->current());
354 $this->assertTrue($subs->current()->isScaffold());
355 $this->assertSame(
'second', $subs->current()->getDefinition()->name());
357 $this->assertSame($third, $subs->current());
359 $this->assertNull($subs->current());
366 $second = $this->getElementWithName(6,
'second');
367 $fourth = $this->getElementWithName(17,
'fourth');
368 $el = $this->getElement(13, $second, $fourth);
370 $el->addScaffoldToSubElements($this->getScaffoldProvider(),
'second');
372 $subs = $el->getSubElements();
373 $this->assertSame($second, $subs->current());
375 $this->assertTrue($subs->current()->isScaffold());
376 $this->assertSame(
'second', $subs->current()->getDefinition()->name());
378 $this->assertSame($fourth, $subs->current());
380 $this->assertNull($subs->current());
385 $el = $this->getElement(37);
387 $this->expectException(\ilMDElementsException::class);
388 $el->addScaffoldsToSubElements($this->getScaffoldProvider(
true));
393 $el = $this->getElement(37);
395 $this->expectException(\ilMDElementsException::class);
396 $el->addScaffoldToSubElements($this->getScaffoldProvider(
true),
'with sub');
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
__construct()
Constructor setup ILIAS global object @access public.
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...