ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
SlateTest.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2018 Nils Haagen <nils.haagen@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
5require_once("libs/composer/vendor/autoload.php");
6require_once(__DIR__ . "/../../../Base.php");
7
8use \ILIAS\UI\Component as C;
9use \ILIAS\UI\Implementation\Component as I;
10use \ILIAS\UI\Implementation\Component\MainControls\Slate\Slate;
11use \ILIAS\UI\Implementation\Component\MainControls\Slate\Combined;
12use \ILIAS\UI\Component\Signal;
13
17class TestGenericSlate extends Slate implements C\MainControls\Slate\Slate
18{
19 public function getContents() : array
20 {
21 return [];
22 }
23 public function withMappedSubNodes(callable $f)
24 {
25 return $this;
26 }
27}
28
33{
34 public function setUp() : void
35 {
36 $this->sig_gen = new I\SignalGenerator();
37 $this->button_factory = new I\Button\Factory($this->sig_gen);
38 $this->icon_factory = new I\Symbol\Icon\Factory();
39 }
40
41 public function testConstruction()
42 {
43 $name = 'name';
44 $icon = $this->icon_factory->custom('', '');
45 $slate = new TestGenericSlate($this->sig_gen, $name, $icon);
46
47 $this->assertInstanceOf(
48 "ILIAS\\UI\\Component\\MainControls\\Slate\\Slate",
49 $slate
50 );
51 $this->assertEquals($name, $slate->getName());
52 $this->assertEquals($icon, $slate->getSymbol());
53 $this->assertFalse($slate->getEngaged());
54 return $slate;
55 }
56
60 public function testWithEngaged(Slate $slate)
61 {
62 $slate = $slate->withEngaged(true);
63 $this->assertTrue($slate->getEngaged());
64 }
65
69 public function testWithAriaRole(Slate $slate)
70 {
71 try {
72 $slate = $slate->withAriaRole(Slate::MENU);
73 $this->assertEquals("menu", $slate->getAriaRole());
74 } catch (\InvalidArgumentException $e) {
75 $this->assertFalse("This should not happen");
76 }
77 }
78
82 public function testWithAriaRoleIncorrect(Slate $slate)
83 {
84 try {
85 $slate = $slate->withAriaRole("loremipsum");
86 $this->assertFalse("This should not happen");
87 } catch (\InvalidArgumentException $e) {
88 $this->assertTrue(true);
89 }
90 }
91
95 public function testSignals(Slate $slate)
96 {
97 $signals = [
98 $slate->getToggleSignal(),
99 $slate->getEngageSignal(),
100 $slate->getReplaceSignal()
101 ];
102 foreach ($signals as $signal) {
103 $this->assertInstanceOf(Signal::class, $signal);
104 }
105 return $signals;
106 }
107
111 public function testDifferentSignals(array $signals)
112 {
113 $this->assertEquals(
114 $signals,
115 array_unique($signals)
116 );
117 }
118}
An exception for terminatinating execution or to throw for unit testing.
getAriaRole()
Get the ARIA role on the slate.
Definition: Slate.php:229
withAriaRole(string $aria_role)
Get a slate like this, but with an additional ARIA role.
Definition: Slate.php:211
Provides common functionality for UI tests.
Definition: Base.php:225
Tests for the Slate.
Definition: SlateTest.php:33
testWithEngaged(Slate $slate)
@depends testConstruction
Definition: SlateTest.php:60
testSignals(Slate $slate)
@depends testConstruction
Definition: SlateTest.php:95
testConstruction()
Definition: SlateTest.php:41
testWithAriaRole(Slate $slate)
@depends testConstruction
Definition: SlateTest.php:69
testDifferentSignals(array $signals)
@depends testSignals
Definition: SlateTest.php:111
testWithAriaRoleIncorrect(Slate $slate)
@depends testConstruction
Definition: SlateTest.php:82
A generic Slate.
Definition: SlateTest.php:18
withMappedSubNodes(callable $f)
Definition: SlateTest.php:23
if($format !==null) $name
Definition: metadata.php:230