ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
TreeTest.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
8use \ILIAS\UI\Implementation\Component\Tree\Tree;
9
13class TestingTree extends Tree
14{
15}
16
21{
22 public function testWrongConstruction()
23 {
24 $this->expectException(\ArgumentCountError::class);
25 $tree = new TestingTree();
26 }
27
28 public function testWrongTypeConstruction()
29 {
30 $this->expectException(\TypeError::class);
31 $tree = new TestingTree('something');
32 }
33
34 public function testConstruction()
35 {
36 $label = "label";
37 $recursion = new class implements \ILIAS\UI\Component\Tree\TreeRecursion {
38 public function getChildren($record, $environment = null) : array
39 {
40 return [];
41 }
42
43 public function build(
44 \ILIAS\UI\Component\Tree\Node\Factory $factory,
45 $record,
46 $environment = null
48 }
49 };
50
51 $tree = new TestingTree($label, $recursion);
52 $this->assertInstanceOf(
53 "ILIAS\\UI\\Component\\Tree\\Tree",
54 $tree
55 );
56
57 return $tree;
58 }
59
63 public function testGetLabel($tree)
64 {
65 $this->assertEquals(
66 "label",
67 $tree->getLabel()
68 );
69 }
70
74 public function testGetRecursion($tree)
75 {
76 $env = ['key1' => 'val1', 'key2' => 2];
77 $this->assertInstanceOf(
78 "ILIAS\\UI\\Component\\Tree\\TreeRecursion",
79 $tree->getRecursion()
80 );
81 }
82
86 public function testWithEnvironment($tree)
87 {
88 $env = ['key1' => 'val1', 'key2' => 2];
89 $this->assertEquals(
90 $env,
91 $tree->withEnvironment($env)->getEnvironment()
92 );
93 }
94
98 public function testWithData($tree)
99 {
100 $data = ['entry1', 'entry2'];
101 $this->assertEquals(
102 $data,
103 $tree->withData($data)->getData()
104 );
105 }
106
110 public function testWithHighlightOnNodeClick($tree)
111 {
112 $this->assertFalse(
113 $tree->getHighlightOnNodeClick()
114 );
115 $this->assertTrue(
116 $tree->withHighlightOnNodeClick(true)->getHighlightOnNodeClick()
117 );
118 }
119}
An exception for terminatinating execution or to throw for unit testing.
Provides common functionality for UI tests.
Definition: Base.php:225
Dummy-implementation for testing.
Definition: TreeTest.php:14
Tests for the (Base-)Tree.
Definition: TreeTest.php:21
testWithEnvironment($tree)
@depends testConstruction
Definition: TreeTest.php:86
testGetRecursion($tree)
@depends testConstruction
Definition: TreeTest.php:74
testConstruction()
Definition: TreeTest.php:34
testWrongTypeConstruction()
Definition: TreeTest.php:28
testWrongConstruction()
Definition: TreeTest.php:22
testWithData($tree)
@depends testConstruction
Definition: TreeTest.php:98
testGetLabel($tree)
@depends testConstruction
Definition: TreeTest.php:63
testWithHighlightOnNodeClick($tree)
@depends testConstruction
Definition: TreeTest.php:110
This describes a Tree Node.
Definition: Node.php:16
$factory
Definition: metadata.php:58
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.
$data
Definition: storeScorm.php:23