180 {
183
184 $this->tos
185 ->expects($this->any())
186 ->method('getRefId')
187 ->willReturn(4711);
188
189 $lastResetDate = $this->getMockBuilder(\ilDate::class)
190 ->disableOriginalConstructor()
191 ->getMock();
192
193 $date = new \DateTime();
194
195 $lastResetDate->setDate($date->getTimestamp(),
IL_CAL_UNIX);
196
197 $lastResetDate
198 ->expects($this->any())
199 ->method('get')
200 ->willReturn([
201 'seconds' => (int) $date->format('s'),
202 'minutes' => (int) $date->format('i'),
203 'hours' => (int) $date->format('G'),
204 'mday' => (int) $date->format('j'),
205 'wday' => (int) $date->format('w'),
206 'mon' => (int) $date->format('n'),
207 'year' => (int) $date->format('Y'),
208 'yday' => (int) $date->format('z'),
209 'weekday' => $date->format('l'),
210 'month' => $date->format('F'),
211 'isoday' => (int) $date->format('N')
212 ]);
213
214 $lastResetDate
215 ->expects($this->any())
216 ->method('isNull')
217 ->willReturn(true);
218
219 $this->tos
220 ->expects($this->any())
221 ->method('getLastResetDate')
222 ->willReturn($lastResetDate);
223
224 $this->ctrl
225 ->expects($this->
once())
226 ->method('getCmd')
227 ->willReturn('getResetMessageBoxHtml');
228
229 $this->ctrl
230 ->expects($this->
once())
231 ->method('getLinkTarget')
232 ->with($this->isInstanceOf(\ilTermsOfServiceDocumentGUI::class), 'confirmReset')
233 ->willReturn('confirmReset');
234
235 $this->rbacsystem
236 ->expects($this->any())
237 ->method('checkAccess')
238 ->willReturn(true);
239
240 $buttonFactory = $this->getMockBuilder(\
ILIAS\
UI\Component\
Button\Factory::class)->getMock();
241 $button = $this->getMockBuilder(\
ILIAS\
UI\Component\
Button\Standard::class)->getMock();
242
243 $buttonFactory
244 ->expects($this->
once())
245 ->method('standard')
246 ->with($this->isType('string'), $this->equalTo('confirmReset'))
247 ->willReturn($button);
248
249 $this->uiFactory
250 ->expects($this->
once())
251 ->method('button')
252 ->willReturn($buttonFactory);
253
254 $messageBoxFactory = $this->getMockBuilder(\
ILIAS\
UI\Component\MessageBox\Factory::class)->getMock();
255 $info = $this->getMockBuilder(\
ILIAS\
UI\Component\MessageBox\MessageBox::class)->getMock();
256
257 $messageBoxFactory
258 ->expects($this->
once())
259 ->method('info')
260 ->with($this->stringContains('Some date:'))
262
264 ->expects($this->
once())
265 ->method('withButtons')
266 ->with($this->countOf(1));
267
268 $this->uiFactory
269 ->expects($this->
once())
270 ->method('messageBox')
271 ->willReturn($messageBoxFactory);
272
274 ->expects($this->never())
275 ->method('raiseError');
276
277 $this->uiRenderer
278 ->expects($this->atLeast(1))
279 ->method('render')
280 ->willReturn('');
281
282 $this->lng
283 ->expects($this->exactly(2))
284 ->method('txt')
285 ->willReturnOnConsecutiveCalls(
286 'Some date: %s',
287 'Some button text'
288 );
289
290 $gui = new \ilTermsOfServiceDocumentGUI(
291 $this->tos,
292 $this->criterionTypeFactory,
293 $this->tpl,
295 $this->ctrl,
296 $this->lng,
297 $this->rbacsystem,
299 $this->log,
300 $this->toolbar,
301 $this->httpState,
302 $this->uiFactory,
303 $this->uiRenderer,
304 $this->fileSystems,
305 $this->fileUpload,
306 $this->tableDataProviderFactory,
307 $this->documentPurifier
308 );
309
310 $gui->executeCommand();
311 }
setGlobalVariable(string $name, $value)