23 : void
24 {
25 $defaultPlaceholderValues = $this->getMockBuilder(ilDefaultPlaceholderValues::class)
26 ->disableOriginalConstructor()
27 ->getMock();
28
29 $language = $this->getMockBuilder(ilLanguage::class)
30 ->disableOriginalConstructor()
31 ->getMock();
32
33 $language->method('txt')
34 ->willReturnCallback(function ($variableValue) {
35 if ($variableValue === 'lang_sep_decimal') {
36 return ',';
37 } elseif ($variableValue === 'lang_sep_thousand') {
38 return '.';
39 }
40
41 return 'Some Translation: ' . $variableValue;
42 });
43
44 $language->expects($this->once())
45 ->method('loadLanguageModule');
46
47 $dateHelper = $this->getMockBuilder(ilCertificateDateHelper::class)
48 ->getMock();
49
50 $objectMock = $this->getMockBuilder(ilObjSAHSLearningModule::class)
51 ->disableOriginalConstructor()
52 ->onlyMethods(['getPointsInPercent', 'getMaxPoints', 'getTitle', 'getId'])
53 ->getMock();
54
55 $objectMock->method('getPointsInPercent')
56 ->willReturn(100.0);
57
58 $objectMock->method('getMaxPoints')
59 ->willReturn(100.0);
60
61 $objectMock->method('getTitle')
62 ->willReturn('SomeTitle');
63
64 $objectMock->method('getId')
65 ->willReturn(500);
66
67 $objectHelper = $this->getMockBuilder(ilCertificateObjectHelper::class)
68 ->getMock();
69
70 $objectHelper->method('getInstanceByObjId')
71 ->willReturn($objectMock);
72
73 $utilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
74 ->getMock();
75
76 $utilHelper->method('prepareFormOutput')
77 ->willReturn('Formatted String');
78
79 $objectLPHelper = $this->getMockBuilder(ilCertificateObjectLPHelper::class)
80 ->getMock();
81
82 $lpCollection = $this->getMockBuilder(ilLPCollectionOfSCOs::class)
83 ->disableOriginalConstructor()
84 ->onlyMethods(['getPossibleItems', 'getScoresForUserAndCP_Node_Id', 'isAssignedEntry'])
85 ->getMock();
86
87 $lpCollection->method('getPossibleItems')
88 ->willReturn([100 => ['title' => 'Some Title']]);
89
90 $lpCollection->method('getScoresForUserAndCP_Node_Id')
91 ->willReturn(
92 [
93 'raw' => 100,
94 'max' => 300,
95 'scaled' => 2
96 ]
97 );
98
99 $lpCollection->method('isAssignedEntry')
100 ->willReturn(true);
101
102 $olp = $this->getMockBuilder(ilObjectLP::class)
103 ->disableOriginalConstructor()
104 ->onlyMethods(['getCollectionInstance'])
105 ->getMock();
106
107 $olp->method('getCollectionInstance')
108 ->willReturn($lpCollection);
109
110 $objectLPHelper->method('getInstance')
111 ->willReturn($olp);
112
113 $lpStatusHelper = $this->getMockBuilder(ilCertificateLPStatusHelper::class)
114 ->getMock();
115
116 $lpStatusHelper->method('lookupStatusChanged')
117 ->willReturn('2018-12-01 13:00:11');
118
120 $defaultPlaceholderValues,
121 $language,
122 $dateHelper,
123 $objectHelper,
124 $utilHelper,
125 $objectLPHelper,
126 $lpStatusHelper
127 );
128
129 $result = $scormPlaceholderValues->getPlaceholderValues(10, 200);
130
131 $this->assertEquals(
132 [
133 'SCORM_TITLE' => 'Formatted String',
134 'SCORM_POINTS' => '100,0 %',
135 'SCORM_POINTS_MAX' => 100,
136 'SCO_T_0' => 'Some Title',
137 'SCO_P_0' => '100,0',
138 'SCO_PM_0' => '300,0',
139 'SCO_PP_0' => '200,0 %',
140 'DATE_COMPLETED' => '',
141 'DATETIME_COMPLETED' => ''
142 ],
143 $result
144 );
145 }