ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Base.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2016 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
5require_once("libs/composer/vendor/autoload.php");
6
7require_once(__DIR__ . "/Renderer/ilIndependentTemplate.php");
8require_once(__DIR__ . "/../../Services/Language/classes/class.ilLanguage.php");
9
16use ILIAS\UI\Implementation\ComponentRendererFSLoader;
19use ILIAS\UI\Component\Component as IComponent;
21
23{
24 public function getTemplate($path, $purge_unfilled_vars, $purge_unused_blocks)
25 {
26 return new ilIndependentTemplate($path, $purge_unfilled_vars, $purge_unused_blocks);
27 }
28}
29
30class NoUIFactory implements Factory
31{
32 public function counter()
33 {
34 }
35 public function glyph()
36 {
37 }
38 public function button()
39 {
40 }
41 public function card()
42 {
43 }
44 public function deck(array $cards)
45 {
46 }
47 public function listing()
48 {
49 }
50 public function image()
51 {
52 }
53 public function legacy($content)
54 {
55 }
56 public function panel()
57 {
58 }
59 public function modal()
60 {
61 }
62 public function dropzone()
63 {
64 }
65 public function popover()
66 {
67 }
68 public function divider()
69 {
70 }
71 public function link()
72 {
73 }
74 public function dropdown()
75 {
76 }
77 public function item()
78 {
79 }
80 public function icon()
81 {
82 }
83 public function viewControl()
84 {
85 }
86 public function breadcrumbs(array $crumbs)
87 {
88 }
89 public function chart()
90 {
91 }
92 public function input()
93 {
94 }
95 public function table()
96 {
97 }
98 public function messageBox()
99 {
100 }
101}
102
104{
105 public $resources = array();
106
107 public function register($name)
108 {
109 $this->resources[] = $name;
110 }
111}
112
114{
115 public $requested = array();
116 public function __construct()
117 {
118 }
119 public function txt($a_topic, $a_default_lang_fallback_mod = "")
120 {
121 $this->requested[] = $a_topic;
122 return $a_topic;
123 }
124 public function toJS($a_key, ilTemplate $a_tpl = null)
125 {
126 }
127 public $lang_module = 'common';
129 {
130 }
131}
132
134{
135 private $count = 0;
136 public $ids = array();
137 public function createId()
138 {
139 $this->count++;
140 $id = "id_" . $this->count;
141 $this->ids[] = $id;
142 return $id;
143 }
144 public $on_load_code = array();
145 public function addOnLoadCode($code)
146 {
147 $this->on_load_code[] = $code;
148 }
149 public function getOnLoadCodeAsync()
150 {
151 }
152}
153
155{
156 public function _getRendererFor(IComponent $component)
157 {
158 return $this->getRendererFor($component);
159 }
160 public function _getContexts()
161 {
162 return $this->getContexts();
163 }
164}
165
167{
168 protected $id = 0;
169
170 protected function createId()
171 {
172 return 'signal_' . ++$this->id;
173 }
174}
175
177{
178}
179
180class DummyComponent implements IComponent
181{
182 public function getCanonicalName()
183 {
184 return "DummyComponent";
185 }
186}
187
192{
193 public function setUp()
194 {
195 assert_options(ASSERT_WARNING, 0);
196 }
197
198 public function tearDown()
199 {
200 assert_options(ASSERT_WARNING, 1);
201 }
202
203 public function getUIFactory()
204 {
205 return new NoUIFactory();
206 }
207
208 public function getTemplateFactory()
209 {
210 return new ilIndependentTemplateFactory();
211 }
212
213 public function getResourceRegistry()
214 {
215 return new LoggingRegistry();
216 }
217
218 public function getLanguage()
219 {
220 return new ilLanguageMock();
221 }
222
223 public function getJavaScriptBinding()
224 {
225 return new LoggingJavaScriptBinding();
226 }
227
228 public function getDefaultRenderer(JavaScriptBinding $js_binding = null)
229 {
230 $ui_factory = $this->getUIFactory();
231 $tpl_factory = $this->getTemplateFactory();
232 $resource_registry = $this->getResourceRegistry();
233 $lng = $this->getLanguage();
234 if (!$js_binding) {
235 $js_binding = $this->getJavaScriptBinding();
236 }
237
238 $component_renderer_loader
241 $resource_registry,
242 new Render\FSLoader(
244 $ui_factory,
245 $tpl_factory,
246 $lng,
247 $js_binding
248 ),
250 $ui_factory,
251 $tpl_factory,
252 $lng,
253 $js_binding
254 )
255 )
256 )
257 );
258 return new TestDefaultRenderer($component_renderer_loader);
259 }
260
261 public function normalizeHTML($html)
262 {
263 return trim(str_replace("\n", "", $html));
264 }
265
270 public function assertHTMLEquals($expected_html_as_string, $html_as_string)
271 {
272 $html = new DOMDocument();
273 $html->formatOutput = true;
274 $html->preserveWhiteSpace = false;
275 $expected = new DOMDocument();
276 $expected->formatOutput = true;
277 $expected->preserveWhiteSpace = false;
278 $html->loadXML($this->normalizeHTML($html_as_string));
279 $expected->loadXML($this->normalizeHTML($expected_html_as_string));
280 $this->assertEquals($expected->saveHTML(), $html->saveHTML());
281 }
282}
$path
Definition: aliased.php:25
An exception for terminatinating execution or to throw for unit testing.
getCanonicalName()
Get the canonical name of the component.
Definition: Base.php:182
Renderer that dispatches rendering of UI components to a Renderer found in the same namespace as the ...
getContexts()
Get the contexts that are added via withAdditionalContext where most recently added contexts come las...
getRendererFor(Component $component)
Get a renderer for a certain Component class.
Loads renderers for components from the file system.
Definition: FSLoader.php:21
Caches renderers loaded by another loader.
Registers resources for retreived renderers at a ResourceRegistry.
Provides common functionality for UI tests.
Definition: Base.php:192
getJavaScriptBinding()
Definition: Base.php:223
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:270
getTemplateFactory()
Definition: Base.php:208
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:228
getResourceRegistry()
Definition: Base.php:213
normalizeHTML($html)
Definition: Base.php:261
createId()
Create a fresh unique id.
Definition: Base.php:137
addOnLoadCode($code)
Add some JavaScript-statements to the on-load handler of the page.
Definition: Base.php:145
getOnLoadCodeAsync()
Get all the registered on-load javascript code for the async context, e.g.
Definition: Base.php:149
card()
Definition: Base.php:41
image()
Definition: Base.php:50
dropzone()
Definition: Base.php:62
listing()
Definition: Base.php:47
panel()
Definition: Base.php:56
link()
Definition: Base.php:71
item()
Definition: Base.php:77
modal()
Definition: Base.php:59
chart()
Definition: Base.php:89
deck(array $cards)
Definition: Base.php:44
divider()
Definition: Base.php:68
counter()
Definition: Base.php:32
button()
Definition: Base.php:38
dropdown()
Definition: Base.php:74
glyph()
Definition: Base.php:35
icon()
Definition: Base.php:80
legacy($content)
Definition: Base.php:53
popover()
Definition: Base.php:65
messageBox()
Definition: Base.php:98
input()
Definition: Base.php:92
viewControl()
Definition: Base.php:83
table()
Definition: Base.php:95
breadcrumbs(array $crumbs)
Definition: Base.php:86
_getRendererFor(IComponent $component)
Definition: Base.php:156
getTemplate($path, $purge_unfilled_vars, $purge_unused_blocks)
Get template instance.
Definition: Base.php:24
txt($a_topic, $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
Definition: Base.php:119
toJS($a_key, ilTemplate $a_tpl=null)
Definition: Base.php:124
loadLanguageModule($lang_module)
Definition: Base.php:128
language handling
special template class to simplify handling of ITX/PEAR
$html
Definition: example_001.php:87
$code
Definition: example_050.php:99
if(!array_key_exists('StateId', $_REQUEST)) $id
A component is the most general form of an entity in the UI.
Definition: Component.php:14
This is how the factory for UI elements looks.
Definition: Factory.php:16
Provides methods to interface with javascript.
Registry for resources required by rendered output like Javascript or CSS.
Interface for a factory that provides templates.
$lng