1 <?php declare(strict_types=1);
27 protected function setUp() : void
30 $this->prg = $this->getMockBuilder(ilObjStudyProgramme::class)
31 ->disableOriginalConstructor()
46 'fiftyfive' => [55, 34.38],
47 'hundred' => [100, 62.5],
48 'oneOone' => [101, 63.13],
49 'onesixty' => [160, 100]
58 $this->prg->method(
'hasLPChildren')
60 $this->prg->method(
'getAllPrgChildren')
63 list($minimum_percents, $current_percents)
64 = $this->gui->mockCalculatePercent($this->prg, $current_user_points);
66 $this->assertEquals(0, $minimum_percents);
67 $this->assertEquals(0, $current_percents);
75 $this->prg->method(
'hasLPChildren')
78 list($minimum_percents, $current_percents)
79 = $this->gui->mockCalculatePercent($this->prg, $current_user_points);
81 $this->assertEquals(100, $minimum_percents);
82 if ($current_user_points == 0) {
83 $this->assertEquals(0, $current_percents);
85 if ($current_user_points > 0) {
86 $this->assertEquals(100, $current_percents);
95 $node = $this->getMockBuilder(ilObjStudyProgramme::class)
96 ->disableOriginalConstructor()
97 ->setMethods([
'getPoints'])
100 $node1 = clone $node;
101 $node1->method(
'getPoints')->willReturn(100);
102 $node2 = clone $node;
103 $node2->method(
'getPoints')->willReturn(50);
104 $node3 = clone $node;
105 $node3->method(
'getPoints')->willReturn(5);
106 $node4 = clone $node;
107 $node4->method(
'getPoints')->willReturn(5);
109 $this->prg->method(
'hasLPChildren')
111 $this->prg->method(
'getAllPrgChildren')
112 ->willReturn([$node1, $node2, $node3, $node4]);
114 $this->prg->method(
'getPoints')->willReturn(60);
116 list($minimum_percents, $current_percents)
117 = $this->gui->mockCalculatePercent($this->prg, $current_user_points);
119 $this->assertEquals(37.5, $minimum_percents);
120 $this->assertEquals($expected, $current_percents);
testPercentageWithCoursesAtTopLevel(int $current_user_points)
userPointsDataProvider
calculatePercent(ilObjStudyProgramme $prg, int $current_points)
mockCalculatePercent($prg, int $current_points)
testPercentageWithPrograms(int $current_user_points, float $expected)
userPointsDataProvider
testPercentageWithoutChildren(int $current_user_points)
userPointsDataProvider
TestCase for SPRG-Section of dashboard.