ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
DeckTest.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 2016 Timon Amstutz <timon.amstutz@ilub.unibe.ch> Extended GPL, see docs/LICENSE */
4 
5 require_once(__DIR__ . "/../../../../libs/composer/vendor/autoload.php");
6 require_once(__DIR__ . "/../../Base.php");
7 
8 use \ILIAS\UI\Component as C;
9 use \ILIAS\UI\Implementation as I;
10 
15 {
16 
20  public function getFactory()
21  {
22  return new \ILIAS\UI\Implementation\Factory(
23  $this->createMock(C\Counter\Factory::class),
24  $this->createMock(C\Glyph\Factory::class),
25  $this->createMock(C\Button\Factory::class),
26  $this->createMock(C\Listing\Factory::class),
27  $this->createMock(C\Image\Factory::class),
28  $this->createMock(C\Panel\Factory::class),
29  $this->createMock(C\Modal\Factory::class),
30  $this->createMock(C\Dropzone\Factory::class),
31  $this->createMock(C\Popover\Factory::class),
32  $this->createMock(C\Divider\Factory::class),
33  $this->createMock(C\Link\Factory::class),
34  $this->createMock(C\Dropdown\Factory::class),
35  $this->createMock(C\Item\Factory::class),
36  $this->createMock(C\Icon\Factory::class),
37  $this->createMock(C\ViewControl\Factory::class),
38  $this->createMock(C\Chart\Factory::class),
39  $this->createMock(C\Input\Factory::class),
40  $this->createMock(C\Table\Factory::class),
41  $this->createMock(C\MessageBox\Factory::class),
42  new I\Component\Card\Factory()
43  );
44  }
45 
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()
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()
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()
75  {
76  $f = $this->getFactory();
77 
78  $c = $f->card()->standard("Card Title");
79  $d = $f->deck(array($c));
80 
81  $this->assertEquals($d->getCardsSize(), C\Deck\Deck::SIZE_S);
82  }
83 
84  public function test_with_size()
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($d->getCardsSize(), C\Deck\Deck::SIZE_XS);
93 
94  $d = $d->withSmallCardsSize();
95  $this->assertEquals($d->getCardsSize(), C\Deck\Deck::SIZE_S);
96 
97  $d = $d->withNormalCardsSize();
98  $this->assertEquals($d->getCardsSize(), C\Deck\Deck::SIZE_M);
99 
100  $d = $d->withLargeCardsSize();
101  $this->assertEquals($d->getCardsSize(), C\Deck\Deck::SIZE_L);
102 
103  $d = $d->withExtraLargeCardsSize();
104  $this->assertEquals($d->getCardsSize(), C\Deck\Deck::SIZE_XL);
105 
106  $d = $d->withFullSizedCardsSize();
107  $this->assertEquals($d->getCardsSize(), C\Deck\Deck::SIZE_FULL);
108  }
109 
110  public function test_render_content()
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 = $r->render($d);
120 
121  $expected_html =
122  '<div class="il-deck">
123  <div class="row row-eq-height">
124  <div class="col-sm-12 col-md-4"><div class="il-card thumbnail"><div class="card-no-highlight"></div><div class="caption"><h5 class="card-title">Card Title</h5></div></div></div>
125  <div class="col-sm-12 col-md-4"><div class="il-card thumbnail"><div class="card-no-highlight"></div><div class="caption"><h5 class="card-title">Card Title</h5></div></div></div>
126  <div class="col-sm-12 col-md-4"><div class="il-card thumbnail"><div class="card-no-highlight"></div><div class="caption"><h5 class="card-title">Card Title</h5></div></div></div>
127  </div>
128  <div class="row row-eq-height">
129  <div class="col-sm-12 col-md-4"><div class="il-card thumbnail"><div class="card-no-highlight"></div><div class="caption"><h5 class="card-title">Card Title</h5></div></div></div>
130  <div class="col-sm-12 col-md-4"><div class="il-card thumbnail"><div class="card-no-highlight"></div><div class="caption"><h5 class="card-title">Card Title</h5></div></div></div>
131  <div class="col-sm-12 col-md-4"><div class="il-card thumbnail"><div class="card-no-highlight"></div><div class="caption"><h5 class="card-title">Card Title</h5></div></div></div>
132  </div>
133  <div class="row row-eq-height">
134  <div class="col-sm-12 col-md-4"><div class="il-card thumbnail"><div class="card-no-highlight"></div><div class="caption"><h5 class="card-title">Card Title</h5></div></div></div>
135  </div>
136  </div>';
137 
138  $this->assertHTMLEquals($expected_html, $html);
139  }
140 }
getFactory()
Definition: DeckTest.php:20
test_render_content()
Definition: DeckTest.php:110
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:228
test_implements_factory_interface()
Definition: DeckTest.php:46
Test on deck implementation.
Definition: DeckTest.php:14
$r
Definition: example_031.php:79
Provides common functionality for UI tests.
Definition: Base.php:191
test_get_cards()
Definition: DeckTest.php:55
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:270
test_with_size()
Definition: DeckTest.php:84
test_get_size()
Definition: DeckTest.php:74
test_with_cards()
Definition: DeckTest.php:64
$html
Definition: example_001.php:87
for($i=6; $i< 13; $i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296