ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 ()
 

Private Member Functions

 getCardFactory ()
 
 getBaseCard ()
 

Detailed Description

Test on card implementation.

Definition at line 31 of file CardTest.php.

Member Function Documentation

◆ getBaseCard()

CardTest::getBaseCard ( )
private

Definition at line 48 of file CardTest.php.

48 : I\Component\Card\Standard
49 {
50 $cf = $this->getCardFactory();
51 $image = new I\Component\Image\Image("standard", "src", "alt");
52
53 return $cf->standard("Card Title", $image);
54 }
getCardFactory()
Definition: CardTest.php:43

References getCardFactory().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCardFactory()

CardTest::getCardFactory ( )
private

Definition at line 43 of file CardTest.php.

43 : I\Component\Card\Factory
44 {
45 return new Factory();
46 }

Referenced by getBaseCard(), and testFactoryWithShyButton().

+ Here is the caller graph for this function:

◆ getFactory()

CardTest::getFactory ( )

Definition at line 33 of file CardTest.php.

34 {
35 return new class () extends NoUIFactory {
36 public function legacy(): I\Component\Legacy\Factory
37 {
38 return new I\Component\Legacy\Factory(new I\Component\SignalGenerator());
39 }
40 };
41 }

References ILIAS\UI\examples\MainControls\Slate\Legacy\legacy().

Referenced by testWithSection().

+ 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 185 of file CardTest.php.

185 : void
186 {
187 $r = $this->getDefaultRenderer();
188 $c = $this->getBaseCard();
189 $title = new I\Component\Button\Shy('Card Title', '');
190 $c = $c->withTitle($title);
191
192 $html = $this->brutallyTrimHTML($r->render($c));
193
194 $expected_html =
195 "<div class=\"il-card thumbnail\">" .
196 " <div class=\"il-card-image-container\"><img src=\"src\" class=\"img-standard\" alt=\"open Card Title\" /></div>" .
197 " <div class=\"card-no-highlight\"></div>" .
198 " <div class=\"caption card-title\">" . $r->render($title) . "</div>" .
199 "</div>";
200
201 $this->assertHTMLEquals($this->brutallyTrimHTML($expected_html), $html);
202 }
getBaseCard()
Definition: CardTest.php:48
$c
Definition: deliver.php:25

References $c, and getBaseCard().

+ Here is the call graph for this function:

◆ testFactoryWithShyButton()

CardTest::testFactoryWithShyButton ( )

Definition at line 61 of file CardTest.php.

61 : void
62 {
63 $button_factory = new I\Component\Button\Factory();
64 $button = $button_factory->shy("Card Title New", "");
65
66 $cf = $this->getCardFactory();
67 $image = new I\Component\Image\Image("standard", "src", "alt");
68
69 $this->assertEquals($button, $cf->standard($button, $image)->getTitle());
70 }

References getCardFactory().

+ Here is the call graph for this function:

◆ testGetImage()

CardTest::testGetImage ( )

Definition at line 119 of file CardTest.php.

119 : void
120 {
121 $card = $this->getBaseCard();
122 $image = new I\Component\Image\Image("standard", "src", "alt");
123
124 $this->assertEquals($card->getImage(), $image);
125 }

References getBaseCard().

+ Here is the call graph for this function:

◆ testGetTitle()

CardTest::testGetTitle ( )

Definition at line 72 of file CardTest.php.

72 : void
73 {
74 $c = $this->getBaseCard();
75
76 $this->assertEquals("Card Title", $c->getTitle());
77 }

References $c, and getBaseCard().

+ Here is the call graph for this function:

◆ testImplementsFactoryInterface()

CardTest::testImplementsFactoryInterface ( )

Definition at line 56 of file CardTest.php.

56 : void
57 {
58 $this->assertInstanceOf("ILIAS\\UI\\Component\\Card\\Standard", $this->getBaseCard());
59 }

References getBaseCard().

+ Here is the call graph for this function:

◆ testRenderContentFull()

CardTest::testRenderContentFull ( )

Definition at line 146 of file CardTest.php.

