ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
NotificationSlateTest Class Reference

Tests for the Slate. More...

+ Inheritance diagram for NotificationSlateTest:
+ Collaboration diagram for NotificationSlateTest:

Public Member Functions

 setUp ()
 
 getIcon ()
 
 getUIFactory ()
 
 testImplementsFactoryInterface ()
 
 testGenerationByFactory ()
 
 testWithAdditionalEntry ()
 
 testRenderingWithSubslateAndButton ()
 
- 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)
 

Additional Inherited Members

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

Detailed Description

Tests for the Slate.

Definition at line 15 of file NotificationSlateTest.php.

Member Function Documentation

◆ getIcon()

NotificationSlateTest::getIcon ( )

Definition at line 22 of file NotificationSlateTest.php.

References getUIFactory().

Referenced by testGenerationByFactory(), testRenderingWithSubslateAndButton(), and testWithAdditionalEntry().

23  {
24  return $this->getUIFactory()->symbol()->icon()->standard("name", "aria_label", "small", false);
25  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUIFactory()

NotificationSlateTest::getUIFactory ( )

Definition at line 27 of file NotificationSlateTest.php.

References $factory.

Referenced by getIcon(), testGenerationByFactory(), testImplementsFactoryInterface(), testRenderingWithSubslateAndButton(), and testWithAdditionalEntry().

28  {
29  $factory = new class extends NoUIFactory {
30  public function button()
31  {
32  return new I\Button\Factory($this->sig_gen);
33  }
34  public function symbol() : ILIAS\UI\Component\Symbol\Factory
35  {
36  return new I\Symbol\Factory(
37  new I\Symbol\Icon\Factory(),
38  new I\Symbol\Glyph\Factory(),
39  new I\Symbol\Avatar\Factory()
40  );
41  }
42  public function item()
43  {
44  return new I\Item\Factory();
45  }
46  public function mainControls() : C\MainControls\Factory
47  {
48  return new I\MainControls\Factory(
49  $this->sig_gen,
50  new I\MainControls\Slate\Factory(
51  $this->sig_gen,
52  new \ILIAS\UI\Implementation\Component\Counter\Factory(),
53  $this->symbol()
54  )
55  );
56  }
57  public function icon() : I\Symbol\Icon\Factory
58  {
59  new I\Symbol\Icon\Factory();
60  }
61  };
62  $factory->sig_gen = $this->sig_gen;
63 
64  return $factory;
65  }
Class Factory.
Class ChatMainBarProvider .
$factory
Definition: metadata.php:58
+ Here is the caller graph for this function:

◆ setUp()

NotificationSlateTest::setUp ( )

Definition at line 17 of file NotificationSlateTest.php.

17  : void
18  {
19  $this->sig_gen = new I\SignalGenerator();
20  }

◆ testGenerationByFactory()

NotificationSlateTest::testGenerationByFactory ( )

Definition at line 74 of file NotificationSlateTest.php.

References getIcon(), and getUIFactory().

75  {
76  $item = $this->getUIFactory()->item()->notification("title", $this->getIcon())
77  ->withDescription("description");
78 
79  $notification_slate = $this->getUIFactory()->mainControls()->slate()->notification("title", [$item,$item]);
80  $this->assertEquals($notification_slate->getName(), "title");
81  $this->assertEquals($notification_slate->getContents(), [$item,$item]);
82  }
+ Here is the call graph for this function:

◆ testImplementsFactoryInterface()

NotificationSlateTest::testImplementsFactoryInterface ( )

Definition at line 67 of file NotificationSlateTest.php.

References getUIFactory().

68  {
69  $notificatino_slate = $this->getUIFactory()->mainControls()->slate()->notification("title", []);
70 
71  $this->assertInstanceOf("ILIAS\\UI\\Component\\MainControls\\Slate\\Notification", $notificatino_slate);
72  }
+ Here is the call graph for this function:

◆ testRenderingWithSubslateAndButton()

NotificationSlateTest::testRenderingWithSubslateAndButton ( )

Definition at line 95 of file NotificationSlateTest.php.

References back(), ILIAS_UI_TestBase\brutallyTrimHTML(), ILIAS_UI_TestBase\getDefaultRenderer(), getIcon(), and getUIFactory().

96  {
97  $item = $this->getUIFactory()->item()->notification("item title", $this->getIcon());
98  $notification_slate = $this->getUIFactory()->mainControls()->slate()->notification("slate title", [$item]);
99 
100 
101  $r = $this->getDefaultRenderer();
102  $html = $r->render($notification_slate);
103 
104  $expected = <<<EOT
105 <div class="il-maincontrols-slate il-maincontrols-slate-notification">
106  <div class="il-maincontrols-slate-notification-title">slate title</div>
107  <div class="il-maincontrols-slate-content">
108  <div class="il-item-notification-replacement-container">
109  <div class="il-item il-notification-item" id="id_1">
110  <div class="media">
111  <div class="media-left">
112  <img class="icon name small" src="./templates/default/images/icon_default.svg" alt="aria_label"/>
113  </div>
114  <div class="media-body">
115  <h4 class="il-item-notification-title">item title</h4>
116  <div class="il-aggregate-notifications" data-aggregatedby="id_1">
117  <div class="il-maincontrols-slate il-maincontrols-slate-notification">
118  <div class="il-maincontrols-slate-notification-title">
119  <button class="btn btn-bulky" data-action="">
120  <span class="glyph" aria-label="back" role="img">
121  <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
122  </span>
123  <span class="bulky-label">back</span>
124  </button>
125  </div>
126  <div class="il-maincontrols-slate-content"></div>
127  </div>
128  </div>
129  </div>
130  </div>
131  </div>
132  </div>
133  </div>
134 </div>
135 EOT;
136  $this->assertEquals(
137  $this->brutallyTrimHTML($expected),
138  $this->brutallyTrimHTML($html)
139  );
140  }
back()
Definition: back.php:2
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:

◆ testWithAdditionalEntry()

NotificationSlateTest::testWithAdditionalEntry ( )

Definition at line 85 of file NotificationSlateTest.php.

References getIcon(), and getUIFactory().

86  {
87  $item = $this->getUIFactory()->item()->notification("title", $this->getIcon())
88  ->withDescription("description");
89  $notification_slate = $this->getUIFactory()->mainControls()->slate()->notification("title", [$item,$item]);
90  $this->assertEquals($notification_slate->getContents(), [$item,$item]);
91  $notification_slate = $notification_slate->withAdditionalEntry($item);
92  $this->assertEquals($notification_slate->getContents(), [$item,$item,$item]);
93  }
+ Here is the call graph for this function:

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