ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ExamplesTest Class Reference

Class ExamplesTest Checks if all examples are implemented and properly returning strings. More...

+ Inheritance diagram for ExamplesTest:
+ Collaboration diagram for ExamplesTest:

Public Member Functions

 setUp ()
 
 testAllNonAbstractComponentsShowcaseExamples ()
 
 testAllExamplesRenderAString (string $example_function_name, string $example_path)
 getFullFunctionNamesAndPathExample More...
 
 getFullFunctionNamesAndPathExample ()
 
 testFullscreenModeExamples (string $example_function_name, string $example_path)
 getListOfFullscreenExamples More...
 
 getListOfFullscreenExamples ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getImagePathResolver ()
 
 getDataFactory ()
 
 getHelpTextRetriever ()
 
 getUploadLimitResolver ()
 
 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 Member Functions

 setUpMockDependencies ()
 Some wiring up of dependencies to get all the examples running. More...
 
 getEntriesFromCrawler ()
 
- 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...
 

Protected Attributes

string $path_to_base_factory = "src/UI/Factory.php"
 
Container $dic
 

Detailed Description

Class ExamplesTest Checks if all examples are implemented and properly returning strings.

Definition at line 32 of file ExamplesTest.php.

Member Function Documentation

◆ getEntriesFromCrawler()

ExamplesTest::getEntriesFromCrawler ( )
protected
Exceptions
Crawler

Definition at line 145 of file ExamplesTest.php.

Referenced by getFullFunctionNamesAndPathExample(), and testAllNonAbstractComponentsShowcaseExamples().

145  : Crawler\Entry\ComponentEntries
146  {
147  $crawler = new Crawler\FactoriesCrawler();
148  return $crawler->crawlFactory($this->path_to_base_factory);
149  }
+ Here is the caller graph for this function:

◆ getFullFunctionNamesAndPathExample()

ExamplesTest::getFullFunctionNamesAndPathExample ( )

Definition at line 151 of file ExamplesTest.php.

References getEntriesFromCrawler().

151  : array
152  {
153  $function_names = [];
154  foreach ($this->getEntriesFromCrawler() as $entry) {
155  foreach ($entry->getExamples() as $name => $example_path) {
156  $function_names[$entry->getExamplesNamespace() . "\\" . $name] = [
157  $entry->getExamplesNamespace() . "\\" . $name,
158  $example_path
159  ];
160  }
161  }
162  return $function_names;
163  }
+ Here is the call graph for this function:

◆ getListOfFullscreenExamples()

ExamplesTest::getListOfFullscreenExamples ( )

Definition at line 181 of file ExamplesTest.php.

181  : array
182  {
183  return [
184  ['ILIAS\UI\examples\MainControls\Footer\renderFooterInFullscreenMode', "src/UI/examples/MainControls/Footer/footer.php"],
185  ['ILIAS\UI\examples\MainControls\Footer\renderFooterWithModalsInFullscreenMode', "src/UI/examples/MainControls/Footer/footer_with_modals.php"],
186  ['ILIAS\UI\examples\MainControls\MetaBar\renderMetaBarInFullscreenMode', "src/UI/examples/MainControls/MetaBar/base_metabar.php"],
187  ['ILIAS\UI\examples\Layout\Page\Standard\getUIMainbarExampleCondensed', "src/UI/examples/Layout/Page/Standard/ui_mainbar.php"],
188  ['ILIAS\UI\examples\Layout\Page\Standard\getUIMainbarExampleFull', "src/UI/examples/Layout/Page/Standard/ui_mainbar.php"],
189  ['ILIAS\UI\examples\Layout\Page\Standard\ui', "src/UI/examples/Layout/Page/Standard/ui.php"],
190  ['ILIAS\UI\examples\MainControls\ModeInfo\renderModeInfoFullscreenMode', "src/UI/examples/MainControls/ModeInfo/modeinfo.php"]
191  ];
192  }

◆ setUp()

ExamplesTest::setUp ( )

Definition at line 37 of file ExamplesTest.php.

References $_SERVER, and setUpMockDependencies().

37  : void
38  {
39  //This avoids various index not set warnings, which are only relevant in test context.
40  $_SERVER["REQUEST_SCHEME"] = "http";
41  $_SERVER["SERVER_NAME"] = "localhost";
42  $_SERVER["SERVER_PORT"] = "80";
43  $_SERVER["REQUEST_URI"] = "";
44  $_SERVER['SCRIPT_NAME'] = "";
45  $_SERVER['QUERY_STRING'] = "param=1";
46 
47  //This avoids Undefined index: ilfilehash for the moment
48  $_POST["ilfilehash"] = "";
49  $this->setUpMockDependencies();
50  }
setUpMockDependencies()
Some wiring up of dependencies to get all the examples running.
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
+ Here is the call graph for this function:

◆ setUpMockDependencies()

ExamplesTest::setUpMockDependencies ( )
protected

Some wiring up of dependencies to get all the examples running.

If you examples needs additional dependencies, please add them here. However, please check carefully if those deps are really needed. Even if the examples, we try to keep them minimal. Note the most deps are wired up here as mocks only.

Definition at line 57 of file ExamplesTest.php.

References ILIAS_UI_TestBase\getLanguage(), ILIAS_UI_TestBase\getTemplateFactory(), and init().

