ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
15
17 public function getTemplate($path, $purge_unfilled_vars, $purge_unused_blocks) {
18 return new ilIndependentTemplate($path, $purge_unfilled_vars, $purge_unused_blocks);
19 }
20}
21
22class NoUIFactory implements Factory {
23 public function counter() {}
24 public function glyph() {}
25 public function button() {}
26 public function card($title, \ILIAS\UI\Component\Image\Image $image = null) {}
27 public function deck(array $cards) {}
28 public function listing() {}
29 public function image() {}
30 public function legacy($content) {}
31 public function panel() {}
32}
33
35 public $resources = array();
36
37 public function register($name) {
38 $this->resources[] = $name;
39 }
40}
41
43 public $requested = array();
44 public function __construct() {}
45 public function txt($a_topic, $a_default_lang_fallback_mod = "") {
46 $this->requested[] = $a_topic;
47 return $a_topic;
48 }
49}
50
52 private $count = 0;
53 public $ids = array();
54 public function createId() {
55 $this->count++;
56 $id = "id_".$this->count;
57 $this->ids[] = $id;
58 return $id;
59 }
60 public $on_load_code = array();
61 public function addOnLoadCode($code) {
62 $this->on_load_code[] = $code;
63 }
64}
65
70 public function setUp() {
71 assert_options(ASSERT_WARNING, 0);
72 assert_options(ASSERT_CALLBACK, null);
73 }
74
75 public function tearDown() {
76 assert_options(ASSERT_WARNING, 1);
77 assert_options(ASSERT_CALLBACK, null);
78 }
79
80 public function getUIFactory() {
81 return new NoUIFactory();
82 }
83
84 public function getTemplateFactory() {
86 }
87
88 public function getResourceRegistry() {
89 return new LoggingRegistry();
90 }
91
92 public function getLanguage() {
93 return new ilLanguageMock();
94 }
95
96 public function getJavaScriptBinding() {
97 return new LoggingJavaScriptBinding();
98 }
99
100 public function getDefaultRenderer() {
101 $ui_factory = $this->getUIFactory();
102 $tpl_factory = $this->getTemplateFactory();
103 $resource_registry = $this->getResourceRegistry();
104 $lng = $this->getLanguage();
105 $js_binding = $this->getJavaScriptBinding();
106 return new DefaultRenderer(
107 $ui_factory, $tpl_factory, $resource_registry, $lng, $js_binding);
108 }
109
110 public function normalizeHTML($html) {
111 return trim(str_replace("\n", "", $html));
112 }
113
118 public function assertHTMLEquals($expected_html_as_string,$html_as_string){
119 $html = new DOMDocument();
120 $html->formatOutput = true;
121 $html->preserveWhiteSpace = false;
122 $expected = new DOMDocument();
123 $expected->formatOutput = true;
124 $expected->preserveWhiteSpace = false;
125 $html->loadXML($this->normalizeHTML($html_as_string));
126 $expected->loadXML($this->normalizeHTML($expected_html_as_string));
127 $this->assertEquals($expected->saveHTML(), $html->saveHTML());
128 }
129}
$path
Definition: aliased.php:25
An exception for terminatinating execution or to throw for unit testing.
Renderer that dispatches rendering of UI components to a Renderer found in the same namespace as the ...
Provides common functionality for UI tests.
Definition: Base.php:69
getJavaScriptBinding()
Definition: Base.php:96
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:118
getTemplateFactory()
Definition: Base.php:84
getResourceRegistry()
Definition: Base.php:88
normalizeHTML($html)
Definition: Base.php:110
getDefaultRenderer()
Definition: Base.php:100
createId()
Create a fresh unique id.
Definition: Base.php:54
addOnLoadCode($code)
Add some JavaScript-statements to the on-load handler of the page.
Definition: Base.php:61
image()
Definition: Base.php:29
listing()
Definition: Base.php:28
card($title, \ILIAS\UI\Component\Image\Image $image=null)
Definition: Base.php:26
panel()
Definition: Base.php:31
deck(array $cards)
Definition: Base.php:27
counter()
Definition: Base.php:23
button()
Definition: Base.php:25
glyph()
Definition: Base.php:24
legacy($content)
Definition: Base.php:30
getTemplate($path, $purge_unfilled_vars, $purge_unused_blocks)
Get template instance.
Definition: Base.php:17
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:45
__construct()
Definition: Base.php:44
language handling
$html
Definition: example_001.php:87
$code
Definition: example_050.php:99
This is how the factory for UI elements looks.
Definition: Factory.php:15
Provides methods to interface with javascript.
Registry for resources required by rendered output like Javascript or CSS.
Interface for a factory that provides templates.
Interface Card \UI\Component\Card.
global $lng
Definition: privfeed.php:17