ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilScormPlaceholderValuesTest Class Reference
+ Inheritance diagram for ilScormPlaceholderValuesTest:
+ Collaboration diagram for ilScormPlaceholderValuesTest:

Public Member Functions

 testGetPlaceholderValues ()
 
 testGetPlaceholderValuesForPreview ()
 

Detailed Description

Definition at line 21 of file ilScormPlaceholderValuesTest.php.

Member Function Documentation

◆ testGetPlaceholderValues()

ilScormPlaceholderValuesTest::testGetPlaceholderValues ( )

Definition at line 23 of file ilScormPlaceholderValuesTest.php.

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 
119  $scormPlaceholderValues = new ilScormPlaceholderValues(
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  }

◆ testGetPlaceholderValuesForPreview()

ilScormPlaceholderValuesTest::testGetPlaceholderValuesForPreview ( )

Definition at line 147 of file ilScormPlaceholderValuesTest.php.

147  : void
148  {
149  $defaultPlaceholderValues = $this->getMockBuilder(ilDefaultPlaceholderValues::class)
150  ->disableOriginalConstructor()
151  ->getMock();
152 
153  $defaultPlaceholderValues->method('getPlaceholderValuesForPreview')
154  ->willReturn(
155  [
156  'SOME_PLACEHOLDER' => 'aaa',
157  'SOME_OTHER_PLACEHOLDER' => 'bbb'
158  ]
159  );
160 
161  $language = $this->getMockBuilder(ilLanguage::class)
162  ->disableOriginalConstructor()
163  ->getMock();
164 
165  $language->method('txt')
166  ->willReturnCallback(function ($variableValue) {
167  if ($variableValue === 'lang_sep_decimal') {
168  return ',';
169  } elseif ($variableValue === 'lang_sep_thousand') {
170  return '.';
171  }
172 
173  return 'Some Translation: ' . $variableValue;
174  });
175 
176  $dateHelper = $this->getMockBuilder(ilCertificateDateHelper::class)
177  ->getMock();
178 
179  $objectMock = $this->getMockBuilder(ilObject::class)
180  ->disableOriginalConstructor()
181  ->getMock();
182 
183  $objectMock->method('getTitle')
184  ->willReturn('Some Title');
185 
186  $objectHelper = $this->getMockBuilder(ilCertificateObjectHelper::class)
187  ->getMock();
188 
189  $objectHelper->method('getInstanceByObjId')
190  ->willReturn($objectMock);
191 
192  $utilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
193  ->getMock();
194 
195  $utilHelper->method('prepareFormOutput')
196  ->willReturnCallback(function ($input) {
197  return $input;
198  });
199 
200  $objectLPHelper = $this->getMockBuilder(ilCertificateObjectLPHelper::class)
201  ->getMock();
202 
203  $lpCollection = $this->getMockBuilder(ilLPCollectionOfSCOs::class)
204  ->disableOriginalConstructor()
205  ->onlyMethods(['getPossibleItems', 'isAssignedEntry'])
206  ->getMock();
207 
208  $lpCollection->method('getPossibleItems')
209  ->willReturn([
210  [
211  'title' => 'Some Title'
212  ],
213  [
214  'title' => 'Some Other Title'
215  ]
216  ]);
217 
218  $lpCollection->method('isAssignedEntry')
219  ->willReturn(true);
220 
221  $objectLPMock = $this->getMockBuilder(ilObjectLP::class)
222  ->disableOriginalConstructor()
223  ->getMock();
224 
225  $objectLPMock->method('getCollectionInstance')
226  ->willReturn($lpCollection);
227 
228  $objectLPHelper->method('getInstance')
229  ->willReturn($objectLPMock);
230 
231  $lpStatusHelper = $this->getMockBuilder(ilCertificateLPStatusHelper::class)
232  ->getMock();
233 
234  $scormPlaceholderValues = new ilScormPlaceholderValues(
235  $defaultPlaceholderValues,
236  $language,
237  $dateHelper,
238  $objectHelper,
239  $utilHelper,
240  $objectLPHelper,
241  $lpStatusHelper
242  );
243 
244  $result = $scormPlaceholderValues->getPlaceholderValuesForPreview(100, 10);
245 
246  $this->assertEquals(
247  [
248  'SCORM_TITLE' => 'Some Title',
249  'SCORM_POINTS' => '80,7 %',
250  'SCORM_POINTS_MAX' => '90',
251  'SCO_T_0' => 'Some Title',
252  'SCO_P_0' => '30,3',
253  'SCO_PM_0' => '90,9',
254  'SCO_PP_0' => '33,3 %',
255  'SCO_T_1' => 'Some Other Title',
256  'SCO_P_1' => '30,3',
257  'SCO_PM_1' => '90,9',
258  'SCO_PP_1' => '33,3 %',
259  'SOME_PLACEHOLDER' => 'aaa',
260  'SOME_OTHER_PLACEHOLDER' => 'bbb'
261  ],
262  $result
263  );
264  }

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