ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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_string_title_action ()
 
 test_with_signal_title_action ()
 
 test_with_highlight ()
 
 test_get_image ()
 
 test_with_image ()
 
 test_with_section ()
 
 test_render_content_full ()
 
 test_render_content_with_highlight ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getImagePathResolver ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML ($html)
 
 assertHTMLEquals ($expected_html_as_string, $html_as_string)
 

Private Member Functions

 getCardFactory ()
 
 getBaseCard ()
 

Additional Inherited Members

- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML ($html)
 A more radical version of normalizeHTML. More...
 

Detailed Description

Test on card implementation.

Definition at line 14 of file CardTest.php.

Member Function Documentation

◆ getBaseCard()

CardTest::getBaseCard ( )
private

Definition at line 36 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_section(), test_with_signal_title_action(), test_with_string_title_action(), and test_with_title().

37  {
38  $cf = $this->getCardFactory();
39  $image = new I\Component\Image\Image("standard", "src", "alt");
40 
41  return $cf->standard("Card Title", $image);
42  }
getCardFactory()
Definition: CardTest.php:31
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCardFactory()

CardTest::getCardFactory ( )
private

Definition at line 31 of file CardTest.php.

Referenced by getBaseCard().

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

◆ getFactory()

CardTest::getFactory ( )
Returns

Definition at line 19 of file CardTest.php.

References Vendor\Package\$f, $factory, and legacy().

Referenced by test_render_content_full(), and test_with_section().

20  {
21  $factory = new class extends NoUIFactory {
22  public function legacy($content)
23  {
24  $f = new I\Component\Legacy\Factory(new I\Component\SignalGenerator());
25  return $f->legacy($content);
26  }
27  };
28  return $factory;
29  }
legacy()
Definition: legacy.php:3
$factory
Definition: metadata.php:58
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ test_get_image()

CardTest::test_get_image ( )

Definition at line 86 of file CardTest.php.

References getBaseCard().

87  {
88  $card = $this->getBaseCard();
89  $image = new I\Component\Image\Image("standard", "src", "alt");
90 
91  $this->assertEquals($card->getImage(), $image);
92  }
getBaseCard()
Definition: CardTest.php:36
+ Here is the call graph for this function:

◆ test_get_title()

CardTest::test_get_title ( )

Definition at line 49 of file CardTest.php.

References $c, and getBaseCard().

50  {
51  $c = $this->getBaseCard();
52 
53  $this->assertEquals($c->getTitle(), "Card Title");
54  }
$c
Definition: cli.php:37
getBaseCard()
Definition: CardTest.php:36
+ Here is the call graph for this function:

◆ test_implements_factory_interface()

CardTest::test_implements_factory_interface ( )

Definition at line 44 of file CardTest.php.

References getBaseCard().

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

◆ test_render_content_full()

CardTest::test_render_content_full ( )

Definition at line 113 of file CardTest.php.

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

114  {
115  $r = $this->getDefaultRenderer();
116  $c = $this->getBaseCard();
117  $content = $this->getFactory()->legacy("Random Content");
118 
119  $c = $c->withSections(array($content));
120 
121  $html = $this->brutallyTrimHTML($r->render($c));
122 
123  $expected_html =
124  "<div class=\"il-card thumbnail\">" .
125  " <div class=\"il-card-image-container\"><img src=\"src\" class=\"img-standard\" alt=\"alt\" /></div>" .
126  " <div class=\"card-no-highlight\"></div>" .
127  " <div class=\"caption card-title\">Card Title</div>" .
128  " <div class=\"caption\">Random Content</div>" .
129  "</div>";
130 
131  $this->assertHTMLEquals($this->brutallyTrimHTML($expected_html), $html);
132  }
$c
Definition: cli.php:37
getBaseCard()
Definition: CardTest.php:36
getFactory()
Definition: CardTest.php:19
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:372
brutallyTrimHTML($html)
A more radical version of normalizeHTML.
Definition: Base.php:392
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
+ Here is the call graph for this function:

