ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
LauncherInlineTest Class Reference
+ Inheritance diagram for LauncherInlineTest:
+ Collaboration diagram for LauncherInlineTest:

Public Member Functions

 setUp ()
 
 getUIFactory ()
 
 testLauncherInlineConstruction ()
 
 testLauncherInlineBasicModifier ()
 
 testLauncherInlineWithFields ()
 
 testLauncherInlineRendering ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getImagePathResolver ()
 
 getDataFactory ()
 
 getHelpTextRetriever ()
 
 getUploadLimitResolver ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML (string $html)
 
 assertHTMLEquals (string $expected_html_as_string, string $html_as_string)
 

Protected Member Functions

 getInputFactory ()
 
 getModalFactory ()
 
 getIconFactory ()
 
 getURI ()
 
 getLauncher ()
 
 getMessageBox ()
 
- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML (string $html)
 A more radical version of normalizeHTML. More...
 
 brutallyTrimSignals (string $html)
 A naive replacement of all il_signal-ids with dots to ease comparisons of rendered output. More...
 

Protected Attributes

ILIAS Data Factory $df
 
ilLanguage $language
 

Detailed Description

Definition at line 29 of file LauncherInlineTest.php.

Member Function Documentation

◆ getIconFactory()

LauncherInlineTest::getIconFactory ( )
protected

Definition at line 60 of file LauncherInlineTest.php.

Referenced by testLauncherInlineBasicModifier(), and testLauncherInlineRendering().

60  : I\Symbol\Icon\Factory
61  {
62  return new I\Symbol\Icon\Factory();
63  }
+ 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(ilLanguage::class);
42  return new I\Input\Field\Factory(
43  $this->createMock(I\Input\UploadLimitResolver::class),
44  new I\SignalGenerator(),
45  $this->df,
46  new Refinery($this->df, $this->language),
47  $this->language
48  );
49  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLauncher()

LauncherInlineTest::getLauncher ( )
protected

Definition at line 104 of file LauncherInlineTest.php.

References getModalFactory(), and getURI().

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

104  : I\Launcher\Inline
105  {
106  $target = $this->df->link('LaunchSomething', $this->getURI());
107  return new I\Launcher\Inline(
108  $this->getModalFactory(),
109  $target
110  );
111  }
+ 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 116 of file LauncherInlineTest.php.

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

