ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
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 76 of file RepositoryObjectTest.php.

References getCardFactory().

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

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

◆ getCardFactory()

RepositoryObjectTest::getCardFactory ( )
private

Definition at line 71 of file RepositoryObjectTest.php.

Referenced by getBaseCard(), and testFactoryWithShyButton().

71  : Factory
72  {
73  return new Factory();
74  }
+ Here is the caller graph for this function:

◆ getFactory()

RepositoryObjectTest::getFactory ( )
Returns
NoUIFactory

Definition at line 36 of file RepositoryObjectTest.php.

References 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(I\Component\Button\Factory::class),
40  'divider' => $this->createMock(I\Component\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(): I\Component\Legacy\Factory
48  {
49  return new I\Component\Legacy\Factory(new I\Component\SignalGenerator());
50  }
51  public function button(): I\Component\Button\Factory
52  {
53  return $this->mocks['button'];
54  }
55  public function divider(): I\Component\Divider\Factory
56  {
57  return $this->mocks['divider'];
58  }
59  public function symbol(): I\Component\Symbol\Factory
60  {
61  return new I\Component\Symbol\Factory(
62  new I\Component\Symbol\Icon\Factory(),
63  new I\Component\Symbol\Glyph\Factory(),
64  new I\Component\Symbol\Avatar\Factory()
65  );
66  }
67  };
68  return $factory;
69  }
button(string $caption, string $cmd)
legacy()
expected output: > ILIAS shows the rendered Component.
Definition: legacy.php:29
__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 89 of file RepositoryObjectTest.php.

References getCardFactory().

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

◆ testImplementsFactoryInterface()

RepositoryObjectTest::testImplementsFactoryInterface ( )

Definition at line 84 of file RepositoryObjectTest.php.

References getBaseCard().

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

◆ testRenderWithActions()

RepositoryObjectTest::testRenderWithActions ( )

Definition at line 257 of file RepositoryObjectTest.php.

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

257  : void
258  {
259  $r = $this->getDefaultRenderer();
260  $c = $this->getBaseCard();
261  $items = array(
262  new I\Component\Button\Shy("Visit ILIAS", "https://www.ilias.de")
263  );
264  $dropdown = new I\Component\Dropdown\Standard($items);
265  $c = $c->withActions($dropdown);
266  $html = $this->brutallyTrimHTML($r->render($c));
267 
268  $expected_html = $this->brutallyTrimHTML('
269  <div class="il-card thumbnail">
270  <div class="il-card-repository-head">
271  <div></div>
272  <div></div>
273  <div class="il-card-repository-dropdown">
274  <div class="dropdown" id="id_3">
275  <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>
276  <ul id="id_3_menu" class="dropdown-menu">
277  <li><button class="btn btn-link" data-action="https://www.ilias.de" id="id_2">Visit ILIAS</button></li>
278  </ul>
279  </div>
280  </div>
281  </div>
282  <div class="il-card-image-container"><img src="src" class="img-standard" alt="open Card Title" /></div>
283  <div class="card-no-highlight"></div>
284  <div class="caption card-title">Card Title</div>
285  </div>
286  ');
287 
288  $this->assertHTMLEquals($expected_html, $html);
289  }
$c
Definition: deliver.php:25
$r
+ Here is the call graph for this function:

◆ testRenderWithCertificateIcon()

RepositoryObjectTest::testRenderWithCertificateIcon ( )

Definition at line 190 of file RepositoryObjectTest.php.

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

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

◆ testRenderWithObjectIcon()

RepositoryObjectTest::testRenderWithObjectIcon ( )

Definition at line 158 of file RepositoryObjectTest.php.

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

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

◆ testRenderWithProgressmeter()

RepositoryObjectTest::testRenderWithProgressmeter ( )

Definition at line 223 of file RepositoryObjectTest.php.

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

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

◆ testWithActions()

RepositoryObjectTest::testWithActions ( )

Definition at line 130 of file RepositoryObjectTest.php.

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

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

◆ testWithCertificateIcon()

RepositoryObjectTest::testWithCertificateIcon ( )

Definition at line 119 of file RepositoryObjectTest.php.

References getBaseCard().

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

◆ testWithObjectIcon()

RepositoryObjectTest::testWithObjectIcon ( )

Definition at line 100 of file RepositoryObjectTest.php.

References getBaseCard().

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

◆ testWithProgress()

RepositoryObjectTest::testWithProgress ( )

Definition at line 109 of file RepositoryObjectTest.php.

References getBaseCard().

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

◆ testWithTitleAsShy()

RepositoryObjectTest::testWithTitleAsShy ( )

Definition at line 148 of file RepositoryObjectTest.php.

References $c, and getBaseCard().

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

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