ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
LSLocatorBuilderTest Class Reference
+ 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 ()
 
 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

Definition at line 11 of file LSLocatorBuilderTest.php.

Member Function Documentation

◆ setUp()

LSLocatorBuilderTest::setUp ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 22 of file LSLocatorBuilderTest.php.

22 : void
23 {
24 $cb = $this->createMock(LSControlBuilder::class);
25 $this->lb = new LSLocatorBuilder('cmd', $cb);
26 }
Class LSTOCBuilder.

◆ stripHTML()

LSLocatorBuilderTest::stripHTML ( string  $html)

Definition at line 16 of file LSLocatorBuilderTest.php.

16 : string
17 {
18 $html = $this->normalizeHTML($html);
19 return preg_replace('!\s+!', ' ', $html);
20 }
normalizeHTML($html)
Definition: Base.php:317

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 28 of file LSLocatorBuilderTest.php.

29 {
30 $this->assertInstanceOf(LSLocatorBuilder::class, $this->lb);
31 }

◆ testEnd()

LSLocatorBuilderTest::testEnd ( )

Definition at line 63 of file LSLocatorBuilderTest.php.

64 {
65 $cb = $this->lb->end();
66 $this->assertInstanceOf(ControlBuilder::class, $cb);
67 }

◆ testGUI()

LSLocatorBuilderTest::testGUI ( )

Definition at line 69 of file LSLocatorBuilderTest.php.

70 {
71 $data_factory = new DataFactory();
72 $uri = $data_factory->uri('http://ilias.de/somepath');
73 $url_builder = new LSUrlBuilder($uri);
74 $ui_factory = $this->mockUIFactory();
75
76 $items = $this->lb
77 ->item('item 1', 1)
78 ->getItems();
79
80 $gui = new ilLSLocatorGUI($url_builder, $ui_factory);
81 $out = $gui->withItems($items)->getComponent();
82
83 $this->assertInstanceOf(Breadcrumbs::class, $out);
84
85 $expected = $this->stripHTML(
86 '<nav aria-label="breadcrumbs_aria_label" class="breadcrumb_wrapper"> ' .
87 ' <div class="breadcrumb"> ' .
88 ' <span class="crumb"> ' .
89 ' <a href="http://ilias.de/somepath?lsocmd=cmd&lsov=1" >item 1</a>' .
90 ' </span> ' .
91 ' </div>' .
92 '</nav>'
93 );
94
95 $renderer = $this->getDefaultRenderer();
96 $html = $this->stripHTML($renderer->render($out));
97 $this->assertEquals($expected, $html);
98 }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
Class LSUrlBuilder.
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 33 of file LSLocatorBuilderTest.php.

34 {
35 $this->lb
36 ->item('item 1', 1)
37 ->item('item 2', 2)
38 ->item('item 3', 3);
39
40 $this->assertCount(3, $this->lb->getItems());
41 }

◆ testItemStruct()

LSLocatorBuilderTest::testItemStruct ( )

Definition at line 43 of file LSLocatorBuilderTest.php.

44 {
45 $this->lb
46 ->item('item 1', 1)
47 ->item('item 2', 2);
48
49 $expected = [
50 [ 'label' => 'item 1',
51 'command' => 'cmd',
52 'parameter' => 1
53 ],
54 [ 'label' => 'item 2',
55 'command' => 'cmd',
56 'parameter' => 2
57 ]
58 ];
59
60 $this->assertEquals($expected, $this->lb->getItems());
61 }

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