ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilStudyProgrammeDashGUITest Class Reference

TestCase for SPRG-Section of dashboard. More...

+ Inheritance diagram for ilStudyProgrammeDashGUITest:
+ Collaboration diagram for ilStudyProgrammeDashGUITest:

Public Member Functions

 userPointsDataProvider ()
 
 testPercentageWithoutChildren (int $current_user_points)
 userPointsDataProvider More...
 
 testPercentageWithCoursesAtTopLevel (int $current_user_points)
 userPointsDataProvider More...
 
 testPercentageWithPrograms (int $current_user_points, float $expected)
 userPointsDataProvider More...
 

Protected Member Functions

 setUp ()
 

Detailed Description

TestCase for SPRG-Section of dashboard.

Definition at line 25 of file ilStudyProgrammeDashGUITest.php.

Member Function Documentation

◆ setUp()

ilStudyProgrammeDashGUITest::setUp ( )
protected

Definition at line 27 of file ilStudyProgrammeDashGUITest.php.

27  : void
28  {
29  $this->gui = new mockSPRGDashGUI();
30  $this->prg = $this->getMockBuilder(ilObjStudyProgramme::class)
31  ->disableOriginalConstructor()
32  ->setMethods([
33  'hasLPChildren',
34  'getAllPrgChildren',
35  'getPoints'
36  ])
37  ->getMock();
38  }
Encapsulation of GUI.

◆ testPercentageWithCoursesAtTopLevel()

ilStudyProgrammeDashGUITest::testPercentageWithCoursesAtTopLevel ( int  $current_user_points)

userPointsDataProvider

Definition at line 73 of file ilStudyProgrammeDashGUITest.php.

74  {
75  $this->prg->method('hasLPChildren')
76  ->willReturn(true);
77 
78  list($minimum_percents, $current_percents)
79  = $this->gui->mockCalculatePercent($this->prg, $current_user_points);
80 
81  $this->assertEquals(100, $minimum_percents);
82  if ($current_user_points == 0) {
83  $this->assertEquals(0, $current_percents);
84  }
85  if ($current_user_points > 0) {
86  $this->assertEquals(100, $current_percents);
87  }
88  }

◆ testPercentageWithoutChildren()

ilStudyProgrammeDashGUITest::testPercentageWithoutChildren ( int  $current_user_points)

userPointsDataProvider

Definition at line 56 of file ilStudyProgrammeDashGUITest.php.

57  {
58  $this->prg->method('hasLPChildren')
59  ->willReturn(false);
60  $this->prg->method('getAllPrgChildren')
61  ->willReturn([]);
62 
63  list($minimum_percents, $current_percents)
64  = $this->gui->mockCalculatePercent($this->prg, $current_user_points);
65 
66  $this->assertEquals(0, $minimum_percents);
67  $this->assertEquals(0, $current_percents);
68  }

◆ testPercentageWithPrograms()

ilStudyProgrammeDashGUITest::testPercentageWithPrograms ( int  $current_user_points,
float  $expected 
)

userPointsDataProvider

Definition at line 93 of file ilStudyProgrammeDashGUITest.php.

94  {
95  $node = $this->getMockBuilder(ilObjStudyProgramme::class)
96  ->disableOriginalConstructor()
97  ->setMethods(['getPoints'])
98  ->getMock();
99 
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);
108 
109  $this->prg->method('hasLPChildren')
110  ->willReturn(false);
111  $this->prg->method('getAllPrgChildren')
112  ->willReturn([$node1, $node2, $node3, $node4]);
113 
114  $this->prg->method('getPoints')->willReturn(60);
115 
116  list($minimum_percents, $current_percents)
117  = $this->gui->mockCalculatePercent($this->prg, $current_user_points);
118 
119  $this->assertEquals(37.5, $minimum_percents); //37.5 = (160 max points / 60 root-prg points) * 100
120  $this->assertEquals($expected, $current_percents);
121  }

◆ userPointsDataProvider()

ilStudyProgrammeDashGUITest::userPointsDataProvider ( )

Definition at line 40 of file ilStudyProgrammeDashGUITest.php.

41  {
42  return [
43  'zero' => [0, 0],
44  'one' => [1, 0.63],
45  'ten' => [10, 6.25],
46  'fiftyfive' => [55, 34.38],
47  'hundred' => [100, 62.5],
48  'oneOone' => [101, 63.13],
49  'onesixty' => [160, 100]
50  ];
51  }

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