ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 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(ILIAS\Language\Language::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  }
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 102 of file LauncherInlineTest.php.

References getModalFactory(), and getURI().

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

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

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

114  : array
115  {
116  $html = sha1(C\MessageBox\MessageBox::class);
117  $stub = $this->createMock(C\MessageBox\MessageBox::class);
118  $stub->method('getCanonicalName')->willReturn($html);
119 
120  return [$stub, $html];
121  }
+ 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  }
+ 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(): I\Button\Factory
72  {
73  return new I\Button\Factory();
74  }
75  public function symbol(): I\Symbol\Factory
76  {
77  return new I\Symbol\Factory(
78  new I\Symbol\Icon\Factory(),
79  new I\Symbol\Glyph\Factory(),
80  new I\Symbol\Avatar\Factory()
81  );
82  }
83  public function modal(): I\Modal\Factory
84  {
85  return new I\Modal\Factory(
86  $this->sig_gen,
87  new I\Modal\InterruptiveItem\Factory(),
88  $this->input_factory
89  );
90  }
91  };
92  $factory->sig_gen = new I\SignalGenerator();
93  $factory->input_factory = $this->getInputFactory();
94  return $factory;
95  }
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 97 of file LauncherInlineTest.php.

Referenced by getLauncher().

97  : URI
98  {
99  return $this->df->uri('http://localhost/ilias.php');
100  }
+ 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 137 of file LauncherInlineTest.php.

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

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

◆ testLauncherInlineConstruction()

LauncherInlineTest::testLauncherInlineConstruction ( )

Definition at line 123 of file LauncherInlineTest.php.

References getLauncher().

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

◆ testLauncherInlineRendering()

LauncherInlineTest::testLauncherInlineRendering ( )

Definition at line 192 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().

192  : void
193  {
194  $ff = $this->getInputFactory();
195  $group = $ff->group([$ff->checkbox('Understood', 'ok')]);
196  $evaluation = fn(Result $result, Launcher & $launcher) => true;
197  [$msg, $msg_html] = $this->getMessageBox();
198  $icon = $this->getIconFactory()->standard('course', 'some icon');
199 
200  $l = $this->getLauncher()
201  ->withDescription('some description')
202  ->withButtonLabel('different label', false)
203  ->withStatusMessageBox($msg)
204  ->withStatusIcon($icon)
205  ->withInputs($group, $evaluation, $msg)
206  ->withModalSubmitLabel('some submit label')
207  ->withModalCancelLabel('some cancel label')
208  ;
209 
210  $expected = <<<EXP
211 <div class="c-launcher c-launcher--inline">
212  <div class="c-launcher__status">
213  <div class="c-launcher__status__message">$msg_html
214  </div>
215  <div class="c-launcher__status__icon"><img class="icon course small" src="./assets/images/standard/icon_default.svg" alt="some icon"/></div>
216  </div>
217  <div class="c-launcher__description">
218  some description
219  </div>
220  <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>
221  <div class="c-launcher__form">
222  <dialog class="c-modal il-modal-roundtrip" tabindex="-1" id="id_1">
223  <div class="modal-dialog" role="document" data-replace-marker="component">
224  <div class="modal-content">
225  <div class="modal-header">
226  <form><button formmethod="dialog" class="close" aria-label="close"><span aria-hidden="true">&times;</span></button></form>
227  <h1 class="modal-title">different label</h1>
228  </div>
229  <div class="modal-body">$msg_html
230  <form id="id_3" class="c-form c-form--horizontal" enctype="multipart/form-data" action="http://localhost/ilias.php" method="post">
231  <fieldset class="c-input" data-il-ui-component="checkbox-field-input" data-il-ui-input-name="form/input_0">
232  <label for="id_2">Understood</label>
233  <div class="c-input__field">
234  <input type="checkbox" id="id_2" value="checked" name="form/input_0" class="c-field-checkbox" />
235  </div>
236  <div class="c-input__help-byline">ok</div>
237  </fieldset>
238  </form>
239  </div>
240  <div class="modal-footer">
241  <form>
242  <button class="btn btn-default" id="id_4">some submit label</button>
243  <button formmethod="dialog" class="btn btn-default" data-dismiss="modal">some cancel label</button>
244  </form>
245  </div>
246  </div>
247  </div>
248  </dialog>
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  }
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 162 of file LauncherInlineTest.php.

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

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