ILIAS  trunk Revision v11.0_alpha-1713-gd8962da2f67
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
DeckTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 require_once(__DIR__ . "/../../../../../../vendor/composer/vendor/autoload.php");
22 require_once(__DIR__ . "/../../Base.php");
23 
24 use ILIAS\UI\Component as C;
26 
31 {
32  public function getFactory(): NoUIFactory
33  {
34  return new class () extends NoUIFactory {
35  public function card(): I\Component\Card\Factory
36  {
37  return new I\Component\Card\Factory();
38  }
39  public function deck(array $cards): I\Component\Deck\Deck
40  {
41  return new I\Component\Deck\Deck($cards, C\Deck\Deck::SIZE_S);
42  }
43  };
44  }
45 
46  public function testImplementsFactoryInterface(): 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 testGetCards(): 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 testWithCards(): 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 testGetSize(): 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 testWithSize(): 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 testRenderContent(): 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 }
testGetSize()
Definition: DeckTest.php:74
getFactory()
Definition: DeckTest.php:32
testImplementsFactoryInterface()
Definition: DeckTest.php:46
$c
Definition: deliver.php:25
testWithSize()
Definition: DeckTest.php:84
Test on deck implementation.
Definition: DeckTest.php:30
testRenderContent()
Definition: DeckTest.php:110
testGetCards()
Definition: DeckTest.php:55
testWithCards()
Definition: DeckTest.php:64
$r