ILIAS  release_7 Revision v7.30-3-g800a261c036
RepositoryObjectTest Class Reference

Test on Repository Object card implementation. More...

+ Inheritance diagram for RepositoryObjectTest:
+ Collaboration diagram for RepositoryObjectTest:

Public Member Functions

 getFactory ()
 
 test_implements_factory_interface ()
 
 test_with_object_icon ()
 
 test_with_progress ()
 
 test_with_certificate_icon ()
 
 test_with_actions ()
 
 test_render_with_object_icon ()
 
 test_render_with_certificate_icon ()
 
 test_render_with_progressmeter ()
 
 test_render_with_actions ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getImagePathResolver ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML ($html)
 
 assertHTMLEquals ($expected_html_as_string, $html_as_string)
 

Private Member Functions

 getCardFactory ()
 
 getBaseCard ()
 

Additional Inherited Members

- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML ($html)
 A more radical version of normalizeHTML. More...
 

Detailed Description

Test on Repository Object card implementation.

Definition at line 14 of file RepositoryObjectTest.php.

Member Function Documentation

◆ getBaseCard()

RepositoryObjectTest::getBaseCard ( )
private

Definition at line 59 of file RepositoryObjectTest.php.

60 {
61 $cf = $this->getCardFactory();
62 $image = new I\Component\Image\Image("standard", "src", "alt");
63
64 return $cf->repositoryObject("Card Title", $image);
65 }

References getCardFactory().

Referenced by test_implements_factory_interface(), test_render_with_actions(), test_render_with_certificate_icon(), test_render_with_object_icon(), test_render_with_progressmeter(), test_with_actions(), test_with_certificate_icon(), test_with_object_icon(), and test_with_progress().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCardFactory()

RepositoryObjectTest::getCardFactory ( )
private

Definition at line 54 of file RepositoryObjectTest.php.

55 {
56 return new \ILIAS\UI\Implementation\Component\Card\Factory();
57 }

Referenced by getBaseCard().

+ Here is the caller graph for this function:

◆ getFactory()

RepositoryObjectTest::getFactory ( )
Returns
\ILIAS\UI\Implementation\Factory

Definition at line 19 of file RepositoryObjectTest.php.

20 {
21 $mocks = [
22 'button' => $this->createMock(C\Button\Factory::class),
23 'divider' => $this->createMock(C\Divider\Factory::class),
24 ];
25 $factory = new class($mocks) extends NoUIFactory {
26 public function __construct($mocks)
27 {
28 $this->mocks = $mocks;
29 }
30 public function legacy($content)
31 {
32 $f = new I\Component\Legacy\Factory(new I\Component\SignalGenerator());
33 return $f->legacy($content);
34 }
35 public function button()
36 {
37 return $this->mocks['button'];
38 }
39 public function divider()
40 {
41 return $this->mocks['divider'];
42 }
43 public function symbol() : C\Symbol\Factory
44 {
45 return new I\Component\Symbol\Factory(
46 new I\Component\Symbol\Icon\Factory(),
47 new I\Component\Symbol\Glyph\Factory()
48 );
49 }
50 };
51 return $factory;
52 }
legacy()
Definition: legacy.php:3
$factory
Definition: metadata.php:58
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References Vendor\Package\$f, $factory, ILIAS\GlobalScreen\Provider\__construct(), and legacy().

Referenced by test_with_actions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ test_implements_factory_interface()

RepositoryObjectTest::test_implements_factory_interface ( )

Definition at line 67 of file RepositoryObjectTest.php.

68 {
69 $this->assertInstanceOf("ILIAS\\UI\\Component\\Card\\RepositoryObject", $this->getBaseCard());
70 }

References getBaseCard().

+ Here is the call graph for this function:

◆ test_render_with_actions()

RepositoryObjectTest::test_render_with_actions ( )

Definition at line 219 of file RepositoryObjectTest.php.

