ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
CardTest Class Reference

Test on card implementation. More...

+ Inheritance diagram for CardTest:
+ Collaboration diagram for CardTest:

Public Member Functions

 getFactory ()
 
 testImplementsFactoryInterface ()
 
 testFactoryWithShyButton ()
 
 testGetTitle ()
 
 testWithTitle ()
 
 testWithTitleAsShyButton ()
 
 testWithStringTitleAction ()
 
 testWithSignalTitleAction ()
 
 testWithHighlight ()
 
 testGetImage ()
 
 testWithImage ()
 
 testWithSection ()
 
 testRenderContentFull ()
 
 testRenderContentWithHighlight ()
 
 test_render_content_with_component_title ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getImagePathResolver ()
 
 getDataFactory ()
 
 getHelpTextRetriever ()
 
 getUploadLimitResolver ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML (string $html)
 
 assertHTMLEquals (string $expected_html_as_string, string $html_as_string)
 

Private Member Functions

 getCardFactory ()
 
 getBaseCard ()
 

Additional Inherited Members

- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML (string $html)
 A more radical version of normalizeHTML. More...
 
 brutallyTrimSignals (string $html)
 A naive replacement of all il_signal-ids with dots to ease comparisons of rendered output. More...
 

Detailed Description

Test on card implementation.

Definition at line 31 of file CardTest.php.

Member Function Documentation

◆ getBaseCard()

CardTest::getBaseCard ( )
private

Definition at line 49 of file CardTest.php.

References getCardFactory().

Referenced by test_render_content_with_component_title(), testGetImage(), testGetTitle(), testImplementsFactoryInterface(), testRenderContentFull(), testRenderContentWithHighlight(), testWithHighlight(), testWithImage(), testWithSection(), testWithSignalTitleAction(), testWithStringTitleAction(), testWithTitle(), and testWithTitleAsShyButton().

49  : I\Component\Card\Standard
50  {
51  $cf = $this->getCardFactory();
52  $image = new I\Component\Image\Image("standard", "src", "alt");
53 
54  return $cf->standard("Card Title", $image);
55  }
getCardFactory()
Definition: CardTest.php:44
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCardFactory()

CardTest::getCardFactory ( )
private

Definition at line 44 of file CardTest.php.

Referenced by getBaseCard(), and testFactoryWithShyButton().

44  : I\Component\Card\Factory
45  {
46  return new Factory();
47  }
+ Here is the caller graph for this function:

◆ getFactory()

CardTest::getFactory ( )

Definition at line 33 of file CardTest.php.

References Vendor\Package\$f, and ILIAS\UI\examples\MainControls\Slate\Legacy\legacy().

Referenced by testRenderContentFull(), and testWithSection().

33  : NoUIFactory
34  {
35  return new class () extends NoUIFactory {
36  public function legacy($content): C\Legacy\Legacy
37  {
38  $f = new I\Component\Legacy\Factory(new I\Component\SignalGenerator());
39  return $f->legacy($content);
40  }
41  };
42  }
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...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ test_render_content_with_component_title()

CardTest::test_render_content_with_component_title ( )

Definition at line 186 of file CardTest.php.

References Vendor\Package\$c, $r, ILIAS_UI_TestBase\assertHTMLEquals(), ILIAS_UI_TestBase\brutallyTrimHTML(), getBaseCard(), and ILIAS_UI_TestBase\getDefaultRenderer().

