19 declare(strict_types=1);
25 $defaultPlaceholderValues = $this->getMockBuilder(ilDefaultPlaceholderValues::class)
26 ->disableOriginalConstructor()
29 $language = $this->getMockBuilder(ilLanguage::class)
30 ->disableOriginalConstructor()
33 $language->method(
'txt')
34 ->willReturnCallback(
function ($variableValue):
string {
35 if ($variableValue ===
'lang_sep_decimal') {
37 } elseif ($variableValue ===
'lang_sep_thousand') {
41 return 'Some Translation: ' . $variableValue;
44 $language->expects($this->once())
45 ->method(
'loadLanguageModule');
47 $dateHelper = $this->getMockBuilder(ilCertificateDateHelper::class)
50 $objectMock = $this->getMockBuilder(ilObjSAHSLearningModule::class)
51 ->disableOriginalConstructor()
52 ->onlyMethods([
'getPointsInPercent',
'getMaxPoints',
'getTitle',
'getId'])
55 $objectMock->method(
'getPointsInPercent')
58 $objectMock->method(
'getMaxPoints')
61 $objectMock->method(
'getTitle')
62 ->willReturn(
'SomeTitle');
64 $objectMock->method(
'getId')
67 $objectHelper = $this->getMockBuilder(ilCertificateObjectHelper::class)
70 $objectHelper->method(
'getInstanceByObjId')
71 ->willReturn($objectMock);
73 $utilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
74 ->disableOriginalConstructor()
77 $utilHelper->method(
'prepareFormOutput')
78 ->willReturn(
'Formatted String');
80 $objectLPHelper = $this->getMockBuilder(ilCertificateObjectLPHelper::class)
83 $lpCollection = $this->getMockBuilder(ilLPCollectionOfSCOs::class)
84 ->disableOriginalConstructor()
85 ->onlyMethods([
'getPossibleItems',
'getScoresForUserAndCP_Node_Id',
'isAssignedEntry'])
88 $lpCollection->method(
'getPossibleItems')
89 ->willReturn([100 => [
'title' =>
'Some Title']]);
91 $lpCollection->method(
'getScoresForUserAndCP_Node_Id')
100 $lpCollection->method(
'isAssignedEntry')
103 $olp = $this->getMockBuilder(ilObjectLP::class)
104 ->disableOriginalConstructor()
105 ->onlyMethods([
'getCollectionInstance'])
108 $olp->method(
'getCollectionInstance')
109 ->willReturn($lpCollection);
111 $objectLPHelper->method(
'getInstance')
114 $lpStatusHelper = $this->getMockBuilder(ilCertificateLPStatusHelper::class)
117 $lpStatusHelper->method(
'lookupStatusChanged')
118 ->willReturn(
'2018-12-01 13:00:11');
121 $defaultPlaceholderValues,
130 $result = $scormPlaceholderValues->getPlaceholderValues(10, 200);
134 'SCORM_TITLE' =>
'Formatted String',
135 'SCORM_POINTS' =>
'100,0 %',
136 'SCORM_POINTS_MAX' => 100,
137 'SCO_T_0' =>
'Some Title',
138 'SCO_P_0' =>
'100,0',
139 'SCO_PM_0' =>
'300,0',
140 'SCO_PP_0' =>
'200,0 %',
141 'DATE_COMPLETED' =>
'',
142 'DATETIME_COMPLETED' =>
'' 150 $defaultPlaceholderValues = $this->getMockBuilder(ilDefaultPlaceholderValues::class)
151 ->disableOriginalConstructor()
154 $defaultPlaceholderValues->method(
'getPlaceholderValuesForPreview')
157 'SOME_PLACEHOLDER' =>
'aaa',
158 'SOME_OTHER_PLACEHOLDER' =>
'bbb' 162 $language = $this->getMockBuilder(ilLanguage::class)
163 ->disableOriginalConstructor()
166 $language->method(
'txt')
167 ->willReturnCallback(
function ($variableValue):
string {
168 if ($variableValue ===
'lang_sep_decimal') {
170 } elseif ($variableValue ===
'lang_sep_thousand') {
174 return 'Some Translation: ' . $variableValue;
177 $dateHelper = $this->getMockBuilder(ilCertificateDateHelper::class)
180 $objectMock = $this->getMockBuilder(ilObject::class)
181 ->disableOriginalConstructor()
184 $objectMock->method(
'getTitle')
185 ->willReturn(
'Some Title');
187 $objectHelper = $this->getMockBuilder(ilCertificateObjectHelper::class)
190 $objectHelper->method(
'getInstanceByObjId')
191 ->willReturn($objectMock);
193 $utilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
194 ->disableOriginalConstructor()
197 $utilHelper->method(
'prepareFormOutput')
198 ->willReturnCallback(
function ($input) {
202 $objectLPHelper = $this->getMockBuilder(ilCertificateObjectLPHelper::class)
205 $lpCollection = $this->getMockBuilder(ilLPCollectionOfSCOs::class)
206 ->disableOriginalConstructor()
207 ->onlyMethods([
'getPossibleItems',
'isAssignedEntry'])
210 $lpCollection->method(
'getPossibleItems')
213 'title' =>
'Some Title' 216 'title' =>
'Some Other Title' 220 $lpCollection->method(
'isAssignedEntry')
223 $objectLPMock = $this->getMockBuilder(ilObjectLP::class)
224 ->disableOriginalConstructor()
227 $objectLPMock->method(
'getCollectionInstance')
228 ->willReturn($lpCollection);
230 $objectLPHelper->method(
'getInstance')
231 ->willReturn($objectLPMock);
233 $lpStatusHelper = $this->getMockBuilder(ilCertificateLPStatusHelper::class)
237 $defaultPlaceholderValues,
246 $result = $scormPlaceholderValues->getPlaceholderValuesForPreview(100, 10);
250 'SCORM_TITLE' =>
'Some Title',
251 'SCORM_POINTS' =>
'80,7 %',
252 'SCORM_POINTS_MAX' =>
'90',
253 'SCO_T_0' =>
'Some Title',
255 'SCO_PM_0' =>
'90,9',
256 'SCO_PP_0' =>
'33,3 %',
257 'SCO_T_1' =>
'Some Other Title',
259 'SCO_PM_1' =>
'90,9',
260 'SCO_PP_1' =>
'33,3 %',
261 'SOME_PLACEHOLDER' =>
'aaa',
262 'SOME_OTHER_PLACEHOLDER' =>
'bbb'
Class ilCertificateBaseTestCase.
testGetPlaceholderValuesForPreview()
testGetPlaceholderValues()