220 {
221 $r = $this->getDefaultRenderer();
222 $c = $this->getBaseCard();
223 $items = array(
224 new I\Component\Button\Shy("Visit ILIAS", "https://www.ilias.de")
225 );
226 $dropdown = new I\Component\Dropdown\Standard($items);
227 $c = $c->withActions($dropdown);
228 $html = $this->brutallyTrimHTML($r->render($c));
229
230 $expected_html = $this->brutallyTrimHTML('
231 <div class="il-card thumbnail">
232 <div class="il-card-repository-head">
233 <div></div>
234 <div></div>
235 <div class="il-card-repository-dropdown">
236 <div class="dropdown">
237 <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" aria-label="actions" aria-haspopup="true" aria-expanded="false"><span class="caret"></span></button>
238 <ul class="dropdown-menu">
239 <li><button class="btn btn-link" data-action="https://www.ilias.de" id="id_2">Visit ILIAS</button></li>
240 </ul>
241 </div>
242 </div>
243 </div>
244 <div class="il-card-image-container"><img src="src" class="img-standard" alt="alt" /></div>
245 <div class="card-no-highlight"></div>
246 <div class="caption card-title">Card Title</div>
247 </div>
248 ');
249
250 $this->assertHTMLEquals($expected_html, $html);
251 }
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:372
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
brutallyTrimHTML($html)
A more radical version of normalizeHTML.
Definition: Base.php:392
$c
Definition: cli.php:37

References $c, ILIAS_UI_TestBase\assertHTMLEquals(), ILIAS_UI_TestBase\brutallyTrimHTML(), getBaseCard(), and ILIAS_UI_TestBase\getDefaultRenderer().

+ Here is the call graph for this function:

◆ test_render_with_certificate_icon()

RepositoryObjectTest::test_render_with_certificate_icon ( )

Definition at line 152 of file RepositoryObjectTest.php.

153 {
154 $r = $this->getDefaultRenderer();
155 $c = $this->getBaseCard();
156
157 //TODO get skin fail?
158 $c = $c->withCertificateIcon(true);
159
160 $html = $this->brutallyTrimHTML($r->render($c));
161
162 $expected_html = $this->brutallyTrimHTML(<<<EOT
163<div class="il-card thumbnail">
164
165 <div class="il-card-repository-head">
166 <div>
167
168 </div>
169 <div>
170 <img class="icon cert medium outlined" src="./templates/default/images/outlined/icon_cert.svg" alt="Certificate" />
171 </div>
172 <div class="il-card-repository-dropdown">
173
174 </div>
175 </div>
176 <div class="il-card-image-container"><img src="src" class="img-standard" alt="alt" /></div>
177 <div class="card-no-highlight"></div>
178 <div class="caption card-title">Card Title</div>
179</div>
180EOT);
181
182 $this->assertHTMLEquals($expected_html, $html);
183 }
Title class.
Definition: Title.php:37

References $c, ILIAS_UI_TestBase\assertHTMLEquals(), ILIAS_UI_TestBase\brutallyTrimHTML(), getBaseCard(), and ILIAS_UI_TestBase\getDefaultRenderer().

+ Here is the call graph for this function:

◆ test_render_with_object_icon()

RepositoryObjectTest::test_render_with_object_icon ( )

Definition at line 120 of file RepositoryObjectTest.php.

121 {
122 $r = $this->getDefaultRenderer();
123
124 $icon = new I\Component\Symbol\Icon\Standard("crs", 'Course', 'medium', false);
125 $c = $this->getBaseCard();
126 $c = $c->withObjectIcon($icon);
127
128 $html = $this->brutallyTrimHTML($r->render($c));
129
130 $expected_html = $this->brutallyTrimHTML(<<<EOT
131<div class="il-card thumbnail">
132 <div class="il-card-repository-head">
133 <div>
134 <img class="icon crs medium" src="./templates/default/images/icon_crs.svg" alt="Course" />
135 </div>
136 <div>
137
138 </div>
139 <div class="il-card-repository-dropdown">
140
141 </div>
142 </div>
143 <div class="il-card-image-container"><img src="src" class="img-standard" alt="alt" /></div>
144 <div class="card-no-highlight"></div>
145 <div class="caption card-title">Card Title</div>
146</div>
147EOT);
148
149 $this->assertHTMLEquals($expected_html, $html);
150 }

References $c, ILIAS_UI_TestBase\assertHTMLEquals(), ILIAS_UI_TestBase\brutallyTrimHTML(), getBaseCard(), and ILIAS_UI_TestBase\getDefaultRenderer().

+ Here is the call graph for this function:

◆ test_render_with_progressmeter()

RepositoryObjectTest::test_render_with_progressmeter ( )

Definition at line 185 of file RepositoryObjectTest.php.

186 {
187 $r = $this->getDefaultRenderer();
188 $c = $this->getBaseCard();
189 $prg = new I\Component\Chart\ProgressMeter\Mini(100, 80);
190 $c = $c->withProgress($prg);
191
192 $html = $this->brutallyTrimHTML($r->render($c));
193
194 $expected_html = $this->brutallyTrimHTML('
195 <div class="il-card thumbnail">
196 <div class="il-card-repository-head">
197 <div></div>
198 <div>
199 <div class="il-chart-progressmeter-box il-chart-progressmeter-mini">
200 <div class="il-chart-progressmeter-container">
201 <svg viewBox="0 0 50 40" class="il-chart-progressmeter-viewbox">
202 <path class="il-chart-progressmeter-circle-bg" stroke-dasharray="100, 100" d="M9,35 q-4.3934,-4.3934 -4.3934,-10.6066 a1,1 0 1,1 40,0 q0,6.2132 -4.3934,10.6066"></path>
203 <path class="il-chart-progressmeter-circle no-success" stroke-dasharray="69.2, 100" d="M9,35 q-4.3934,-4.3934 -4.3934,-10.6066 a1,1 0 1,1 40,0 q0,6.2132 -4.3934,10.6066"></path>
204 <path class="il-chart-progressmeter-needle no-needle" stroke-dasharray="100, 100" d="M25,10 l0,15" style="transform: rotate(deg)"></path>
205 </svg>
206 </div>
207 </div>
208 </div>
209 <div class="il-card-repository-dropdown"></div>
210 </div>
211 <div class="il-card-image-container"><img src="src" class="img-standard" alt="alt"/></div>
212 <div class="card-no-highlight"></div>
213 <div class="caption card-title">Card Title</div>
214 </div>');
215
216 $this->assertHTMLEquals($expected_html, $html);
217 }

References $c, ILIAS_UI_TestBase\assertHTMLEquals(), ILIAS_UI_TestBase\brutallyTrimHTML(), getBaseCard(), and ILIAS_UI_TestBase\getDefaultRenderer().

+ Here is the call graph for this function:

◆ test_with_actions()

RepositoryObjectTest::test_with_actions ( )

Definition at line 102 of file RepositoryObjectTest.php.

103 {
104 $f = $this->getFactory();
105 $items = array(
106 $f->button()->shy("Go to Course", "#"),
107 $f->button()->shy("Go to Portfolio", "#"),
108 $f->divider()->horizontal(),
109 $f->button()->shy("ilias.de", "http://www.ilias.de")
110 );
111
112 $dropdown = new I\Component\Dropdown\Standard($items);
113 $card = $this->getBaseCard();
114 $card = $card->withActions($dropdown);
115
116 $this->assertInstanceOf("ILIAS\\UI\\Component\\Dropdown\\Standard", $dropdown);
117 $this->assertEquals($card->getActions(), $dropdown);
118 }

References Vendor\Package\$f, getBaseCard(), and getFactory().

+ Here is the call graph for this function:

◆ test_with_certificate_icon()

RepositoryObjectTest::test_with_certificate_icon ( )

Definition at line 91 of file RepositoryObjectTest.php.

92 {
93 $card = $this->getBaseCard();
94 $card_with_cert_true = $card->withCertificateIcon(true);
95 $card_with_cert_false = $card->withCertificateIcon(false);
96
97 $this->assertNull($card->getCertificateIcon());
98 $this->assertTrue($card_with_cert_true->getCertificateIcon());
99 $this->assertFalse($card_with_cert_false->getCertificateIcon());
100 }

References getBaseCard().

+ Here is the call graph for this function:

◆ test_with_object_icon()

RepositoryObjectTest::test_with_object_icon ( )

Definition at line 72 of file RepositoryObjectTest.php.

73 {
74 $icon = new I\Component\Symbol\Icon\Standard("crs", 'Course', 'medium', false);
75 $card = $this->getBaseCard();
76 $card = $card->withObjectIcon($icon);
77
78 $this->assertEquals($card->getObjectIcon(), $icon);
79 }

References getBaseCard().

+ Here is the call graph for this function:

◆ test_with_progress()

RepositoryObjectTest::test_with_progress ( )

Definition at line 81 of file RepositoryObjectTest.php.

82 {
83 $progressmeter = new I\Component\Chart\ProgressMeter\Mini(100, 70);
84 $card = $this->getBaseCard();
85 $card = $card->withProgress($progressmeter);
86
87 $this->assertInstanceOf("ILIAS\\UI\\Component\\Chart\\ProgressMeter\\Mini", $progressmeter);
88 $this->assertEquals($progressmeter, $card->getProgress());
89 }

References getBaseCard().

+ Here is the call graph for this function:

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