ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilStudyProgrammeProgressTreeTest Class Reference
+ Inheritance diagram for ilStudyProgrammeProgressTreeTest:
+ Collaboration diagram for ilStudyProgrammeProgressTreeTest:

Public Member Functions

 setUp ()
 
 testPGSTreeCreation ()
 
 testPGSTreeZipperNav ()
 
 testPGSTreeZipperManipulation ()
 
 testPGSTreeZipperManipulateAll ()
 

Protected Member Functions

 build (array $data, $node_id)
 

Protected Attributes

NodeMock $topnode
 

Detailed Description

Definition at line 41 of file ilStudyProgrammeProgressTreeTest.php.

Member Function Documentation

◆ build()

ilStudyProgrammeProgressTreeTest::build ( array  $data,
  $node_id 
)
protected

Definition at line 45 of file ilStudyProgrammeProgressTreeTest.php.

45 : Node
46 {
47 $subnodes = [];
48 foreach ($data[$node_id] as $subnode_id) {
49 $subnodes[] = $this->build($data, $subnode_id);
50 }
51 return (new NodeMock($node_id))->setSubnodes($subnodes);
52 }

References $data, and build().

Referenced by build(), and setUp().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setUp()

ilStudyProgrammeProgressTreeTest::setUp ( )

Definition at line 54 of file ilStudyProgrammeProgressTreeTest.php.

54 : void
55 {
56 $data = [
57 'top' => ['1.2', '1.1'],
58 '1.1' => [],
59 '1.2' => ['1.2.1', '1.2.2'],
60 '1.2.1' => ['1.2.1.1'],
61 '1.2.2' => [],
62 '1.2.1.1' => []
63 ];
64
65 $this->topnode = $this->build($data, 'top');
66 }

References $data, and build().

+ Here is the call graph for this function:

◆ testPGSTreeCreation()

ilStudyProgrammeProgressTreeTest::testPGSTreeCreation ( )

Definition at line 68 of file ilStudyProgrammeProgressTreeTest.php.

68 : void
69 {
70 $n = $this->topnode;
71 $this->assertEquals($n->getId(), 'top');
72 $this->assertInstanceOf(Node::class, $n->getSubnode('1.1'));
73
74 $this->assertEquals(
75 ['top', '1.2', '1.2.2'],
76 $n->getSubnode('1.2')->getSubnode('1.2.2')->getPath()
77 );
78
79 $this->assertEquals(
80 ['top', '1.2', '1.2.1'],
81 $n->findSubnodePath('1.2.1')
82 );
83 }

References $topnode.

◆ testPGSTreeZipperManipulateAll()

ilStudyProgrammeProgressTreeTest::testPGSTreeZipperManipulateAll ( )

Definition at line 128 of file ilStudyProgrammeProgressTreeTest.php.

128 : void
129 {
130 $zipper = new Zipper($this->topnode);
131 $modified = $zipper
132 ->modifyAll(fn($n) => $n->withScore(count($n->getSubnodes())))
133 ->getRoot();
134
135 $this->assertEquals(2, $modified->getScore());
136 $this->assertEquals(0, $modified->getSubnode('1.1')->getScore());
137 $this->assertEquals(2, $modified->getSubnode('1.2')->getScore());
138 $this->assertEquals(1, $modified->getSubnode('1.2')->getSubnode('1.2.1')->getScore());
139 $this->assertEquals(0, $modified->getSubnode('1.2')->getSubnode('1.2.1')->getSubnode('1.2.1.1')->getScore());
140 $this->assertEquals(0, $modified->getSubnode('1.2')->getSubnode('1.2.2')->getScore());
141 }

◆ testPGSTreeZipperManipulation()

ilStudyProgrammeProgressTreeTest::testPGSTreeZipperManipulation ( )

Definition at line 99 of file ilStudyProgrammeProgressTreeTest.php.

99 : void
100 {
101 $zipper = new Zipper($this->topnode);
102
103 $path = $this->topnode->findSubnodePath('1.2.1');
104 $modified = $zipper
105 ->toPath($path)->modifyFocus(fn($n) => $n->withScore(7))
106 ->toParent()->modifyFocus(fn($n) => $n->withScore(6))
107 ->getRoot();
108
109 $zipper = new Zipper($modified);
110 $other_path = $this->topnode->findSubnodePath('1.1');
111 $modified = $zipper
112 ->toPath($other_path)->modifyFocus(fn($n) => $n->withScore(8))
113 ->getRoot();
114 $this->assertEquals(7, $modified->getSubnode('1.2')->getSubnode('1.2.1')->getScore());
115 $this->assertEquals(6, $modified->getSubnode('1.2')->getScore());
116 $this->assertEquals(8, $modified->getSubnode('1.1')->getScore());
117
118 //should not change others...
119 $zipper = new Zipper($modified);
120 $modified = $zipper
121 ->toPath($path)->modifyFocus(fn($n) => $n->withScore(17))
122 ->getRoot();
123 $this->assertEquals(17, $modified->getSubnode('1.2')->getSubnode('1.2.1')->getScore());
124 $this->assertEquals(6, $modified->getSubnode('1.2')->getScore());
125 $this->assertEquals(8, $modified->getSubnode('1.1')->getScore());
126 }
$path
Definition: ltiservices.php:30

References $path.

◆ testPGSTreeZipperNav()

ilStudyProgrammeProgressTreeTest::testPGSTreeZipperNav ( )

Definition at line 85 of file ilStudyProgrammeProgressTreeTest.php.

85 : void
86 {
87 $zipper = new Zipper($this->topnode);
88 $this->assertInstanceOf(Zipper::class, $zipper->toChild('1.1'));
89 $this->assertInstanceOf(
90 Zipper::class,
91 $zipper->toPath($this->topnode->findSubnodePath('1.2.1'))->toParent()
92 );
93 $this->assertInstanceOf(
94 Node::class,
95 $zipper->toPath($this->topnode->findSubnodePath('1.2.1'))->getRoot()
96 );
97 }

Field Documentation

◆ $topnode

NodeMock ilStudyProgrammeProgressTreeTest::$topnode
protected

Definition at line 43 of file ilStudyProgrammeProgressTreeTest.php.

Referenced by testPGSTreeCreation().


The documentation for this class was generated from the following file: