ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
SlateTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21require_once("vendor/composer/vendor/autoload.php");
22require_once(__DIR__ . "/../../../Base.php");
23
28
32class TestGenericSlate extends Slate implements C\MainControls\Slate\Slate
33{
34 public function getContents(): array
35 {
36 return [];
37 }
38 public function withMappedSubNodes(callable $f): C\MainControls\Slate\Slate
39 {
40 return $this;
41 }
42}
43
48{
49 protected I\SignalGenerator $sig_gen;
50 protected I\Button\Factory $button_factory;
51 protected I\Symbol\Icon\Factory $icon_factory;
52
53 public function setUp(): void
54 {
55 $this->sig_gen = new I\SignalGenerator();
56 $this->button_factory = new I\Button\Factory();
57 $this->icon_factory = new I\Symbol\Icon\Factory();
58 }
59
61 {
62 $name = 'name';
63 $icon = $this->icon_factory->custom('', '');
64 $slate = new TestGenericSlate($this->sig_gen, $name, $icon);
65
66 $this->assertInstanceOf(
67 "ILIAS\\UI\\Component\\MainControls\\Slate\\Slate",
68 $slate
69 );
70 $this->assertEquals($name, $slate->getName());
71 $this->assertEquals($icon, $slate->getSymbol());
72 $this->assertFalse($slate->getEngaged());
73 return $slate;
74 }
75
76 #[\PHPUnit\Framework\Attributes\Depends('testConstruction')]
77 public function testWithEngaged(Slate $slate): void
78 {
79 $slate = $slate->withEngaged(true);
80 $this->assertTrue($slate->getEngaged());
81 }
82
83 #[\PHPUnit\Framework\Attributes\Depends('testConstruction')]
84 public function testWithAriaRole(Slate $slate): void
85 {
86 try {
87 $slate = $slate->withAriaRole(Slate::MENU);
88 $this->assertEquals("menu", $slate->getAriaRole());
89 } catch (InvalidArgumentException $e) {
90 $this->assertFalse("This should not happen");
91 }
92 }
93
94 #[\PHPUnit\Framework\Attributes\Depends('testConstruction')]
95 public function testWithAriaRoleIncorrect(Slate $slate): void
96 {
97 try {
98 $slate->withAriaRole("loremipsum");
99 $this->assertFalse("This should not happen");
100 } catch (InvalidArgumentException $e) {
101 $this->assertTrue(true);
102 }
103 }
104
105 #[\PHPUnit\Framework\Attributes\Depends('testConstruction')]
106 public function testSignals(Slate $slate): array
107 {
108 $signals = [
109 $slate->getToggleSignal(),
110 $slate->getEngageSignal(),
111 $slate->getReplaceSignal()
112 ];
113 foreach ($signals as $signal) {
114 $this->assertInstanceOf(Signal::class, $signal);
115 }
116 return $signals;
117 }
118
119 #[\PHPUnit\Framework\Attributes\Depends('testSignals')]
120 public function testDifferentSignals(array $signals): void
121 {
122 $this->assertEquals(
123 $signals,
124 array_unique($signals)
125 );
126 }
127}
getAriaRole()
Get the ARIA role on the slate.
Definition: Slate.php:201
withAriaRole(string $aria_role)
Get a slate like this, but with an additional ARIA role.
Definition: Slate.php:185
Provides common functionality for UI tests.
Definition: Base.php:337
Tests for the Slate.
Definition: SlateTest.php:48
testWithEngaged(Slate $slate)
Definition: SlateTest.php:77
testSignals(Slate $slate)
Definition: SlateTest.php:106
testConstruction()
Definition: SlateTest.php:60
testWithAriaRole(Slate $slate)
Definition: SlateTest.php:84
I Symbol Icon Factory $icon_factory
Definition: SlateTest.php:51
testDifferentSignals(array $signals)
Definition: SlateTest.php:120
I SignalGenerator $sig_gen
Definition: SlateTest.php:49
I Button Factory $button_factory
Definition: SlateTest.php:50
testWithAriaRoleIncorrect(Slate $slate)
Definition: SlateTest.php:95
A generic Slate.
Definition: SlateTest.php:33
withMappedSubNodes(callable $f)
Definition: SlateTest.php:38