ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
NodeTest.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
29
33class TestingNode extends Node
34{
35 public function __construct(string $label, ?URI $link = null)
36 {
38 }
39
43 public function withLink(URI $link): \ILIAS\UI\Component\Tree\Node\Node
44 {
45 return new TestingNode(
46 $this->label,
47 $link
48 );
49 }
50}
51
56{
57 public function testConstruction(): TestingNode
58 {
59 $node = new TestingNode("");
60 $this->assertInstanceOf("ILIAS\\UI\\Component\\Tree\\Node\\Node", $node);
61
62 return $node;
63 }
64
65 #[\PHPUnit\Framework\Attributes\Depends('testConstruction')]
66 public function testDefaults(TestingNode $node): void
67 {
68 $this->assertFalse($node->isExpanded());
69 $this->assertFalse($node->isHighlighted());
70 $this->assertEquals([], $node->getSubnodes());
71 }
72
73 #[\PHPUnit\Framework\Attributes\Depends('testConstruction')]
74 public function testWithExpanded(TestingNode $node): void
75 {
76 $this->assertTrue(
77 $node->withExpanded(true)->isExpanded()
78 );
79 }
80
81 #[\PHPUnit\Framework\Attributes\Depends('testConstruction')]
82 public function testWithHighlighted(TestingNode $node): void
83 {
84 $this->assertTrue(
85 $node->withHighlighted(true)->isHighlighted()
86 );
87 }
88
89 #[\PHPUnit\Framework\Attributes\Depends('testConstruction')]
90 public function testWithOnClick(TestingNode $node): Clickable
91 {
92 $sig_gen = new I\SignalGenerator();
93 $sig = $sig_gen->create();
94
95 $node = $node->withOnClick($sig);
96 $check = $node->getTriggeredSignals()[0]->getSignal();
97 $this->assertEquals($sig, $check);
98 return $node;
99 }
100
101 #[\PHPUnit\Framework\Attributes\Depends('testWithOnClick')]
102 public function testWithAppendOnClick(Clickable $node): void
103 {
104 $sig_gen = new I\SignalGenerator();
105 $sig = $sig_gen->create();
106
107 $node = $node->appendOnClick($sig);
108 $check = $node->getTriggeredSignals()[1]->getSignal();
109 $this->assertEquals($sig, $check);
110 }
111
112 #[\PHPUnit\Framework\Attributes\Depends('testWithOnClick')]
113 public function testWithURI(Clickable $node): void
114 {
115 $uri = new URI('http://google.de:8080');
116
117 $node = $node->withLink($uri);
118
119 $stringTransformation = new StringTransformation();
120
121 $this->assertEquals('http://google.de:8080', $stringTransformation->transform($node->getLink()));
122 }
123}
$check
Definition: buildRTE.php:81
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:35
withHighlighted(bool $highlighted)
@inhertidoc
Definition: Node.php:101
withOnClick(Signal $signal)
@inhertidoc
Definition: Node.php:119
Provides common functionality for UI tests.
Definition: Base.php:337
Tests for the (Base-)Node.
Definition: NodeTest.php:56
testWithURI(Clickable $node)
Definition: NodeTest.php:113
testConstruction()
Definition: NodeTest.php:57
testWithExpanded(TestingNode $node)
Definition: NodeTest.php:74
testDefaults(TestingNode $node)
Definition: NodeTest.php:66
testWithOnClick(TestingNode $node)
Definition: NodeTest.php:90
testWithHighlighted(TestingNode $node)
Definition: NodeTest.php:82
testWithAppendOnClick(Clickable $node)
Definition: NodeTest.php:102
Dummy-implementation for testing.
Definition: NodeTest.php:34
__construct(string $label, ?URI $link=null)
Definition: NodeTest.php:35
withLink(URI $link)
Create a new node object with an URI that will be added to the UI.
Definition: NodeTest.php:43
appendOnClick(Signal $signal)
Get a component like this, triggering a signal of another component on click.
This describes a Tree Node.
Definition: Node.php:31
getTriggeredSignals()
Get all triggered signals of this component.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.