Referenced by setUp().

57  : void
58  {
59  $this->dic = new Container();
60  $this->dic["tpl"] = $this->getTemplateFactory()->getTemplate("tpl.main.html", false, false);
61  $this->dic["lng"] = $this->getLanguage();
62  $this->dic["refinery"] = new \ILIAS\Refinery\Factory(
63  new ILIAS\Data\Factory(),
64  $this->getLanguage()
65  );
66  (new InitUIFramework())->init($this->dic);
67 
68  $this->dic["ui.template_factory"] = $this->getTemplateFactory();
69 
70  $this->dic["ilCtrl"] = $this->getMockBuilder(\ilCtrl::class)->disableOriginalConstructor()->onlyMethods([
71  "getFormActionByClass","setParameterByClass","saveParameterByClass","getLinkTargetByClass", "isAsynch"
72  ])->getMock();
73  $this->dic["ilCtrl"]->method("getFormActionByClass")->willReturn("Testing");
74  $this->dic["ilCtrl"]->method("getLinkTargetByClass")->willReturn("2");
75  $this->dic["ilCtrl"]->method("isAsynch")->willReturn(false);
76 
77  $this->dic["upload"] = $this->getMockBuilder(FileUpload::class)->getMock();
78 
79  $this->dic["tree"] = $this->getMockBuilder(ilTree::class)
80  ->disableOriginalConstructor()
81  ->onlyMethods(["getNodeData"])->getMock();
82 
83  $this->dic["tree"]->method("getNodeData")->willReturn([
84  "ref_id" => "1",
85  "title" => "mock root node",
86  "type" => "crs"
87  ]);
88 
89  $component_factory = $this->createMock(ilComponentFactory::class);
90  $component_factory->method("getActivePluginsInSlot")->willReturn(new ArrayIterator());
91  $this->dic["component.factory"] = $component_factory;
92 
93  $this->dic["help.text_retriever"] = new ILIAS\UI\Help\TextRetriever\Echoing();
94 
95  $this->dic["ilUser"] = $this->getMockBuilder(\ilObjUser::class)
96  ->disableOriginalConstructor()
97  ->onlyMethods(["getDateFormat"])
98  ->getMock();
99 
100  (new InitHttpServices())->init($this->dic);
101  }
Class ChatMainBarProvider .
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:35
Responsible for loading the UI Framework into the dependency injection container of ILIAS...
getTemplateFactory()
Definition: Base.php:327
Responsible for loading the HTTP Service into the dependency injection container of ILIAS...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testAllExamplesRenderAString()

ExamplesTest::testAllExamplesRenderAString ( string  $example_function_name,
string  $example_path 
)

getFullFunctionNamesAndPathExample

Definition at line 129 of file ExamplesTest.php.

References $DIC, $dic, and Vendor\Package\$e.

129  : void
130  {
131  global $DIC;
132  $DIC = $this->dic;
133 
134  include_once $example_path;
135  try {
136  $this->assertIsString($example_function_name(), " Example $example_function_name does not render a string");
137  } catch (NotImplementedException $e) {
138  $this->assertTrue(true);
139  }
140  }
This exception indicates that an UI component was accepted by the JF but is not backed by a real impl...
global $DIC
Definition: feed.php:28
Container $dic

◆ testAllNonAbstractComponentsShowcaseExamples()

ExamplesTest::testAllNonAbstractComponentsShowcaseExamples ( )
Exceptions
Crawler

Definition at line 106 of file ExamplesTest.php.

References $DIC, $dic, and getEntriesFromCrawler().

106  : void
107  {
108  global $DIC;
109  $DIC = $this->dic;
110 
111  foreach ($this->getEntriesFromCrawler() as $entry) {
112  if ($entry->getNamespace() === "\ILIAS\UI\Help\Topic[]") {
113  continue;
114  }
115  if (!$entry->isAbstract()) {
116  $this->assertGreaterThan(
117  0,
118  count($entry->getExamples()),
119  "Non abstract Component " . $entry->getNamespace()
120  . " does not provide any example. Please provide at least one in " . $entry->getExamplesNamespace() . " at " . $entry->getExamplesPath()
121  );
122  }
123  }
124  }
global $DIC
Definition: feed.php:28
Container $dic
+ Here is the call graph for this function:

◆ testFullscreenModeExamples()

ExamplesTest::testFullscreenModeExamples ( string  $example_function_name,
string  $example_path 
)

getListOfFullscreenExamples

Definition at line 168 of file ExamplesTest.php.

References $DIC, $dic, and Vendor\Package\$e.

168  : void
169  {
170  global $DIC;
171  $DIC = $this->dic;
172 
173  include_once $example_path;
174  try {
175  $this->assertIsString($example_function_name($DIC), " Example $example_function_name does not render a string");
176  } catch (NotImplementedException $e) {
177  $this->assertTrue(true);
178  }
179  }
This exception indicates that an UI component was accepted by the JF but is not backed by a real impl...
global $DIC
Definition: feed.php:28
Container $dic

Field Documentation

◆ $dic

◆ $path_to_base_factory

string ExamplesTest::$path_to_base_factory = "src/UI/Factory.php"
protected

Definition at line 34 of file ExamplesTest.php.


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