186  : void
187  {
188  $r = $this->getDefaultRenderer();
189  $c = $this->getBaseCard();
190  $title = new I\Component\Button\Shy('Card Title', '');
191  $c = $c->withTitle($title);
192 
193  $html = $this->brutallyTrimHTML($r->render($c));
194 
195  $expected_html =
196  "<div class=\"il-card thumbnail\">" .
197  " <div class=\"il-card-image-container\"><img src=\"src\" class=\"img-standard\" alt=\"open Card Title\" /></div>" .
198  " <div class=\"card-no-highlight\"></div>" .
199  " <div class=\"caption card-title\">" . $r->render($title) . "</div>" .
200  "</div>";
201 
202  $this->assertHTMLEquals($this->brutallyTrimHTML($expected_html), $html);
203  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:377
getBaseCard()
Definition: CardTest.php:49
brutallyTrimHTML(string $html)
A more radical version of normalizeHTML.
Definition: Base.php:475
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:458
$r
+ Here is the call graph for this function:

◆ testFactoryWithShyButton()

CardTest::testFactoryWithShyButton ( )

Definition at line 62 of file CardTest.php.

References getCardFactory().

62  : void
63  {
64  $button_factory = new I\Component\Button\Factory();
65  $button = $button_factory->shy("Card Title New", "");
66 
67  $cf = $this->getCardFactory();
68  $image = new I\Component\Image\Image("standard", "src", "alt");
69 
70  $this->assertEquals($button, $cf->standard($button, $image)->getTitle());
71  }
getCardFactory()
Definition: CardTest.php:44
+ Here is the call graph for this function:

◆ testGetImage()

CardTest::testGetImage ( )

Definition at line 120 of file CardTest.php.

References getBaseCard().

120  : void
121  {
122  $card = $this->getBaseCard();
123  $image = new I\Component\Image\Image("standard", "src", "alt");
124 
125  $this->assertEquals($card->getImage(), $image);
126  }
getBaseCard()
Definition: CardTest.php:49
+ Here is the call graph for this function:

◆ testGetTitle()

CardTest::testGetTitle ( )

Definition at line 73 of file CardTest.php.

References Vendor\Package\$c, and getBaseCard().

73  : void
74  {
75  $c = $this->getBaseCard();
76 
77  $this->assertEquals("Card Title", $c->getTitle());
78  }
getBaseCard()
Definition: CardTest.php:49
+ Here is the call graph for this function:

◆ testImplementsFactoryInterface()

CardTest::testImplementsFactoryInterface ( )

Definition at line 57 of file CardTest.php.

References getBaseCard().

57  : void
58  {
59  $this->assertInstanceOf("ILIAS\\UI\\Component\\Card\\Standard", $this->getBaseCard());
60  }
getBaseCard()
Definition: CardTest.php:49
+ Here is the call graph for this function:

◆ testRenderContentFull()

CardTest::testRenderContentFull ( )

Definition at line 147 of file CardTest.php.

References Vendor\Package\$c, $r, ILIAS_UI_TestBase\assertHTMLEquals(), ILIAS_UI_TestBase\brutallyTrimHTML(), getBaseCard(), ILIAS_UI_TestBase\getDefaultRenderer(), and getFactory().

147  : void
148  {
149  $r = $this->getDefaultRenderer();
150  $c = $this->getBaseCard();
151  $content = $this->getFactory()->legacy("Random Content");
152 
153  $c = $c->withSections(array($content));
154 
155  $html = $this->brutallyTrimHTML($r->render($c));
156 
157  $expected_html =
158  "<div class=\"il-card thumbnail\">" .
159  " <div class=\"il-card-image-container\"><img src=\"src\" class=\"img-standard\" alt=\"open Card Title\" /></div>" .
160  " <div class=\"card-no-highlight\"></div>" .
161  " <div class=\"caption card-title\">Card Title</div>" .
162  " <div class=\"caption\">Random Content</div>" .
163  "</div>";
164 
165  $this->assertHTMLEquals($this->brutallyTrimHTML($expected_html), $html);
166  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:377
getBaseCard()
Definition: CardTest.php:49
brutallyTrimHTML(string $html)
A more radical version of normalizeHTML.
Definition: Base.php:475
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:458
getFactory()
Definition: CardTest.php:33
$r
+ Here is the call graph for this function:

◆ testRenderContentWithHighlight()

CardTest::testRenderContentWithHighlight ( )

Definition at line 168 of file CardTest.php.

References Vendor\Package\$c, $r, ILIAS_UI_TestBase\assertHTMLEquals(), ILIAS_UI_TestBase\brutallyTrimHTML(), getBaseCard(), and ILIAS_UI_TestBase\getDefaultRenderer().

168  : void
169  {
170  $r = $this->getDefaultRenderer();
171  $c = $this->getBaseCard();
172  $c = $c->withHighlight(true);
173 
174  $html = $this->brutallyTrimHTML($r->render($c));
175 
176  $expected_html =
177  "<div class=\"il-card thumbnail\">" .
178  " <div class=\"il-card-image-container\"><img src=\"src\" class=\"img-standard\" alt=\"open Card Title\" /></div>" .
179  " <div class=\"card-highlight\"></div>" .
180  " <div class=\"caption card-title\">Card Title</div>" .
181  "</div>";
182 
183  $this->assertHTMLEquals($this->brutallyTrimHTML($expected_html), $html);
184  }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:377
getBaseCard()
Definition: CardTest.php:49
brutallyTrimHTML(string $html)
A more radical version of normalizeHTML.
Definition: Base.php:475
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:458
$r
+ Here is the call graph for this function:

◆ testWithHighlight()

CardTest::testWithHighlight ( )

Definition at line 113 of file CardTest.php.

References Vendor\Package\$c, and getBaseCard().

113  : void
114  {
115  $c = $this->getBaseCard();
116  $c = $c->withHighlight(true);
117  $this->assertTrue($c->isHighlighted());
118  }
getBaseCard()
Definition: CardTest.php:49
+ Here is the call graph for this function:

◆ testWithImage()

CardTest::testWithImage ( )

Definition at line 128 of file CardTest.php.

References Vendor\Package\$c, and getBaseCard().

128  : void
129  {
130  $card = $this->getBaseCard();
131  $image_new = new I\Component\Image\Image("standard", "src/new", "alt");
132  $c = $card->withImage($image_new);
133 
134  $this->assertEquals($c->getImage(), $image_new);
135  }
getBaseCard()
Definition: CardTest.php:49
+ Here is the call graph for this function:

◆ testWithSection()

CardTest::testWithSection ( )

Definition at line 137 of file CardTest.php.

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

137  : void
138  {
139  $f = $this->getFactory();
140  $c = $this->getBaseCard();
141  $content = $f->legacy("Random Content");
142  $c = $c->withSections(array($content));
143 
144  $this->assertEquals($c->getSections(), array($content));
145  }
getBaseCard()
Definition: CardTest.php:49
getFactory()
Definition: CardTest.php:33
+ Here is the call graph for this function:

◆ testWithSignalTitleAction()

CardTest::testWithSignalTitleAction ( )

Definition at line 105 of file CardTest.php.

References Vendor\Package\$c, and getBaseCard().

105  : void
106  {
107  $c = $this->getBaseCard();
108  $signal = $this->createMock(C\Signal::class);
109  $c = $c->withTitleAction($signal);
110  $this->assertEquals([$signal], $c->getTitleAction());
111  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getBaseCard()
Definition: CardTest.php:49
+ Here is the call graph for this function:

◆ testWithStringTitleAction()

CardTest::testWithStringTitleAction ( )

Definition at line 98 of file CardTest.php.

References Vendor\Package\$c, and getBaseCard().

98  : void
99  {
100  $c = $this->getBaseCard();
101  $c = $c->withTitleAction("newAction");
102  $this->assertEquals("newAction", $c->getTitleAction());
103  }
getBaseCard()
Definition: CardTest.php:49
+ Here is the call graph for this function:

◆ testWithTitle()

CardTest::testWithTitle ( )

Definition at line 80 of file CardTest.php.

References Vendor\Package\$c, and getBaseCard().

80  : void
81  {
82  $c = $this->getBaseCard();
83  $c = $c->withTitle("Card Title New");
84 
85  $this->assertEquals("Card Title New", $c->getTitle());
86  }
getBaseCard()
Definition: CardTest.php:49
+ Here is the call graph for this function:

◆ testWithTitleAsShyButton()

CardTest::testWithTitleAsShyButton ( )

Definition at line 88 of file CardTest.php.

References Vendor\Package\$c, and getBaseCard().

88  : void
89  {
90  $c = $this->getBaseCard();
91  $button_factory = new I\Component\Button\Factory();
92  $button = $button_factory->shy("Card Title New", "");
93 
94  $c = $c->withTitle($button);
95  $this->assertEquals($button, $c->getTitle());
96  }
getBaseCard()
Definition: CardTest.php:49
+ Here is the call graph for this function:

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