ILIAS  release_8 Revision v8.24
LSLocatorBuilderTest Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for LSLocatorBuilderTest:
+ Collaboration diagram for LSLocatorBuilderTest:

Public Member Functions

 stripHTML (string $html)
 
 setUp ()
 
 testConstruction ()
 
 testItemCreation ()
 
 testItemStruct ()
 
 testEnd ()
 
 testGUI ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getImagePathResolver ()
 
 getDataFactory ()
 
 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 Attributes

LSLocatorBuilder $lb
 

Additional Inherited Members

- 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...
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning

Definition at line 30 of file LSLocatorBuilderTest.php.

Member Function Documentation

◆ setUp()

LSLocatorBuilderTest::setUp ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 42 of file LSLocatorBuilderTest.php.

42 : void
43 {
44 $cb = $this->createMock(LSControlBuilder::class);
45 $this->lb = new LSLocatorBuilder('cmd', $cb);
46 }

◆ stripHTML()

LSLocatorBuilderTest::stripHTML ( string  $html)

Definition at line 36 of file LSLocatorBuilderTest.php.

36 : string
37 {
38 $html = $this->normalizeHTML($html);
39 return preg_replace('!\s+!', ' ', $html);
40 }
normalizeHTML(string $html)
Definition: Base.php:422

References ILIAS_UI_TestBase\normalizeHTML().

Referenced by testGUI().

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

◆ testConstruction()

LSLocatorBuilderTest::testConstruction ( )

Definition at line 48 of file LSLocatorBuilderTest.php.

48 : void
49 {
50 $this->assertInstanceOf(LSLocatorBuilder::class, $this->lb);
51 }

◆ testEnd()

LSLocatorBuilderTest::testEnd ( )

Definition at line 83 of file LSLocatorBuilderTest.php.

83 : void
84 {
85 $cb = $this->lb->end();
86 $this->assertInstanceOf(ControlBuilder::class, $cb);
87 }

◆ testGUI()

LSLocatorBuilderTest::testGUI ( )

Definition at line 89 of file LSLocatorBuilderTest.php.

89 : void
90 {
91 $data_factory = new DataFactory();
92 $uri = $data_factory->uri('https://ilias.de/somepath');
93 $url_builder = new LSUrlBuilder($uri);
94 $ui_factory = $this->mockUIFactory();
95
96 $items = $this->lb
97 ->item('item 1', 1)
98 ->getItems();
99
100 $gui = new ilLSLocatorGUI($url_builder, $ui_factory);
101 $out = $gui->withItems($items)->getComponent();
102
103 $this->assertInstanceOf(Breadcrumbs::class, $out);
104
105 $expected = $this->stripHTML(
106 '<nav aria-label="breadcrumbs_aria_label" class="breadcrumb_wrapper"> ' .
107 ' <div class="breadcrumb"> ' .
108 ' <span class="crumb"> ' .
109 ' <a href="https://ilias.de/somepath?lsocmd=cmd&lsov=1" >item 1</a>' .
110 ' </span> ' .
111 ' </div>' .
112 '</nav>'
113 );
114
115 $renderer = $this->getDefaultRenderer();
116 $html = $this->stripHTML($renderer->render($out));
117 $this->assertEquals($expected, $html);
118 }
$out
Definition: buildRTE.php:24
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355
GUI for Locator element.

References $out, ILIAS_UI_TestBase\getDefaultRenderer(), and stripHTML().

+ Here is the call graph for this function:

◆ testItemCreation()

LSLocatorBuilderTest::testItemCreation ( )

Definition at line 53 of file LSLocatorBuilderTest.php.

53 : void
54 {
55 $this->lb
56 ->item('item 1', 1)
57 ->item('item 2', 2)
58 ->item('item 3', 3);
59
60 $this->assertCount(3, $this->lb->getItems());
61 }

◆ testItemStruct()

LSLocatorBuilderTest::testItemStruct ( )

Definition at line 63 of file LSLocatorBuilderTest.php.

63 : void
64 {
65 $this->lb
66 ->item('item 1', 1)
67 ->item('item 2', 2);
68
69 $expected = [
70 [ 'label' => 'item 1',
71 'command' => 'cmd',
72 'parameter' => 1
73 ],
74 [ 'label' => 'item 2',
75 'command' => 'cmd',
76 'parameter' => 2
77 ]
78 ];
79
80 $this->assertEquals($expected, $this->lb->getItems());
81 }

Field Documentation

◆ $lb

LSLocatorBuilder LSLocatorBuilderTest::$lb
protected

Definition at line 34 of file LSLocatorBuilderTest.php.


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