ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
HasOptionFilterTestHelper.php File Reference

Go to the source code of this file.

Functions

 getUIFactory ()
 
 testHasOptionFilter (I\Input\Field\HasOptionFilterInternal $component)
 

Variables

trait HasOptionFilterTestHelper
 

Function Documentation

◆ getUIFactory()

getUIFactory ( )

Definition at line 28 of file HasOptionFilterTestHelper.php.

29 {
30 return new class ($this->createRelayArgumentLanguageStub()) extends NoUIFactory {
31 public function __construct(
32 protected \ILIAS\Language\Language $language,
33 ) {
34 }
35
36 public function symbol(): I\Symbol\Factory
37 {
38 return new S\Factory(
39 new S\Icon\Factory(),
40 new S\Glyph\Factory($this->language),
41 new S\Avatar\Factory()
42 );
43 }
44 };
45 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

References ILIAS\GlobalScreen\Provider\__construct(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), and ILIAS\Repository\symbol().

Referenced by ILIAS\UI\Implementation\Component\Entity\Renderer\createUnfinishedWorkflowActions(), ILIAS\UI\Implementation\Component\Table\Renderer\fillCells(), ILIAS\UI\Implementation\Component\Table\Renderer\getSingleActionsForRow(), ViewControlPaginationTest\getStubRenderer(), ILIAS\UI\Implementation\Component\Table\Renderer\getUrlTooLongWarning(), ILIAS\UI\Implementation\Component\Transfer\Renderer\renderClipboardTransferMechanism(), ILIAS\UI\Implementation\Component\MainControls\Renderer\renderFooter(), ILIAS\UI\Implementation\Component\Input\ViewControl\Renderer\renderMode(), ILIAS\UI\Implementation\Component\MainControls\Renderer\renderModeInfo(), ILIAS\UI\Implementation\Component\Input\Field\Renderer\renderOptionFilter(), ILIAS\UI\Implementation\Component\Table\Renderer\renderOrderingRow(), ILIAS\UI\Implementation\Component\Table\Renderer\renderOrderingTable(), ILIAS\UI\Implementation\Component\Input\ViewControl\Renderer\renderPagination(), ILIAS\UI\Implementation\Component\Input\Field\Renderer\renderPasswordField(), ILIAS\UI\Implementation\Component\MainControls\Renderer\renderTriggerButtonsAndSlates(), ILIAS\UI\Implementation\Component\Transfer\Renderer\renderWebShareTransferMechanism(), AbstractRendererTest\setUp(), and GlyphTest\testDontRenderCounter().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testHasOptionFilter()

testHasOptionFilter ( I\Input\Field\HasOptionFilterInternal  $component)
protected

check if filter elements are present at all

compare rendered html of the filter field context ABOVE and BELOW the nested field

Definition at line 47 of file HasOptionFilterTestHelper.php.

47 : void
48 {
49 $this->assertTrue($component->hasOptionFilter(), 'The component should be searchable.');
50
54 $html = $this->renderInsideContainer($component);
55 $expected1 = 'role="search"';
56 $expected2 = 'c-field--has-option-filter__item';
57 $this->assertStringContainsString($expected1, $html);
58 $this->assertStringContainsString($expected2, $html);
59
64 // Id count varies depending on complexity of nested input. We have to strip them out.
65 $strip_ids_fn = function (string $html): string {
66 return preg_replace_callback(
67 '/\b(id|for|aria-labelledby|aria-describedby|aria-controls)="id_\d+"/',
68 function ($matches) {
69 return $matches[1] . '="id_stripped"';
70 },
71 $html
72 );
73 };
74 $html = $strip_ids_fn($html);
75
76 // getting html up to and after nested input
77 $start_cut_anchor = 'c-input--has-option-filter__nothing-selected';
78 $end_cut_anchor = '<span class="message-no-match';
79 $start_pos = mb_strpos($html, $start_cut_anchor);
80 $closing_div_pos = mb_strpos($html, '</div>', $start_pos);
81 $cut_after_pos = $closing_div_pos + mb_strlen('</div>');
82 $span_pos = mb_strpos($html, $end_cut_anchor, $cut_after_pos);
83
84 $filter_before_nesting = $strip_ids_fn(parent::brutallyTrimHTML('<label>label</label><div class="c-input__field"><button type="button" class="c-input--has-option-filter__visibility-toggle btn btn-link" aria-controls="id_5" aria-expanded="false"><span class="text-expand"><span class="glyph" aria-hidden="true"><span class="glyphicon glyphicon-triangle-right" aria-hidden="true"></span></span>ui_field_option_filter_show_all_options</span><span class="text-collapse" style="display: none;"><span class="glyph" aria-hidden="true"><span class="glyphicon glyphicon-triangle-left" aria-hidden="true"></span></span>ui_field_option_filter_show_less</span></button><div class="c-input--has-option-filter__search-input" role="search"><label for="id_2"><span class="label__text" id="id_3">ui_field_option_filter_search_in</span><span class="screen-reader-hint sr-only" id="id_4">ui_field_option_filter_screen_reader_hint</span><input id="id_2" type="text" role="searchbox" aria-labelledby="id_3" aria-describedby="id_4"></label><button type="button" class="c-input--has-option-filter__clear-search btn btn-link" aria-controls="id_2" style="display: none;"><span class="glyph" aria-hidden="true"><span class="glyphicon glyphicon-minus-sign" aria-hidden="true"></span></span>ui_field_option_filter_clear_search</button></div><div class="c-input--has-option-filter__field" id="id_5" role="region" aria-label="ui_field_option_filter_filtered_results_aria_label"><div class="c-input--has-option-filter__synopsis"><div class="result-count sr-only" role="status" aria-live="polite" style="display: none;">ui_field_option_filter_options_shown</div></div><div class="c-input--has-option-filter__nothing-selected">ui_field_option_filter_no_selection</div>'));
85 $filter_after_nesting = $strip_ids_fn(parent::brutallyTrimHTML('<span class="message-no-match" style="display: none">ui_field_option_filter_no_match</span></div></div><div class="c-input__help-byline">byline</div></fieldset>'));
86 $expected_before_nesting = mb_substr($html, 0, $cut_after_pos);
87 $expected_after_nesting = mb_substr($html, $span_pos);
88
89 $this->assertStringContainsString($filter_before_nesting, $expected_before_nesting);
90 $this->assertEquals($filter_after_nesting, $expected_after_nesting);
91 }

Referenced by MultiSelectInputTest\testRenderWithHasOptionFilter(), and RadioInputTest\testRenderWithHasOptionFilter().

+ Here is the caller graph for this function:

Variable Documentation

◆ HasOptionFilterTestHelper

trait HasOptionFilterTestHelper
Initial value:
{
use LanguageStubs

Definition at line 24 of file HasOptionFilterTestHelper.php.