19 declare(strict_types=1);
23 protected function setUp(): void
27 $DIC[
'file_delivery'] = $this->createMock(\
ILIAS\FileDelivery\Services::class);
32 $defaultPlaceholderValues = $this->getMockBuilder(ilDefaultPlaceholderValues::class)
33 ->disableOriginalConstructor()
36 $language = $this->getMockBuilder(ilLanguage::class)
37 ->disableOriginalConstructor()
40 $language->method(
'txt')
41 ->willReturnCallback(
function ($variableValue) {
42 if ($variableValue ===
'lang_sep_decimal') {
44 } elseif ($variableValue ===
'lang_sep_thousand') {
48 return 'Some Translation: ' . $variableValue;
51 $language->expects($this->once())
52 ->method(
'loadLanguageModule');
54 $dateHelper = $this->getMockBuilder(ilCertificateDateHelper::class)
57 $objectMock = $this->getMockBuilder(ilObjSAHSLearningModule::class)
58 ->disableOriginalConstructor()
59 ->onlyMethods([
'getPointsInPercent',
'getMaxPoints',
'getTitle',
'getId'])
62 $objectMock->method(
'getPointsInPercent')
65 $objectMock->method(
'getMaxPoints')
68 $objectMock->method(
'getTitle')
69 ->willReturn(
'SomeTitle');
71 $objectMock->method(
'getId')
74 $user_object = $this->getMockBuilder(ilObjUser::class)
75 ->disableOriginalConstructor()
78 $objectHelper = $this->getMockBuilder(ilCertificateObjectHelper::class)
80 $objectHelper->method(
'getInstanceByObjId')
88 $utilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
91 $utilHelper->method(
'prepareFormOutput')
92 ->willReturn(
'Formatted String');
94 $objectLPHelper = $this->getMockBuilder(ilCertificateObjectLPHelper::class)
97 $lpCollection = $this->getMockBuilder(ilLPCollectionOfSCOs::class)
98 ->disableOriginalConstructor()
99 ->onlyMethods([
'getPossibleItems',
'getScoresForUserAndCP_Node_Id',
'isAssignedEntry'])
102 $lpCollection->method(
'getPossibleItems')
103 ->willReturn([100 => [
'title' =>
'Some Title']]);
105 $lpCollection->method(
'getScoresForUserAndCP_Node_Id')
114 $lpCollection->method(
'isAssignedEntry')
117 $olp = $this->getMockBuilder(ilObjectLP::class)
118 ->disableOriginalConstructor()
119 ->onlyMethods([
'getCollectionInstance'])
122 $olp->method(
'getCollectionInstance')
123 ->willReturn($lpCollection);
125 $objectLPHelper->method(
'getInstance')
128 $lpStatusHelper = $this->getMockBuilder(ilCertificateLPStatusHelper::class)
131 $lpStatusHelper->method(
'lookupStatusChanged')
132 ->willReturn(
'2018-12-01 13:00:11');
135 $defaultPlaceholderValues,
144 $result = $scormPlaceholderValues->getPlaceholderValues(10, 200);
148 'SCORM_TITLE' =>
'Formatted String',
149 'SCORM_POINTS' =>
'100,0 %',
150 'SCORM_POINTS_MAX' => 100,
151 'SCO_T_0' =>
'Some Title',
152 'SCO_P_0' =>
'100,0',
153 'SCO_PM_0' =>
'300,0',
154 'SCO_PP_0' =>
'200,0 %',
155 'DATE_COMPLETED' =>
'',
156 'DATETIME_COMPLETED' =>
'' 164 $defaultPlaceholderValues = $this->getMockBuilder(ilDefaultPlaceholderValues::class)
165 ->disableOriginalConstructor()
168 $defaultPlaceholderValues->method(
'getPlaceholderValuesForPreview')
171 'SOME_PLACEHOLDER' =>
'aaa',
172 'SOME_OTHER_PLACEHOLDER' =>
'bbb' 176 $language = $this->getMockBuilder(ilLanguage::class)
177 ->disableOriginalConstructor()
180 $language->method(
'txt')
181 ->willReturnCallback(
function ($variableValue) {
182 if ($variableValue ===
'lang_sep_decimal') {
184 } elseif ($variableValue ===
'lang_sep_thousand') {
188 return 'Some Translation: ' . $variableValue;
191 $dateHelper = $this->getMockBuilder(ilCertificateDateHelper::class)
194 $objectMock = $this->getMockBuilder(ilObject::class)
195 ->disableOriginalConstructor()
198 $objectMock->method(
'getTitle')
199 ->willReturn(
'Some Title');
201 $objectHelper = $this->getMockBuilder(ilCertificateObjectHelper::class)
204 $objectHelper->method(
'getInstanceByObjId')
205 ->willReturn($objectMock);
207 $utilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
210 $utilHelper->method(
'prepareFormOutput')
211 ->willReturnCallback(
function ($input) {
215 $objectLPHelper = $this->getMockBuilder(ilCertificateObjectLPHelper::class)
218 $lpCollection = $this->getMockBuilder(ilLPCollectionOfSCOs::class)
219 ->disableOriginalConstructor()
220 ->onlyMethods([
'getPossibleItems',
'isAssignedEntry'])
223 $lpCollection->method(
'getPossibleItems')
226 'title' =>
'Some Title' 229 'title' =>
'Some Other Title' 233 $lpCollection->method(
'isAssignedEntry')
236 $objectLPMock = $this->getMockBuilder(ilObjectLP::class)
237 ->disableOriginalConstructor()
240 $objectLPMock->method(
'getCollectionInstance')
241 ->willReturn($lpCollection);
243 $objectLPHelper->method(
'getInstance')
244 ->willReturn($objectLPMock);
246 $lpStatusHelper = $this->getMockBuilder(ilCertificateLPStatusHelper::class)
250 $defaultPlaceholderValues,
259 $result = $scormPlaceholderValues->getPlaceholderValuesForPreview(100, 10);
263 'SCORM_TITLE' =>
'Some Title',
264 'SCORM_POINTS' =>
'80,7 %',
265 'SCORM_POINTS_MAX' =>
'90',
266 'SCO_T_0' =>
'Some Title',
268 'SCO_PM_0' =>
'90,9',
269 'SCO_PP_0' =>
'33,3 %',
270 'SCO_T_1' =>
'Some Other Title',
272 'SCO_PM_1' =>
'90,9',
273 'SCO_PP_1' =>
'33,3 %',
274 'SOME_PLACEHOLDER' =>
'aaa',
275 'SOME_OTHER_PLACEHOLDER' =>
'bbb'
Interface Observer Contains several chained tasks and infos about them.
testGetPlaceholderValuesForPreview()
testGetPlaceholderValues()