ILIAS  release_8 Revision v8.24
SlateTest.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
21require_once("libs/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{
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
79 public function testWithEngaged(Slate $slate): void
80 {
81 $slate = $slate->withEngaged(true);
82 $this->assertTrue($slate->getEngaged());
83 }
84
88 public function testWithAriaRole(Slate $slate): void
89 {
90 try {
91 $slate = $slate->withAriaRole(Slate::MENU);
92 $this->assertEquals("menu", $slate->getAriaRole());
93 } catch (InvalidArgumentException $e) {
94 $this->assertFalse("This should not happen");
95 }
96 }
97
101 public function testWithAriaRoleIncorrect(Slate $slate): void
102 {
103 try {
104 $slate->withAriaRole("loremipsum");
105 $this->assertFalse("This should not happen");
106 } catch (InvalidArgumentException $e) {
107 $this->assertTrue(true);
108 }
109 }
110
114 public function testSignals(Slate $slate): array
115 {
116 $signals = [
117 $slate->getToggleSignal(),
118 $slate->getEngageSignal(),
119 $slate->getReplaceSignal()
120 ];
121 foreach ($signals as $signal) {
122 $this->assertInstanceOf(Signal::class, $signal);
123 }
124 return $signals;
125 }
126
130 public function testDifferentSignals(array $signals): void
131 {
132 $this->assertEquals(
133 $signals,
134 array_unique($signals)
135 );
136 }
137}
getAriaRole()
Get the ARIA role on the slate.
Definition: Slate.php:199
withAriaRole(string $aria_role)
Get a slate like this, but with an additional ARIA role.
Definition: Slate.php:183
Provides common functionality for UI tests.
Definition: Base.php:299
Tests for the Slate.
Definition: SlateTest.php:48
testWithEngaged(Slate $slate)
@depends testConstruction
Definition: SlateTest.php:79
testSignals(Slate $slate)
@depends testConstruction
Definition: SlateTest.php:114
testConstruction()
Definition: SlateTest.php:60
testWithAriaRole(Slate $slate)
@depends testConstruction
Definition: SlateTest.php:88
I Symbol Icon Factory $icon_factory
Definition: SlateTest.php:51
testDifferentSignals(array $signals)
@depends testSignals
Definition: SlateTest.php:130
I SignalGenerator $sig_gen
Definition: SlateTest.php:49
I Button Factory $button_factory
Definition: SlateTest.php:50
testWithAriaRoleIncorrect(Slate $slate)
@depends testConstruction
Definition: SlateTest.php:101
A generic Slate.
Definition: SlateTest.php:33
withMappedSubNodes(callable $f)
Definition: SlateTest.php:38
if($format !==null) $name
Definition: metadata.php:247
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...