19 declare(strict_types=1);
37 require_once(__DIR__ .
"/../../../../../../../vendor/composer/vendor/autoload.php");
38 require_once(__DIR__ .
"/../../../Base.php");
39 require_once(__DIR__ .
"/InputTest.php");
68 $this->numberedlist_glyph_mock = $this->
getGlyphStub(
'numberedlist');
69 $this->bulledpoint_glyph_mock = $this->
getGlyphStub(
'bulletpoint');
70 $this->header_glyph_mock = $this->
getGlyphStub(
'header');
71 $this->italic_glyph_mock = $this->
getGlyphStub(
'italic');
102 $this->view_control_factory = $view_control_factory;
103 $this->button_factory = $button_factory;
104 $this->symbol_factory = $symbol_factory;
109 return $this->view_control_factory;
114 return $this->button_factory;
119 return $this->symbol_factory;
126 $label =
'test_label';
128 $input = $this->
factory->markdown($this->markdown_renderer, $label)->withNameFrom($this->name_source);
130 $expected = $this->brutallyTrimHTML(
132 <fieldset class=\"c-input\" data-il-ui-component=\"markdown-field-input\" data-il-ui-input-name=\"name_0\" id=\"id_8\" tabindex=\"0\"> 133 <label>$label</label> 134 <div class=\"c-input__field\"> 136 <div class=\"c-field-markdown\"> 137 <div class=\"c-field-markdown__controls\"> 139 <div class=\"c-field-markdown__actions\"> 140 <span data-action=\"insert-heading\"> 141 <button class=\"btn btn-default\" data-action=\"#\" id=\"id_2\">header</button> 143 <span data-action=\"insert-link\"> 144 <button class=\"btn btn-default\" data-action=\"#\" id=\"id_3\">link</button> 146 <span data-action=\"insert-bold\"> 147 <button class=\"btn btn-default\" data-action=\"#\" id=\"id_4\">bold</button> 149 <span data-action=\"insert-italic\"> 150 <button class=\"btn btn-default\" data-action=\"#\" id=\"id_5\">italic</button> 152 <span data-action=\"insert-bullet-points\"> 153 <button class=\"btn btn-default\" data-action=\"#\" id=\"id_7\">bulletpoint</button> 155 <span data-action=\"insert-enumeration\"> 156 <button class=\"btn btn-default\" data-action=\"#\" id=\"id_6\">numberedlist</button> 160 <textarea id=\"id_1\" class=\"c-field-textarea\" name=\"name_0\"></textarea> 161 <div class=\"c-field-markdown__preview hidden\"> 171 $this->assertEquals($expected, $html);
176 $label =
'test_label';
177 $byline =
'test_byline';
179 $input = $this->
factory->markdown(
180 $this->markdown_renderer,
183 )->withNameFrom($this->name_source);
185 $expected = $this->brutallyTrimHTML(
187 <fieldset class=\"c-input\" data-il-ui-component=\"markdown-field-input\" data-il-ui-input-name=\"name_0\" id=\"id_8\" tabindex=\"0\"> 188 <label>$label</label> 189 <div class=\"c-input__field\"> 191 <div class=\"c-field-markdown\"> 192 <div class=\"c-field-markdown__controls\"> 194 <div class=\"c-field-markdown__actions\"> 195 <span data-action=\"insert-heading\"> 196 <button class=\"btn btn-default\" data-action=\"#\" id=\"id_2\">header</button> 198 <span data-action=\"insert-link\"> 199 <button class=\"btn btn-default\" data-action=\"#\" id=\"id_3\">link</button> 201 <span data-action=\"insert-bold\"> 202 <button class=\"btn btn-default\" data-action=\"#\" id=\"id_4\">bold</button> 204 <span data-action=\"insert-italic\"> 205 <button class=\"btn btn-default\" data-action=\"#\" id=\"id_5\">italic</button> 207 <span data-action=\"insert-bullet-points\"> 208 <button class=\"btn btn-default\" data-action=\"#\" id=\"id_7\">bulletpoint</button> 210 <span data-action=\"insert-enumeration\"> 211 <button class=\"btn btn-default\" data-action=\"#\" id=\"id_6\">numberedlist</button> 216 <textarea id=\"id_1\" class=\"c-field-textarea\" name=\"name_0\"></textarea> 218 <div class=\"c-field-markdown__preview hidden\"> 224 <div class=\"c-input__help-byline\">$byline</div> 231 $this->assertEquals($expected, $html);
236 $label =
'test_label';
237 $byline =
'test_byline';
241 $input = $this->
factory->markdown(
242 $this->markdown_renderer,
245 )->withMinLimit($min)->withMaxLimit($max)->withNameFrom($this->name_source);
247 $expected = $this->brutallyTrimHTML(
249 <fieldset class=\"c-input\" data-il-ui-component=\"markdown-field-input\" data-il-ui-input-name=\"name_0\" id=\"id_8\" tabindex=\"0\"> 250 <label>$label</label> 251 <div class=\"c-input__field\"> 253 <div class=\"c-field-markdown\"> 254 <div class=\"c-field-markdown__controls\"> 256 <div class=\"c-field-markdown__actions\"> 257 <span data-action=\"insert-heading\"> 258 <button class=\"btn btn-default\" data-action=\"#\" id=\"id_2\">header</button> 260 <span data-action=\"insert-link\"> 261 <button class=\"btn btn-default\" data-action=\"#\" id=\"id_3\">link</button> 263 <span data-action=\"insert-bold\"> 264 <button class=\"btn btn-default\" data-action=\"#\" id=\"id_4\">bold</button> 266 <span data-action=\"insert-italic\"> 267 <button class=\"btn btn-default\" data-action=\"#\" id=\"id_5\">italic</button> 269 <span data-action=\"insert-bullet-points\"> 270 <button class=\"btn btn-default\" data-action=\"#\" id=\"id_7\">bulletpoint</button> 272 <span data-action=\"insert-enumeration\"> 273 <button class=\"btn btn-default\" data-action=\"#\" id=\"id_6\">numberedlist</button> 277 <textarea id=\"id_1\" class=\"c-field-textarea\" name=\"name_0\" minlength=\"$min\" maxlength=\"$max\"></textarea> 278 <div class=\"ui-input-textarea-remainder\"> ui_chars_remaining<span data-action=\"remainder\">$max</span></div> 279 <div class=\"c-field-markdown__preview hidden\"> 284 <div class=\"c-input__help-byline\">$byline</div> 291 $this->assertEquals($expected, $html);
296 $label =
'test_label';
297 $byline =
'test_byline';
299 $input = $this->
factory->markdown(
300 $this->markdown_renderer,
303 )->withDisabled(
true)->withNameFrom($this->name_source);
305 $expected = $this->brutallyTrimHTML(
307 <fieldset class=\"c-input\" data-il-ui-component=\"markdown-field-input\" data-il-ui-input-name=\"name_0\" disabled=\"disabled\" id=\"id_2\" tabindex=\"0\"> 308 <label>$label</label> 309 <div class=\"c-input__field\"> 311 <div class=\"c-field-markdown\"> 312 <div class=\"c-field-markdown__controls\"> 314 <div class=\"c-field-markdown__actions\"> 315 <span data-action=\"insert-heading\"> 316 <button class=\"btn btn-default\" data-action=\"#\" disabled=\"disabled\">header</button> 318 <span data-action=\"insert-link\"> 319 <button class=\"btn btn-default\" data-action=\"#\" disabled=\"disabled\">link</button> 321 <span data-action=\"insert-bold\"> 322 <button class=\"btn btn-default\" data-action=\"#\" disabled=\"disabled\">bold</button> 324 <span data-action=\"insert-italic\"> 325 <button class=\"btn btn-default\" data-action=\"#\" disabled=\"disabled\">italic</button> 327 <span data-action=\"insert-bullet-points\"> 328 <button class=\"btn btn-default\" data-action=\"#\" disabled=\"disabled\">bulletpoint</button> 330 <span data-action=\"insert-enumeration\"> 331 <button class=\"btn btn-default\" data-action=\"#\" disabled=\"disabled\">numberedlist</button> 335 <textarea id=\"id_1\" class=\"c-field-textarea\" name=\"name_0\"></textarea> 336 <div class=\"c-field-markdown__preview hidden\"> 341 <div class=\"c-input__help-byline\">$byline</div> 348 $this->assertEquals($expected, $html);
353 $label =
'test_label';
354 $byline =
'test_byline';
356 $input = $this->
factory->markdown(
357 $this->markdown_renderer,
360 )->withRequired(
true)->withNameFrom($this->name_source);
362 $expected = $this->brutallyTrimHTML(
364 <fieldset class=\"c-input\" data-il-ui-component=\"markdown-field-input\" data-il-ui-input-name=\"name_0\" id=\"id_8\" tabindex=\"0\"> 365 <label>$label<span class=\"asterisk\" aria-label=\"required_field\">*</span></label> 366 <div class=\"c-input__field\"> 368 <div class=\"c-field-markdown\"> 369 <div class=\"c-field-markdown__controls\"> 371 <div class=\"c-field-markdown__actions\"> 372 <span data-action=\"insert-heading\"> 373 <button class=\"btn btn-default\" data-action=\"#\" id=\"id_2\">header</button> 375 <span data-action=\"insert-link\"> 376 <button class=\"btn btn-default\" data-action=\"#\" id=\"id_3\">link</button> 378 <span data-action=\"insert-bold\"> 379 <button class=\"btn btn-default\" data-action=\"#\" id=\"id_4\">bold</button> 381 <span data-action=\"insert-italic\"> 382 <button class=\"btn btn-default\" data-action=\"#\" id=\"id_5\">italic</button> 384 <span data-action=\"insert-bullet-points\"> 385 <button class=\"btn btn-default\" data-action=\"#\" id=\"id_7\">bulletpoint</button> 387 <span data-action=\"insert-enumeration\"> 388 <button class=\"btn btn-default\" data-action=\"#\" id=\"id_6\">numberedlist</button> 392 <textarea id=\"id_1\" class=\"c-field-textarea\" name=\"name_0\"></textarea> 393 <div class=\"c-field-markdown__preview hidden\"> 398 <div class=\"c-input__help-byline\">$byline</div> 405 $this->assertEquals($expected, $html);
410 $label =
'test_label';
411 $byline =
'test_byline';
412 $error =
'test_error';
414 $input = $this->
factory->markdown(
415 $this->markdown_renderer,
418 )->withError($error)->withNameFrom($this->name_source);
420 $expected = $this->brutallyTrimHTML(
422 <fieldset class=\"c-input\" data-il-ui-component=\"markdown-field-input\" data-il-ui-input-name=\"name_0\" aria-describedby=\"id_9\" id=\"id_8\" tabindex=\"0\"> 423 <label>$label</label> 424 <div class=\"c-input__field\"> 426 <div class=\"c-field-markdown\"> 427 <div class=\"c-field-markdown__controls\"> 429 <div class=\"c-field-markdown__actions\"> 430 <span data-action=\"insert-heading\"> 431 <button class=\"btn btn-default\" data-action=\"#\" id=\"id_2\">header</button> 433 <span data-action=\"insert-link\"> 434 <button class=\"btn btn-default\" data-action=\"#\" id=\"id_3\">link</button> 436 <span data-action=\"insert-bold\"> 437 <button class=\"btn btn-default\" data-action=\"#\" id=\"id_4\">bold</button> 439 <span data-action=\"insert-italic\"> 440 <button class=\"btn btn-default\" data-action=\"#\" id=\"id_5\">italic</button> 442 <span data-action=\"insert-bullet-points\"> 443 <button class=\"btn btn-default\" data-action=\"#\" id=\"id_7\">bulletpoint</button> 445 <span data-action=\"insert-enumeration\"> 446 <button class=\"btn btn-default\" data-action=\"#\" id=\"id_6\">numberedlist</button> 450 <textarea id=\"id_1\" class=\"c-field-textarea\" name=\"name_0\"></textarea> 451 <div class=\"c-field-markdown__preview hidden\"> 456 <div class=\"c-input__error-msg alert alert-danger\" id=\"id_9\"><span class=\"sr-only\">ui_error:</span>$error</div> 457 <div class=\"c-input__help-byline\">$byline</div> 464 $this->assertEquals($expected, $html);
469 return $this->getDefaultRenderer(
null, [
470 $this->view_control_mock,
471 $this->header_glyph_mock,
472 $this->italic_glyph_mock,
473 $this->bold_glyph_mock,
474 $this->link_glyph_mock,
475 $this->numberedlist_glyph_mock,
476 $this->bulledpoint_glyph_mock,
483 $this->createMock(UploadLimitResolver::class),
485 $this->createMock(DataFactory::class),
486 $this->createMock(Refinery::class),
498 $markdown_renderer = $this->createMock(MarkdownRenderer::class);
499 $markdown_renderer->method(
'getAsyncUrl')->willReturn(self::TEST_ASYNC_URL);
500 $markdown_renderer->method(
'getParameterName')->willReturn(self::TEST_PARAMETER_NAME);
501 $markdown_renderer->method(
'render')->willReturnCallback(
502 static function ($value) {
512 $glyph_factory = $this->createMock(GlyphFactory::class);
513 $glyph_factory->method(
'header')->willReturn($this->header_glyph_mock);
514 $glyph_factory->method(
'italic')->willReturn($this->italic_glyph_mock);
515 $glyph_factory->method(
'bold')->willReturn($this->bold_glyph_mock);
516 $glyph_factory->method(
'link')->willReturn($this->link_glyph_mock);
517 $glyph_factory->method(
'numberedlist')->willReturn($this->numberedlist_glyph_mock);
518 $glyph_factory->method(
'bulletlist')->willReturn($this->bulledpoint_glyph_mock);
520 $symbol_factory = $this->createMock(SymbolFactory::class);
521 $symbol_factory->method(
'glyph')->willReturn($glyph_factory);
523 return $symbol_factory;
528 $view_control_factory = $this->createMock(ViewControlFactory::class);
531 return $view_control_factory;
536 $view_control = $this->createMock(ViewControlMode::class);
537 $view_control->method(
'getCanonicalName')->willReturn(
'view_control_mode');
539 return $view_control;
544 $glyph = $this->createMock(Glyph::class);
545 $glyph->method(
'getCanonicalName')->willReturn($name);
547 $glyph->method(
'withUnavailableAction')->willReturnSelf();
button(string $caption, string $cmd)
getUIFactory()
The rendering of this input requires actual or minimal instances of:
Glyph $bulledpoint_glyph_mock
DefNamesource $name_source
getMarkdownRendererMock()
ViewControlMode $view_control_mock
buildMinimalFieldFactory()
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
Glyph $numberedlist_glyph_mock
getViewControlFactoryMock()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
const TEST_PARAMETER_NAME
getGlyphStub(string $name)
MarkdownRenderer $markdown_renderer