ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
LauncherInlineTest Class Reference
+ Inheritance diagram for LauncherInlineTest:
+ Collaboration diagram for LauncherInlineTest:

Public Member Functions

 setUp ()
 
 getUIFactory ()
 
 testLauncherInlineConstruction ()
 
 testLauncherInlineBasicModifier ()
 
 testLauncherInlineWithFields ()
 
 testLauncherInlineRendering ()
 

Protected Member Functions

 getInputFactory ()
 
 getModalFactory ()
 
 getIconFactory ()
 
 getURI ()
 
 getLauncher ()
 
 getMessageBox ()
 

Protected Attributes

ILIAS Data Factory $df
 
ILIAS Language Language $language
 

Detailed Description

Definition at line 29 of file LauncherInlineTest.php.

Member Function Documentation

◆ getIconFactory()

LauncherInlineTest::getIconFactory ( )
protected

Definition at line 61 of file LauncherInlineTest.php.

Referenced by testLauncherInlineBasicModifier(), and testLauncherInlineRendering().

61  : I\Symbol\Icon\Factory
62  {
63  return new I\Symbol\Icon\Factory();
64  }
+ Here is the caller graph for this function:

◆ getInputFactory()

LauncherInlineTest::getInputFactory ( )
protected

Definition at line 39 of file LauncherInlineTest.php.

References ILIAS\UI\examples\Symbol\Glyph\Language\language().

Referenced by getModalFactory(), getUIFactory(), testLauncherInlineRendering(), and testLauncherInlineWithFields().

39  : I\Input\Field\Factory
40  {
41  $this->language = $this->createMock(ILIAS\Language\Language::class);
42  return new I\Input\Field\Factory(
43  $this->createMock(\ILIAS\UI\Implementation\Component\Input\Field\Node\Factory::class),
44  $this->createMock(I\Input\UploadLimitResolver::class),
45  new I\SignalGenerator(),
46  $this->df,
47  new Refinery($this->df, $this->language),
48  $this->language
49  );
50  }
Interface Observer Contains several chained tasks and infos about them.
language()
description: > Example for rendring a language glyph.
Definition: language.php:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLauncher()

LauncherInlineTest::getLauncher ( )
protected

Definition at line 103 of file LauncherInlineTest.php.

References getModalFactory(), and getURI().

Referenced by testLauncherInlineBasicModifier(), testLauncherInlineConstruction(), testLauncherInlineRendering(), and testLauncherInlineWithFields().

