ILIAS  release_8 Revision v8.24
DeckTest.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
21require_once(__DIR__ . "/../../../../libs/composer/vendor/autoload.php");
22require_once(__DIR__ . "/../../Base.php");
23
26
31{
32 public function getFactory(): NoUIFactory
33 {
34 return new class () extends NoUIFactory {
35 public function card(): C\Card\Factory
36 {
37 return new I\Component\Card\Factory();
38 }
39 public function deck(array $cards): C\Deck\Deck
40 {
41 return new I\Component\Deck\Deck($cards, C\Deck\Deck::SIZE_S);
42 }
43 };
44 }
45
46 public function test_implements_factory_interface(): void
47 {
48 $f = $this->getFactory();
49
50 $this->assertInstanceOf("ILIAS\\UI\\Factory", $f);
51 $c = $f->card()->standard("Card Title");
52 $this->assertInstanceOf("ILIAS\\UI\\Component\\Deck\\Deck", $f->deck(array($c)));
53 }
54
55 public function test_get_cards(): void
56 {
57 $f = $this->getFactory();
58 $c = $f->card()->standard("Card Title");
59 $d = $f->deck(array($c));
60
61 $this->assertEquals($d->getCards(), array($c));
62 }
63
64 public function test_with_cards(): void
65 {
66 $f = $this->getFactory();
67 $c = $f->card()->standard("Card Title");
68 $d = $f->deck(array($c));
69
70 $d = $d->withCards(array($c,$c));
71 $this->assertEquals($d->getCards(), array($c,$c));
72 }
73
74 public function test_get_size(): void
75 {
76 $f = $this->getFactory();
77
78 $c = $f->card()->standard("Card Title");
79 $d = $f->deck(array($c));
80
81 $this->assertEquals(C\Deck\Deck::SIZE_S, $d->getCardsSize());
82 }
83
84 public function test_with_size(): void
85 {
86 $f = $this->getFactory();
87
88 $c = $f->card()->standard("Card Title");
89 $d = $f->deck(array($c));
90
91 $d = $d->withExtraSmallCardsSize();
92 $this->assertEquals(C\Deck\Deck::SIZE_XS, $d->getCardsSize());
93
94 $d = $d->withSmallCardsSize();
95 $this->assertEquals(C\Deck\Deck::SIZE_S, $d->getCardsSize());
96
97 $d = $d->withNormalCardsSize();
98 $this->assertEquals(C\Deck\Deck::SIZE_M, $d->getCardsSize());
99
100 $d = $d->withLargeCardsSize();
101 $this->assertEquals(C\Deck\Deck::SIZE_L, $d->getCardsSize());
102
103 $d = $d->withExtraLargeCardsSize();
104 $this->assertEquals(C\Deck\Deck::SIZE_XL, $d->getCardsSize());
105
106 $d = $d->withFullSizedCardsSize();
107 $this->assertEquals(C\Deck\Deck::SIZE_FULL, $d->getCardsSize());
108 }
109
110 public function test_render_content(): void
111 {
112 $r = $this->getDefaultRenderer();
113 $f = $this->getFactory();
114 $c = $f->card()->standard("Card Title");
115 $d = $f->deck(array($c));
116
117 $d = $d->withCards(array($c,$c,$c,$c,$c,$c,$c))->withLargeCardsSize();
118
119 $html = $this->brutallyTrimHTML($r->render($d));
120
121 $expected_html =
122 '<div class="il-deck"><div class="row row-eq-height">
123 <div class="col-xs-12 col-sm-6 col-md-6 col-lg-4"><div class="il-card thumbnail"><div class="card-no-highlight"></div><div class="caption card-title">Card Title</div></div></div>
124 <div class="col-xs-12 col-sm-6 col-md-6 col-lg-4"><div class="il-card thumbnail"><div class="card-no-highlight"></div><div class="caption card-title">Card Title</div></div></div>
125 <div class="col-xs-12 col-sm-6 col-md-6 col-lg-4"><div class="il-card thumbnail"><div class="card-no-highlight"></div><div class="caption card-title">Card Title</div></div></div>
126 <div class="col-xs-12 col-sm-6 col-md-6 col-lg-4"><div class="il-card thumbnail"><div class="card-no-highlight"></div><div class="caption card-title">Card Title</div></div></div>
127 <div class="col-xs-12 col-sm-6 col-md-6 col-lg-4"><div class="il-card thumbnail"><div class="card-no-highlight"></div><div class="caption card-title">Card Title</div></div></div>
128 <div class="col-xs-12 col-sm-6 col-md-6 col-lg-4"><div class="il-card thumbnail"><div class="card-no-highlight"></div><div class="caption card-title">Card Title</div></div></div>
129 <div class="col-xs-12 col-sm-6 col-md-6 col-lg-4"><div class="il-card thumbnail"><div class="card-no-highlight"></div><div class="caption card-title">Card Title</div></div></div>
130 </div>
131 </div>';
132
133 $this->assertHTMLEquals($this->brutallyTrimHTML($expected_html), $html);
134 }
135}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: DeckTest.php:31
test_with_size()
Definition: DeckTest.php:84
test_with_cards()
Definition: DeckTest.php:64
getFactory()
Definition: DeckTest.php:32
test_implements_factory_interface()
Definition: DeckTest.php:46
test_get_size()
Definition: DeckTest.php:74
test_get_cards()
Definition: DeckTest.php:55
test_render_content()
Definition: DeckTest.php:110
Provides common functionality for UI tests.
Definition: Base.php:299
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:427
brutallyTrimHTML(string $html)
A more radical version of normalizeHTML.
Definition: Base.php:444
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355
$c
Definition: cli.php:38
for( $i=6;$i< 13;$i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...