ILIAS  release_8 Revision v8.24
TreeTest.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
28
32class TestingTree extends Tree
33{
34}
35
40{
41 public function testWrongConstruction(): void
42 {
43 $this->expectException(ArgumentCountError::class);
44 $tree = new TestingTree();
45 }
46
47 public function testWrongTypeConstruction(): void
48 {
49 $this->expectException(TypeError::class);
50 $tree = new TestingTree('something');
51 }
52
53 public function testConstruction(): TestingTree
54 {
55 $label = "label";
56 $recursion = new class () implements TreeRecursion {
57 public function getChildren($record, $environment = null): array
58 {
59 return [];
60 }
61
62 public function build(
64 $record,
65 $environment = null
66 ): Node {
67 }
68 };
69
70 $tree = new TestingTree($label, $recursion);
71 $this->assertInstanceOf("ILIAS\\UI\\Component\\Tree\\Tree", $tree);
72
73 return $tree;
74 }
75
79 public function testGetLabel(TestingTree $tree): void
80 {
81 $this->assertEquals("label", $tree->getLabel());
82 }
83
87 public function testGetRecursion(TestingTree $tree): void
88 {
89 $this->assertInstanceOf("ILIAS\\UI\\Component\\Tree\\TreeRecursion", $tree->getRecursion());
90 }
91
95 public function testWithEnvironment(TestingTree $tree): void
96 {
97 $env = ['key1' => 'val1', 'key2' => 2];
98 $this->assertEquals($env, $tree->withEnvironment($env)->getEnvironment());
99 }
100
104 public function testWithData(TestingTree $tree): void
105 {
106 $data = ['entry1', 'entry2'];
107 $this->assertEquals($data, $tree->withData($data)->getData());
108 }
109
113 public function testWithHighlightOnNodeClick(TestingTree $tree): void
114 {
115 $this->assertFalse($tree->getHighlightOnNodeClick());
116 $this->assertTrue($tree->withHighlightOnNodeClick(true)->getHighlightOnNodeClick());
117 }
118
122 public function testWithIsSubTree(TestingTree $tree): void
123 {
124 $this->assertFalse($tree->isSubTree());
125 $this->assertTrue($tree->withIsSubTree(true)->isSubTree());
126 }
127}
withIsSubTree(bool $is_sub)
Set this tree to be a part of a tree.Needed if parts are loaded async.
Definition: Tree.php:136
withHighlightOnNodeClick(bool $highlight_nodes_on_click)
Should a clicked node be highlighted?
Definition: Tree.php:110
withEnvironment($environment)
Configure the Tree with additional information that will be relayed to TreeRecursion.
Definition: Tree.php:66
getHighlightOnNodeClick()
Is the tree configured to highlight a clicked node?
Definition: Tree.php:120
isSubTree()
Is this only a part of a tree? Needed if parts are loaded async.
Definition: Tree.php:128
withData($data)
Apply data to the Tree.
Definition: Tree.php:76
getRecursion()
Get the mapping-class.
Definition: Tree.php:102
Provides common functionality for UI tests.
Definition: Base.php:299
Dummy-implementation for testing.
Definition: TreeTest.php:33
Tests for the (Base-)Tree.
Definition: TreeTest.php:40
testWithHighlightOnNodeClick(TestingTree $tree)
@depends testConstruction
Definition: TreeTest.php:113
testWithData(TestingTree $tree)
@depends testConstruction
Definition: TreeTest.php:104
testConstruction()
Definition: TreeTest.php:53
testWrongTypeConstruction()
Definition: TreeTest.php:47
testGetLabel(TestingTree $tree)
@depends testConstruction
Definition: TreeTest.php:79
testWrongConstruction()
Definition: TreeTest.php:41
testGetRecursion(TestingTree $tree)
@depends testConstruction
Definition: TreeTest.php:87
testWithEnvironment(TestingTree $tree)
@depends testConstruction
Definition: TreeTest.php:95
testWithIsSubTree(TestingTree $tree)
@depends testConstruction
Definition: TreeTest.php:122
This describes a Tree Node.
Definition: Node.php:31
Interface for mapping data-structures to the Tree.
This describes a Tree Control.
Definition: Tree.php:29
$factory
Definition: metadata.php:75