ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
CombinedSlateTest Class Reference

Tests for the Slate. More...

+ Inheritance diagram for CombinedSlateTest:
+ Collaboration diagram for CombinedSlateTest:

Public Member Functions

 setUp ()
 
 getUIFactory ()
 
 brutallyTrimHTML ($html)
 
 testRendering ()
 
 testRenderingWithAriaRole ()
 
 testRenderingWithSubDivider ()
 
 testRenderingWithSubslateAndButton ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null)
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML ($html)
 
 assertHTMLEquals ($expected_html_as_string, $html_as_string)
 

Additional Inherited Members

- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML ($html)
 A more radical version of normalizeHTML. More...
 

Detailed Description

Tests for the Slate.

Definition at line 15 of file CombinedSlateTest.php.

Member Function Documentation

◆ brutallyTrimHTML()

CombinedSlateTest::brutallyTrimHTML (   $html)

Definition at line 52 of file CombinedSlateTest.php.

Referenced by testRendering(), testRenderingWithAriaRole(), testRenderingWithSubDivider(), and testRenderingWithSubslateAndButton().

53  {
54  $html = str_replace(["\n", "\r", "\t"], "", $html);
55  $html = preg_replace('# {2,}#', " ", $html);
56  return trim($html);
57  }
+ Here is the caller graph for this function:

◆ getUIFactory()

CombinedSlateTest::getUIFactory ( )

Definition at line 25 of file CombinedSlateTest.php.

References $factory.

26  {
27  $factory = new class extends NoUIFactory {
28  public function button()
29  {
30  return $this->button_factory;
31  }
32  public function glyph()
33  {
34  return new I\Symbol\Glyph\Factory();
35  }
36 
37  public function divider()
38  {
39  return new I\Divider\Factory();
40  }
41 
42  public function mainControls() : C\MainControls\Factory
43  {
44  return new I\MainControls\Factory($this->sig_gen);
45  }
46  };
47  $factory->button_factory = $this->button_factory;
48  $factory->sig_gen = $this->sig_gen;
49  return $factory;
50  }
$factory
Definition: metadata.php:58

◆ setUp()

CombinedSlateTest::setUp ( )

Definition at line 17 of file CombinedSlateTest.php.

17  : void
18  {
19  $this->sig_gen = new I\SignalGenerator();
20  $this->button_factory = new I\Button\Factory($this->sig_gen);
21  $this->divider_factory = new I\Divider\Factory();
22  $this->icon_factory = new I\Symbol\Icon\Factory();
23  }

◆ testRendering()

CombinedSlateTest::testRendering ( )

Definition at line 59 of file CombinedSlateTest.php.

References $name, brutallyTrimHTML(), and ILIAS_UI_TestBase\getDefaultRenderer().

60  {
61  $name = 'name';
62  $icon = $this->icon_factory->custom('', '');
63  $slate = new Combined($this->sig_gen, $name, $icon);
64 
65  $r = $this->getDefaultRenderer();
66  $html = $r->render($slate);
67 
68  $expected = '<div class="il-maincontrols-slate disengaged" id="id_1"><div class="il-maincontrols-slate-content" data-replace-marker="content"></div></div>';
69  $this->assertEquals(
70  $expected,
71  $this->brutallyTrimHTML($html)
72  );
73  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
if($format !==null) $name
Definition: metadata.php:230
+ Here is the call graph for this function:

◆ testRenderingWithAriaRole()

CombinedSlateTest::testRenderingWithAriaRole ( )

Definition at line 75 of file CombinedSlateTest.php.

References $name, brutallyTrimHTML(), and ILIAS_UI_TestBase\getDefaultRenderer().

76  {
77  $name = 'name';
78  $icon = $this->icon_factory->custom('', '');
79  $slate = new Combined($this->sig_gen, $name, $icon);
80  $slate = $slate->withAriaRole(Combined::MENU);
81 
82  $r = $this->getDefaultRenderer();
83  $html = $r->render($slate);
84 
85  $expected = '<div class="il-maincontrols-slate disengaged" id="id_1" role="menu"><div class="il-maincontrols-slate-content" data-replace-marker="content"></div></div>';
86  $this->assertEquals(
87  $expected,
88  $this->brutallyTrimHTML($html)
89  );
90  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
if($format !==null) $name
Definition: metadata.php:230
+ Here is the call graph for this function:

◆ testRenderingWithSubDivider()

CombinedSlateTest::testRenderingWithSubDivider ( )

Definition at line 92 of file CombinedSlateTest.php.

References $name, brutallyTrimHTML(), and ILIAS_UI_TestBase\getDefaultRenderer().

93  {
94  $name = 'name';
95  $icon = $this->icon_factory->custom('', '');
96  $subdivider = new I\Divider\Horizontal();
97  $subdivider_with_text = new I\Divider\Horizontal();
98  $subdivider_with_text = $subdivider_with_text->withLabel('Title');
99  $slate = new Combined($this->sig_gen, $name, $icon);
100  $slate = $slate
101  ->withAdditionalEntry($subdivider_with_text)
102  ->withAdditionalEntry($subdivider);
103 
104  $r = $this->getDefaultRenderer();
105  $html = $r->render($slate);
106 
107  $expected = <<<EOT
108  <div class="il-maincontrols-slate disengaged" id="id_1">
109  <div class="il-maincontrols-slate-content" data-replace-marker="content">
110  <hr class="il-divider-with-label" />
111  <h4 class="il-divider">Title</h4>
112  <hr /></div></div>
113 EOT;
114  $this->assertEquals(
115  $this->brutallyTrimHTML($expected),
116  $this->brutallyTrimHTML($html)
117  );
118  }
Title class.
Definition: Title.php:36
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
if($format !==null) $name
Definition: metadata.php:230
+ Here is the call graph for this function:

◆ testRenderingWithSubslateAndButton()

CombinedSlateTest::testRenderingWithSubslateAndButton ( )

Definition at line 120 of file CombinedSlateTest.php.

References $name, brutallyTrimHTML(), and ILIAS_UI_TestBase\getDefaultRenderer().

121  {
122  $name = 'name';
123  $icon = $this->icon_factory->custom('', '');
124  $subslate = new Combined($this->sig_gen, $name, $icon);
125  $subbutton = $this->button_factory->bulky($icon, '', '');
126  $slate = new Combined($this->sig_gen, $name, $icon);
127  $slate = $slate
128  ->withAdditionalEntry($subslate)
129  ->withAdditionalEntry($subbutton);
130 
131  $r = $this->getDefaultRenderer();
132  $html = $r->render($slate);
133 
134  $expected = <<<EOT
135  <div class="il-maincontrols-slate disengaged" id="id_3">
136  <div class="il-maincontrols-slate-content" data-replace-marker="content">
137 
138  <button class="btn btn-bulky" id="id_1" >
139  <div class="icon custom small" aria-label="">
140  <img src="" />
141  </div>
142  <span class="bulky-label">name</span>
143  </button>
144  <div class="il-maincontrols-slate disengaged" id="id_2">
145  <div class="il-maincontrols-slate-content" data-replace-marker="content">
146  </div>
147  </div>
148 
149  <button class="btn btn-bulky" data-action="" >
150  <div class="icon custom small" aria-label="">
151  <img src="" />
152  </div>
153  <span class="bulky-label"></span>
154  </button>
155 
156  </div>
157  </div>
158 EOT;
159  $this->assertEquals(
160  $this->brutallyTrimHTML($expected),
161  $this->brutallyTrimHTML($html)
162  );
163  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
if($format !==null) $name
Definition: metadata.php:230
+ Here is the call graph for this function:

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