ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ModalBase.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 require_once(__DIR__ . "/../../../../../../vendor/composer/vendor/autoload.php");
22 require_once(__DIR__ . "/../../Base.php");
23 
24 use ILIAS\UI\Component as C;
26 use ILIAS\UI\Component\Input\Field\Factory as FieldFactory;
28 
34 abstract class ModalBase extends ILIAS_UI_TestBase
35 {
36  public function getUIFactory(): NoUIFactory
37  {
38  return new class () extends NoUIFactory {
39  public function counter(): C\Counter\Factory
40  {
41  return new I\Component\Counter\Factory();
42  }
43  public function legacy(string $content): C\Legacy\Legacy
44  {
45  $f = new I\Component\Legacy\Factory(new I\Component\SignalGenerator());
46  return $f->legacy($content);
47  }
48  };
49  }
50 
51  protected function getModalFactory(): I\Component\Modal\Factory
52  {
53  $group_mock = $this->createMock(Group::class);
54  $group_mock->method('withNameFrom')->willReturnSelf();
55 
56  $factory_mock = $this->createMock(FieldFactory::class);
57  $factory_mock->method('group')->willReturn($group_mock);
58 
59  return new I\Component\Modal\Factory(
60  new SignalGeneratorMock(),
61  $this->createMock(C\Modal\InterruptiveItem\Factory::class),
62  $factory_mock
63  );
64  }
65 
66  protected function getButtonFactory(): I\Component\Button\Factory
67  {
68  return new I\Component\Button\Factory();
69  }
70 
71  protected function getDummyComponent(): DummyComponent
72  {
73  return new DummyComponent();
74  }
75 
76  public function normalizeHTML(string $html): string
77  {
78  $html = parent::normalizeHTML($html);
79  // The times entity is used for closing the modal and not supported in DomDocument::loadXML()
80  return str_replace(['&times;', "\t"], ['', ''], $html);
81  }
82 }
This is what a factory for input fields looks like.
Definition: Factory.php:28
getButtonFactory()
Definition: ModalBase.php:66
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getUIFactory()
Definition: ModalBase.php:36
getDummyComponent()
Definition: ModalBase.php:71
Base class for modal tests.
Definition: ModalBase.php:34
legacy()
expected output: > ILIAS shows the rendered Component.
Definition: legacy.php:13
normalizeHTML(string $html)
Definition: ModalBase.php:76
getModalFactory()
Definition: ModalBase.php:51