ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
LSLocatorBuilderTest Class Reference
+ Inheritance diagram for LSLocatorBuilderTest:
+ Collaboration diagram for LSLocatorBuilderTest:

Public Member Functions

 stripHTML (string $html)
 
 setUp ()
 
 testConstruction ()
 
 testItemCreation ()
 
 testItemStruct ()
 
 testEnd ()
 
 testGUI ()
 

Protected Attributes

LSLocatorBuilder $lb
 

Detailed Description

Definition at line 28 of file LSLocatorBuilderTest.php.

Member Function Documentation

◆ setUp()

LSLocatorBuilderTest::setUp ( )

Definition at line 40 of file LSLocatorBuilderTest.php.

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

◆ stripHTML()

LSLocatorBuilderTest::stripHTML ( string  $html)

Definition at line 34 of file LSLocatorBuilderTest.php.

Referenced by testGUI().

34  : string
35  {
36  $html = $this->normalizeHTML($html);
37  return preg_replace('!\s+!', ' ', $html);
38  }
+ Here is the caller graph for this function:

◆ testConstruction()

LSLocatorBuilderTest::testConstruction ( )

Definition at line 46 of file LSLocatorBuilderTest.php.

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

◆ testEnd()

LSLocatorBuilderTest::testEnd ( )

Definition at line 81 of file LSLocatorBuilderTest.php.

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

◆ testGUI()

LSLocatorBuilderTest::testGUI ( )

Definition at line 87 of file LSLocatorBuilderTest.php.

References $out, $renderer, and stripHTML().

87  : void
88  {
89  $data_factory = new DataFactory();
90  $uri = $data_factory->uri('https://ilias.de/somepath');
91  $url_builder = new LSUrlBuilder($uri);
92  $ui_factory = $this->mockUIFactory();
93 
94  $items = $this->lb
95  ->item('item 1', 1)
96  ->getItems();
97 
98  $gui = new ilLSLocatorGUI($url_builder, $ui_factory);
99  $out = $gui->withItems($items)->getComponent();
100 
101  $this->assertInstanceOf(Breadcrumbs::class, $out);
102 
103  $expected = $this->stripHTML(
104  '<nav aria-label="breadcrumbs_aria_label" class="breadcrumb_wrapper"> ' .
105  ' <div class="breadcrumb"> ' .
106  ' <span class="crumb"> ' .
107  ' <a href="https://ilias.de/somepath?lsocmd=cmd&lsov=1">item 1</a>' .
108  ' </span> ' .
109  ' </div>' .
110  '</nav>'
111  );
112 
113  $renderer = $this->getDefaultRenderer();
114  $html = $this->stripHTML($renderer->render($out));
115  $this->assertEquals($expected, $html);
116  }
$renderer
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$out
Definition: buildRTE.php:24
GUI for Locator element.
+ Here is the call graph for this function:

◆ testItemCreation()

LSLocatorBuilderTest::testItemCreation ( )

Definition at line 51 of file LSLocatorBuilderTest.php.

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

◆ testItemStruct()

LSLocatorBuilderTest::testItemStruct ( )

Definition at line 61 of file LSLocatorBuilderTest.php.

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

Field Documentation

◆ $lb

LSLocatorBuilder LSLocatorBuilderTest::$lb
protected

Definition at line 32 of file LSLocatorBuilderTest.php.


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