ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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;
18use ILIAS\UI\Component\Component as IComponent;
20
22{
23 public function getTemplate($path, $purge_unfilled_vars, $purge_unused_blocks)
24 {
25 return new ilIndependentTemplate($path, $purge_unfilled_vars, $purge_unused_blocks);
26 }
27}
28
29class NoUIFactory implements Factory
30{
31 public function counter()
32 {
33 }
34 public function glyph()
35 {
36 }
37 public function button()
38 {
39 }
40 public function card($title, \ILIAS\UI\Component\Image\Image $image = null)
41 {
42 }
43 public function deck(array $cards)
44 {
45 }
46 public function listing()
47 {
48 }
49 public function image()
50 {
51 }
52 public function legacy($content)
53 {
54 }
55 public function panel()
56 {
57 }
58 public function modal()
59 {
60 }
61 public function dropzone()
62 {
63 }
64 public function popover()
65 {
66 }
67 public function divider()
68 {
69 }
70 public function link()
71 {
72 }
73 public function dropdown()
74 {
75 }
76 public function item()
77 {
78 }
79 public function icon()
80 {
81 }
82 public function viewControl()
83 {
84 }
85 public function breadcrumbs(array $crumbs)
86 {
87 }
88 public function chart()
89 {
90 }
91}
92
94{
95 public $resources = array();
96
97 public function register($name)
98 {
99 $this->resources[] = $name;
100 }
101}
102
104{
105 public $requested = array();
106 public function __construct()
107 {
108 }
109 public function txt($a_topic, $a_default_lang_fallback_mod = "")
110 {
111 $this->requested[] = $a_topic;
112 return $a_topic;
113 }
114 public function toJS($a_key, ilTemplate $a_tpl = null)
115 {
116 }
117}
118
120{
121 private $count = 0;
122 public $ids = array();
123 public function createId()
124 {
125 $this->count++;
126 $id = "id_" . $this->count;
127 $this->ids[] = $id;
128 return $id;
129 }
130 public $on_load_code = array();
131 public function addOnLoadCode($code)
132 {
133 $this->on_load_code[] = $code;
134 }
135 public function getOnLoadCodeAsync()
136 {
137 }
138}
139
141{
142 public function _getRendererFor(IComponent $component)
143 {
144 return $this->getRendererFor($component);
145 }
146 public function _getContexts()
147 {
148 return $this->getContexts();
149 }
150}
151
153{
154 protected $id = 0;
155
156 protected function createId()
157 {
158 return 'signal_' . ++$this->id;
159 }
160}
161
163{
164}
165
166class DummyComponent implements IComponent
167{
168 public function getCanonicalName()
169 {
170 return "DummyComponent";
171 }
172}
173
178{
179 public function setUp()
180 {
181 assert_options(ASSERT_WARNING, 0);
182 assert_options(ASSERT_CALLBACK, null);
183 }
184
185 public function tearDown()
186 {
187 assert_options(ASSERT_WARNING, 1);
188 assert_options(ASSERT_CALLBACK, null);
189 }
190
191 public function getUIFactory()
192 {
193 return new NoUIFactory();
194 }
195
196 public function getTemplateFactory()
197 {
198 return new ilIndependentTemplateFactory();
199 }
200
201 public function getResourceRegistry()
202 {
203 return new LoggingRegistry();
204 }
205
206 public function getLanguage()
207 {
208 return new ilLanguageMock();
209 }
210
211 public function getJavaScriptBinding()
212 {
213 return new LoggingJavaScriptBinding();
214 }
215
216 public function getDefaultRenderer(JavaScriptBinding $js_binding = null)
217 {
218 $ui_factory = $this->getUIFactory();
219 $tpl_factory = $this->getTemplateFactory();
220 $resource_registry = $this->getResourceRegistry();
221 $lng = $this->getLanguage();
222 if (!$js_binding) {
223 $js_binding = $this->getJavaScriptBinding();
224 }
225
226 $component_renderer_loader
229 $resource_registry,
230 new Render\FSLoader(
232 $ui_factory,
233 $tpl_factory,
234 $lng,
235 $js_binding
236 )
237 )
238 )
239 );
240 return new TestDefaultRenderer($component_renderer_loader);
241 }
242
243 public function normalizeHTML($html)
244 {
245 return trim(str_replace("\n", "", $html));
246 }
247
252 public function assertHTMLEquals($expected_html_as_string, $html_as_string)
253 {
254 $html = new DOMDocument();
255 $html->formatOutput = true;
256 $html->preserveWhiteSpace = false;
257 $expected = new DOMDocument();
258 $expected->formatOutput = true;
259 $expected->preserveWhiteSpace = false;
260 $html->loadXML($this->normalizeHTML($html_as_string));
261 $expected->loadXML($this->normalizeHTML($expected_html_as_string));
262 $this->assertEquals($expected->saveHTML(), $html->saveHTML());
263 }
264}
An exception for terminatinating execution or to throw for unit testing.
getCanonicalName()
Get the canonical name of the component.
Definition: Base.php:168
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:178
getJavaScriptBinding()
Definition: Base.php:211
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:252
getTemplateFactory()
Definition: Base.php:196
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:216
getResourceRegistry()
Definition: Base.php:201
normalizeHTML($html)
Definition: Base.php:243
createId()
Create a fresh unique id.
Definition: Base.php:123
addOnLoadCode($code)
Add some JavaScript-statements to the on-load handler of the page.
Definition: Base.php:131
getOnLoadCodeAsync()
Get all the registered on-load javascript code for the async context, e.g.
Definition: Base.php:135
image()
Definition: Base.php:49
dropzone()
Definition: Base.php:61
listing()
Definition: Base.php:46
card($title, \ILIAS\UI\Component\Image\Image $image=null)
Definition: Base.php:40
panel()
Definition: Base.php:55
link()
Definition: Base.php:70
item()
Definition: Base.php:76
modal()
Definition: Base.php:58
chart()
Definition: Base.php:88
deck(array $cards)
Definition: Base.php:43
divider()
Definition: Base.php:67
counter()
Definition: Base.php:31
button()
Definition: Base.php:37
dropdown()
Definition: Base.php:73
glyph()
Definition: Base.php:34
icon()
Definition: Base.php:79
legacy($content)
Definition: Base.php:52
popover()
Definition: Base.php:64
viewControl()
Definition: Base.php:82
breadcrumbs(array $crumbs)
Definition: Base.php:85
_getRendererFor(IComponent $component)
Definition: Base.php:142
getTemplate($path, $purge_unfilled_vars, $purge_unused_blocks)
Get template instance.
Definition: Base.php:23
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:109
toJS($a_key, ilTemplate $a_tpl=null)
Definition: Base.php:114
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.
if($format !==null) $name
Definition: metadata.php:146
Class BaseForm.
Class Factory.
global $lng
Definition: privfeed.php:17