103  : I\Launcher\Inline
104  {
105  $target = $this->df->link('LaunchSomething', $this->getURI());
106  return new I\Launcher\Inline(
107  $this->getModalFactory(),
108  $target
109  );
110  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMessageBox()

LauncherInlineTest::getMessageBox ( )
protected
Returns
array{C, string}

Definition at line 115 of file LauncherInlineTest.php.

Referenced by testLauncherInlineBasicModifier(), testLauncherInlineRendering(), and testLauncherInlineWithFields().

115  : array
116  {
117  $html = sha1(C\MessageBox\MessageBox::class);
118  $stub = $this->createMock(C\MessageBox\MessageBox::class);
119  $stub->method('getCanonicalName')->willReturn($html);
120 
121  return [$stub, $html];
122  }
+ Here is the caller graph for this function:

◆ getModalFactory()

LauncherInlineTest::getModalFactory ( )
protected

Definition at line 52 of file LauncherInlineTest.php.

References getInputFactory().

Referenced by getLauncher().

52  : I\Modal\Factory
53  {
54  return new I\Modal\Factory(
55  new I\SignalGenerator(),
56  new I\Modal\InterruptiveItem\Factory(),
57  $this->getInputFactory()
58  );
59  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUIFactory()

LauncherInlineTest::getUIFactory ( )

Definition at line 66 of file LauncherInlineTest.php.

References ILIAS\Repository\button(), getInputFactory(), ILIAS\Repository\modal(), and ILIAS\Repository\symbol().

66  : NoUIFactory
67  {
68  $factory = new class () extends NoUIFactory {
69  public I\SignalGenerator $sig_gen;
70  public I\Input\Field\Factory $input_factory;
71 
72  public function button(): I\Button\Factory
73  {
74  return new I\Button\Factory();
75  }
76  public function symbol(): I\Symbol\Factory
77  {
78  return new I\Symbol\Factory(
79  new I\Symbol\Icon\Factory(),
80  new I\Symbol\Glyph\Factory(),
81  new I\Symbol\Avatar\Factory()
82  );
83  }
84  public function modal(): I\Modal\Factory
85  {
86  return new I\Modal\Factory(
87  $this->sig_gen,
88  new I\Modal\InterruptiveItem\Factory(),
89  $this->input_factory
90  );
91  }
92  };
93  $factory->sig_gen = new I\SignalGenerator();
94  $factory->input_factory = $this->getInputFactory();
95  return $factory;
96  }
button(string $caption, string $cmd)
modal(string $title="", string $cancel_label="")
+ Here is the call graph for this function:

◆ getURI()

LauncherInlineTest::getURI ( )
protected

Definition at line 98 of file LauncherInlineTest.php.

Referenced by getLauncher().

98  : URI
99  {
100  return $this->df->uri('http://localhost/ilias.php');
101  }
+ Here is the caller graph for this function:

◆ setUp()

LauncherInlineTest::setUp ( )

Definition at line 34 of file LauncherInlineTest.php.

34  : void
35  {
36  $this->df = new \ILIAS\Data\Factory();
37  }

◆ testLauncherInlineBasicModifier()

LauncherInlineTest::testLauncherInlineBasicModifier ( )

Definition at line 138 of file LauncherInlineTest.php.

References getIconFactory(), getLauncher(), and getMessageBox().

138  : void
139  {
140  [$msg] = $this->getMessageBox();
141  $icon = $this->getIconFactory()->standard('course', 'some icon');
142  $some_submit_label = 'some submit label';
143  $some_cancel_label = 'some cancel label';
144  $l = $this->getLauncher()
145  ->withDescription('some description')
146  ->withButtonLabel('different label', false)
147  ->withStatusMessageBox($msg)
148  ->withStatusIcon($icon)
149  ->withModalSubmitLabel($some_submit_label)
150  ->withModalCancelLabel($some_cancel_label)
151  ;
152 
153  $this->assertEquals($this->df->link('LaunchSomething', $this->getURI()), $l->getTarget());
154  $this->assertEquals('different label', $l->getButtonLabel());
155  $this->assertfalse($l->isLaunchable());
156  $this->assertEquals($msg, $l->getStatusMessageBox());
157  $this->assertEquals($icon, $l->getStatusIcon());
158  $this->assertNull($l->getModal());
159  $this->assertEquals($l->getModalSubmitLabel(), $some_submit_label);
160  $this->assertEquals($l->getModalCancelLabel(), $some_cancel_label);
161  }
+ Here is the call graph for this function:

◆ testLauncherInlineConstruction()

LauncherInlineTest::testLauncherInlineConstruction ( )

Definition at line 124 of file LauncherInlineTest.php.

References getLauncher().

124  : void
125  {
126  $l = $this->getLauncher();
127  $this->assertInstanceOf(C\Launcher\Inline::class, $l);
128  $this->assertEquals($this->df->link('LaunchSomething', $this->getURI()), $l->getTarget());
129  $this->assertEquals('LaunchSomething', $l->getButtonLabel());
130  $this->assertTrue($l->isLaunchable());
131  $this->assertNull($l->getStatusIcon());
132  $this->assertNull($l->getStatusMessageBox());
133  $this->assertNull($l->getModal());
134  $this->assertNull($l->getModalSubmitLabel());
135  $this->assertNull($l->getModalCancelLabel());
136  }
+ Here is the call graph for this function:

◆ testLauncherInlineRendering()

LauncherInlineTest::testLauncherInlineRendering ( )

Definition at line 193 of file LauncherInlineTest.php.

References $r, ILIAS\Repository\button(), ILIAS\UI\examples\Input\Field\Checkbox\disabled(), ILIAS\Repository\form(), getIconFactory(), getInputFactory(), getLauncher(), getMessageBox(), null, and ILIAS\Repository\ui().

193  : void
194  {
195  $ff = $this->getInputFactory();
196  $group = $ff->group([$ff->checkbox('Understood', 'ok')]);
197  $evaluation = fn(Result $result, Launcher & $launcher) => true;
198  [$msg, $msg_html] = $this->getMessageBox();
199  $icon = $this->getIconFactory()->standard('course', 'some icon');
200 
201  $l = $this->getLauncher()
202  ->withDescription('some description')
203  ->withButtonLabel('different label', false)
204  ->withStatusMessageBox($msg)
205  ->withStatusIcon($icon)
206  ->withInputs($group, $evaluation, $msg)
207  ->withModalSubmitLabel('some submit label')
208  ->withModalCancelLabel('some cancel label')
209  ;
210 
211  $expected = <<<EXP
212 <div class="c-launcher c-launcher--inline">
213  <div class="c-launcher__status">
214  <div class="c-launcher__status__message">$msg_html
215  </div>
216  <div class="c-launcher__status__icon"><img class="icon course small" src="./assets/images/standard/icon_default.svg" alt="some icon"/></div>
217  </div>
218  <div class="c-launcher__description">
219  some description
220  </div>
221  <button class="btn btn-bulky" id="id_5" disabled="disabled"><span class="glyph" role="img"><span class="glyphicon glyphicon-launch" aria-hidden="true"></span></span><span class="bulky-label">different label</span></button>
222  <div class="c-launcher__form">
223  <dialog class="c-modal il-modal-roundtrip" tabindex="-1" id="id_1">
224  <div class="modal-dialog" role="document" data-replace-marker="component">
225  <div class="modal-content">
226  <div class="modal-header">
227  <form><button formmethod="dialog" class="close" aria-label="close"><span aria-hidden="true">&times;</span></button></form>
228  <h1 class="modal-title">different label</h1>
229  </div>
230  <div class="modal-body">$msg_html
231  <form id="id_3" class="c-form c-form--horizontal" enctype="multipart/form-data" action="http://localhost/ilias.php" method="post">
232  <fieldset class="c-input" data-il-ui-component="checkbox-field-input" data-il-ui-input-name="form/input_0">
233  <label for="id_2">Understood</label>
234  <div class="c-input__field">
235  <input type="checkbox" id="id_2" value="checked" name="form/input_0" class="c-field-checkbox" />
236  </div>
237  <div class="c-input__help-byline">ok</div>
238  </fieldset>
239  </form>
240  </div>
241  <div class="modal-footer">
242  <form>
243  <button class="btn btn-default" id="id_4">some submit label</button>
244  <button formmethod="dialog" class="btn btn-default" data-dismiss="modal">some cancel label</button>
245  </form>
246  </div>
247  </div>
248  </div>
249  </dialog>
250  </div>
251 </div>
252 EXP;
253  $r = $this->getDefaultRenderer(null, [$msg]);
254  $actual = $r->render($l);
255  $this->assertEquals(
256  $this->brutallyTrimSignals($this->brutallyTrimHTML($expected)),
257  $this->brutallyTrimSignals($this->brutallyTrimHTML($actual))
258  );
259  }
button(string $caption, string $cmd)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
form( $class_path, string $cmd, string $submit_caption="")
disabled()
description: > Example showing how to plug a disabled checkbox into a form
Definition: disabled.php:32
$r
+ Here is the call graph for this function:

◆ testLauncherInlineWithFields()

LauncherInlineTest::testLauncherInlineWithFields ( )

Definition at line 163 of file LauncherInlineTest.php.

References getInputFactory(), getLauncher(), and getMessageBox().

163  : void
164  {
165  $ff = $this->getInputFactory();
166  $field = $ff->checkbox('Understood', 'ok');
167  $group = $ff->group([$field]);
168  $evaluation = fn(Result $result, Launcher & $launcher) => true;
169  [$instruction] = $this->getMessageBox();
170  $l = $this->getLauncher()
171  ->withInputs($group, $evaluation, $instruction);
172 
173  $this->assertEquals($evaluation, $l->getEvaluation());
174  $this->assertInstanceOf(C\Modal\Roundtrip::class, $l->getModal());
175 
176  $this->assertEquals(
177  $instruction,
178  $l->getModal()->getContent()[0]
179  );
180 
181  $ns = new class () extends I\Input\FormInputNameSource {
182  public function getNewName(): string
183  {
184  return 'form/input_0';
185  }
186  };
187  $this->assertEquals(
188  [$field->withNameFrom($ns)],
189  $l->getModal()->getInputs()
190  );
191  }
+ Here is the call graph for this function:

Field Documentation

◆ $df

ILIAS Data Factory LauncherInlineTest::$df
protected

Definition at line 31 of file LauncherInlineTest.php.

◆ $language

ILIAS Language Language LauncherInlineTest::$language
protected

Definition at line 32 of file LauncherInlineTest.php.


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