ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
CardTest Class Reference

Test on card implementation. More...

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

Public Member Functions

 getFactory ()
 
 test_implements_factory_interface ()
 
 test_get_title ()
 
 test_with_title ()
 
 test_with_title_action ()
 
 test_with_highlight ()
 
 test_get_image ()
 
 test_with_image ()
 
 test_with_section ()
 
 test_with_image_action ()
 
 test_render_content_full ()
 
 test_render_content_with_highlight ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null)
 
 normalizeHTML ($html)
 
 assertHTMLEquals ($expected_html_as_string, $html_as_string)
 

Private Member Functions

 getCardFactory ()
 
 getBaseCard ()
 

Detailed Description

Test on card implementation.

Definition at line 14 of file CardTest.php.

Member Function Documentation

◆ getBaseCard()

CardTest::getBaseCard ( )
private

Definition at line 51 of file CardTest.php.

References getCardFactory().

Referenced by test_get_image(), test_get_title(), test_implements_factory_interface(), test_render_content_full(), test_render_content_with_highlight(), test_with_highlight(), test_with_image(), test_with_image_action(), test_with_section(), test_with_title(), and test_with_title_action().

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

◆ getCardFactory()

CardTest::getCardFactory ( )
private

Definition at line 46 of file CardTest.php.

Referenced by getBaseCard().

47  {
48  return new \ILIAS\UI\Implementation\Component\Card\Factory();
49  }
+ Here is the caller graph for this function:

◆ getFactory()

CardTest::getFactory ( )
Returns

Definition at line 20 of file CardTest.php.

Referenced by test_with_section().

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  $this->createMock(C\Card\Factory::class)
43  );
44  }
+ Here is the caller graph for this function:

◆ test_get_image()

CardTest::test_get_image ( )

Definition at line 93 of file CardTest.php.

References getBaseCard().

94  {
95  $card = $this->getBaseCard();
96  $image = new I\Component\Image\Image("standard", "src", "alt");
97 
98  $this->assertEquals($card->getImage(), $image);
99  }
getBaseCard()
Definition: CardTest.php:51
+ Here is the call graph for this function:

◆ test_get_title()

CardTest::test_get_title ( )

Definition at line 64 of file CardTest.php.

References $c, and getBaseCard().

65  {
66  $c = $this->getBaseCard();
67 
68  $this->assertEquals($c->getTitle(), "Card Title");
69  }
getBaseCard()
Definition: CardTest.php:51
+ Here is the call graph for this function:

◆ test_implements_factory_interface()

CardTest::test_implements_factory_interface ( )

Definition at line 59 of file CardTest.php.

References getBaseCard().

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

◆ test_render_content_full()

CardTest::test_render_content_full ( )

Definition at line 129 of file CardTest.php.

References $c, $html, $r, ILIAS_UI_TestBase\assertHTMLEquals(), getBaseCard(), and ILIAS_UI_TestBase\getDefaultRenderer().

130  {
131  $r = $this->getDefaultRenderer();
132 
133  $c = $this->getBaseCard();
134 
135  $content = new I\Component\Legacy\Legacy("Random Content");
136 
137  $c = $c->withSections(array($content));
138 
139  $html = $r->render($c);
140 
141  $expected_html =
142  "<div class=\"il-card thumbnail\">" .
143  " <img src=\"src\" class=\"img-standard\" alt=\"alt\" />" .
144  " <div class=\"card-no-highlight\"></div>" .
145  " <div class=\"caption\">" .
146  " <h5 class=\"card-title\">Card Title</h5>" .
147  " </div>" .
148  " <div class=\"caption\">Random Content</div>" .
149  "</div>";
150 
151  $this->assertHTMLEquals($expected_html, $html);
152  }
getBaseCard()
Definition: CardTest.php:51
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:228
$r
Definition: example_031.php:79
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:270
$html
Definition: example_001.php:87
+ Here is the call graph for this function:

◆ test_render_content_with_highlight()

CardTest::test_render_content_with_highlight ( )

Definition at line 154 of file CardTest.php.

References $c, $html, $r, ILIAS_UI_TestBase\assertHTMLEquals(), getBaseCard(), and ILIAS_UI_TestBase\getDefaultRenderer().

155  {
156  $r = $this->getDefaultRenderer();
157  $c = $this->getBaseCard();
158  $c = $c->withHighlight(true);
159 
160  $html = $r->render($c);
161 
162  $expected_html =
163  "<div class=\"il-card thumbnail\">" .
164  " <img src=\"src\" class=\"img-standard\" alt=\"alt\" />" .
165  " <div class=\"card-highlight\"></div>" .
166  " <div class=\"caption\">" .
167  " <h5 class=\"card-title\">Card Title</h5>" .
168  " </div>" .
169  "</div>";
170 
171  $this->assertHTMLEquals($expected_html, $html);
172  }
getBaseCard()
Definition: CardTest.php:51
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:228
$r
Definition: example_031.php:79
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:270
$html
Definition: example_001.php:87
+ Here is the call graph for this function:

◆ test_with_highlight()

CardTest::test_with_highlight ( )

Definition at line 86 of file CardTest.php.

References $c, and getBaseCard().

87  {
88  $c = $this->getBaseCard();
89  $c = $c->withHighlight(true);
90  $this->assertTrue($c->isHighlighted());
91  }
getBaseCard()
Definition: CardTest.php:51
+ Here is the call graph for this function:

◆ test_with_image()

CardTest::test_with_image ( )

Definition at line 101 of file CardTest.php.

References $c, and getBaseCard().

102  {
103  $card = $this->getBaseCard();
104  $image_new = new I\Component\Image\Image("standard", "src/new", "alt");
105  $c = $card->withImage($image_new);
106 
107  $this->assertEquals($c->getImage(), $image_new);
108  }
getBaseCard()
Definition: CardTest.php:51
+ Here is the call graph for this function:

◆ test_with_image_action()

CardTest::test_with_image_action ( )

Definition at line 120 of file CardTest.php.

References $action, $c, and getBaseCard().

121  {
122  $c = $this->getBaseCard();
123  $action = "https://www.ilias.de";
124  $c = $c->withImageAction($action);
125 
126  $this->assertEquals($c->getImageAction(), $action);
127  }
$action
getBaseCard()
Definition: CardTest.php:51
+ Here is the call graph for this function:

◆ test_with_section()

CardTest::test_with_section ( )

Definition at line 110 of file CardTest.php.

References $c, $f, getBaseCard(), and getFactory().

111  {
112  $f = $this->getFactory();
113  $c = $this->getBaseCard();
114  $content = $f->legacy("Random Content");
115  $c = $c->withSections(array($content));
116 
117  $this->assertEquals($c->getSections(), array($content));
118  }
getBaseCard()
Definition: CardTest.php:51
getFactory()
Definition: CardTest.php:20
+ Here is the call graph for this function:

◆ test_with_title()

CardTest::test_with_title ( )

Definition at line 71 of file CardTest.php.

References $c, and getBaseCard().

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

◆ test_with_title_action()

CardTest::test_with_title_action ( )

Definition at line 79 of file CardTest.php.

References $c, and getBaseCard().

80  {
81  $c = $this->getBaseCard();
82  $c = $c->withTitleAction("newAction");
83  $this->assertEquals("newAction", $c->getTitleAction());
84  }
getBaseCard()
Definition: CardTest.php:51
+ Here is the call graph for this function:

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