116  : array
117  {
118  $html = sha1(C\MessageBox\MessageBox::class);
119  $stub = $this->createMock(C\MessageBox\MessageBox::class);
120  $stub->method('getCanonicalName')->willReturn($html);
121 
122  return [$stub, $html];
123  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ getModalFactory()

LauncherInlineTest::getModalFactory ( )
protected

Definition at line 51 of file LauncherInlineTest.php.

References getInputFactory().

Referenced by getLauncher().

51  : I\Modal\Factory
52  {
53  return new I\Modal\Factory(
54  new I\SignalGenerator(),
55  new I\Modal\InterruptiveItem\Factory(),
56  $this->getInputFactory()
57  );
58  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUIFactory()

LauncherInlineTest::getUIFactory ( )

Definition at line 65 of file LauncherInlineTest.php.

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

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

◆ getURI()

LauncherInlineTest::getURI ( )
protected

Definition at line 99 of file LauncherInlineTest.php.

Referenced by getLauncher().

99  : URI
100  {
101  return $this->df->uri('http://localhost/ilias.php');
102  }
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:18
+ 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 139 of file LauncherInlineTest.php.

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

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

◆ testLauncherInlineConstruction()

LauncherInlineTest::testLauncherInlineConstruction ( )

Definition at line 125 of file LauncherInlineTest.php.

References getLauncher().

125  : void
126  {
127  $l = $this->getLauncher();
128  $this->assertInstanceOf(C\Launcher\Inline::class, $l);
129  $this->assertEquals($this->df->link('LaunchSomething', $this->getURI()), $l->getTarget());
130  $this->assertEquals('LaunchSomething', $l->getButtonLabel());
131  $this->assertTrue($l->isLaunchable());
132  $this->assertNull($l->getStatusIcon());
133  $this->assertNull($l->getStatusMessageBox());
134  $this->assertNull($l->getModal());
135  $this->assertNull($l->getModalSubmitLabel());
136  $this->assertNull($l->getModalCancelLabel());
137  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ testLauncherInlineRendering()

LauncherInlineTest::testLauncherInlineRendering ( )

Definition at line 194 of file LauncherInlineTest.php.

References $r, ILIAS_UI_TestBase\brutallyTrimHTML(), ILIAS_UI_TestBase\brutallyTrimSignals(), ILIAS\Repository\button(), ILIAS\UI\examples\Input\Field\Checkbox\disabled(), ILIAS\Repository\form(), ILIAS_UI_TestBase\getDefaultRenderer(), getIconFactory(), getInputFactory(), getLauncher(), and getMessageBox().

194  : void
195  {
196  $ff = $this->getInputFactory();
197  $group = $ff->group([$ff->checkbox('Understood', 'ok')]);
198  $evaluation = fn(Result $result, Launcher & $launcher) => true;
199  [$msg, $msg_html] = $this->getMessageBox();
200  $icon = $this->getIconFactory()->standard('course', 'some icon');
201 
202  $l = $this->getLauncher()
203  ->withDescription('some description')
204  ->withButtonLabel('different label', false)
205  ->withStatusMessageBox($msg)
206  ->withStatusIcon($icon)
207  ->withInputs($group, $evaluation, $msg)
208  ->withModalSubmitLabel('some submit label')
209  ->withModalCancelLabel('some cancel label')
210  ;
211 
212  $expected = <<<EXP
213 <div class="c-launcher c-launcher--inline" id="">
214  <div class="c-launcher__status">
215  <div class="c-launcher__status__message">$msg_html
216  </div>
217  <div class="c-launcher__status__icon"><img class="icon course small" src="./templates/default/images/standard/icon_default.svg" alt="some icon"/></div>
218  </div>
219  <div class="c-launcher__description">
220  some description
221  </div>
222  <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>
223  <div class="c-launcher__form">
224  <div class="modal fade il-modal-roundtrip" tabindex="-1" role="dialog" id="id_1">
225  <div class="modal-dialog" role="document" data-replace-marker="component">
226  <div class="modal-content">
227  <div class="modal-header">
228  <button type="button" class="close" data-dismiss="modal" aria-label="close"><span aria-hidden="true">&times;</span></button>
229  <h1 class="modal-title">different label</h1>
230  </div>
231  <div class="modal-body">$msg_html
232  <form id="id_3" role="form" class="il-standard-form form-horizontal" enctype="multipart/form-data" action="http://localhost/ilias.php" method="post" >
233  <div class="form-group row">
234  <label for="id_2" class="control-label col-sm-4 col-md-3 col-lg-2">Understood</label>
235  <div class="col-sm-8 col-md-9 col-lg-10">
236  <input type="checkbox" id="id_2" value="checked" name="form/input_0" class="form-control form-control-sm" />
237  <div class="help-block">ok</div>
238  </div>
239  </div>
240  </form>
241  </div>
242  <div class="modal-footer">
243  <button class="btn btn-default" id="id_4">some submit label</button>
244  <button class="btn btn-default" data-dismiss="modal">some cancel label</button>
245  </div>
246  </div>
247  </div>
248  </div>
249  </div>
250 </div>
251 EXP;
252  $r = $this->getDefaultRenderer(null, [$msg]);
253  $actual = $r->render($l);
254  $this->assertEquals(
255  $this->brutallyTrimSignals($this->brutallyTrimHTML($expected)),
256  $this->brutallyTrimSignals($this->brutallyTrimHTML($actual))
257  );
258  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:377
button(string $caption, string $cmd)
brutallyTrimHTML(string $html)
A more radical version of normalizeHTML.
Definition: Base.php:475
form( $class_path, string $cmd, string $submit_caption="")
brutallyTrimSignals(string $html)
A naive replacement of all il_signal-ids with dots to ease comparisons of rendered output...
Definition: Base.php:490
disabled()
Example showing how to plug a disabled checkbox into a form.
Definition: disabled.php:10
$r
+ Here is the call graph for this function:

◆ testLauncherInlineWithFields()

LauncherInlineTest::testLauncherInlineWithFields ( )

Definition at line 164 of file LauncherInlineTest.php.

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

164  : void
165  {
166  $ff = $this->getInputFactory();
167  $field = $ff->checkbox('Understood', 'ok');
168  $group = $ff->group([$field]);
169  $evaluation = fn(Result $result, Launcher & $launcher) => true;
170  [$instruction] = $this->getMessageBox();
171  $l = $this->getLauncher()
172  ->withInputs($group, $evaluation, $instruction);
173 
174  $this->assertEquals($evaluation, $l->getEvaluation());
175  $this->assertInstanceOf(C\Modal\Roundtrip::class, $l->getModal());
176 
177  $this->assertEquals(
178  $instruction,
179  $l->getModal()->getContent()[0]
180  );
181 
182  $ns = new class () extends I\Input\FormInputNameSource {
183  public function getNewName(): string
184  {
185  return 'form/input_0';
186  }
187  };
188  $this->assertEquals(
189  [$field->withNameFrom($ns)],
190  $l->getModal()->getInputs()
191  );
192  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ 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

ilLanguage LauncherInlineTest::$language
protected

Definition at line 32 of file LauncherInlineTest.php.


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