ILIAS  release_8 Revision v8.24
NodeTest.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
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
68 public function testDefaults(TestingNode $node): void
69 {
70 $this->assertFalse($node->isExpanded());
71 $this->assertFalse($node->isHighlighted());
72 $this->assertEquals([], $node->getSubnodes());
73 }
74
78 public function testWithExpanded(TestingNode $node): void
79 {
80 $this->assertTrue(
81 $node->withExpanded(true)->isExpanded()
82 );
83 }
84
88 public function testWithHighlighted(TestingNode $node): void
89 {
90 $this->assertTrue(
91 $node->withHighlighted(true)->isHighlighted()
92 );
93 }
94
98 public function testWithOnClick(TestingNode $node): Clickable
99 {
100 $sig_gen = new I\SignalGenerator();
101 $sig = $sig_gen->create();
102
103 $node = $node->withOnClick($sig);
104 $check = $node->getTriggeredSignals()[0]->getSignal();
105 $this->assertEquals($sig, $check);
106 return $node;
107 }
108
112 public function testWithAppendOnClick(Clickable $node): void
113 {
114 $sig_gen = new I\SignalGenerator();
115 $sig = $sig_gen->create();
116
117 $node = $node->appendOnClick($sig);
118 $check = $node->getTriggeredSignals()[1]->getSignal();
119 $this->assertEquals($sig, $check);
120 }
121
125 public function testWithURI(Clickable $node): void
126 {
127 $uri = new URI('http://google.de:8080');
128
129 $node = $node->withLink($uri);
130
131 $stringTransformation = new StringTransformation();
132
133 $this->assertEquals('http://google.de:8080', $stringTransformation->transform($node->getLink()));
134 }
135}
$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:299
Tests for the (Base-)Node.
Definition: NodeTest.php:56
testWithURI(Clickable $node)
@depends testWithOnClick
Definition: NodeTest.php:125
testConstruction()
Definition: NodeTest.php:57
testWithExpanded(TestingNode $node)
@depends testConstruction
Definition: NodeTest.php:78
testDefaults(TestingNode $node)
@depends testConstruction
Definition: NodeTest.php:68
testWithOnClick(TestingNode $node)
@depends testConstruction
Definition: NodeTest.php:98
testWithHighlighted(TestingNode $node)
@depends testConstruction
Definition: NodeTest.php:88
testWithAppendOnClick(Clickable $node)
@depends testWithOnClick
Definition: NodeTest.php:112
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
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...
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.