146 : void
147 {
148 $r = $this->getDefaultRenderer();
149 $c = $this->getBaseCard();
150 $content = $this->getfactory()->legacy()->content("Random Content");
151
152 $c = $c->withSections(array($content));
153
154 $html = $this->brutallyTrimHTML($r->render($c));
155
156 $expected_html =
157 "<div class=\"il-card thumbnail\">" .
158 " <div class=\"il-card-image-container\"><img src=\"src\" class=\"img-standard\" alt=\"open Card Title\" /></div>" .
159 " <div class=\"card-no-highlight\"></div>" .
160 " <div class=\"caption card-title\">Card Title</div>" .
161 " <div class=\"caption\">Random Content</div>" .
162 "</div>";
163
164 $this->assertHTMLEquals($this->brutallyTrimHTML($expected_html), $html);
165 }

References $c, and getBaseCard().

+ Here is the call graph for this function:

◆ testRenderContentWithHighlight()

CardTest::testRenderContentWithHighlight ( )

Definition at line 167 of file CardTest.php.

167 : void
168 {
169 $r = $this->getDefaultRenderer();
170 $c = $this->getBaseCard();
171 $c = $c->withHighlight(true);
172
173 $html = $this->brutallyTrimHTML($r->render($c));
174
175 $expected_html =
176 "<div class=\"il-card thumbnail\">" .
177 " <div class=\"il-card-image-container\"><img src=\"src\" class=\"img-standard\" alt=\"open Card Title\" /></div>" .
178 " <div class=\"card-highlight\"></div>" .
179 " <div class=\"caption card-title\">Card Title</div>" .
180 "</div>";
181
182 $this->assertHTMLEquals($this->brutallyTrimHTML($expected_html), $html);
183 }

References $c, and getBaseCard().

+ Here is the call graph for this function:

◆ testWithHighlight()

CardTest::testWithHighlight ( )

Definition at line 112 of file CardTest.php.

112 : void
113 {
114 $c = $this->getBaseCard();
115 $c = $c->withHighlight(true);
116 $this->assertTrue($c->isHighlighted());
117 }

References $c, and getBaseCard().

+ Here is the call graph for this function:

◆ testWithImage()

CardTest::testWithImage ( )

Definition at line 127 of file CardTest.php.

127 : void
128 {
129 $card = $this->getBaseCard();
130 $image_new = new I\Component\Image\Image("standard", "components/ILIAS/new", "alt");
131 $c = $card->withImage($image_new);
132
133 $this->assertEquals($c->getImage(), $image_new);
134 }

References $c, and getBaseCard().

+ Here is the call graph for this function:

◆ testWithSection()

CardTest::testWithSection ( )

Definition at line 136 of file CardTest.php.

136 : void
137 {
138 $f = $this->getFactory();
139 $c = $this->getBaseCard();
140 $content = $f->legacy()->content("Random Content");
141 $c = $c->withSections(array($content));
142
143 $this->assertEquals($c->getSections(), array($content));
144 }
getFactory()
Definition: CardTest.php:33

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

+ Here is the call graph for this function:

◆ testWithSignalTitleAction()

CardTest::testWithSignalTitleAction ( )

Definition at line 104 of file CardTest.php.

104 : void
105 {
106 $c = $this->getBaseCard();
107 $signal = $this->createMock(C\Signal::class);
108 $c = $c->withTitleAction($signal);
109 $this->assertEquals([$signal], $c->getTitleAction());
110 }

References $c, and getBaseCard().

+ Here is the call graph for this function:

◆ testWithStringTitleAction()

CardTest::testWithStringTitleAction ( )

Definition at line 97 of file CardTest.php.

97 : void
98 {
99 $c = $this->getBaseCard();
100 $c = $c->withTitleAction("newAction");
101 $this->assertEquals("newAction", $c->getTitleAction());
102 }

References $c, and getBaseCard().

+ Here is the call graph for this function:

◆ testWithTitle()

CardTest::testWithTitle ( )

Definition at line 79 of file CardTest.php.

79 : void
80 {
81 $c = $this->getBaseCard();
82 $c = $c->withTitle("Card Title New");
83
84 $this->assertEquals("Card Title New", $c->getTitle());
85 }

References $c, and getBaseCard().

+ Here is the call graph for this function:

◆ testWithTitleAsShyButton()

CardTest::testWithTitleAsShyButton ( )

Definition at line 87 of file CardTest.php.

87 : void
88 {
89 $c = $this->getBaseCard();
90 $button_factory = new I\Component\Button\Factory();
91 $button = $button_factory->shy("Card Title New", "");
92
93 $c = $c->withTitle($button);
94 $this->assertEquals($button, $c->getTitle());
95 }

References $c, and getBaseCard().

+ Here is the call graph for this function:

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