ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
StandardToastTest.php
Go to the documentation of this file.
1 <?php
18 declare(strict_types=1);
19 
22 
23 require_once(__DIR__ . "/BaseToastSetUp.php");
24 
26 {
27  public function testStandardToast()
28  {
29  $id = $this->createMock(\ILIAS\GlobalScreen\Identification\IdentificationInterface::class);
30 
31  $standard_toast = $this->factory->standard(
32  $id,
33  'Toast Title'
34  );
35 
36  $this->assertInstanceOf(StandardToastItem::class, $standard_toast);
37  $this->assertEquals('Toast Title', $standard_toast->getTitle());
38  $this->assertEquals([], $standard_toast->getAllToastActions());
39  $this->assertCount(0, $standard_toast->getAllToastActions());
40  $this->assertCount(0, $standard_toast->getAdditionalToastActions());
41 
42  $handle = function () {
43  return true;
44  };
45 
46  $standard_toast = $standard_toast->withShownCallable($handle);
47  $this->assertCount(1, $standard_toast->getAllToastActions());
48  $this->assertCount(0, $standard_toast->getAdditionalToastActions());
49 
50  $standard_toast = $standard_toast->withClosedCallable($handle);
51  $this->assertCount(2, $standard_toast->getAllToastActions());
52  $this->assertCount(0, $standard_toast->getAdditionalToastActions());
53 
54  $standard_toast = $standard_toast->withVanishedCallable($handle);
55  $this->assertCount(3, $standard_toast->getAllToastActions());
56  $this->assertCount(0, $standard_toast->getAdditionalToastActions());
57 
58  $standard_toast = $standard_toast->withAdditionToastAction($this->factory->action('one', 'One', $handle));
59  $this->assertCount(4, $standard_toast->getAllToastActions());
60  $this->assertCount(1, $standard_toast->getAdditionalToastActions());
61 
62  $standard_toast = $standard_toast->withAdditionToastAction($this->factory->action('two', 'Two', $handle));
63  $this->assertCount(5, $standard_toast->getAllToastActions());
64  $this->assertCount(2, $standard_toast->getAdditionalToastActions());
65 
66  // double add
67  $this->expectException(\InvalidArgumentException::class);
68  $standard_toast = $standard_toast->withAdditionToastAction($this->factory->action('two', 'Two', $handle));
69  }
70 
71  public function reservedActionsProvider(): array
72  {
73  $action = function () {
74  return true;
75  };
76 
77  return [
78  [new ToastAction('shown', 'shown', $action)],
79  [new ToastAction('closed', 'closed', $action)],
80  [new ToastAction('vanished', 'vanished', $action)],
81  ];
82  }
83 
87  public function testReservedActions(ToastAction $action): void
88  {
89  $id = $this->createMock(\ILIAS\GlobalScreen\Identification\IdentificationInterface::class);
90 
91  $standard_toast = $this->factory->standard(
92  $id,
93  'Toast Title'
94  );
95 
96  $this->expectException(\InvalidArgumentException::class);
97  $standard_toast = $standard_toast->withAdditionToastAction($action);
98  }
99 }
Class ChatMainBarProvider .
testReservedActions(ToastAction $action)
reservedActionsProvider
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23