◆ test_render_content_with_highlight()

CardTest::test_render_content_with_highlight ( )

Definition at line 134 of file CardTest.php.

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

135  {
136  $r = $this->getDefaultRenderer();
137  $c = $this->getBaseCard();
138  $c = $c->withHighlight(true);
139 
140  $html = $this->brutallyTrimHTML($r->render($c));
141 
142  $expected_html =
143  "<div class=\"il-card thumbnail\">" .
144  " <div class=\"il-card-image-container\"><img src=\"src\" class=\"img-standard\" alt=\"alt\" /></div>" .
145  " <div class=\"card-highlight\"></div>" .
146  " <div class=\"caption card-title\">Card Title</div>" .
147  "</div>";
148 
149  $this->assertHTMLEquals($this->brutallyTrimHTML($expected_html), $html);
150  }
$c
Definition: cli.php:37
getBaseCard()
Definition: CardTest.php:36
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:372
brutallyTrimHTML($html)
A more radical version of normalizeHTML.
Definition: Base.php:392
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
+ Here is the call graph for this function:

◆ test_with_highlight()

CardTest::test_with_highlight ( )

Definition at line 79 of file CardTest.php.

References $c, and getBaseCard().

80  {
81  $c = $this->getBaseCard();
82  $c = $c->withHighlight(true);
83  $this->assertTrue($c->isHighlighted());
84  }
$c
Definition: cli.php:37
getBaseCard()
Definition: CardTest.php:36
+ Here is the call graph for this function:

◆ test_with_image()

CardTest::test_with_image ( )

Definition at line 94 of file CardTest.php.

References $c, and getBaseCard().

95  {
96  $card = $this->getBaseCard();
97  $image_new = new I\Component\Image\Image("standard", "src/new", "alt");
98  $c = $card->withImage($image_new);
99 
100  $this->assertEquals($c->getImage(), $image_new);
101  }
$c
Definition: cli.php:37
getBaseCard()
Definition: CardTest.php:36
+ Here is the call graph for this function:

◆ test_with_section()

CardTest::test_with_section ( )

Definition at line 103 of file CardTest.php.

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

104  {
105  $f = $this->getFactory();
106  $c = $this->getBaseCard();
107  $content = $f->legacy("Random Content");
108  $c = $c->withSections(array($content));
109 
110  $this->assertEquals($c->getSections(), array($content));
111  }
$c
Definition: cli.php:37
getBaseCard()
Definition: CardTest.php:36
getFactory()
Definition: CardTest.php:19
+ Here is the call graph for this function:

◆ test_with_signal_title_action()

CardTest::test_with_signal_title_action ( )

Definition at line 71 of file CardTest.php.

References $c, and getBaseCard().

72  {
73  $c = $this->getBaseCard();
74  $signal = $this->createMock(C\Signal::class);
75  $c = $c->withTitleAction($signal);
76  $this->assertEquals([$signal], $c->getTitleAction());
77  }
$c
Definition: cli.php:37
getBaseCard()
Definition: CardTest.php:36
+ Here is the call graph for this function:

◆ test_with_string_title_action()

CardTest::test_with_string_title_action ( )

Definition at line 64 of file CardTest.php.

References $c, and getBaseCard().

65  {
66  $c = $this->getBaseCard();
67  $c = $c->withTitleAction("newAction");
68  $this->assertEquals("newAction", $c->getTitleAction());
69  }
$c
Definition: cli.php:37
getBaseCard()
Definition: CardTest.php:36
+ Here is the call graph for this function:

◆ test_with_title()

CardTest::test_with_title ( )

Definition at line 56 of file CardTest.php.

References $c, and getBaseCard().

57  {
58  $c = $this->getBaseCard();
59  $c = $c->withTitle("Card Title New");
60 
61  $this->assertEquals($c->getTitle(), "Card Title New");
62  }
$c
Definition: cli.php:37
getBaseCard()
Definition: CardTest.php:36
+ Here is the call graph for this function:

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