ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null)
 
 normalizeHTML ($html)
 
 assertHTMLEquals ($expected_html_as_string, $html_as_string)
 

Detailed Description

Definition at line 11 of file LSLocatorBuilderTest.php.

Member Function Documentation

◆ setUp()

LSLocatorBuilderTest::setUp ( )

Definition at line 22 of file LSLocatorBuilderTest.php.

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.

References ILIAS_UI_TestBase\normalizeHTML().

Referenced by testGUI().

16  : string
17  {
18  $html = $this->normalizeHTML($html);
19  return preg_replace('!\s+!', ' ', $html);
20  }
normalizeHTML($html)
Definition: Base.php:261
$html
Definition: example_001.php:87
+ 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.

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

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 role="navigation" aria-label="breadcrumbs"> ' .
87  ' <ul class="breadcrumb"> ' .
88  ' <li class="crumb"> ' .
89  ' <a href="http://ilias.de/somepath?lsocmd=cmd&lsov=1" >item 1</a>' .
90  ' </li> ' .
91  ' </ul>' .
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:228
Class LSUrlBuilder.
GUI for Locator element.
$html
Definition: example_001.php:87
+ 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: