ILIAS  release_7 Revision v7.30-3-g800a261c036
NodeTest.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2019 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
9use \ILIAS\UI\Implementation\Component\Tree\Node\Node;
10use \ILIAS\UI\Implementation\Component as I;
11
15class TestingNode extends Node
16{
17 public function __construct(string $label, URI $link = null)
18 {
20 }
21
27 public function withLink(URI $link) : \ILIAS\UI\Component\Tree\Node\Node
28 {
29 return new TestingNode(
30 $this->label,
31 $link
32 );
33 }
34}
35
40{
41 public function testConstruction()
42 {
43 $node = new TestingNode("");
44 $this->assertInstanceOf(
45 "ILIAS\\UI\\Component\\Tree\\Node\\Node",
46 $node
47 );
48
49 return $node;
50 }
51
55 public function testDefaults($node)
56 {
57 $this->assertFalse($node->isExpanded());
58 $this->assertFalse($node->isHighlighted());
59 $this->assertEquals([], $node->getSubnodes());
60 }
61
65 public function testWithExpanded($node)
66 {
67 $this->assertTrue(
68 $node->withExpanded(true)->isExpanded()
69 );
70 }
71
75 public function testWithHighlighted($node)
76 {
77 $this->assertTrue(
78 $node->withHighlighted(true)->isHighlighted()
79 );
80 }
81
85 public function testWithOnClick($node)
86 {
87 $sig_gen = new I\SignalGenerator();
88 $sig = $sig_gen->create();
89
90 $node = $node->withOnClick($sig);
91 $check = $node->getTriggeredSignals()[0]->getSignal();
92 $this->assertEquals($sig, $check);
93 return $node;
94 }
95
99 public function testWithAppendOnClick($node)
100 {
101 $sig_gen = new I\SignalGenerator();
102 $sig = $sig_gen->create();
103
104 $node = $node->appendOnClick($sig);
105 $check = $node->getTriggeredSignals()[1]->getSignal();
106 $this->assertEquals($sig, $check);
107 }
108
113 public function testWithURI($node)
114 {
115 $uri = new URI('http://google.de:8080');
116
117 $node = $node->withLink($uri);
118
119 $stringTransformation = new \ILIAS\Refinery\URI\StringTransformation();
120
121 $this->assertEquals('http://google.de:8080', $stringTransformation->transform($node->getLink()));
122 }
123}
An exception for terminatinating execution or to throw for unit testing.
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:18
Provides common functionality for UI tests.
Definition: Base.php:263
Tests for the (Base-)Node.
Definition: NodeTest.php:40
testConstruction()
Definition: NodeTest.php:41
testWithAppendOnClick($node)
@depends testWithOnClick
Definition: NodeTest.php:99
testWithExpanded($node)
@depends testConstruction
Definition: NodeTest.php:65
testWithOnClick($node)
@depends testConstruction
Definition: NodeTest.php:85
testWithURI($node)
Definition: NodeTest.php:113
testDefaults($node)
@depends testConstruction
Definition: NodeTest.php:55
testWithHighlighted($node)
@depends testConstruction
Definition: NodeTest.php:75
Dummy-implementation for testing.
Definition: NodeTest.php:16
__construct(string $label, URI $link=null)
Definition: NodeTest.php:17
withLink(URI $link)
Create a new node object with an URI that will be added to the UI.
Definition: NodeTest.php:27
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.