ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ToastTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 require_once("vendor/composer/vendor/autoload.php");
22 require_once(__DIR__ . "/../../Base.php");
23 
27 
29 {
30  public function getToastFactory(): \ILIAS\UI\Implementation\Component\Toast\Factory
31  {
33  }
34 
35  public function getIconFactory(): \ILIAS\UI\Implementation\Component\Symbol\Icon\Factory
36  {
38  }
39 
40  public function getLinkFactory(): \ILIAS\UI\Implementation\Component\Link\Factory
41  {
43  }
44 
45  public function testImplementsFactoryInterface(): void
46  {
47  $f = $this->getToastFactory();
48 
49  $this->assertInstanceOf("ILIAS\\UI\\Component\\Toast\\Factory", $f);
50 
51  $this->assertInstanceOf("ILIAS\\UI\\Component\\Toast\\Toast", $f->standard('', $this->getIconFactory()->standard('', '')));
52  $this->assertInstanceOf("ILIAS\\UI\\Component\\Toast\\Container", $f->container());
53  }
54 
58  public function testToast(string $title, string $description, string $action): void
59  {
60  $toast = $this->getToastFactory()->standard($title, $this->getIconFactory()->standard('', ''))
61  ->withDescription($description)
62  ->withAction($action)
63  ->withAdditionalLink($this->getLinkFactory()->standard('', ''));
64 
65  $this->assertNotNull($toast);
66  $this->assertEquals($title, $toast->getTitle());
67  $this->assertEquals($description, $toast->getDescription());
68  $this->assertEquals($action, $toast->getAction());
69  $this->assertCount(1, $toast->getLinks());
70  $this->assertInstanceOf(Link::class, $toast->getLinks()[0]);
71  $this->assertCount(0, $toast->withoutLinks()->getLinks());
72  $this->assertInstanceOf(Icon::class, $toast->getIcon());
73  }
74 
78  public function testToastContainer(string $title, string $description): void
79  {
80  $container = $this->getToastFactory()->container()->withAdditionalToast(
81  $this->getToastFactory()->standard('', $this->getIconFactory()->standard('', ''))
82  );
83 
84  $this->assertNotNull($container);
85  $this->assertCount(1, $container->getToasts());
86  $this->assertInstanceOf(Toast::class, $container->getToasts()[0]);
87  $this->assertCount(0, $container->withoutToasts()->getToasts());
88  }
89 
90  public static function getToastProvider(): array
91  {
92  return [
93  ['title', 'description', 'test.php'],
94  ['', '', ''],
95  ['"/><script>alert("hack")</script>', '"/><script>alert("hack")</script>', 'test.php']
96  ];
97  }
98 }
standard()
description: > This is an example, of how the Notification Slate is generated by assigning Notificat...
Definition: standard.php:38
Interface Observer Contains several chained tasks and infos about them.
static getToastProvider()
Definition: ToastTest.php:90
testImplementsFactoryInterface()
Definition: ToastTest.php:45
$container
Definition: wac.php:36
getLinkFactory()
Definition: ToastTest.php:40
testToast(string $title, string $description, string $action)
getToastProvider
Definition: ToastTest.php:58
testToastContainer(string $title, string $description)
getToastProvider
Definition: ToastTest.php:78
getIconFactory()
Definition: ToastTest.php:35
getToastFactory()
Definition: ToastTest.php:30