ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
NodeTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 require_once("vendor/composer/vendor/autoload.php");
22 require_once(__DIR__ . "../../../../Base.php");
23 
24 use ILIAS\Data\URI;
29 
33 class TestingNode extends Node
34 {
35  public function __construct(string $label, ?URI $link = null)
36  {
37  parent::__construct($label, $link);
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 }
Tests for the (Base-)Node.
Definition: NodeTest.php:55
Interface Observer Contains several chained tasks and infos about them.
testWithHighlighted(TestingNode $node)
Definition: NodeTest.php:82
testWithURI(Clickable $node)
Definition: NodeTest.php:113
testWithAppendOnClick(Clickable $node)
Definition: NodeTest.php:102
testDefaults(TestingNode $node)
Definition: NodeTest.php:66
withLink(URI $link)
Create a new node object with an URI that will be added to the UI.
Definition: NodeTest.php:43
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
Dummy-implementation for testing.
Definition: NodeTest.php:33
testWithExpanded(TestingNode $node)
Definition: NodeTest.php:74
__construct(Container $dic, ilPlugin $plugin)
getTriggeredSignals()
Get all triggered signals of this component.
testWithOnClick(TestingNode $node)
Definition: NodeTest.php:90
testConstruction()
Definition: NodeTest.php:57
$check
Definition: buildRTE.php:81
appendOnClick(Signal $signal)
Get a component like this, triggering a signal of another component on click.
__construct(string $label, ?URI $link=null)
Definition: NodeTest.php:35