ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
RepositoryObjectTest Class Reference

Test on Repository Object card implementation. More...

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

Public Member Functions

 getFactory ()
 
 testImplementsFactoryInterface ()
 
 testFactoryWithShyButton ()
 
 testWithObjectIcon ()
 
 testWithProgress ()
 
 testWithCertificateIcon ()
 
 testWithActions ()
 
 testWithTitleAsShy ()
 
 testRenderWithObjectIcon ()
 
 testRenderWithCertificateIcon ()
 
 testRenderWithProgressmeter ()
 
 testRenderWithActions ()
 

Private Member Functions

 getCardFactory ()
 
 getBaseCard ()
 

Detailed Description

Test on Repository Object card implementation.

Definition at line 31 of file RepositoryObjectTest.php.

Member Function Documentation

◆ getBaseCard()

RepositoryObjectTest::getBaseCard ( )
private

Definition at line 77 of file RepositoryObjectTest.php.

References getCardFactory().

Referenced by testImplementsFactoryInterface(), testRenderWithActions(), testRenderWithCertificateIcon(), testRenderWithObjectIcon(), testRenderWithProgressmeter(), testWithActions(), testWithCertificateIcon(), testWithObjectIcon(), testWithProgress(), and testWithTitleAsShy().

77  : C\Card\RepositoryObject
78  {
79  $cf = $this->getCardFactory();
80  $image = new I\Component\Image\Image("standard", "src", "alt");
81 
82  return $cf->repositoryObject("Card Title", $image);
83  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCardFactory()

RepositoryObjectTest::getCardFactory ( )
private

Definition at line 72 of file RepositoryObjectTest.php.

Referenced by getBaseCard(), and testFactoryWithShyButton().

72  : Factory
73  {
74  return new Factory();
75  }
Implementation of factory for cards.
Definition: Factory.php:31
+ Here is the caller graph for this function:

◆ getFactory()

RepositoryObjectTest::getFactory ( )
Returns
NoUIFactory

Definition at line 36 of file RepositoryObjectTest.php.

References Vendor\Package\$f, ILIAS\GlobalScreen\Provider\__construct(), ILIAS\Repository\button(), ILIAS\UI\examples\MainControls\Slate\Legacy\legacy(), and ILIAS\Repository\symbol().

Referenced by testWithActions().

37  {
38  $mocks = [
39  'button' => $this->createMock(C\Button\Factory::class),
40  'divider' => $this->createMock(C\Divider\Factory::class),
41  ];
42  $factory = new class ($mocks) extends NoUIFactory {
43  public function __construct(
44  protected array $mocks
45  ) {
46  }
47  public function legacy($content): C\Legacy\Legacy
48  {
49  $f = new I\Component\Legacy\Factory(new I\Component\SignalGenerator());
50  return $f->legacy($content);
51  }
52  public function button(): C\Button\Factory
53  {
54  return $this->mocks['button'];
55  }
56  public function divider(): C\Divider\Factory
57  {
58  return $this->mocks['divider'];
59  }
60  public function symbol(): C\Symbol\Factory
61  {
62  return new I\Component\Symbol\Factory(
63  new I\Component\Symbol\Icon\Factory(),
64  new I\Component\Symbol\Glyph\Factory(),
65  new I\Component\Symbol\Avatar\Factory()
66  );
67  }
68  };
69  return $factory;
70  }
button(string $caption, string $cmd)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Implementation of factory for cards.
Definition: Factory.php:31
legacy()
expected output: > ILIAS shows the rendered Component.
Definition: legacy.php:13
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testFactoryWithShyButton()

RepositoryObjectTest::testFactoryWithShyButton ( )

Definition at line 90 of file RepositoryObjectTest.php.

References getCardFactory().

90  : void
91  {
92  $button_factory = new I\Component\Button\Factory();
93  $button = $button_factory->shy("Card Title New", "");
94 
95  $cf = $this->getCardFactory();
96  $image = new I\Component\Image\Image("standard", "src", "alt");
97 
98  $this->assertEquals($button, $cf->repositoryObject($button, $image)->getTitle());
99  }
+ Here is the call graph for this function:

◆ testImplementsFactoryInterface()

RepositoryObjectTest::testImplementsFactoryInterface ( )

Definition at line 85 of file RepositoryObjectTest.php.

References getBaseCard().

85  : void
86  {
87  $this->assertInstanceOf("ILIAS\\UI\\Component\\Card\\RepositoryObject", $this->getBaseCard());
88  }
+ Here is the call graph for this function:

◆ testRenderWithActions()

RepositoryObjectTest::testRenderWithActions ( )

Definition at line 258 of file RepositoryObjectTest.php.

References $c, $r, and getBaseCard().

258  : void
259  {
260  $r = $this->getDefaultRenderer();
261  $c = $this->getBaseCard();
262  $items = array(
263  new I\Component\Button\Shy("Visit ILIAS", "https://www.ilias.de")
264  );
265  $dropdown = new I\Component\Dropdown\Standard($items);
266  $c = $c->withActions($dropdown);
267  $html = $this->brutallyTrimHTML($r->render($c));
268 
269  $expected_html = $this->brutallyTrimHTML('
270  <div class="il-card thumbnail">
271  <div class="il-card-repository-head">
272  <div></div>
273  <div></div>
274  <div class="il-card-repository-dropdown">
275  <div class="dropdown" id="id_3">
276  <button class="btn btn-default dropdown-toggle" type="button" aria-label="actions" aria-haspopup="true" aria-expanded="false" aria-controls="id_3_menu"><span class="caret"></span></button>
277  <ul id="id_3_menu" class="dropdown-menu">
278  <li><button class="btn btn-link" data-action="https://www.ilias.de" id="id_2">Visit ILIAS</button></li>
279  </ul>
280  </div>
281  </div>
282  </div>
283  <div class="il-card-image-container"><img src="src" class="img-standard" alt="open Card Title" /></div>
284  <div class="card-no-highlight"></div>
285  <div class="caption card-title">Card Title</div>
286  </div>
287  ');
288 
289  $this->assertHTMLEquals($expected_html, $html);
290  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$c
Definition: deliver.php:9
$r
+ Here is the call graph for this function:

◆ testRenderWithCertificateIcon()

RepositoryObjectTest::testRenderWithCertificateIcon ( )

Definition at line 191 of file RepositoryObjectTest.php.

References $c, $r, and getBaseCard().

191  : void
192  {
193  $r = $this->getDefaultRenderer();
194  $c = $this->getBaseCard();
195 
196  //TODO get skin fail?
197  $c = $c->withCertificateIcon(true);
198 
199  $html = $this->brutallyTrimHTML($r->render($c));
200 
201  $expected_html = $this->brutallyTrimHTML(<<<EOT
202 <div class="il-card thumbnail">
203 
204  <div class="il-card-repository-head">
205  <div>
206 
207  </div>
208  <div>
209  <img class="icon cert medium" src="./assets/images/standard/icon_cert.svg" alt="Certificate" />
210  </div>
211  <div class="il-card-repository-dropdown">
212 
213  </div>
214  </div>
215  <div class="il-card-image-container"><img src="src" class="img-standard" alt="open Card Title" /></div>
216  <div class="card-no-highlight"></div>
217  <div class="caption card-title">Card Title</div>
218 </div>
219 EOT);
220 
221  $this->assertHTMLEquals($expected_html, $html);
222  }
Title class.
Definition: Title.php:26
$c
Definition: deliver.php:9
$r
+ Here is the call graph for this function:

◆ testRenderWithObjectIcon()

RepositoryObjectTest::testRenderWithObjectIcon ( )

Definition at line 159 of file RepositoryObjectTest.php.

References $c, $r, and getBaseCard().

159  : void
160  {
161  $r = $this->getDefaultRenderer();
162 
163  $icon = new I\Component\Symbol\Icon\Standard("crs", 'Course', 'medium', false);
164  $c = $this->getBaseCard();
165  $c = $c->withObjectIcon($icon);
166 
167  $html = $this->brutallyTrimHTML($r->render($c));
168 
169  $expected_html = $this->brutallyTrimHTML(<<<EOT
170 <div class="il-card thumbnail">
171  <div class="il-card-repository-head">
172  <div>
173  <img class="icon crs medium" src="./assets/images/standard/icon_crs.svg" alt="Course" />
174  </div>
175  <div>
176 
177  </div>
178  <div class="il-card-repository-dropdown">
179 
180  </div>
181  </div>
182  <div class="il-card-image-container"><img src="src" class="img-standard" alt="open Card Title" /></div>
183  <div class="card-no-highlight"></div>
184  <div class="caption card-title">Card Title</div>
185 </div>
186 EOT);
187 
188  $this->assertHTMLEquals($expected_html, $html);
189  }
Title class.
Definition: Title.php:26
$c
Definition: deliver.php:9
$r
+ Here is the call graph for this function:

◆ testRenderWithProgressmeter()

RepositoryObjectTest::testRenderWithProgressmeter ( )

Definition at line 224 of file RepositoryObjectTest.php.

References $c, $r, and getBaseCard().

224  : void
225  {
226  $r = $this->getDefaultRenderer();
227  $c = $this->getBaseCard();
228  $prg = new I\Component\Chart\ProgressMeter\Mini(100, 80);
229  $c = $c->withProgress($prg);
230 
231  $html = $this->brutallyTrimHTML($r->render($c));
232 
233  $expected_html = $this->brutallyTrimHTML('
234  <div class="il-card thumbnail">
235  <div class="il-card-repository-head">
236  <div></div>
237  <div>
238  <div class="il-chart-progressmeter-box il-chart-progressmeter-mini">
239  <div class="il-chart-progressmeter-container">
240  <svg viewBox="0 0 50 40" class="il-chart-progressmeter-viewbox">
241  <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>
242  <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>
243  <path class="il-chart-progressmeter-needle no-needle" stroke-dasharray="100, 100" d="M25,10 l0,15" style="transform: rotate(deg)"></path>
244  </svg>
245  </div>
246  </div>
247  </div>
248  <div class="il-card-repository-dropdown"></div>
249  </div>
250  <div class="il-card-image-container"><img src="src" class="img-standard" alt="open Card Title"/></div>
251  <div class="card-no-highlight"></div>
252  <div class="caption card-title">Card Title</div>
253  </div>');
254 
255  $this->assertHTMLEquals($expected_html, $html);
256  }
$c
Definition: deliver.php:9
$r
+ Here is the call graph for this function:

◆ testWithActions()

RepositoryObjectTest::testWithActions ( )

Definition at line 131 of file RepositoryObjectTest.php.

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

131  : void
132  {
133  $f = $this->getFactory();
134  $items = array(
135  $f->button()->shy("Go to Course", "#"),
136  $f->button()->shy("Go to Portfolio", "#"),
137  $f->divider()->horizontal(),
138  $f->button()->shy("ilias.de", "http://www.ilias.de")
139  );
140 
141  $dropdown = new I\Component\Dropdown\Standard($items);
142  $card = $this->getBaseCard();
143  $card = $card->withActions($dropdown);
144 
145  $this->assertInstanceOf("ILIAS\\UI\\Component\\Dropdown\\Standard", $dropdown);
146  $this->assertEquals($card->getActions(), $dropdown);
147  }
+ Here is the call graph for this function:

◆ testWithCertificateIcon()

RepositoryObjectTest::testWithCertificateIcon ( )

Definition at line 120 of file RepositoryObjectTest.php.

References getBaseCard().

120  : void
121  {
122  $card = $this->getBaseCard();
123  $card_with_cert_true = $card->withCertificateIcon(true);
124  $card_with_cert_false = $card->withCertificateIcon(false);
125 
126  $this->assertNull($card->getCertificateIcon());
127  $this->assertTrue($card_with_cert_true->getCertificateIcon());
128  $this->assertFalse($card_with_cert_false->getCertificateIcon());
129  }
+ Here is the call graph for this function:

◆ testWithObjectIcon()

RepositoryObjectTest::testWithObjectIcon ( )

Definition at line 101 of file RepositoryObjectTest.php.

References getBaseCard().

101  : void
102  {
103  $icon = new I\Component\Symbol\Icon\Standard("crs", 'Course', 'medium', false);
104  $card = $this->getBaseCard();
105  $card = $card->withObjectIcon($icon);
106 
107  $this->assertEquals($card->getObjectIcon(), $icon);
108  }
+ Here is the call graph for this function:

◆ testWithProgress()

RepositoryObjectTest::testWithProgress ( )

Definition at line 110 of file RepositoryObjectTest.php.

References getBaseCard().

110  : void
111  {
112  $progressmeter = new I\Component\Chart\ProgressMeter\Mini(100, 70);
113  $card = $this->getBaseCard();
114  $card = $card->withProgress($progressmeter);
115 
116  $this->assertInstanceOf("ILIAS\\UI\\Component\\Chart\\ProgressMeter\\Mini", $progressmeter);
117  $this->assertEquals($progressmeter, $card->getProgress());
118  }
+ Here is the call graph for this function:

◆ testWithTitleAsShy()

RepositoryObjectTest::testWithTitleAsShy ( )

Definition at line 149 of file RepositoryObjectTest.php.

References $c, and getBaseCard().

149  : void
150  {
151  $c = $this->getBaseCard();
152  $button_factory = new I\Component\Button\Factory();
153  $button = $button_factory->shy("Card Title New", "");
154 
155  $c = $c->withTitle($button);
156  $this->assertEquals($button, $c->getTitle());
157  }
$c
Definition: deliver.php:9
+ Here is the call graph for this function:

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